Data Structures final exam

Ace your homework & exams now with Quizwiz!

Which of the following best describes a balanced tree?

A balanced tree has all of the nodes within one level of each other.

Finding an element in a balanced binary search tree that contains n elements requires _____________________ comparisons.

O(lon2n)

In the worst case, a general binary search tree could require __________________ comparisons to find an element.

O(n)

When removing an element from a binary search tree, we must always ______________________.

always make sure the new tree is a binary search tree

A binary search tree that is highly unbalanced is called a ________________ tree.

dengnerate

A binary search tree is always a full tree.

false

A heap sort sorts elements by constructing a heap out of them, and then removing them one at a time from the root.

false

Finding an element in a binary search tree always requires O(log2 n) comparisons.

false

In a binary search tree, the elements in the right subtree of the root are always larger than the element stored at the root.

false

In an inorder traversal, the elements of a tree are visited in order of their distance from the root.

false

In an inorder traversal, the root is the first element to be visited in the tree.

false

The height of a tree and the depth of a tree are different.

false

There are four basic ways to traverse a tree, and they are all implemented recursively.

false

Whenever a new element is added to a maxheap, it always becomes the root.

false

In a binary search tree, the elements in the right subtree of the root are __________________ the root element.

greater than or equal to

A ____________________ is a complete binary tree in which each element is greater than or equal to both of its children.

heap

Which method of traversing a tree would result in a sorted list for a binary search tree?

inorder traversal

When adding a new element to a binary search tree, the element is added as a(n) ______________.

leaf

In a binary search tree, the elements in the left subtree of the root are __________________ the root element.

less than or equal to

Which of the following traversals is implemented using a queue as a supporting data structure?

level order

Which of the following traversals is not easily implemented recursively?

level order

Which of the following traversals visits the nodes that are closer to the top of the tree before visiting those that are closer to the bottom?

level order

A tree in which every node can have at most n children is referred to as a __________________ tree.

n-ary

Which of the following traversals never visits the root?

none of the above

Which of the following is always true when adding an element to a heap?

none of the above is always true

Which of the following traversals visits the root after visiting the left and right subtrees?

postorder

Which of the following tree traversals traverses the subtrees from left to right and then visits the root?

postorder

Which of the following traversals visits the root before visiting the left and right subtrees?

preorder

When removing an element from a binary search tree that has two children, _______________________ will ensure that the resulting tree is still a binary search tree.

replacing it with its ignorer successor

When removing an element from a binary search tree that has a single child, _____________________ will ensure that the resulting tree is still a binary search tree.

replacing it with its only child

A _____________________ is a tree whose elements are organized to facilitate finding a particular element when needed.

search tree

When removing an element from a binary search tree that is a leaf, ______________ will ensure that the resulting tree is still a binary search tree.

simply deleting it

In a maxheap, the largest element in the structure is always ______________________ .

the root

A _________________ is a nonlinear structure in which elements are organized into a hierarchy.

tree

A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.

true

A maxheap has the ordering property that the node is greater than both of its children. A minheap has the ordering property that the node is less than both of its children.

true

A min-heap is a binary tree such that the data contained in each node is less than (or equal to) the data in that node's children.

true

By definition, a complete heap is balanced.

true

In a balanced binary search tree, adding an element always requires approximately O(log2 n) steps.

true

In a binary search tree, a new element is always added as a leaf.

true

In a maxheap, the largest element is always the root.

true

In a postorder traversal, the root is the last element visited in the tree.

true

In a tree, a node that does not have any children is called a leaf.

true

Left and right rotations can be used to rebalance an unbalanced binary search tree.

true

The most efficient binary search trees are balanced.

true

If a binary search tree becomes unbalanced after an element is added, it is sometimes possible to efficiently rebalance the tree by ___________________ .

using left and right rotations

A full binary tree of height n has _________________ leaves

2n


Related study sets

Vocabulary from Classical Roots, book B, Lessons 3 & 4

View Set

Critical Care Silvestri Questions Exam 1

View Set

Chapter 3: Title VII of the Civil Rights Act of 1964

View Set