/end change(this routine first checks that the index given in the first argument is validand if sochanges the idata field of the node at that index to the value specified as the second argument thenif the priority has been raisedthe node is trickled upif it' been loweredthe node is trickled down actuallythe difficult part of changing node' priority is not shown in this routinefinding the node you want to change in the change(method just shown we supply the index as an argumentand in the heap workshop applet the user simply clicks on the selected node in real-world application mechanism would be needed to find the appropriate nodeas we've seenthe only node to which we normally have convenient access in heap is the one with the largest key the problem can be solved in linear (ntime by searching the array sequentially ora separate data structure (perhaps hash tablecould be updated with the new index value whenever node was moved in the priority queue this would allow quick access to any node of coursekeeping second structure updated would itself be timeconsuming the array size we should note that the array sizeequivalent to the number of nodes in the heapis vital piece of information about the heap' state and critical field in the heap class nodes copied from the last position aren' erasedso the only way for algorithms to know the location of the last occupied cell is to refer to the current size of the array the heap java program the heap java program (see listing uses node class whose only field is the idata variable that serves as the node' key as usualthis class would hold many other fields in useful program the heap class contains the methods we discussedplus isempty(and displayheap()which outputs crude but comprehensible characterbased representation of the heap listing the heap java program /heap java /demonstrates heaps /to run this programc>java heapapp import java io */for / import java lang integer/for parseint(///////////////////////////////////////////////////////////////class node public int idata/data item (keypublic node(int keyidata key/end class node /constructor ///////////////////////////////////////////////////////////////