Carrano Chapter 11

Ace your homework & exams now with Quizwiz!

Suppose we insert these values into a binary search tree: 1, 7, 2, 5, 8, 3, 6. Give a postorder traversal of this tree.

3 6 5 2 8 7 1

A descendant of node n is a node on a path from node n to ______. the root a leaf a sibling of node n a child of node n

a leaf

The ______ of a tree is the number of nodes on the longest path from the root to a leaf. height length width age

height

The maximum number of comparisons for a retrieval operation in a binary search tree is the ______. length of the tree height of the tree number of nodes in the tree number of leaves in the tree

height of the tree

A full binary tree with height 4 has ______ nodes. 7 8 15 31

15

A ______ of height h is full down to level h - 1, with level h filled in from left to right. full binary tree complete binary tree balanced binary tree general tree

complete binary tree

A data element within a record is called a ______. field tree collection key

field

The operations of the ADT sorted list are based upon the ______ of data items. names values sizes positions

values

A node of a tree is called a(n) ______. edge root branch vertex

vertex

A complete binary tree of n nodes has a height of log2(n + 1).

true

All trees are hierarchical in nature.

true

The ADT binary search tree is value-oriented.

true

The array based representation of a binary tree requires a complete binary tree.

true

What are the characteristics of a binary tree?

A binary tree is a set of nodes that is either empty or partitioned into a root node and one or two subsets that are binary subtrees of the root. Each node has at most two children, the left child and the right child.

In an array-based representation of a binary tree, what kind of information is stored in a free list?

A free list keeps track of the available nodes

Define a leaf of a tree.

A leaf of a tree is a node in the tree that has no children.

What is a search key?

A search key is the part of a record that identifies it within a collection of records. A search algorithm uses a search key to locate a record within a collection of records.

What is a subtree?

A subtree is any node in a tree together with all of its descendants.

Define an n-ary tree.

An n-ary tree is a generalization of a binary tree whose nodes each can have no more than n children.

In a binary tree, if a node does not have a parent, can it have any children?

Answer: Yes, the root is the only node that does not have a parent, and it certainly may have children.

Suppose a binary tree has 3 nodes. The root node is A, and A has a left child B. B has a right child C. Write the inorder, preorder and postorder traversals of this tree.

Inorder = B C A; Preorder = A B C; Postorder = C B A

In inorder traversal, what is the order of visiting a node and its subtrees?

Inorder traversal traverses a node's left subtree, then visits the node, and then traverses the node's right subtree.

The traversal of a binary tree is ______. O(n) O(1) O(n2) O(log2n)

O(n)

In postorder traversal, what is the order of visiting a node and its subtrees?

Postorder traversal traverses a node's left subtree, then traverses the node's right subtree, and then visits the node.

In preorder traversal, what is the order of visiting a node and its subtrees?

Preorder traversal visits a node, then traverses the node's left subtree, and then traverses the node's right subtree.

Briefly describe an algorithm for finding the largest key value in a binary search tree.

Start at the root, and follow the right child reference as far as you can. Once you reach a node whose right child is null, you have found the node with the largest key value.

Define the left child of node n in a binary tree.

The left child of node n in a binary tree is the node directly below and to the left of node n.

Define the root of a tree.

The root of a tree is the only node in the tree with no parent.

What are the three methods that a class that implements the Iterator interface must provide?

The three methods are next(), hasNext(), and remove().

What are the three properties of each node n in a binary search tree?

The three properties of each node n in a binary search tree are: n's value is greater than all values in its left subtree TL n's value is less than all values in its right subtree TR both TL and TR are binary search trees

A subtree of node n is a subtree rooted at ______. node n the parent of node n a child of node n a sibling of node n

a child of node n

Which of the following is NOT a property of a complete binary tree of height h? all nodes at level h - 2 and above have two children each when a node at level h - 1 has children, all nodes to its left at the same level have two children each when a node at level h - 1 has one child, it is a left child all leaves are at level h

all leaves are at level h

A node on the path from the root to node n is a(n) ______ of node n. ancestor descendant subtree leaf

ancestor

Each node in a tree has ______. exactly one parent at most one parent exactly two parents at most two parents

at most one parent

Each node in a binary tree has ______. exactly one child at most one child exactly two children at most two children

at most two children

In ______, the left and right subtrees of any node have heights that differ by at most 1. all trees all binary tress n-ary trees balanced binary trees

balanced binary trees

The ______ is a position-oriented ADT that is not linear. sorted list queue binary tree list

binary tree

Which of the following ADT is position-oriented? binary tree sorted list table priority queue

binary tree

A node directly below node n in a tree is called a ______ of node n. root leaf parent child

child

The lines between the nodes of a tree are called ______. branches edges arches subtrees

edges

A binary tree cannot be empty.

false

Inorder traversal visits a node before it traverses either of its subtrees.

false

The ADT queue is value-oriented.

false

The root of a tree has one parent.

false

The root of a tree is at level 0.

false

In a ______ of height h, all nodes that are at a level less than h have two children each. general tree binary tree full binary tree complete binary tree

full binary tree

The minimum height of a binary tree of n nodes is ______. n n / 2 (n / 2) - 2 log2(n + 1)

log2(n + 1)

In a binary tree, what is the maximum number of siblings a node may have? What is the minimum?

maximum = 1 minimum = 0

The maximum height of a binary tree of n nodes is ______. n n / 2 (n / 2) - 2 log2(n + 1)

n

In a general tree, the leftmost child of a node is called the ______. left child oldest child youngest child binary child

oldest child

What are the three general categories of data management operations?

operations that insert data into a data collection operations that delete data from a data collection operations that ask questions about the data in a data collection

The node that is directly above node n in a tree is called the ______ of node n. root leaf parent child

parent

The ADT stack manages an association between data items and the ______ of the data items. names values sizes positions

positions

In a tree, the children of the same parent are called ______. leafs siblings roots contemporaries

siblings

Which of the following ADT is value-oriented? list sorted list stack queue binary tree

sorted list

List three position-oriented ADTs.

the ADT list the ADT queue the ADT stack the ADT binary tree.

In an array based representation of a complete binary tree, which of the following represents the parent of node tree[i]? tree[i-2] tree[(i-1)/2] tree[2*i-1] tree[2*i-2]

tree[(i-1)/2]

In an array based representation of a complete binary tree, which of the following represents the left child of node tree[i]? tree[i+2] tree[i-2] tree[2*i+1] tree[2*i+2]

tree[2*i+1]

In an array based representation of a complete binary tree, which of the following represents the right child of node tree[i]? tree[i+2] tree[i-2] tree[2*i+1] tree[2*i+2]

tree[2*i+2]

The ADT binary tree is position-oriented.

true


Related study sets

IB Biology HL: Genetics Objectives

View Set

Chapter 13 Shareholder Rights and Corporate Governance

View Set

CH. 11 Diagnostic Procedures for Vision

View Set

Environmental Sustainability - What's the Answer

View Set

Supply Chain Management Section 1

View Set

NH Driver's Manual Road Signs and Colors and Shapes

View Set