CS2420 Midterm 2

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

At what index is the root index generally stored?

1

What is the location of the left child of an item at index i?

2*i

What is the location of the right child of an item at index i?

2*i+1

An ADT stands for _______________?

Abstract Data Type

Which ADT has an insert method that requires a constant cost O(1)?

Binary Heap

The binary heap supports access to the minimum item in ______________ time.

Constant

True/False: A BST allows duplicates.

False

True/False: A binary heap does not allow duplicates.

False

True/False: A complete binary tree is constructed using nodes, just like a balanced BST.

False

What is the property that ensures that a complete binary tree has constant time operations?

Heap-order

Using an array to store a tree is called ___________________?

Implicit Representation

The binary heap supports deletion to the minimum item in ______________ time.

Logarithmic

The binary heap supports insertion to the minimum item in ______________ time in the worst case.

Logarithmic

To get a list of items in ascending order with Heapsort, do we need a binary min- or max-heap?

Max-heap/max

To get a list of items in descending order with Heapsort, do we need a binary min- or max-heap?

Min-heap/min

For a basic array kept in unsorted order, what is the cost for insertion?

O(1)/Constant

What is the cost for deleteMin for a basic array kept in sorted order (that implements a priority queue)?

O(1)/Constant

What is the cost for findMin for a basic array kept in sorted order (that implements a priority queue)?

O(1)/Constant

For a basic array kept in unsorted order, what is the cost for calling findMin?

O(N)/Linear

For a basic array kept in unsorted order, what is the cost for deleteMin?

O(N)/Linear

What is the cost of Heapsort?

O(NlogN)/NlogN

What is the cost of insert for a self-balancing BST?

O(logN)/Logarithmic

What is the worst-case performance of insertion with a binary heap?

O(logN)/Logarithmic

True/False: Heap sort is slower than merge sort in practice.

True

True/False: If k is almost equal to N, quicksort and a binary min heap approach to the k smallest items problem is expected to have NlogN complexity.

True

True/False: In a binary heap, inserting a new item requires starting with a hole at the bottom and percolating to the top.

True

If k is much smaller than N, is quick sort or a binary min heap a better algorithm for finding k smallest items?

binary min heap

True/False: The worst case scenario for inserting a new item to a binary heap with a min-heap structure is when the new item is greater than the root.

False

True/False: the buildHeap operation is logarithmic.

False

What is the cost for insertion to a basic array kept in sorted order?

O(N)/Linear

What is the cost of deleteMin for a self-balancing BST?

O(logN)/Logarithmic

True/False: the buildHeap operation is linear.

True

For a complete binary tree, the height of an N-node tree is at most __________

log(N)/Logarithmic

True/False: A data structure is defined in terms of its behavior (possible values and operations) from the point of view of the user.

False

True/False: An ADT is a concrete representation of data from the point of view of the implementer.

False

True/False: For a doubly-ended priority queue, for any node X at even depth, the key stored at X is the maximum of its subtree.

False

True/False: For a doubly-ended priority queue, for any node X at odd depth, the key stored at X is the minimum of its subtree.

False

True/False: For a max-heap order property, for every node X with parent node P, the key in P is > the key in X.

False

True/False: If k is almost equal to N, quicksort and a binary min heap approach to the k smallest items problem is expected to have a quadratic complexity.

False

True/False: If k is almost equal to N, quicksort and a binary min heap approach to the k smallest items problem is expected to have logN complexity.

False

True/False: In a binary heap, deleting a new item requires starting with a hole at the bottom and percolating to the correct placement for the item at the top of the list.

False

True/False: In a binary heap, inserting a new item requires starting with a hole at the top and percolating to the bottom.

False

True/False: The average cost for deleteMin for a binary heap is O(N)

False

True/False: The binary min-max heap has the same structure property as the binary max heap.

False

True/False: The cost of traversing a balanced BST to find the minimum element is the height of the tree, which yields a linear cost for traversal.

False

True/False: The min-heap order property requires that for every node X with parent node P, the key in p is < the key in X.

False

True/False: The min-heap order property requires that for every node X with parent node P, the key in p is > the key in X.

False

True/False: The min-heap order property requires that for every node X with parent node P, the key in p is >= the key in X.

False

True/False: The worst case performance of insert for a binary heap is linear.

False

True/False: This is how a generic array is declared: Type[] array = new Object[10];

False

True/False: This is how a generic array is declared: Type[] array = new Type[10];

False

True/False: When inserting a new item to a binary heap, you must first satisfy the order property and then satisfy the structure property.

False

Heap operations lead to a O(________) sorting algorithm

NlogN

When finding k smallest items in a list, what is the cost of using a binary min heap (using buildHeap)?

O(N*klogN)/NklogN

When finding k smallest items in a list, what is the cost of using quicksort (assuming good pivot choice)?

O(NlogN)/NlogN

What is the cost of findMin for a self-balancing BST?

O(logN)/Logarithmic

True/False: A BST does not allow duplicates.

True

True/False: A binary heap allows duplicates.

True

True/False: A binary heap can be used to implement a priority queue.

True

True/False: A data structure is a concrete representation of data from the point of view of the implementer.

True

True/False: A priority queue can be implemented using a basic array in sorted order.

True

True/False: An ADT is defined in terms of its behavior (possible values and operations) from the point of view of the user.

True

True/False: For a double-ended priority queue, the root is at even depth.

True

True/False: For a doubly-ended priority queue, for any node X at even depth, the key stored at X is the minimum of its subtree.

True

True/False: For a doubly-ended priority queue, for any node X at odd depth, the key stored at X is the maximum of its subtree.

True

True/False: For a max-heap order property, for every node X with parent node P, the key in P is >= the key in X.

True

True/False: In a binary heap, deleting a new item requires starting with a hole at the top and percolating to the correct placement for the item at the bottom of the list.

True

True/False: In a self-balancing BST, we are guaranteed that the height of the tree is logarithmic in the number of nodes.

True

True/False: The average cost for deleteMin for a binary heap is O(logN)

True

True/False: The binary min-max heap has the same structure property as the binary min heap.

True

True/False: The cost of traversing a balanced BST to find the minimum element is the height of the tree, which yields a logarithmic cost for traversal.

True

True/False: The min-heap order property requires that for every node X with parent node P, the key in p is <= the key in X.

True

True/False: The minimum item in a self-balancing BST is in the left-most node.

True

True/False: The only structure that gives dynamic logarithmic running time is the tree.

True

True/False: The root of a complete binary tree can be stored at index 0.

True

True/False: The worst case performance of insert for a binary heap is logarithmic.

True

True/False: The worst case scenario for inserting a new item to a binary heap with a min-heap structure is when the new item is less than the root.

True

True/False: This is how a generic array is declared: Type[] array = (Type[]) new Object[10];

True

True/False: When inserting a new item to a binary heap, you must first satisfy the structure property and then satisfy the order property.

True

True/False: you do not need to reference the left and right for a complete binary tree.

True

What is the location of the parent of an item at index i?

i/2


Set pelajaran terkait

Corporate Finance MGMT 332 Chapter 3

View Set

Nursing Care of the Child With an Alteration in Tissue Integrity/Integumentary Disorder

View Set

Macro Unit 4 AG supply and Demand

View Set

Anatomy Chapter 3: Practice Questions

View Set

ATI: Medical Terminology and Documentation, ATI O2, ATI respiratory, ATI practice test 4

View Set

Unix/Linux System Administration Final Exam Review

View Set