CSD Quiz 2
CSD Quiz 2
a.
256
b.
511
c.
1024
d.
512
e.
Feedback
Question 2
Complete
Flag question
Question text
What is the tightest Big-O running time to calculate the Flesch readability score in the
EfficientDocument class, where n is the length of the document, assuming you DO NOT include
the time it takes to initialize the numSyllables, numWords, and numSentences variables (i.e. do
not include the time taken by processText)?
a.
O(1)
b.
O(n^2)
c.
O( n )
Feedback
Question 3
Complete
Flag question
Question text
a.
c.
d.
Question 4
Complete
Flag question
Question text
a.
The algorithm have consideration to edges be, de and cd but does not add them to MST.
b.
c.
The correct answer is: The algorithm have consideration to edges be, de and cd but does
not add them to MST.
Question 5
Complete
Flag question
Question text
a.
Two entries with the exact same key have different hash values.
b.
Two entries with different data have the exact same key.
c.
Two entries with different keys have the same exact hash value.
Feedback
The correct answer is: Two entries with different keys have the same exact hash value.
Question 6
Complete
Flag question
Question text
What data structure can be used to check if a syntax has balanced paranthesis ?
a.
queue
b.
stack
c.
list
d.
tree
Feedback
Complete
Flag question
Question text
a. If our task is to process vertices adjacent to a vertex v, then the adjacency list requires
only deg(v) steps, whereas the adjacency matrix requires |V| steps.
b. Inserting or deleting a edge requires linked list maintenance for an adjacency list (if such
an implementation is used); for a matrix, it requires only changing 0 to 1 for insertion, or 1
to 0 for deletion, in one cell of the matrix.
a.
b.
c.
d.
Complete
Flag question
Question text
What is the tightest Big-O running time to calculate the Flesch readability score the first time in
the EfficientDocument class, where n is the length of the document, assuming you include the
time it takes to initialize the numSyllables, numWords, and numSentences variables?
Note that this is not necessarily the running time that you saw when you plotted the graph of
your EfficientDocument running time when you did your benchmarking. That time included the
time to initialize the numSyllables, numWords and numSentences variables.
a.
O( n )
b.
O(n^2)
c.
O(1)
Feedback
Question 9
Complete
Question text
Which of the following algorithms in graphs can be implemented by extending Depth First
Search algorithm?
a.
b.
c.
Cycle detection.
d.
Feedback
Question 10
Complete
Flag question
Question text
Which the sorting technique always makes recursive calls to sort pieces that are about half
the size of the original array?
a.
Heap sort.
b.
Radix sort.
c.
Merge sort.
d.
Quick sort.
Feedback
Question 11
Complete
Flag question
Question text
a.
O(1)
b.
O(logn)
c.
O( n )
d.
Ο(n^2)
Feedback
O( n )
Question 12
Complete
Flag question
Question text
Suppose you are doing a breadth-first search of a graph with n vertices, using a queue
implemented with a static array. What is the minimum number of elements of this array?
a.
2n
b.
n
c.
n-1
d.
n+1
Feedback
Question 13
Complete
Flag question
Question text
In .................................. algorithm, each vertex v is visited and then each unvisited vertex
adjacent to v is visited. If a vertex v has no adjacent vertices or all of its adjacent vertices
have been visited, we backtrack to the predecessor of v. The traversal is finished if this
visiting and backtracking process leads to the first vertex where the traversal started. If
there are still some unvisited vertices in the graph, the traversal continues restarting for
one of the unvisited vertices.
a.
b.
c.
None of the others
Feedback
Question 14
Complete
Flag question
Question text
In a min-heap:
a.
b.
c.
d.
Complete
Mark 0.0 out of 1.0
Flag question
Question text
Given a raw message 'BBBUUUUBBBUUBBBBBUU' (without single quote). Run the run-
length encoding algorithm for that message, what is the output?
a.
3B4U4B3U2B5UU2
b.
3B4U3B2U5B
c.
3B4U3B2U5B2UU
d.
3B4U3B2U5B2U
Feedback
Question 16
Complete
Flag question
Question text
You want to place 1000 elements in a hash table using linear probing, and you would like
an average numbers of trials for successful search two elements. How big does the array of
hash table need to be?
a.
1500
b.
1000
c.
1250
d.
500
Feedback
Question 17
Complete
Flag question
Question text
What is output if using LZW algorithm with the table initialized with the letters x, y, z
encode the string “xyxyzxxy”?
a.
443112
b.
12123112
c.
124314
d.
124352
Feedback
Question 18
Complete
Flag question
Question text
a.
26 13 23 7 8 44 57 98
b.
57 26 44 7 13 8 23 98
c.
7 8 13 23 26 44 57 98
d.
44 26 23 7 13 8 57 98
Feedback
Question 19
Complete
Flag question
Question text
47 3 21 32 56 92
3 21 47 32 56 92
a.
bubble sort.
b.
all of them.
c.
selection sort.
d.
insertion sort.
Feedback
Question 20
Complete
Flag question
Question text
In your benchmarking of the DictionaryBST structure, you probably found that the time to find
words did not significantly increase as the Dictionary got larger. Which of the following is the
most likely reason for this behavior?
a.
log( n ) is sufficiently small and grows sufficiently slowly that other factors (e.g. memory use)
had a bigger effect on the running time than the size to find the word in the dictionary.
b.
We were measuring the best case performance of the dictionary, which does not change as the
dictionary size grows.
c.
The running time to find an element in a balanced BST is O(1) so we would not expect the
running time to get larger as the dictionary got bigger.
Feedback
The correct answer is: log( n ) is sufficiently small and grows sufficiently slowly that other
factors (e.g. memory use) had a bigger effect on the running time than the size to find the word
in the dictionary.
Question 21
Complete
Flag question
Question text
The “prime number division remainder” method is a well-known hashing algorithm. In this
method, a key value is divided by a number N, and the remainder which is also called a
hash value is used directly as an index into the hash table. N is the largest prime number
less than or equal to the size of the table. When the table size is 20, which of the following
is the correct hash value calculated from the key value 136? Here, a prime number is one
that cannot be divided evenly by any other number except one (1). 2, 3, 5, 7, 11, and 13
are the first few prime numbers.
a.
b.
c.
3
d.
16
e.
Question 22
Complete
Flag question
Question text
The keys 12, 18, 13, 2, 3, 23, 5 and 15 are inserted into an initially empty hash table of
length 10 using open addressing with hash function h(k) = k mod 10 and linear probing.
What is the resultant hash table?
a.
b.
c.
d.
Feedback
Question 23
Complete
Flag question
Question text
Suppose that you place 180 elements in a hash table with an array size of 200. What is the
load factor?
a.
0.75
b.
0.9
c.
1.45
d.
0.5
Feedback
Question 24
Complete
Flag question
Question text
a.
3, 4, 5, 6, 8, 7, 9, 10
b.
3, 4, 5, 6, 8, 10, 7, 9
c.
3, 4, 6, 5, 8, 10, 7, 9
d.
3, 4, 5, 6, 7, 8, 10, 9
Feedback
Question 25
Complete
Flag question
Question text
a.
The sibling property is described as each node has a sibling (except for the root) and the
breadth-first right-to-left tree traversal generates a list of nodes with nonincreasing
frequency counters.
b.
If the sibling property is violated, Huffman tree has to be restructured to restore this
property.
c.
If Adaptive Huffman coding is used to compress execute file, output file is much smaller
than the original.
d.
Feedback
The correct answer is: If Adaptive Huffman coding is used to compress execute file, output
file is much smaller than the original.
Question 26
Complete
Flag question
Question text
When the bubble sort algorithm is used for sorting the dataset (23, 43, 56, 12, 87, 14, 87,
15, 90, 23, 10) in descending order, how many data exchanges occur during the first
iteration of outer loop?
a.
b.
10
c.
d.
7
Feedback
Question 27
Complete
Flag question
Question text
What is output if using LZW algorithm with the table initialized with the letters a, b, c
encode the string “ababcaab”?
a.
124314
b.
12123112
c.
124352
d.
443112
Feedback
Question 28
Complete
Mark 0.0 out of 1.0
Flag question
Question text
In order to sort the sequence “98, 12, 4, 56, 34, 23” in ascending order by Bubble Sort
algorithm, how many exchange operations are required?
a.
b.
11
c.
d.
Feedback
Question 29
Complete
Flag question
Question text
Which of the following is true of searching for an element in a Hash Table that is implemented
using linear probing (you may assume a Hash Table that is ~70% full)?
a.
b.
c.
Question 30
Complete
Flag question
Question text
Consider a hash table of size seven, with starting index zero, and a hash function h(x)= (3x +
4) mod 7. Assuming the hash table is initially empty, which of the following is the contents
of the table when the sequence 1, 3, 8, 10 is inserted into the table using linear probing?
Note that ‘_’ denotes an empty location in the table.
a.
1, 10, 8, _, _, _, 3
b.
1, _, _, _, _, _,3
c.
8, _, _, _, _, _, 10
d.
1, 8, 10, _, _, _, 3
Feedback
Question 31
Complete
Flag question
Question text
Encoding the string "aaabbccddddddeee" with Huffman. Please indicate the size of the
output string?
a.
24 bits
b.
16 bits
c.
36 bits
d.
128 bits
Feedback
Question 32
Complete
Flag question
Question text
Use Dijkstra’s algorithm to find shortest paths from vertex A to others in the following
graph:
a.
95
b.
20
c.
infinity
d.
70
Feedback
Question 33
Complete
Flag question
Question text
Which of the following is the appropriate description of the “selection sort” algorithm?
a.
The element with the smallest value is determined and swapped for the first element, and
then the smallest value of the unsorted elements is determined and swapped for the
second-to-the-first element. This operation is repeated in the same way.
b.
An intermediate reference value is determined, and then the elements are divided into two
groups of “larger” values and “smaller”values. This operation is recursively repeated.
c.
Two adjacent elements are repeatedly compared and swapped if the first element is larger
than the second. This operation is repeated until all elements are arranged in an orderly
fashion.
d.
Each set of the elements extracted at regularintervals is sorted, and then the interval is
further decreased. The operation is repeatedly performed until the interval becomes 1.
Feedback
The correct answer is: The element with the smallest value is determined and swapped for
the first element, and then the smallest value of the unsorted elements is determined and
swapped for the second-to-the-first element. This operation is repeated in the same way.
Question 34
Complete
Flag question
Question text
When a hash table becomes too full, which of the following is required to resize the table?
a.
Create a new table which is larger than the original table. Then individually reinsert each key
from the old table into the new table (i.e. if a key is in location X in the original table, it may or
may not be in position X in the new table).
b.
Add extra space at the end of the existing hash table and leave the old keys in place.
c.
Create a new table which is larger than the original table. Then bulk copy keys from one table to
the other (i.e. if a key is in location X in the original table, it remains in position X in the new
table).
Feedback
The correct answer is: Create a new table which is larger than the original table. Then
individually reinsert each key from the old table into the new table (i.e. if a key is in location X in
the original table, it may or may not be in position X in the new table).
Question 35
Complete
Flag question
Question text
Which of the following Sorting algorithms use Divide and Conquer strategy?
a.
Quick sort
b.
Bubble sort
c.
Heap sort
d.
Radix sort
Feedback
Question 36
Complete
Flag question
Question text
Use Dijkstra’s algorithm to find shortest paths from vertex C to others in the following
graph:
a.
35
b.
40
c.
inifinity
d.
0
Feedback
Question 37
Complete
Flag question
Question text
Use Dijkstra’s algorithm to find shortest paths from vertex A to others in the following
graph:
Which vertex is chosen in iteration 4 of the algorithm?
a.
b.
c.
d.
Feedback
Question 38
Complete
Flag question
Question text
Select incorrect statement about restrictions need to be imposed on the prospective codes:
a.
There should not be any unused short codewords either as stand-alone encodings or as
prefixes for longer codewords.
c.
The length of the codeword for a given symbol A should not exceed the length of the
codeword of a less probable symbol B.
d.
Feedback
The correct answer is: Each codeword may be corresponds to one or many symbols.
Question 39
Complete
Flag question
Question text
Which of the following Sorting algorithms have complexity of O( n ) in best case ?
a.
Insertion sort
b.
Buble sort
d.
Selection sort
Feedback
Question 40
Complete
Flag question
Question text
In the algorithm for spelling suggestions in this week's assignment, there was a hash set to
mark Strings as visited. What is the BEST ANSWER for why we used the visited set?
a.
To avoid testing to see if a mutated String was a real word (and hence a spelling suggestion)
more than once.
b.
So that our exploration was of a tree of words, and if we had a word repeated, it wouldn't be a
tree anymore.
c.
To avoid exploring all the possible String mutations for an individual String more than once.
Feedback
The correct answer is: To avoid exploring all the possible String mutations for an individual
String more than once.
Question 41
Complete
Flag question
Question text
a.
b.
We can find shortest paths from any vertex to others in this graph.
c.
The shortest path from vertex a to vertex e is zero.
d.
The correct answer is: We can find shortest paths from any vertex to others in this graph.
Question 42
Complete
Flag question
Question text
a.
b.
c.
d.
Feedback
The correct answer is: a sequence of identical characters.
Question 43
Complete
Flag question
Question text
Which of the following is a reason why hash tables are a good choice for storing and retrieving
data?
a.
They store data in sorted order so it is easy to find the minimum and maximum element
b.
They are very space efficient compared to binary search trees and linked lists
c.
The correct answer is: They are very fast in practice for finding items in a set
Question 44
Complete
Flag question
Question text
The best technique when the amount of data is not well known is ……
a.
quadratic probing.
b.
linear probing.
c.
separate chaining.
d.
double hashing.
Feedback
Question 45
Complete
Flag question
Question text
a.
Union-Find
b.
c.
Graph coloring
d.
Question 46
Complete
Flag question
Question text
a.
Dynamic Programming
b.
c.
Greedy approach
d.
Complete
Flag question
Question text
a.
The higher the Flesch Index Score, the simpler the text and the easier it is to read.
b.
The lower the Flesch Index Score, the simpler the text and the easier it is to read.
Feedback
The correct answer is: The higher the Flesch Index Score, the simpler the text and the easier it
is to read.
Question 48
Complete
Question text
a.
b.
c.
d.
Dijkstra’s algorithm finds the shortest path from one specified vertex to all other vertices.
Feedback
The correct answer is: Dijkstra’s algorithm cannot be applied to undirected weighted
graphs.
Question 49
Complete
Flag question
Question text
Select correct statement:
a.
The bubble sort always ends up comparing every item with every other item.
b.
c.
If there are N items, the bubble sort makes exactly N*N comparisons.
d.
In a particular sorting situation, if swaps take much longer than comparisons, the selection
sort is about twice as fast as the bubble sort.
Feedback
Question 50
Complete
Flag question
Question text
What is the tightest Big-O running time to calculate the Flesch readability score for the
BasicDocument class, where n is the length of the document?
a.
O( n )
b.
O(n^2)
c.
O(n^3)
d.
O(1)
Feedback
Question 51
Complete
Flag question
Question text
a.
the total weight of the edges from the starting vertex to a specified vertex.
b.
c.
the total weight of edges connecting all the vertices.
d.
Feedback
The correct answer is: the total weight of edges connecting all the vertices.
Question 52
Complete
Flag question
Question text
Find the average length LHuf for the letters X, Y, and Z and their probabilities .05, .05 and .9
respectively.
a.
0.8
b.
1.75
c.
2.3
d.
1.1
e.
Feedback
Question 53
Complete
Flag question
Question text
Maximum number of nodes in a binary tree with height k, where root is height 0, is
a.
(2^k) -1
b.
(2^(k-1)) -1
c.
(2^(k+1)) -1
d.
(2^k) +1
Feedback
Complete
Flag question
Question text
Which of the following data structures are the most suites for handling the minimum
(maximum) weighted distances?
a.
Linked list
b.
Queue
c.
Priority Queue
d.
Stack
Feedback
Question 55
Complete
Question text
Which of the following data structures does not suitable for implementing Huffman
algorithm?
a.
Heap.
b.
c.
d.
Queue.
Feedback
Question 56
Complete
Flag question
Question text
A hash table of length 10 uses open addressing with hash function h(k)=k mod 10, and
linear probing. After inserting 6 values into an empty hash table, the table is
as shown below.
Which one of the following choices gives a possible order in which the key values could
have been inserted in the table? (Assume that Linear probing was used to resolved
collision)
a.
b.
c.
d.
34, 42, 23, 52, 33, 46
Feedback
Question 57
Complete
Flag question
Question text
Using the coalesced hashing to put the following values in a table with 10 elements:
a.
A5-B5
b.
A5-B5-A9-B9
c.
A5-B2-C2
d.
A5-A2-A3
Feedback
Question 58
Complete
Flag question
Question text
a.
01
b.
101
c.
001
d.
100
Feedback
Question 59
Complete
Flag question
Question text
Which of the following statements about the shortest path finding algorithm of Dijkstra is
true?
a.
It is label-setting algorithm.
b.
c.
d.
Feedback
Question 60
Complete
Flag question
Question text
Which of the following graphs looks most like the graph you (should have) produced in part
2 of the programming assignment? We are looking for you to compare the shapes of the
functions only--these graphs are much smoother than what you would have seen. Also,
ignore the specific numbers, and concentrate on the shapes and the relationship between
the two lines. Note that the correct answer assumes that you have correctly implemented
your two Document classes and your DocumentBenchmarking class.
a.
b.
c.
d.
a
Feedback
The correct answer is: a