CMSC 341 Quiz 1

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/12

encourage image

There's no tags or description

Looks like no tags are added yet.

13 Terms

1
New cards

In a Heap data structure implementation, the tree does not have to preserve the binary search tree property.

True

2
New cards

The tree has root A; A has children K and Q; K has left child Z; Q has right child Y. This tree is not complete. True or False?

True

3
New cards

The storage space of a Heap data structure is O(log n). True or False?

False

4
New cards

In an unsorted list implementation of priority queue, what is the worst-case running time of removal? A. O(1) B. O(log n) C. O(n) D. O(n²)

C. O(n)

5
New cards

In a sorted list implementation of priority queue, what is the worst-case running time of insertion? A. O(1) B. O(log n) C. O(n) D. O(n²)

C. O(n)

6
New cards

In the C++ STL class std::priority_queue, what is the insertion operation called? A. insert(…) B. push(…) C. pushEnd(…) D. enqueue(…)

B. push(…)

7
New cards

What is the height of a regular Heap data structure? A. O(n log n) B. O(log log n) C. O(n) D. O(log n)

D. O(log n)

8
New cards

In the array implementation of a Heap, how is the index of the left child determined (with 1-based indexing)? A. nodeIndex + 2 B. nodeIndex / 2 C. nodeIndex % 2 D. nodeIndex * 2

D. nodeIndex * 2

9
New cards

A min-heap has root D; children K and Q; K has children Z and S; Q has left child Y. What is the final heap after inserting B, where A has the highest priority? Give level-order representation.

B, K, D, Z, S, Y, Q (Option C)

10
New cards

What is the array representation (level-order) of the min-heap with root D, children K and Q, K's children Z and S, and Q's left child Y?

D, K, Q, Z, S, Y

11
New cards

Does this tree represent a valid max-leftist-heap after a remove operation? Root G; children F and D; F has children E and B; B has left child A; D has right child C.

No. The leftist property is violated; the source says F and D must be swapped.

12
New cards

What is the worst-case running time for heap sort? A. O(n²) B. O(n log n) C. O(n) D. O(1)

B. O(n log n)

13
New cards

What is the worst-case running time for merging two leftist heaps?

O(log n)