2c03-review - 00061

2c03-review - 00061 - 5[15 Consider ADT Sets with the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
4 5.[15] Consider ADT Sets with the following operations: MEMBER, DELETE, INSERT, UNION, MERGE. Show that a binary search trees are not an efficient way to implement this ADT. What about 2-3 trees or red-black? Which operation is the most problematic? Provide big O estimations of the ADT operations for each implementation. For binary search trees: The time complexity of MEMBER is O(n) in the worst case, because you need to go alone the path from root to leaf, which takes O(depth). And in the worst case, O(depth)=O(n). Average case is O(depth)=O(log n) The time complexity of DELETE is O(n) in the worst case and O(log n) in the average case, because you have to find out the position of x in the binary search tree, just like what MEMBER do. The time complexity of INSERT is O(n) or O(log n), because you need to go alone the path from root to leaf, which takes O(depth). And in the worst case, O(depth)=O(n), while in the average case O(depth)=O(log n).
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Ask a homework question - tutors are online