Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Peta-me.AS-Inurt ntnk! repl,.it HW3 - A5 - Insert into Min Heap repl talk my repls loameteach Hgnadnr.. This is a preview. Take or import to

image text in transcribed

"Peta-me.AS-Inurt ntnk! repl,.it HW3 - A5 - Insert into Min Heap repl talk my repls loameteach Hgnadnr.. This is a preview. Take or import to see all content Due back ho clnssrocnm Irstructions fram your Iusert into Min Heap 1 Iron nath incort flccr in this assignment you will be working mutia min heap nstead of max heap. Tbe goal of this assignment is to implement the function insert_in_nin_heop() which will insert a new element into a min heap and then reheapify it et paretii): Retun the indox o the parent ot index 1. pturn fioot(i-1) ) I've given you a fionction called is min heap() whach does exactly what ut says it dces 7-def cet left childi: Expected behavrior heap 11,2,3,5,5,7,7 inscrt in min_heap (18, heap) hoop[1 len(heap) .. H is nin heap(heap) True Retum the Index of the left child of ndex .""" 11 def set right child(i) Return the index of the right child of index i." return i212 etu trua 11 tha array is a rax heap inap) left-al 1(heaplijheapLest-lef.child(1)l fon 1 1n rarge(s17e) right - all(naap[1] neaplest-right-child(1)] for 1 In ranga(s17 heap 11,2,3,5,5,7,7 insert in min heap(-8, heap) 1f eet-left-ch1ld(1)size) ) 1f eet_r'ent child(1) s!7*) len(heap) is nin heap(heap) rua 22-ef insert in nin heap(leent, hesp): heap [1,2,3,5, 5,7,7 inserl ir min hesp(4, hesp) +Your code here len(heap)8 is_nin_heap(heap)True Pythkm 3.6.1 (default, Dec 2015, 13:05:1) [GCC 4..2] on linux

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

Step: 3

blur-text-image

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

Students also viewed these Databases questions

Question

=+3 In what ways can an MNE improve or change its approach to IHRM?

Answered: 1 week ago