Course Hero Logo

The essential part of heap sort is construction of

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 31 - 34 out of 97 pages.

109.The essential part of Heap sort is construction of max-heap.Consider the tree shown below, the node 24 violates the max-heapproperty. Once heapify procedure is applied to it, which position willit be in?a) 4b) 5c) 8d) 9
110.The descending heap property is ___________
111.What is its wort case time complexity of Heap sort?
c) O(n2)d) O(n3)112.In average case Heap sort is as efficient as the Quick sort.
113.Choose the correct option to fill? X so that the code given belowimplements the Heap sort.#include<stdio.h>voidheapify(intarr[],intn,inti){intlargest=i;// Initialize largest as rootintl=2*i+1;// left = 2*i + 1intr=2*i+2;// right = 2*i + 2if(l<n&&arr[l]>arr[largest])largest=l;if(r<n&&arr[r]>arr[largest])largest=r;if(largest!=i){swap(arr[i], arr[largest]);heapify(arr, n, largest);}}voidheapSort(intarr[],intn){for(inti=n/2-1;i>=0;i--)heapify(arr, n, i);for(inti=n-1;i>=0;i--){X;heapify(arr, i,0);}}voidprintArray(intarr[],intn){for(inti=0;i<n;++i)printf(%d”,arr[i]);printf(“\n”);}intmain(){intarr[]={12,11,13,5,6,7};intn=sizeof(arr)/sizeof(arr[0]);heapSort(arr, n);printf(“Sorted array is \n");printArray(arr, n);}a) swap(arr[0], arr[n])b) swap(arr[i], arr[n])
c) swap(arr[0], arr[i])d) swap(arr[i], arr[2*i])114.Which one of the following is a variation of Heap sort?a) Comb sortb) Smooth sortc) Binary tree sortd) Shell sort
115.Introsort algorithm is combination of _____________
116.How many elements can be sorted in O(logn) time using Heapsort?
117.Master’s theorem is used for?
118.How many cases are there under Master’s theorem?a) 2b) 3

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 97 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
Mr.Enoch
Tags

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture