Quiz 4 Flashcards
Path or branch
Moving from one node to another in a tree
Tree
Nonlinear data structure used to store data in a hierarchical manner.
Binary tree (BST)
A tree with nodes that have only two children each.
What level is the root node of a tree?
Level 0
Leaf
Node with no left or right children
Length of a path
Number of branches on a path
Height of a binary tree
Number of nodes on the longest path from the root to a leaf
Inorder traversal
Visits all the nodes in a tree in ascending order
Preorder traversal
Visits the root node first, then the subtree nodes from left to right
Postorder traversal
Visits the subtree nodes left to right first, then the root node
Graphs
Similar to trees, except they have vertices in place of nodes
Edge
Represents the interaction between vertices and could contain data significant to the vertices
Connected graph
When there is at least one path to every vertex in the graph
Non connected graph
When there is at least one vertex that cannot be reached via edges
Directed graphs
When edges have a direction for traversal between edges
Non directed graphs
When the edges can be traversed in either direction
Weighted graphs s
When the edges have a value that relates the connection between two vertices
ADT
Abstract data type
Adjacency Matrix
2D array listing all of the vertices in rows and columns, each intersection indicates if there is an edge between the two vertices
Adjacency list
A linked list for each vertex showing the vertices connected to it
Depth-First searches
Implemented with stacks.
Attempts to go as far away from the starting point as fast as possible.
If the edges are recording during this search you will get a MST.
Breadth-first searches
Implemented with queues
Attempts to stay as close to the starting point as possible (find the shortest path to the vertex as possible)
Minimum Spanning Trees(MST)
Navigates to each vertex only once. # of edges in an MST will always equal the number of connected vertices - 1.
Topological sort
Maps all the paths that can be traversed constrained by the edge direction.
Can only be done on graphs without cycles