Solutions of Theory of Algorithms assignment 7-4

Solutions of Theory of Algorithms assignment 7-4 - ( lg n)...

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

View Full Document Right Arrow Icon
Solutions of Theory of Algorithms Assignment 4 Exercise 7-4 a. QUICKSORT' is the same algorithm of QUICKSORT, therefore it is also correct. b. The stack depth will be ( ) θ n if the worst case occurs. c. The running time will be the same because the algorithm itself doesn't change, but the code can be modified to enhance the worst case of the stack depth to be
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ( lg n) by making the QUICKSORT call the c-sized array instead of the (n-c) sized array, where c is a small number d. QUICKSORT'( A , p , r ) while p < r do Partition and sort left subarray. q PARTITION( A , p , r ) If q-p <q-r QUICKSORT'( A , p , q- 1) p q + 1 else QUICKSORT'( A , q+1,r) r q -1...
View Full Document

This note was uploaded on 11/09/2010 for the course CS 11841 taught by Professor Dr.ayman during the Spring '09 term at Alexandria University.

Ask a homework question - tutors are online