CS 235 - Final

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Shell sort can be interpreted as an improved version of which sorting algorithm?

Insertion sort

What are the characteristics of a good pivot in the quicksort algorithm?

It is close tot he median value of the list

What kind of mapping is used in a map from keys to values?

Many-to-one

When using a map to implement a phone directory, the ____________ should be the key and the ____________ should be the value.

Name, phone number

Is it possible to have all black nodes in a Red-Black tree?

No

What is the expected run time for inserting into a hash table?

O(1)

What is the best case performance of the quicksort algorithm?

O(n)

The Big O of the number of exchanges of selection sort is ___. The Big O of the comparisons is ___.

O(n), O(n)

What is the worst case performance of bubble sort?

O(n^2)

Which of the following most accurately describes the insertion sort algorithm?

Placing each item into the correct position in the list one at a time, like a hand of cards.

Which of the following most accurately describes the heap sort algorithm?

Placing every item into a heap and moving the top item into the sorted list

Given an empty AVL tree, how could you populate the tree without performing any rotations?

Recursively find the median of the set of elements, insert, and then construct left and right subtrees with elements less and greater than the median element.

If you wanted to use a data structure to store a club roster (names only), which of the following should you use?

Set

Which of the following most accurately describes the merge sort algorithm?

Splitting the array evenly in half, and sorting the halves recursively.

Which of the following most accurately describes the quicksort algorithm?

Splitting the array in halves based on size, and sorting the halves recursively

What is the difference between sort and stable_sort?

Stable_sort will preserve ordering of duplicate items

What is "chaining?"

Storing a linked list in each table entry that contains each value that hashes to the same location.

Balance factor refers to...

The difference between the heights of the right and left nodes

When collisions are resolved using linear probing...

The insertion occurs at the first available slot that was not previously occupied

A map consists of a set of keys, each with one or more values. Which typically is/are unique?

The keys

Which of the following most accurately describes the shell sort algorithm?

The last step is to perform an insertion sort on the entire array, which has been presorted by the earlier sorts.

"Divide-and-conquer" refers to:

The list being divided into smaller sublists, then those sorted sublists are merged back together.

Which of the following is NOT an invariant of a Red-Black tree?

The root is always red

The merge step of merge sort depends on which of the following characteristics?

The subarrays are sorted

Suppose you want to traverse a hash table of names in alphabetical order. How would you do that?

This cannot be done.

A Red-Black tree may not be as balanced as an AVL tree for the same series of inputs.

True

An internal node of a 2-3-4 tree always has one more child than the number of elements in the node.

True

To maintain balance after inserting an element, we start at the insertion point and move towards the root of the tree

True

Unlike a vector, a set does not support the subscript operator (e.g. mySet[0]). If someone still wanted to iterate through each item in a set, they should __________.

Use an iterator

Quadratic probing...

Uses a hash table of prime size and it is never more than half full

Which of the following is true about the selection sort?

With each pass, an element jumps to its final location

While insertion sort is generally O(n^2), it is...

sometimes O(n)

Good hashing functions...

will distribute the keys uniformly over the hash table buckets.

What are the properties of a 2-3-4 tree?

(1) each node stores three values at most sorted from smallest to largest, (2) all leaf nodes are at the same level (perfectly balanced), (3) an internal (non-leaf) node can either have 2,3, or 4 children, (4) a leaf node can have 2, 3, or 4 items but no children

How can you verify that a list is sorted?

Check each element in the list and make sure that it is not less than its predecessor.

When inserting into a 2-3-4 tree, the new value is always inserted...

In a leaf node

When hashing, the "Big O" for find, insert, and erase should be ___, ____, and ____, respectively.

1, 1, 1

What is the worst case possible height of AVL tree?

1.44 * log n

Set A has 10 members and set B has 14 members. The intersection of the two sets has 5 members. How many members are in the union of the two sets?

19

A left-right imbalance calls for _________ rotation(s); a right-right imbalance calls for _________ rotation(s) to correct the imbalance

2, 1

In this sequence, 11 4 20 45 32 60 98 70, which element seems to be the pivot?

20

What is the max height of a balanced tree with 7 nodes?

3

How many different types of nodes are in a 2-3-4 tree (including internal and leaf nodes)

4

Suppose set A contains the strings "apples", "oranges", and "pineapples". Then the strings "apples" and "grapes" are inserted. How many items are in A after those two insertions?

4

As a general rule, what would be a good load threshold?

75%

An associative set can be implemented using

A BST, ordered linked list, chained hash table, or probed hash table

What types of maps would NOT be useful in a Huffman Code algorithm?

A map of strings to characters, representing the decodings of each string.

What is true of shell and/or merge sorts?

A merge sort is a stable sort

How does a 2-3 tree maintain balance?

All of its leaf nodes are at the lowest level

When 2 rotations are needed in an AVL tree, the first rotation should be around the ________; the second rotation should be around the __________.

Child, parent in the opposite direction

If the local root has an AVL imbalance of -2 and both its children have balances of 0, ___________.

Do a single rotation

Which of the following can help to reduce collisions in a hash table?

Expanding table size and using quadratic probing instead of linear probing

Which of the following most accurately describes the bubble sort algorithm?

Gradually shifting larger items to the back of the array, or smaller items to the front.

Let H(value) be a function that returns the hash code of "value". If A == B, then ___

H(A) == H(B)

What is the primary advantage of heap sort over merge sort?

Heap sort requires less space than merge sort


Ensembles d'études connexes

98-367 #4 Understanding Security Software, 98-367 #1 Understanding Security Layers, 98-367 #2 Understanding Operating System Security, 98-367 #3 Understanding Network Security

View Set

MAT E9, Maternity Exam 8, Maternity Exam 7, Maternity Exam 6, Maternity Exam Ch. 13,14,15, Maternity Chapters 1-12

View Set

Types of Understatement and Irony (Figures of speech)

View Set

NURS 482 - Final Exam Practice Questions (Module 5-7)

View Set

Chapter 17.3 and 17.5 Connect Conceptual, Comprehensive, and Concept Questions

View Set

Final COMLEX/USMLE STEP 1 Study Set

View Set