Comp 285 test 2 study guide
Given the list (27, 40, 15, 25, 10, 19, 30), what are the new partitioned lists if the pivot is 25?
(10,15,19,25) and (27,30,40)
Given the list (62,45,29,32,25,10,75), what is the list after sorting by the 1 's digit?
(10,62,32,45,25,75,29)
Given the list (20,−35,50,−52,65,−53), what is the list after sorting by the 1's digit?
(20,50,-52,-53,-35,65)
Sort the following list of video extensions using selection sort: mpg,mp4,mov,mkv,m4v. What is the order of the elements after the second swap?
(m4v,mkv,mov,mp4,mpg)
If A Hash Table Has 20 Buckets And 12 Elements, What Will The Load Factor Be?
0.6
If (H+Cl * I + C2 * ;?)\Bmod(Tablesize) Maps To An Occupied Bucket, Then The Item's Index (I) Is Incremented By
1
Consider a hash table, a hash function of key % 10. Which of the following programmer-defined constants for quadratic probing cannot be used in a quadratic probing equation?
c1 = 10 and c2 = 10
Given the list (37, 33, 40, 12, 15, 16, 25, 42), what is the new array after the first iteration of shell sort's outer loop with a gap value of 4?
15,16,25,12,37,33,40,42
insertion sort requires at most ____ swaps to sort a list of 20 elements
190
Given the following hash table, how many items are compared when searching for item 45 using the following search algorithm? HashSearch (hashTable, key) { bucket List = hashTable (Hash (key) 1 itemNode List Search (bucket List, key) if (itemNode is not null) return itemNode-data else return null
2 items: 25 and 45
Sort the following list into descending order.20.24, 20.12, 20.245, 20.025
20.245,20.24,20.12,20.025
The array (67,23,32,80,53,60) is to be sorting using selection sort. What is the order of the elements after the third swap?
23,32,53,80,67,60
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(hash Table, item 12) Hashinsert(hash Table, item 23) HashInsert(hash Table, item 34) HashInsert(hash Table, item 45) Hashinsert(hash Table, item 33) HashInsert(hash Table, item 31) HashInsert(hash Table, item 30)
23,33
Given the following table, where a hash function returns key % 11 and quadratic probing is used with c1 = 1 and c2 = 1, which values can be inserted sequentially without collision?
23,35,47
Consider the following hash table, and a hash function of key % 10. How many list items will be compared for the search operations? HashInsert(new Table, item 25) HashInsert(new Table, item 54) HashRemove(newTable, 27) Hashinsert(new Table, item 84) Hashinsert(new Table, item 83) HashSearch(new Table, 72) HashSearch(new Table, 77) HashSearch(newTable, 63)
2;0;1
Given the following hash table and a hash function of key % 10, hashSearch(hashTable, 53) probes _____ buckets.
3
Which of the following could be inserted in a direct access table with 5 buckets, out of which 4 are occupied?
3
how many additional recursive partitioning levels are required for a list of 64 elements compared to a list of 8 elements?
3
a direct access hash table has items 51, 53, 54, and 56. The table must have a minimum of ... buckets ?
57
Consider the following hash table. If the table gets resized for N/3 collisions, where will the new item 57 reside? Use the hash function hash(key) = key %N, where N is the table size.
6
Consider a hash table named idTable that uses linear probing and a hash function of key % 10. What is printed after the following operations?HashInsert(idTable, item 45)HashInsert(idTable, item 67)HashInsert(idTable, item 76)HashInsert(idTable, item 78)HashInsert(idTable, item 79)HashInsert(idTable, item 92)HashInsert(idTable, item 87)Print HashSearch(idTable, 67)Print HashSearch(idTable, 77)Print HashSearch(idTable, 87)
67, null, 87
A hash table named numTable uses a hash function of key % 10 and quadratic probing with c1 = 1 and c2 = 2. Into which bucket is item 44 inserted? HashInsert(numTable, item 1) HashInsert(numTable, item 12) HashInsert(numTable, item 23) HashInsert(numTable, item 34) HashInsert(numTable, item 44)
7
For a 100-entry hash table, compute the multiplicative hash for the string JAVA using the specific initial value 6 and hash multiplier 2. The decimal ASCII value for each character is given below.
85
Which of the following list is sorted?
89,79,63,22
The following code finds the number of digits in an integer. Identify the correct algorithm to find the maximum number of digits in an integer array.
FindMaxLen(listOfAges, listSize){ maxDigits = 0; for(i=0; i>= listSize; i++){ digitCount = FindMaxLen(listOfAges[i]); if(digitCount > maxDigits) maxDigits = digitCount; } return maxDigits; }
Which of the following algorithms has the same best, average, and worst case runtime complexity?
Merge Sort
What is the merge sort algorithms runtime?
O (N * logN)
Which collision resolution technique places the item in another empty bucket?
Open addressing
Which is the correct implementation of the quicksort algorithm?
Quicksort(mylist, lowIndex,highIndex){ if (lowIndex >=highIndex) { return } lowEndIndex = Partition(myList, lowIndex, highIndex) Quicksort(myList,lowIndex,lowEndIndex) Quicksort(myList,lowEndIndex + 1,highIndex) }
Which sorting technique does not compare two values and then sort the values?
Radix sort
Which list is sorted in ascending order
Ral,Reece,Rita,Ryan
Identify the correct shell sort algorithm for the given interleaved sorting.InsertionSortinterleaved(numbers, numbersSize, startIndex, gap) { i=0 i = 0 temp = 0 // Temporary variable for swap for (i = startIndex + gap; i < numbersSize; i = 1+ gap) { while ( - gap >= startindex && numberstil < numbersli - gap) { temp = numbers numbers[i] = numbersſi - gap] numbers) - gap] = temp j = 1 - gap } } }
Shellsort(listOfGames, listSize, gapValues){ for each (gapValue in gapValues) { for (i=0; i<gapValue; i++){ insertionSortinterleaved(numbers, numberSize,i, gapValue) } } }
A hash function uses an item's ___ to compute the item's bucket index.
key
What operation is used to compute a bucket index in the range 0 to 16 from a key
key % 17
in the selection sort, the smallest element is selected and swapped with the _____ unsorted element.
leftmost
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
During sorting the algorithm swaps ____.
two elements at a time
Identify the correct algorithm for shell sort.
Step-1 Initialize a gap value of k Step-2 Divide the list into smaller interleaved lists of equal interval h Step-3 Sort the interleaved lists using insertion sort Step-4 Reduce the value of k and repeat until the complete list is sorted.