return = int root(array heapint nif heapempty(heap,nerror('heap is empty'else return heap[ int lastleaf(array heapint nif heapempty(heap,nerror('heap is empty'else return heap[ninserting and deleting heap tree nodes is also straightforwardbut not quite so easy inserting new heap tree node since we always keep track of the last position in the tree which has been filled so farwe can easily insert new element at position provided there is still room in the arrayand increment the tree that results will still be complete binary treebut the heap tree priority ordering property might have been violated hence we may need to 'bubble upthe new element into valid position this can be done easily by comparing its priority with that of its parentand if the new element has higher prioritythen it is exchanged with its parent we may have to repeat this processbut once we reach parent that has higher or equal prioritywe can stop because we know there can be no lower priority items further up the tree hence an algorithm which inserts new heap tree node with priority isinsert(int parray heapint nif =max error('heap is full'else heap[ + bubbleup( + ,heap, + bubbleup(int iarray heapint nif isroot(ireturn elseif heap[iheap[parent( )swap heap[iand heap[parent( )bubbleup(parent( ),heap,