Question: In python https://repl.it/student/submissions/5687899 Orepl.it HW7- P2.Inse Please verify your enm share your program enhance your work after submitting export to repl back to classroom 1-
In python
https://repl.it/student/submissions/5687899 Orepl.it HW7- P2.Inse Please verify your enm share your program enhance your work after submitting export to repl back to classroom 1- def get parent (node_idx): "Return the index of the parent of a node." return (node idx-1)12 5- def get left child(node idx): Return the index of the left child of a node.* return node_idx 2+1 9 def get right child(node_idx): 1e Return the index of the right child of a node. return node idx 2 2 12 13 def is nin_heap(heap): 14 15 16 17 18 return left and right sReturn true if the array is a max heap. size len(heap) left all(heap[i] heap[root idx): af this node value is greater than the root ie nees to susp and contsnue sifting 3e 31 heap[node idx), heap[root_idx) return sift up(hesp, root idx) heap[root idx], hesp[node_idx] s- def insert in-ein hesp(element, heap) 36 Due: Feb 22,2019 11:59 pm (ate) submit tructions from your teacher insert into Min Heap The goal of this assignment is to implement the function insert _in min heap() which will insert a new element into a min heap and then reheapify it I've given you a function called is min heap() which does exactly what it says it does Additionally. I have given you sif up which bubbles an element up the heap What you need to do 1 Refer to the slides to see the insertion example 2.Modify sift up function to work for min heap instead of a max heap (find the line to be fixe 3. Append the new element to the heap Sift it up the heap to restore the heap property Expected bebavior heap[1,2,3,5,5,7,7 insert in min heap (10, heap) heap[o] 1 len(heap) ** 8 is min heap(heap) True heap -1,2,3,5,5,7,71 nsert in min heap(-8, heap) len(heap)8 1s min heap (heap) as True insers in sin heap(4, heep 1051 AM 26/02/2019