A[ 18, 4, 38, 19, 12, 15, 22, 55, 100 , 200 ]
Find the total number of inversions possible for the given array.
[ Hint: Inversion formal definition is two elements A[i] and A[j] form an inversion if A[i] > A[j] and i < j ]
X
|
Y
|
P: Selection sort
|
1: Ω(n)
|
Q: Insertion sort
|
2: ϴ(d(n+k))
|
R: Merge Sort
|
3: O(n^2)
|
S: Radix sort
|
4: O(nlogn)
|
5, 6, 9, 15, 13, 12, 11
Minimum ____ number of interchanges are needed to convert it into a max-heap?
15, 20, 25, 30, 35, 40, 45
The maximum chain length in the hash table is____?
h(k,i)=(h1(k)+ih2(k)) mod m
Where h1(k)=k mod m
h2(k)=1+(k mod n)
Where n=m-2 and m=501 for k=15150,
What is the difference between first and second probes in terms of slots?
[ Note: i >= 1 ]
void function(int arr[ ], int n)
{
int i, key, j;
for (i = 1; i < n; i++)
{
key = arr[i];
j = i-1;
while (j >= 0 && arr[j] > key)
{
arr[j+1] = arr[j];
j = j-1;
}
arr[j+1] = key;
}
}
empty tree and inserting one element at a time from an input sequence, without any rotations or other manipulations. Which of the following assertions about the order of elements in the input sequence cannot be true?
P: If we randomly choose a pivot elements each time, quicksort will always terminate in time O(n logn)
Q: Bubble and Merge sort is an example of stable property.
R: The collision resolution techniques by chaining and open addressing may result in the worst case search time for one of the ‘n’ keys in the hash table is O(n).
P: Consider an array containing n elements and divided into k (>=2) parts, each of size n-a. Where ‘a’ is a small integer and k is a constant. The computation cost of this operation (i.e dividing into parts) is a unit time. Find the recurrence relation for the given problem?
Q: Consider an array ‘A’ containing n distinct elements and those elements are in non decreasing order. What is the time complexity to find the element in which A[i] = i using divide-and-conquer approach?
What is the correct method recommended for finding if a given number is in an array?
Q: We can always find the maximum in a min-heap in O(log n) time
R: Given two heaps with n elements each, it is possible to construct a single heap comprising all 2n elements in O(n) time
S: Building a heap with n elements can always be done in O(n) time.
I. Heapsort can be used as the auxiliary sorting routine in radix sort, because it operates in place.
II. Consider a heap ‘H’. Each key in a heap is randomly increased or decreased by 1. Then we can restore the heap property on H in linear time O(n). The random choices are independent.
III. A major disadvantage of merge sort is that it cannot easily be converted into a stable sort.