QUIZ 10, CPTR 242 - quizzes 1-6, 9-10, 13-14
Pens
In the given list, which item has the highest value-to-weight ratio?
__ returns but does not remove the item at the front of the de que.
PeekFront(deque
Identify the chosen list of activities after executing the activity selection algorithm on the following list.
see picture
Using double hashing, how is the index determined when inserting item 20? hash1(key) = key % 11 hash2(key) = 5 - key % 5 And a hash table with a table size of 10
20 % 11 + 1 * (5-20%5)) % 11
Consider a hash table using chaining with 10 buckets and a hash function of key % 10. What would bucket 3's list be after the following operations? hashInsert(hashTable, item 12) hashInsert(hashTable, item 23) hashInsert(hashTable, item 34) hashInsert(hashTable, item 45) hashInsert(hashTable, item 33) hashInsert(hashTable, item 31) hashInsert(hashTable, item 30)
23, 33
3 (probably)
3 (probably)What is the number of children that a leaf node in a 2-3-4 B-tree must have?
An array-based stacks data array is [10, 83, 19, 42, 56], If the stacks top item is 42, then the stacks length is ___
4
Given a stack myData: 34,56,78,12,66 (top is 34) what is the output after the following operations? Push(myData 43) Pop(myData) Pop(myData) print(peek(myData) Pop(myData) print(peek(myData)
56 78
rotation or fusion
A B-tree merge operates on a node with 1 key and increases the node's keys to 2 or 3 using either a(n) ___
$2
A greedy algorithm is attempting to minimize costs and has a choice among five items with equivalent functionality but with different costs: $6, $5, $7, $8, and $2. Which item cost will be chosen?
Identify the correct statement
A hash value can help identify corrupted data
10
A list of 10 elements is to be sorted using insertion sort algorithm. How many times will the outer loop be executed?
72,67,45,89,54,34,22
A move-to-front self-adjusting heuristic algorithm was applied to the given list when searching for 67 and then 72. What is the list after the search operations? 45, 89,54,34,22,72,67
1
A move-to-front self-adjusting heuristic algorithm was applied to the given list when searching for 89. How many comparisons would be made for a subsequent search for 89?
leaf node
A node in an order 4 B-tree that contains no children is called a(n) ____
Given the queue myData 12,24,48 (front is 12), where will the new time 72 be enqueued?
After 18
null and ∞
After running Dijkstra's shortest path algorithm with T as the start vertex, what are the predecessor and distance of vertex Y?
If a stack is implemented as a linked list, then a push will be a(n) __ operation.
Append
When implementing a queue with a linked list in C++, the Enqueue() function calls the LinkedList class's ___ function
Append()
For an unbounded, array-based stack, which operations take O(1) time in the BEST case?
ArrayStackPush() and ArrayStockPop()
A, D, E, C
As per Dijkstra's shortest path algorithm, identify the shortest path from A to C.
A, C, D
Assuming A is the starting vertex for DFS and B is at the top of the stack after the first iteration of the while loop, which vertices are in the stack after the second iteration of the while loop?
sorts the item vector in descending order by value
Before starting the item selection loop, the C++ Knapsack01() ____•
What will the output be if the caesar cipher restricted to lower-case alphabet characters with a right shift of 5 is applied to "wax"?
Bfc
Consider a hash table named marksTable that uses linear probing and a hash function of key % 5. What would be the location of the item 46? HashInsert(markTable, item 49) HashInsert(markTable, item 41) HashInsert(markTable, item 42) HashInsert(markTable, item 44) HashInsert(markTable, item 46)
Bucket 3
middle
During a split operation, the node's key moves from the node to the node's parent.
stores solutions to subproblems in memory
Dynamic programming _____
the upper left
Each iteration of the inner loop in the C++ LongestCommonSubstring() function compares two characters. If the characters match, the matrix entry's value is updated to 1 + ______ entry's value.
Which of the following is an optional characteristic of password hash function?
Extra random data stored alongside the password hash value
Given a stack of myData: 34, 78 (top is 34), what is the output after the following operations? Peek(myData) Push(myData, 2) Push(myData, 15) Pop(myData) pop(myData) print(isEmpty(myData))
False
Visit the node, then call ListTraverseRecursive(node→next)
For forward traversal of singly-linked list, the ListTraverseRecursive(node) function must ___
Node 3 and null
Given a double linked list (2,3,4,5,6,7), nodes 2 pointer(s) points(s) to ___
11
Given a set with ID as key, SetRemove(courseTeamSet, ____) would remove the player with Pos: 005.
Head = node Bird, Tail = node Dog
Given the double-linked list animalList (Cat, Dog), which nodes will be the head and tail nodes after the following operations? ListInsertAfter(animalList, node Cat, node Bird) ListInsertAfter(animalList, node Dog, node Fish) ListRemove(animalList, node cat) ListRemove(animal,List, node Fish)
Tom
Given the doubly linked list students (Tom, Sam, Hal, Pam), what is the student lists head node after the operation ListInsertAfter(students, node TIm, node Tim)?
null
Given the following doubly-linked list, what is node Hals previous pointer value after ListPrepend(students, node Hal) is executed
Prepend(list, 12)
Given the list (24,36,48), which is the correct way to add 12 at the start of the list?
(10, 15, 19, 25) and (27, 30, 40)
Given the list (27, 40, 15, 25,10, 19, 30), what are the new partitioned list if the pivot is 25?
append(list, 80)Remove(list, 68) Append(list,82)GetLength(list)
Given the list (75, 76, 68), identify the commands for the following operations.
Null
Given the singly-linked list (80, 81, 82, 83), what is returned from ListSearch(list, 84)?
If a stack is implemented as linked list, then a pop will remove the ___
Head node
When implementing a queue with a linked list in the C++, the Dequeue() function returns the list ___
Head nodes data
B, A, D, E, C
Identify the DFS traversal of the graph if the starting vertex is B.
1. Binary search first checks the middle element of the list. 2. If the search key is not found, the algorithm:i checks the left sublist if the search key is less than the middle element orii. Checks the right sublist if the search key is greater than the middle element.
Identify the correct sequence of performing a binary search.
You can count the number of elements of a dynamic set.
Identify the correct statement about dynamic sets.
A U B
Identify the correct way of denoting the union of sets A and B.
ArrayListPrepend(list, 10)
Identify the correct way to add 10 to the start of the array list 11, 12, 13, 14
ListRemoveAfter(list, null)
Identify the correct way to remove 18 from the singly-linked list (18, 20, 22, 24)
C, since it has no incoming edges
Identify the current vertex in the first iteration of the while loop using topological sorting.
T(N) = Ω(f(N))
Identify the notation for algorithm complexity that has a positive contact c for all T(N) >= c * f (N)
3
Identify the number of elements in a set formed by adding the following: element 10, 4 times element 15, 5 times element 20, 6 times
{10, 11, 20, 22, 33, 39, 43}
Identify the valid set that can be constructed from a collection of numbers 10, 11, 20, 22, 33, 39, 43, 11, 20.
Head nodes next pointer may point to the lists tail node.
In a double linked list with 2 dummy nodes, the lists ___
Terminates
In a recursive function, the base case ___ the function.
Leftmost
In selection sort, the smallest element is selected and swapped with the ___ unsorted element
10
In the following 2-3-4 tree, a right rotation on the root's left child moves key into the root and 12 into the root's middle1 child.
2
In the following B-tree, what is the number of nodes visited when searching for key 10?
BTreeSearch(node ->middle1, key)
In the following B-tree, which recursive search call is made when searching for key 14?
Thm
In the following matrix, identify the longest common substring.
The lists head pointer is null
In the listAfter function for singly-linked lists, the curNode parameter is ignore when ____
190
Insertion sort requires at most__ swaps to sort a list of 20 elements
Consider a hash table with keys 10, 20, 30, 40, 50, 60. Which hash function produces the fewest collisions?
Key % 50
An array-based queue is full if ___
Length == maxLength
All the nodes
ListSearch visits ___ when searching for 83 in the singly-linked list (80,81,82, 82)
A perfect hash function ___
Maps items to buckets with no collisions
Consider a hash table named numTable that uses linear probing and a hash function of key % 5. What is the status of bucket 4 after the following operations? HashInsert(numTable, item 24) HashInsert(numTable, item 33) HashInsert(numTable, item 51) HashInsert(numTable, item 44) HashInsert(numTable, item 52) HashRemove(numTable, 44) HashInsert(numTable, item 50)
Occupied
During insertions, if the bucket is occupied, iterating over i values to determine next empty bucket is called ___
Probing sequence
26, 42
Set A = {12, 24, 26, 38, 42} and Set B = {10, 20, 26, 30, 42}. Identify A ∩ B.
20.245, 20.24, 20.12, 20.025
Sort the following list into descending order. 20.24, 20.12, 20.245, 20.025
Given an empty stack menuItems, what will be the result of the following operations? StackPush(menuItems, item Pizza) StackPush(menuItems, item Chips) StackPush(menuItems, item Nachos) StackPush(menuItems, item Tea) print(stackpop(menuItems))
Tea
O(1)
The Big O notation for an algorithm with exactly 50 constant time operations is
O(N^3)
The Big O notations of the composite function 5 N^3 + O (N^2) is ___
value-to-weight ratio
The C++ FractionalKnapsack() function sorts items in descending order based on each item's ____
All elements before i are in sorted order.
The C++ InserstionSort() functions outer loop used the variable i. Which statement is true?
Is already sorted in ascending order
The C++ InsertionSort() function performs best when the list ___
Length
The C++ LongestCommonSubstring() function makes a matrix. The matrix's maximum entry is the longest common substring's
The second partition starts right after the first
The C++ Merge() function merges two sorted partitions. Four indices are typically needed to indicate start and end indices for two partitions. Merge() has only three index parameters because __
The element at the array's midpoint
The C++ Partition() function used by Quicksort selects __ as the pivot.
All elements before i are in sorted order
The C++ SelectionSort() functions outer loop uses the variable i. Which statements is true?
unsorted, first, unsorted
The C++ SelectionSort() functions swaps the smallest element in the __ portion of the list with the __ element in the ___ portion of the list.
Which c++ class function prepends to a linked list?
The Stack class's Push() function
O(str2.length())
The optimized C++ LongestCommonSubstring) function has _ space complexity.
The maximum
The worst-case runtime of an algorithm is ___ number of steps taken to execute a program.
O(n^2)
What is the typical runtime for insertion sort for singly linked lists?
curNodes predecessor
When removing curNode from a doubly-linked list with at least 2 elements, the lists tail may be assigned with __
The root's middle2 child (probably)
When searching for key 13 in the following B-tree, which node is visited first?
3
When using the function BreeRemoveKey (node, key Index) to remove a key from a 2-3-4 tree node, which is NOT a valid value for keyIndex?
E.
Which is the last vertex in a valid topological sort?
O(n^2)
Which is the worst case runtime for a quicksort algorithm?
Ral, Reece, Rita, Ryan
Which list is sorted into ascending order?
(12, 10, 25} and {10, 25, 123
Which of the below sets are equivalent?
Merge
Which of the following algorithms has the same best, average, and worst case runtime complexity?
An internal node with N keys must have N - 1 children.
Which of the following is not a property of a B-tree?
(11, 22, 33, 11}
Which of the following is not a valid set?
89, 79, 63, 22
Which of the following lists is sorted?
Guest list in a hotel
Which of the following should be a dynamic set?
A, D, E, B, C
Which ordering is a valid topological sort?
fraction = remaining / item.* weight
Which statement would replace XXX in the given greedy algorithm? FractionalKnapsack(knapsack, itemList, itemListSize) { Sort itemList descending by item's (value / weight) ratio remaining - knapsack maximumWeight for each item in itemList { if (item-›weight <= remaining) { Put item in knapsack remaining = remaining - item-weight } else { XXX Put (fraction * item) in knapsack Break } } }
What data value does a bounded stack data structure require that an unbounded stack data structure does not?
maxLength
If a stack is implemented as a linked list, then an empty stack will have __
null head and null tail pointer