Answered step by step
Verified Expert Solution
Question
1 Approved Answer
python I need to complete the code to get the output Three way heap Due February 18, 2021 11:59 PM Instructions The following are the
python
I need to complete the code to get the output
Three way heap Due February 18, 2021 11:59 PM Instructions The following are the functions for max heap using a Binary tree. def get parent: if i % 2 = = 1: J = 1/2 #odd equation else: j = 1/2 - 1 return def get children left child = i 2 + night.child = i 2-2 return left child, right child def insert heap(heap, new number: heap.append(new number last index = len(heap-1 heap = heapifycheaplast index return heap def heapify heap, index: if index=0 return heap my value heap index parent index - ger parentindex PARL. We are indexl Primy vale parent Malue Baren anden if my value Parent these indexentinderen y value else with heap.append(new number) last_index = len(heap)-| heap = heapify heap. last index) return heap def heapify heap, index: if index = parent value: heaplindexl, heapparent indexl = parent value, my value else: #finish return heap heap = heapify(heap,parent.index) return heap Assuming we have the following list of numbers: > > > list of numbers = [48, 24, 37, 25, 38, 16.50 The heap would be created as follows: heap=0 for new number in list of numbers heap = insert heap cheap, new.number The output would be > > > heap [50, 38 48 24 29 16.37 Assuming we have the follo >>> list of numbers = [48 The heap would be created heap=0 for new number in list of heap = insert_heap(hea The output would be : > > > heap [50, 38, 48, 24, 25, 16, 37] Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started