Graphs and Trees Flashcards

1
Q

Connected Graph

A

a graph in which any node can be reached from any other node (no islands)

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

Complete Graph

A

Every vertex is connected to every other vertex

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

Cyclic Graph

A

possible to get from a point of origin and then back to that same point (without taking the same path back)

-note: vertices can be repeated, but edges cannot

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

Acyclic Graph

A

No cycles

impossible to get from point of origin and then back without retracing your steps

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

Define a balanced tree

A

No subtrees differ in height by more than one

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

Define a complete tree

A

All levels of the tree are completely filled in, with the possible exception of the last level

Note: a heap is always a compete tree

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

Most common data structure for implementing a heap

A

an array

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

Equation for finding a child in a heap array

A

to find child of a parent node: (index * 2) + 1

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

Describe Heapify

A
  • start with parent of last node in the tree
  • swap that parent node with the max value of its two children
  • swap all other parent nodes at the same level
  • then move up to the level above
  • continue this process until you have touched every level of the heap

-efficiency of heapify: O(n log n)

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

Describe Heapsort

A

-must start with a max heap

  • take element from top, move to sorted portion at end of the array
  • take smallest element and move to top
  • sift down the small element from the top to its proper place
  • repeat until finished

-efficiency of Heapsort: O(n log n)

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