exer2 - CMPT 307 — Data Structures and Algorithms...

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

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 worst-case running time of Heapify-Up 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

{[ snackBarMessage ]}

Ask a homework question - tutors are online