Trees and Graphs Flashcards

1
Q

Graph

A
  • node-based data structure
  • a series of nodes that each may or may not have child nodes. These nodes may direct to each other in a circular fashion, and they may be bi-directional
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Breath first search (BFS)

A

-visits every neighbor of a node before visiting its children

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Depth first search (DFS)

A
  • search each complete branch before moving to the next one

- covers searches through every available child node before moving to a neighbor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Recursive

A

calls itself with new data until its done

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Trees

A
  • a subtype of graph
  • cannot contain cycles
  • nodes without children are called “leaf nodes”
  • may be restricted to n children per node, like a Binary Tree (n=2)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Binary search tree

A
  • a sorted binary tree
  • left hand children are less or equal to root node and right hand children are greater than that node
  • searching happens in O(logn) time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Balanced vs Complete Tree vs Full

A
  • balanced when the number of nodes to either side of the root are roughly equal
  • complete when every non-leaf node has two children (except the rightmost node)
  • full where every Level has exactly 0 or 2 children
  • perfect tree is both full and complete
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Tree Traversal

A
  • Inorder
  • preorder
  • post-order
How well did you know this?
1
Not at all
2
3
4
5
Perfectly