MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / pre_order

Method pre_order

data_structures/heap/binomial_heap.py:359–372  ·  view source on GitHub ↗

Returns the Pre-order representation of the heap including values of nodes plus their level distance from the root; Empty nodes appear as #

(self)

Source from the content-addressed store, hash-verified

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 """

Callers 1

__str__Method · 0.95

Calls 1

__traversalMethod · 0.95

Tested by

no test coverage detected