analysis of algorithms Q plz.... you can use the kth largest algorithms from pag
ID: 3673775 • Letter: A
Question
analysis of algorithms Q plz.... you can use the kth largest algorithms from page1 & page 2 to find the median of a list . Analyze the worst case scenarios for both of these algorithms in finding the median. The algorithm for this process is. FindKthLargest( list, N, K) // list the values to look through the size of the list the element to select for i = 1 to K do largest = list [1] largestocation = 1 for j = 2 to N-(1-1) do if list j]largest then largest = list [j] largest!ocation = j end if end for Swap( list (N-(-1), list[largestLocation] ) end for return largest What is the complexity of this process? On each pass, we initialize largest to the first element of the list, and then we compare largest to every otherExplanation / Answer
In the first page ,it is bubble sort technique because always we are passing the largest element in to its location.
The complexity of the process is in the best case O(n) and in the worst case O(N^2).
In the second page this median concept used in quick sort so the worst case analysis is O(nlogn).
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.