recursion and binary

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

When working with a binary tree, a node that has more than two children:

is theoretically impossible in a correctly-developed binary tree structure

A node that has no children is known as a ________.

leaf node

Values are typically stored in a binary search tree so that a node's ________ child holds data is less than the ________ data.

left, nodes

A recursive function cannot call another function.

false

Output will be the same if you use inorder, postorder, or preorder traversals of the same binary tree.

false

The inorder, preorder, and postorder traversals can be accomplished using ________.

recursion

A ________ function is one that calls itself

recursive

The process of stepping through the nodes of a binary tree is known as ________.

traversing

The head pointer, anchored at the top of a binary tree, is called the ________.

tree pointer

A subtree is an entire branch of a tree, from one particular node down.

true

All nodes to the right of a node hold values greater than the node's value.

true

Any algorithm that can be coded with recursion can also be coded with an iterative structure.

true

Binary trees are commonly used to organize key values that index database records.

true

Deleting a leaf node from a binary tree is not difficult. Deleting a non-leaf node requires several steps.

true

Dereferencing a pointer to a pointer gives you another pointer.

true

Like a loop, a recursive function must have some method to control the number of times it repeats.

true

Recursive algorithms are less efficient than iterative algorithms.

true

The binary tree structure is called a "tree" because it resembles an upside-down tree.

true

The height of a tree describes how many levels there are in the tree.

true

The inorder method of traversing a binary tree involves traversing the node's left subtree, processing the node's data, and then traversing the node's right subtree.

true

The preorder method of traversing a binary tree involves processing the node's data, traversing the node's left subtree, then traversing the node's right subtree.

true

The width of a tree is the largest number of nodes in the same level.

true

When a recursive function directly calls itself, this is known as direct recursion.

true

A binary tree can be created using a struct or class containing a data value and ________.

two pointers, one for the left child and one for the right child

How many times will the following function call itself, if the value 5 is passed as the argument? void showMessage(int n) { if (n > 0) { cout << "Good day!" << endl; showMessage(n - 1); } }

5

Binary trees may be implemented as templates, but any data types used with them must support the ________ operator.

All of these < > ==

post order

L -> R -> root

in order

L-> root -> right

In a binary tree, each node may point to ________ other nodes.

One or Two

Deleting a node that has two children offers an opportunity to use:

a function that returns a pointer to a pointer, a function parameter that is a pointer to a pointer, double indirection

The programmer must ensure that a recursive function does not become

an endless loop

When you dereference a pointer to a pointer, the result is:

another pointer

A recursive function is designed to terminate when it reaches its ________.

base case

When a binary tree is used to facilitate a search, it is referred to as a ________.

binary search tree

When the root node points to two other nodes, the nodes are referred to as ________.

child nodes or children

The ________ of recursion is the number of times a recursive function calls itself.

depth

The shape of a binary tree is ________.

determined by the order in which values are inserted

In a binary tree, each node must have a minimum of two children.

false

Indirect recursion means that a function calls itself n number of times, then processing of the function starts from the first call

false

To remove a node that has children, you must first remove the children.

false

When recursion is used on a linked list, it will always display the contents of the list in reverse order.

false

When function A calls function B, which in turn calls function A, this is known as:

indirect recursion

How many times will the following function call itself, if the value 5 is passed as the argument? void showMessage(int n) { if (n > 0) { cout << "Good day!" << endl; showMessage(n + 1); } }

infinite

pre proder

root -> L -> R

The first node in a binary tree list is called the ________.

root node

In a binary tree class, you usually have a pointer as a member that is set to ________.

root of the tree

The ________ in a binary tree is similar to the head pointer in a linked list.

root pointer

Binary trees can be divided into:

subtrees

A binary tree with a height of three has:

three levels

A good reason to use the binary tree structure is:

to expedite the process of searching large sets of information

Recursion can be used to:

traverse linked lists, compute factorials, find GCD's

The speed and amount of memory available to modern computers diminishes the performance impact of recursion so much that inefficiency is no longer a strong argument against it.

true

If a recursive function does not contain a base case, it ________.

uses up all available stack memory, causing the program to crash


Kaugnay na mga set ng pag-aaral

vocabulary unit 2 (def, syn, ant, part of speech)

View Set

Chapter 39: Oxygenation and Perfusion PREPU

View Set

A&P II: THE DIGESTIVE SYSTEM PART B HOMEWORK

View Set