Answered step by step
Verified Expert Solution
Link Copied!

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 image text in transcribed
image text in transcribed
I need to complete the code to get the output
image text in transcribed
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions