✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
What is the worst-case time complexity of getting the union of two sets (see example code below), if implemented with an array?
Explain your answer (no explanation, no marks) and define your input variables.
def union(self, other):
res = ArraySet(len(self.array) + len(other.array))
for i in range(len(self)):
res.array[i] = self.array[i]
res.length = self.length
for j in range(len(other)):
if other.array[j] not in self:
res.array[res.length] = other.array[j]
res.length += 1
return res
Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!