mightypy.data_structures package#
Module contents#
mightypy.dsa#
- class BinaryTree[source]#
Bases:
object
- property height#
- insert(val)[source]#
Level order insertion.
https://en.wikipedia.org/wiki/Breadth-first_search
- Parameters:
val (Any) – value of the node in tree.
- traverse(order='in', method='stack')[source]#
Tree traversal operation
- Parameters:
order (str, optional) – order in which the tree will be traversed. Defaults to “in”. Options available - “level”,”in”,”pre”,”post”
- Raises:
ValueError – If wrong order is passed. only “level”,”in”,”pre”,”post” is allowed
- Returns:
Values of tree nodes in specified order
- Return type:
values (list)
- class LinkedList[source]#
Bases:
object
- binary_search(arr: List[int | float | str], ele: int | float | str) Tuple[bool, int] | Tuple[bool, None] [source]#
Binary search algorithm