# Exer2 - CSE 5311 Design and Analysis of Algorithms FALL...

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

CSE 5311 Design and Analysis of Algorithms FALL 2007 Department of Computer Science The University of Texas at Arlington Exercise Set 2 1) Answer questions 1a to 1c pertaining to the STOOGE_SORT Algorithm given below. STOOGE_SORT(A, i , j ) 1 if A [ i ] > A [ j ] 2 then exchange A [ i ] A [ j ] 3 if i +1 j 4 then return 5 k (j-i+1)/3 6 STOOGE_SORT(A, i , j-k ) 7 STOOGE_SORT(A, i+k , j ) 8 STOOGE_SORT(A, i , j-k ) a. Argue that STOOGE_SORT ( A ,1,length[ A ]) correctly sorts the input array A [1 . . n ], where n = length[ A ]. b. Give a recurrence for the worst-case running time of STOOGE_SORT and a tight asymptotic bound on the worst-case running time. c. Compare the worst-case running time of STOOGE_SORT with that of insertion sort, merge sort, heapsort, and quicksort. 2) Given an array of integers A [1. . n ], such that, for all i , 1 i < n , we have A [ i ]- A [ i +1] 1. Let A [1] = x and A [ n ] = y , such that x < y . Design an efficient search algorithm to find j such that

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

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

## This document was uploaded on 11/18/2009.

### Page1 / 2

Exer2 - CSE 5311 Design and Analysis of Algorithms FALL...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online