Returns the Pre-order representation of the heap including values of nodes plus their level distance from the root; Empty nodes appear as #
(self)
| 357 | return int(min_value) |
| 358 | |
| 359 | def pre_order(self): |
| 360 | """ |
| 361 | Returns the Pre-order representation of the heap including |
| 362 | values of nodes plus their level distance from the root; |
| 363 | Empty nodes appear as # |
| 364 | """ |
| 365 | # Find top root |
| 366 | top_root = self.bottom_root |
| 367 | while top_root.parent: |
| 368 | top_root = top_root.parent |
| 369 | # preorder |
| 370 | heap_pre_order = [] |
| 371 | self.__traversal(top_root, heap_pre_order) |
| 372 | return heap_pre_order |
| 373 | |
| 374 | def __traversal(self, curr_node, preorder, level=0): |
| 375 | """ |