{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

HW2 - Homework#2 Due Date Wednesday September 29th start of...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Homework #2 Due Date: Wednesday, September 29th, start of class 1. Let X be a binary search tree with height indicators located at each node. Let X 1 and X 2 be the subtrees rooted at the children of the root of X . Assuming X 1 and X 2 are height balanced AVL trees of height h 1 and h 2 respectively, give an O ( | h 1 - h 2 | + 1) algorithm to balance the whole tree without increasing its height. 2. Suppose we are given all the elements we wish to insert into an initially empty MaxHeap up front. If we insert one at a time, it takes O ( n log n ) time to build the MaxHeap. Suppose we instead build a “pre-heap” of depth d by forming a complete binary tree with each node in an arbitrary position. We must “heapify” this pre-heap so that each node has value greater than its children. (a) Suppose we take the subtrees of size 3 rooted at depth d - 1. Show how to heapify all subtrees in O ( n ) total time. (b) Assuming that all subtrees rooted at depth j are valid MaxHeaps, show how to heapify all subtrees rooted at depth j - 1 in O ( ( d - j ) n 2 d - j ) total time. (c) Analyze the running time to build a heap, using the inductive design process outlined in parts a and b . Hint: n i =1 i 2 i = O (1). 3. Aaron and Ranjan, being diabolical overlords, design a new data structure, Q, for the express purpose of assigning torturous homework problems to CSCI 570 students at USC. Let ARQ
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
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