Trees Flashcards

1
Q

What is an Internal Node?

A

A node with at least one child.

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

What is a Leaf/External Node?

A

A node with no children.

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

What is an Ancestor of a Node?

A

parent, grandparent, etc of a node.

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

What is the height of a Node?

A

Maximum number of nodes needed to be
traversed to reach a leaf node. In this class, the
height of a leaf node is 0.

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

What is the depth of a Node?

A

Number of nodes needed to be traversed to reach
the root node. In this class, the depth of the root
node is 1 (which means the depth of the root node’s
children is 2).

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

What is a Binary Tree?

A

A binary tree is a special case of a tree where each node has at most two children (a left child and a right child).

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

What is a Binary Search Tree?

A

A binary search tree is a special case of a binary tree where the left child of a node is smaller than the current node and the right child of a node is larger than the current node (where equal items go is implementation-defined).

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

What is a Tree Traversal?

A

A traversal visits the nodes of a tree in a systematic manner.

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

What Tree Traversals can you perform on a Binary Search Tree?

A

For all trees, you can perform a preorder traversal, postorder traversal, or a level-order traversal. For a Binary Search Tree you can also do an In-order traversal.

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

Describe a Pre-Order Traversal.

A

In a preorder traversal, a node is visited first, then the child nodes are visited (from left to right).

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

Describe a Post-Order Traversal.

A

In a postorder traversal, the child nodes are visited first (from left to right), then the node itself is visited.

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

What is a predecessor?

A

The predecessor node is the node that has the largest data, but is less than the data in the current node (in other words, the node with the largest data in the left subtree of the
current node).

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

What is a successor?

A

The successor node is the node that has the smallest data, but is greater than the data in the current node (in other words, the node with the smallest data in the right subtree of the current node).

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

What is the best case Big O for Inserting into a BST?

A

O ( log n )

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

What is the worst case Big O for Inserting into a BST?

A

O ( n )

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

What is the best case Big O for Searching in a BST?

A

O ( 1 )

17
Q

What is the worst case Big O for Searching in a BST?

A

O ( n )

18
Q

What is the best case Big O for Deletion in a BST?

A

O ( log n )

19
Q

What is the worst case Big O for Deletion in a BST?

A

O ( n )

20
Q

What is the average case Big O for Inserting in a BST?

A

O ( log n )

21
Q

What is the average case Big O for Searching in a BST?

A

O ( log n )

22
Q

What is the average case Big O for Deletion in a BST?

A

O ( log n )