hw03 - CSE331 Homework 3 Due Friday Feb 1 2008 at 11:59am 1...

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

View Full Document Right Arrow Icon
CSE331 Homework 3 Due: Friday Feb. 1, 2008 at 11:59am 1. Show how the quick-sort algorithm (page 286, but let the quick-sort work all the way to size 1 and 0 rather than calling insertion sort) sorts the following list: Index: 0 1 2 3 4 5 6 7 8 Key: 414 132 327 554 877 542 433 986 233 Draw the calling diagram as a tree, where each node corresponds to a quick-sort call. The root is the original call. In each node: a. Provide the A array right after the pivot is restored. b. Give the parameters of every call, including the content of the A array, left and right parameters. The order of the numbers in A array needs to be correct. 2. (Problem 7.32 (a-c) on page 309.) Suppose you are given a sorted list of N elements, followed by f(N) randomly ordered elements. How would you sort the entire list if (a) f(N) = O(1) ? (b) f(N) = O(log N) ? (c) f(N) = O( sqrt (N) ) ? Describe your algorithm in detail for each size N. Try to keep the running time of your algorithm as efficient as possible. Additionally, provide the complexity (in
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