Binary Tree

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/37

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

38 Terms

1
New cards

In a binary tree, the branches go only from a child to a parent.

F.

In a binary tree, the branches go only from parent to its children.

2
New cards

The level of the root node of a binary tree is 1.

F.

The level of the root node of a binary tree is 0.

3
New cards

All binary tree traversals start at the left-most child node.

F.

All binary tree traversals start at the root node.

4
New cards

The item search, insertion, and deletion operations all require the binary tree to be traversed.

T.

5
New cards

For classes with pointer data members, you must explicitly overload the assignment operator and include the destructor.

T.

6
New cards

The operations to do inorder, preorder, and postorder traversals of a binary search tree are the same as those for a binary tree.

T.

7
New cards

Duplicates are allowed in a binary search tree.

F.

All keys in left-sub tree of a key must be smaller and all keys in right-sub tree must be greater.

8
New cards

After deleting the desired item from a binary search tree, the resulting tree must be a binary search tree

T.

9
New cards

To delete an item from the binary search tree, you must do the following:

1. Find the node containing the item (if any) to be deleted.

2. Delete the node.

T.

10
New cards

In C++, a function name without any parentheses is considered a pointer to the function.

T.

11
New cards

1. In the diagram of a binary tree, an arrow is called a(n) ____.

a. relation

b. path

c. directed line

d. directed branch

D. directed branch

12
New cards

2. A binary tree has a special node called the ____ node.

a. super

b. root

c. superparent

d. rootleaf

B. root

13
New cards

In a diagram of a binary tree, each node is represented as a(n) ____.

a. line

b. triangle

c. circle

d. rectangle

C. circle

14
New cards

In copying a binary tree, if you use just the value of the pointer of the root node, you get a ____ copy of the data.

a. static

b. shallow

c. deep

d. local

B. shallow

15
New cards

The most common operation performed on a binary tree is a(n) ____.

a. insertion

b. deletion

c. search

d. traversal

D. traversal

16
New cards

The three traversal algorithms discussed for binary trees are ____, ____, and ____.

a. order, preorder, postorder

b. in, preorder, order

c. order, preorder, post

d. inorder, preorder, postorder

D. inorder, preorder, postorder

17
New cards

16. The listing of the nodes produced by the postorder traversal of a binary tree is called the ____.

a. postsequence

b. postorder sequence

c. postorder table

d. post-script

B. postorder sequence

18
New cards

17. The sequence of operations in a postorder traversal is ____.

a. traverse left; traverse right

b. traverse left; traverse right; visit

c. visit; traverse left; traverse right

d. traverse left; visit; traverse right

B. traverse left; traverse right; visit

19
New cards

18. A binary tree is also a(n) ____.

a. stack

b. linked list

c. graph

d. array

C. graph

20
New cards

19. A binary tree is empty if root is ____.

a. 0

b. 1

c. "zero"

d. NULL

D. NULL

21
New cards

20. Assume the key of the left child below the root node of a binary search tree is 30. The value in the root node could be ____.

a. 0

b. 10

c. 30

d. 40

D. 40

22
New cards

The key of the right child below the root node of a search binary tree is 40. The value in the root node could be ____.

a. 30

b. 40

c. 50

d. 60

A. 30

23
New cards

22. In a binary search tree, the data in each node is ____ the data in the left child.

a. larger than

b. smaller than

c. equal to

d. larger or equal to

A. larger than

24
New cards

In a binary search tree, the data in each node is ____ the data in the right child.

a. equal to

b. smaller than

c. greater than

d. smaller or equal to

B. smaller than

25
New cards

The search function searches the binary search tree for a given item. If the item is found in the binary search tree, it returns ____.

a. true

b. false

c. a reference to the node where the item was found

d. 1

A. true

26
New cards

When traversing a binary tree with the pointer current, the pointer current is initialized to ____.

a. NULL

b. llink

c. rlink

d. root

D. root

27
New cards

The ____________________ of a path in a binary tree is the number of branches on that path.

lenght

28
New cards

The ____________________ of a binary tree is the number of nodes on the longest path from the root to a leaf.

height

29
New cards

In a(n) ____________________ traversal, the binary tree is traversed as follows:

1. Traverse the left subtree

2. Visit the node

3. Traverse the right subtree

inorder

30
New cards

In a(n) ____________________ traversal, the binary tree is traversed as follows:

1. Visit the node.

2. Traverse the left subtree.

3. Traverse the right subtree.

preorder

31
New cards

The listing of the nodes produced by the preorder traversal of a binary tree is called the ____________________.

preorder sequence

32
New cards

The listing of the nodes produced by the inorder traversal of a binary tree is called the ____________________.

inorder sequence

33
New cards

In addition to the inorder, preorder, and postorder traversals, a binary tree can also be traversed level-bylevel, which is also known as ____________________ traversal.

breadth-first

34
New cards

To destroy a binary tree, for each node, first we destroy its left subtree, then its right subtree, and then the node itself. We must then use the operator ____________________ to deallocate the memory occupied by the node.

delete

35
New cards

When a class object is passed by value, the ____________________ constructor copies the value of the actual parameters into the formal parameters.

copy

36
New cards

After inserting an item in a binary search tree, the resulting binary tree must be a(n) ____________________.

binary search tree

37
New cards

Let T be a binary search tree with n nodes, in which n > 0. When T is linear, the search algorithm makes ____________________ key comparisons, in the unsuccessful case.

n

38
New cards

Let T be a binary search tree with n nodes, in which n > 0. The average number of nodes visited in a search of T is approximately O(____________________).

log2n