{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

2c03-review - 00062 - 6[25 Consider ADT Sets(of numbers...

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

View Full Document Right Arrow Icon
5 6.[25] Consider ADT Sets (of numbers) with the following operations: MEMBER(x), DELETEMIN, INSERT(x), DELETEMAX, and MEDIAN, which is a function returning the (n+1)/2 -th element in set S, where n = |S|, and x is the smallest integer greater than or equal to x, i.e. 3.1 = 4, 4 = 4. What model(s) would you recommend and why? Provide big O estimations of the ADT operations for each implementation. We can use AVL trees, red-black trees or 2-3 trees. We do not need to modify the operations: MEMBER(x), DELETEMIN, and DELETEMAX. We need to add two variables: MED, which will hold the value of median and EO which will hold 0 if median is an even element of the set treated as an ordered list, and 1 if median is an odd element of the set treated as an ordered list. Now each INSERT and DELETE must update the values of MED and EO. For INSERT(x) we need to: (1) insert x into an (AVL, red-black, 2-3) tree, according to standard procedure (2) update MED . We have to consider 4 cases: - EO = 0 (EO = even) and x
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern