algorithm contains(value prevalue is the value to search the heap for count is the number of items in the heap heap is the array used to store the heap items postvalue is located in the heapin which case trueotherwise false start nodes while start count start nodes end nodes start count while start count and start end if value heap[start return true else if value parent(heap[start]and value heap[start count count end if start start end while if count nodes return false end if nodes nodes end while return false end contains the new contains algorithm determines if the value is not in the heap by checking whether count nodes in such an event where this is true then we can confirm that nodes at level value parent( )value thus there is no possible way that value is in the heap as an example consider figure if we are searching for the value within the min-heap displayed it is obvious that we don' need to search the whole heap to determine is not present we can verify this after traversing the nodes in the second level of the heap as the previous expression defined holds true traversal as mentioned in ss traversal of heap is usually done like that of any other array data structure which our heap implementation is based upon as result you traverse the array starting at the initial array index ( in most languagesand then visit each value within the array until you have reached the upper bound of the heap you will note that in the search algorithm that we use count as this upper bound rather than the actual physical bound of the allocated array count is used to partition the conceptual heap from the actual array implementation of the heapwe only care about the items in the heapnot the whole array--the latter may contain various other bits of data as result of heap mutation