1/31 Flashcards
(12 cards)
Tree vs Graph
Tree: each node has only one parent. Root node is ancestor of all nodes.
Graph or cycle: node can have multiple parents
Binary Tree
Each node has up to 2 children.
Edges
Nodes are connected by edges.
A tree with n nodes has n-1 edges
Level
Represents a node’s heirarchy
Root
Single node at the top level
Children
The nodes at each successive level of a tree ate the children of the nodes at the previous level
Parent
A node that has children is the parent of those children
Leaf
A node that has no children
Subtree
Any node and its descendants form a subtree of the OG tree. Must include all descendants.
Interior node
Non-leaf nodes (parent and has children)
Class
A data structure where all instances share the same attributes and uses
What is the point of OOP
We do not have to change the code every time we want to add/remove a similarly structured “object”. This is why we have classes for REUSABILITY.