This preview shows page 1. Sign up to view the full content.
Unformatted text preview: CMPT 307 Data Structures and Algorithms Exercises on Sorting. Due: Thursday, October 8th (at the begin ning of the class) Reminder: the work you submit must be your own. Any collaboration and consulting outside resourses must be explicitely mentioned on your submission. 1. Show that the worstcase running time of HeapifyUp on a heap of size n is (log n ). 2. (a) What is the running time of Quicksort whe all elements of array A have the same value? (b) Show that the running time of Quicksort is ( n 2 ) when the array A contains distinct elements and is ordered in decreasing order. 3. The Quicksort algorithm contains two recursive calls to itself. After the call to Partition, the left suarray is recursively sorted and then the right subarray is recursively sorted. The second recursive call in Quicksort is not really necessary; it can be avoided by using an iterative control structure. This technique, called tail recursion , is provided automatically by good compilers. Consider the following version of Quicksort, which simulates tail recursion.compilers....
View
Full
Document
 Fall '09
 A.BULATOV
 Algorithms, Data Structures, Sort

Click to edit the document details