Analysis of Algorithms: Heapification, Minimum Spanning Tree, Inversions, Sorting, and Random-Select

This paper analyzes key algorithms in computer science, including heapification, minimum spanning trees, and sorting techniques.

Michael Davis
Contributor
4.1
32
7 months ago
Preview (3 of 8 Pages)
100%
Purchase to unlock

Page 1

Analysis of Algorithms: Heapification, Minimum Spanning Tree, Inversions, Sorting, and Random-Select - Page 1 preview image

Loading page ...

Analysis of Algorithms: Heapification, Minimum Spanning Tree, Inversions,Sorting, and Random-SelectProblem 1:Answer:The provided solution will not heapify the given array.TheHeapifyHeap()function can beconsidered as building a heap from the bottom up, consecutively pushing downward to establishthe property of the heap.The algorithm for the supporting functionHeapifyHeap()is given below:Algorithmalter_heapify(array, arraySize) isInput:An arrayarrayand its sizearraySize.Ouput:A bubble down array.Assign the index in array of the last parent node to the variablebegin.The index of the lastparent node will be equal to(arraySize-2 ) / 2.//assign valuei← (arraySize-2 ) / 2With the help of awhileloop push down the node at indexbeginto the proper place suchthat all nodes below theindexbeginare in heap order.//create while loopwhile i ≥ 0 do// call PushDown()PushDown(array,begin, arraySize-1)// decrement begini ← i1After pushing down the root, all the elements will be in heap order. Thus, now the bubble downarray is heapify. An example to show this is as given below:

Page 2

Page 3

Preview Mode

This document has 8 pages. Sign in to access the full document!

Study Now!

XY-Copilot AI
Unlimited Access
Secure Payment
Instant Access
24/7 Support
Document Chat

Document Details

Related Documents

View all