figure two complete trees (only the left tree is heapapplying this logicwe arrive at the heap-order property in heapfor every node xthe key in the parent of is smaller than (or equal tothe key in xwith the exception of the root (which has no parent in figure the tree on the left is heapbut the tree on the right is not (the dashed line shows the violation of heap orderby the heap-order propertythe minimum element can always be found at the root thuswe get the extra operationfindminin constant time basic heap operations it is easy (both conceptually and practicallyto perform the two required operations all the work involves ensuring that the heap-order property is maintained insert to insert an element into the heapwe create hole in the next available locationsince otherwisethe tree will not be complete if can be placed in the hole without violating heap orderthen we do so and are done otherwisewe slide the element that is in the hole' parent node into the holethus bubbling the hole up toward the root we continue this process until can be placed in the hole figure shows that to insert we create hole in the next available heap location inserting in the hole would violate the heaporder propertyso is slid down into the hole this strategy is continued in figure until the correct location for is found this general strategy is known as percolate upthe new element is percolated up the heap until the correct location is found insertion is easily implemented with the code shown in figure analogously we can declare (maxheapwhich enables us to efficiently find and remove the maximum element by changing the heap-order property thusa priority queue can be used to find either minimum or maximumbut this needs to be decided ahead of time