Binary Trees Flashcards

1
Q

what’s the motivation behind developing trees

A

to access and search more efficiently than using linear data structures

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

definition of binary tree

A
  1. each node has at most 2 children
  2. children are labeled left and right
  3. left child precedees right child
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what’s a full binary tree

A

each node must have either 0 or 2 children

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

what’s a complete binary tree

A

every level must be filled except for the last one, which is filled left to right

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

what’s a denegerate tree

A

a linked list

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

what’s BST

A
  • a binary tree that has a certain order property where every node to the left branch of the current node must be smaller than the current node
  • while every node to the right branch of the current node must be greater than the current node
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what’s preorder traversal’s pseudocode

A

preorder(Node node)
if node is not null:
look at the data in node
recurse left
recurse right

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

what’s inorder traversal’s pesudocode

A

inorder(Node node)
if node is not null:
recurse left
look at the data in node
recurse right

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

what’s postorder traversal’s pesudocode

A

postorder(Node node)
if node is not null:
recurse left
recurse right
look at the data in node

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

what’s levelorder traversal’s pesudocode

A

levelorer():
Create Queue q
Add root to q
while q is not empty:
Node curr = q.dequeue()
if curr is not null:
q.enqueue(curr.left)
q.enqueue(curr.right)

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