Sample Flashcards

1
Q

Quicksort - when available, tail recursion eliminates stack overflows caused by pathological pivot selection.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

With proper pivot selection, Quicksort performs in Θ(n) in the best case of inputs.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Quicksort - Diverting to a heap sort after a certain depth can prevent Θ(n^2) complexity in the worst case.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Quicksort always performs more efficiently than merge sort.

A

False.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A pathological case for quicksort when always selecting the rightmost value as the pivot would be to sort an already sorted data.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When available, tail recursion can prevent Θ(n^2) complexity in the worst case.

A

False.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Linked lists can deal with growth effectively by doubling its size when it reaches half capacity.

A

False.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Linked lists can be readily traversed using the next operator.

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Linked lists are more efficient data structures than array-based lists of size 2n by a constant factor when performing a merge sort.

A

False.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Linked lists can deal with growth effectively by keeping a pool of unused nodes.

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Linked lists are less effective than an Array-based list when the values stored in each node are objects of varying size.

A

False.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Linked lists are composed of nodes or links.

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

You can use a priority queue to build a Huffman coding tree.

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Huffman coding trees support variable-length encoding.

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

In Huffman coding trees, more frequently occurring characters will be closer to the top.

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Huffman coding trees support fixed-length encoding.

A

False.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Huffman coding trees have minimum external path weight.

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Huffman - if the frequencies of characters are different on the text to be encoded, the Huffman coding still always outperforms fixed-length encoding.

A

False.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

The combined weight of all edges yields the weighted path length.

A

False.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How do you obtain the weighted path length of a leaf?

A

Multiply its weight (frequency) by its depth.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How do you obtain the external path weight of a Huffman tree?

A

By summing the weighted path lengths of its leaves.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

In the average case, BST access time can be Θ(n).

A

True (unbalanced).

23
Q

Given an array of sorted values, it takes a best Θ(n log n) operations to create a balanced BST.

24
Q

When removing a node from a BST, the smallest node form its right subtree can be promoted to replace the removed node.

25
Binary search trees do not work when duplicates are allowed.
False
26
When removing a node from a BST, the smallest node from its right subtree can be promoted to replace the removed node.
True.
27
BST are most commonly implemented within arrays.
False.
28
In a Huffman coding tree, what is the weight of the root node?
It is the sum of the weights of its leaves.
29
Asymptotic complexity of dictionary operations depends on the underlying storage mechanism.
True.
30
Dictionary - All possible keys are considered when comparing two records for placement.
False.
31
Dictionary - Finding a record with a sorted array-based list as the underlying storage mechanism is of complexity Θ(n).
False.
32
Dictionary search keys are comparable.
True.
33
Dictionary - Removing a record with an unsorted array based list as the underlying storage mechanism is of complexity Θ(n).
True.
34
Dictionaries cannot be used with multi-dimensional keys, like points.
False.
35
A heap in an array will generally always be complete.
True.
36
The height of a heap in an array is known if know how many elements are in it.
True.
37
Finding an element in a heap takes Θ(n) operations.
True - complete heap traversal is required.
38
Finding an element in a heap takes Θ(log n) operations.
False.
39
Starting from the end of the array where a heap is stored, it takes Θ(n) operations to find the first non-leaf node.
False.
40
A heap in an array will in general always be full.
False.
41
If you add one child to any node that has only one child, and two children to every leaf node, you have added n + 1 nodes.
True.
42
Postorder is a traversal of a binary tree where children are processed before the parent node is processed.
True
43
The number of leaves in a non-empty full binary tree is one more than the number of internal nodes.
True.
44
Binary trees must be traversed depth-first.
False.
45
Preorder is a traversal of a binary tree where children are processed after the parent node is processed.
True.
46
If you add one child to any node that has only one child, and two children to every leaf node, you have added n nodes.
False.
47
Preorder is a traversal of a binary tree where the left child is processed before the parent node, and the right child is processed last.
False - this is inorder traversal.
48
A heap is the standard BST used in priority queues.
False.
49
Θ(n log n) is a realistic complexity to find the next item, for a well written priority queue.
False.
50
Adding/removing nodes and retrieving the highest priority element will have the same complexity for a heap.
True.
51
Θ(log n) is a realistic complexity to find the next item, for a well written priority queue.
True.
52
A max-heap, where the key is the priority, is the optimal form of heap for a priority queue.
True.
53
Θ(n) is a realistic complexity to find the next item, for a well written priority queue.
False.