Question 1 (1 point) The _____ data structure can be used to efficiently find th
ID: 3736863 • Letter: Q
Question
Question 1 (1 point)
The _____ data structure can be used to efficiently find the kth smallest (or largest) element in an array (called order statistics)
Question 1 options:
Save
Question 2 (1 point)
Which data structure is the most efficient in finding the top 10 largest items in a million stored in a file?
Question 2 options:
1)
2)
3)
4)
Save
Question 3 (1 point)
Which data structure would be best suited for converting a recursive implementation of an algorithm to an iterative implementation
Question 3 options:
1)
2)
3)
4)
Save
Question 4 (1 point)
Which of the following data structures is best suited for efficient implementation of priority queue?
Question 4 options:
1)
2)
3)
4)
Save
Question 5 (1 point)
Which data structure is used for balancing of symbols? (such as making sure an open parenthesis has a closing one)
Question 5 options:
1)
2)
3)
4)
Save
Question 6 (1 point)
Run time of a graph traversal can be reduced to polynomial order by the use of a ____ as the internal traversal data structure.
Question 6 options:
Save
Question 7 (1 point)
The keys 12, 18, 13, 2, 3, 23, 5, and 15 are placed into an emptyy hash table of length 10 with address values of 0 through 9 using open addressing, hash function of h(k) = k mod 10 and linear probing.
If inserted in the order given the 15 will go in shich slot?
Question 7 options:
Save
Question 8 (1 point)
The minimum possible time complexity for a comparison based sorting algorithm and a random input array is O(n)
Question 8 options:
Save
Question 9 (1 point)
What is the output of the following function if called with the argument doFun2(7)?
function doFun2(n) {
// Enqueue is equivalent to push, Dequeue is equivalent to shift
var q = [];
q.push(0); q.push(1);
for (var i = 0; i < n; i++ ){
var a = q.shift();
var b = q.shift();
q.push(b);
q.push(a + b);
}
return q.pop();
}
Question 9 options:
Save
Question 10 (1 point)
What would be the results of f(2) for the following function?
function f(n) {
if (n == 4) return n;
return 2*f(n+1);
}
Explanation / Answer
If you post more than 1 question, as per chegg guidelines I have to solve only 1 question.
Ques 2. Answer : (4) Sorted array
In a sorted array, we just have to traverse the last 10 elements. We don't need to reorder the data structure.
In all other data structure, in order to find to 10 largest element we need to reorder the data structure which takes more time.
Ques 4. (d) Heap
The time complexity of heap is very less. In order to build a heap, we need only O(nlogn) time. Also, we can set the heap according to priority. If we extract an element, we just need O(logn) time to create the heap again usin HEAPIFY() funciton.
Other data structures take more time than this.
Ques 5. (c) Stack
The definition or implementation of stack is such that we can check for balancing. We push the opening symbol and pop when the closing symbol is encountered.