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

Method __str__

data_structures/heap/binomial_heap.py:385–394  ·  view source on GitHub ↗

Overwriting str for a pre-order print of nodes in heap; Performance is poor, so use only for small examples

(self)

Source from the content-addressed store, hash-verified

383 preorder.append(("#", level))
384
385 def __str__(self):
386 """
387 Overwriting str for a pre-order print of nodes in heap;
388 Performance is poor, so use only for small examples
389 """
390 if self.is_empty():
391 return ""
392 preorder_heap = self.pre_order()
393
394 return "\n".join(("-" * level + str(value)) for value, level in preorder_heap)
395
396
397# Unit Tests

Callers

nothing calls this directly

Calls 2

is_emptyMethod · 0.95
pre_orderMethod · 0.95

Tested by

no test coverage detected