return log(iint parent(int ireturn int left(int ireturn int right(int ireturn which make the processing of these trees much easier this way of storing binary tree as an arrayhoweverwill not be efficient if the tree is not completebecause it involves reserving space in the array for every possible node in the tree since keeping binary search trees balanced is difficult problemit is therefore not really viable option to adapt the algorithms for binary search trees to work with them stored as arrays array-based representations will also be inefficient for binary search trees because node insertion or deletion will usually involve shifting large portions of the array howeverwe shall now see that there is another kind of binary tree for which array-based representations allow very efficient processing priority queues and binary heap trees while most queues in every-day life operate on first comefirst served basisit is sometimes important to be able to assign priority to the items in the queueand always serve the item with the highest priority next an example of this would be in hospital casualty departmentwhere life-threatening injuries need to be treated first the structure of complete binary tree in array form is particularly useful for representing such priority queues it turns out that these queues can be implemented efficiently by particular type of complete binary tree known as binary heap tree the idea is that the node labelswhich were the search keys when talking about binary search treesare now numbers representing the priority of each item in question (with higher numbers meaning higher priority in our exampleswith heap treesit is possible to insert and delete elements efficiently without having to keep the whole tree sorted like binary search tree this is because we only ever want to remove one element at timenamely the one with the highest priority presentand the idea is that the highest priority item will always be found at the root of the tree definition binary heap tree is complete binary tree which is either empty or satisfies the following conditionsthe priority of the root is higher than (or equal tothat of its children the left and right subtrees of the root are heap trees