Binary Trees Flashcards
1
Q
What is a binary tree?
A
- hierarchical with nodes branching in one direction with multiple pointers
- trees expand in one direction
2
Q
Parent and Children
A
- trees made up of parents and children, every parent can be a child
- every node can only have one parent, but can have many children
- each Node can hv max of 2 children
- children represented using
. left and .right
3
Q
Terminolgy
A
Root node: top node
Leaf node: any node w/o children
Branch: path btw root node and leaf node
4
Q
binary search trees
A
node.cargo must be more than node.left.cargo and less than node.right.cargo
rule must be true fol entire tree
if root node is 3, everything to right must be greater than 3, to right must be less than 3
5
Q
Truthy and Falsy Values
A
Truthy Values - by default an object is considered True
- non-empty sequences of collections(lists, tuples, strings, dicts, sets)
- numeric values that are not zero
- True
Falsy Values - evaluate to False
- empty sequences and collections
- zero of any numeric type(int, float, complex)
- Constants (None, False)