Binary trees Flashcards

1
Q

What is the first node added to a binary tree called?
a) Leaf node
b) Root node
c) Parent node
d) Child node

A

b) Root node

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

How many child nodes can a single node in a binary tree have?
a) One
b) Two
c) Three
d) Unlimited

A

b) Two

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

What happens when a new node’s value is less than the current node’s value during insertion?
a) It is added to the left of the current node
b) It is added to the right of the current node
c) It is ignored
d) The tree is rebalanced

A

a) It is added to the left of the current node

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

What is the name of the class property in the Node class that refers to the left child?
a) leftChild
b) leftNode
c) leftLink
d) childLeft

A

b) leftNode

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

What does the insert() method in the Node class do when encountering a null left or right node?
a) Replaces it with a new node
b) Deletes the current node
c) Ignores the insertion
d) Moves to the parent node

A

a) Replaces it with a new node

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

What type of class is the Node class described as, due to its references to itself?
a) Recursive class
b) Cyclic class
c) Self-referential class
d) Linked class

A

c) Self-referential class

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

What property does the Tree class use to store the first node of the tree?
a) root
b) firstNode
c) startNode
d) initialNode

A

a) root

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

What happens when the insert() method in the Tree class is called and the root is null?
a) An error occurs
b) A new Node object is assigned to the root
c) The method exits without action
d) The tree is cleared

A

b) A new Node object is assigned to the root

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

In the traversal process, what is the first step taken when the current node is null?
a) Print a null value
b) Return from the method
c) Insert a default node
d) Move to the next sibling

A

b) Return from the method

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

What is the output of a left-favored traversal of the tree created in the example with values [47, 48, 20, 15, 26, 18]?
a) 15, 18, 20, 26, 47, 48
b) 48, 47, 26, 20, 18, 15
c) 47, 20, 15, 18, 26, 48
d) 26, 15, 20, 18, 48, 47

A

a) 15, 18, 20, 26, 47, 48

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

Which method is used to print the tree in descending order?
a) traverse()
b) reverse()
c) traverseFromRoot()
d) reverseFromRoot()

A

d) reverseFromRoot()

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

What feature of a binary tree allows it to efficiently store and retrieve ordered data?
a) Self-balancing nodes
b) Branch sorting during insertion
c) Hierarchical memory allocation
d) Contiguous storage

A

b) Branch sorting during insertion

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

In a binary tree, what happens if you attempt to insert a value equal to an existing node?
a) The value is ignored
b) The tree duplicates the node
c) The value replaces the existing one
d) The tree rebalances itself

A

a) The value is ignored

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

What modification allows a binary tree to return values in descending order during traversal?
a) Adding an extra property to each node
b) Traversing right nodes before left nodes
c) Reversing the root and leaf nodes
d) Adding duplicate nodes

A

b) Traversing right nodes before left nodes

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

Which of the following is NOT a common application of binary trees?
a) File systems
b) Email storage
c) Network routing
d) Backtracking algorithms

A

d) Backtracking algorithms

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