Quiz
Exam Algo Practice
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (168)
1Where is linear searching used?
- AWhen the list has only a few elements
- BWhen performing a single search in an unordered list
- CUsed all the time
- DWhen the list has only a few elements and When performing a single search in an unordered list
2Select the code snippet which performs unordered linear search iteratively?
- Aint unorderedLinearSearch(int arr[], int size, int data)
{
int index;
for(int i = 0; i < size; i++)
{
if(arr[i] == data)
{
index = i;
break;
}
}
return index;
} - Bint unorderedLinearSearch(int arr[], int size, int data)
{
int index;
for(int i = 0; i < size; i++)
{
if(arr[i] == data)
{
break;
}
}
return index;
} - Cint unorderedLinearSearch(int arr[], int size, int data)
{
int index;
for(int i = 0; i <= size; i++)
{
if(arr[i] == data)
{
index = i;
break;
}
}
return index;
} - Dint unorderedLinearSearch(int arr[], int size, int data)
{
int index;
for(int i = 0; i < size-1; i++)
{
if(arr[i] == data)
{
index = i;
break;
}
}
return index;
}
- Aint unorderedLinearSearch(int arr[], int size, int data)
3 What is the best case for linear search?
- AO(nlogn)
- BO(logn)
- CO(1)
- DO(n)
4What is the worst case for linear search?
- AO(nlogn)
- BO(logn)
- CO(1)
- DO(n)
5Select the code snippet which performs ordered linear search iteratively?
- Apublic int linearSearch(int arr[],int key,int size)
{
int index = -1;
int i = 0;
while(size > 0)
{
if(data[i] == key)
{
index = i;
}
if(data[i] > key))
{
index = i;
break;
}
i++;
}
return index;
} - Bpublic int linearSearch(int arr[],int key,int size)
{
int index = -1;
int i = 0;
while(size > 0)
{
if(data[i] == key)
{
index = i;
}
if(data[i] > key))
{
break;
}
i++;
}
return index;
} - Cpublic int linearSearch(int arr[],int key,int size)
{
int index = -1;
int i = 0;
while(size > 0)
{
if(data[i] == key)
{
break;
}
if(data[i] > key))
{
index = i;
}
i++;
}
return index;
} - Dpublic int linearSearch(int arr[],int key,int size)
{
int index = -1;
int i = 0;
while(size > 0)
{
if(data[i] == key)
{
break;
}
if(data[i] > key))
{
break;
index=i;
}
i++;
}
return index;
}
- Apublic int linearSearch(int arr[],int key,int size)
6What is the best case and worst case complexity of ordered linear search?
- AO(nlogn), O(logn)
- BO(logn), O(nlogn)
- CO(n), O(1)
- DO(1), O(n)
7Choose the code snippet which uses recursion for linear search.
- Apublic void linSearch(int[] arr, int first, int last, int key)
{
if(first == last)
{
System.out.print("-1");
}
else
{
if(arr[first] == key)
{
System.out.print(first);
}
else
{
linSearch(arr, first+1, last, key);
}
}
} - Bpublic void linSearch(int[] arr, int first, int last, int key)
{
if(first == last)
{
System.out.print("-1");
}
else
{
if(arr[first] == key)
{
System.out.print(first);
}
else
{
linSearch(arr, first+1, last-1, key);
}
}
} - Cpublic void linSearch(int[] arr, int first, int last, int key)
{
if(first == last)
{
System.out.print("-1");
}
else
{
if(arr[first] == key)
{
System.out.print(last);
}
else
{
linSearch(arr, first+1, last, key);
}
}
} - Dpublic void linSearch(int[] arr, int first, int last, int key)
{
if(first == last)
{
System.out.print("-1");
}
else
{
if(arr[first] == key)
{
System.out.print(first);
}
else
{
linSearch(arr, first+1, last+1, key);
}
}
}
- Apublic void linSearch(int[] arr, int first, int last, int key)
8What does the following piece of code do?
for (int i = 0; i < arr.length-1; i++)
{
for (int j = i+1; j < arr.length; j++)
{
if( (arr[i].equals(arr[j])) && (i != j) )
{
System.out.println(arr[i]);
}
}
}- APrint the duplicate elements in the array
- BPrint the element with maximum frequency
- CPrint the unique elements in the array
- DPrints the element with minimum frequnecy
9Select the code snippet which prints the element with maximum frequency.
- Apublic int findPopular(int[] a)
{
if (a == null || a.length == 0)
return 0;
Arrays.sort(a);
int previous = a[0];
int popular = a[0];
int count = 1;
int maxCount = 1;
for (int i = 1; i < a.length; i++)
{
if (a[i] == previous)
count++;
else
{
if (count > maxCount)
{
popular = a[i-1];
maxCount = count;
}
previous = a[i];
count = 1;
}
}
return count > maxCount ? a[a.length-1] : popular;
} - Bpublic int findPopular(int[] a)
{
if (a == null || a.length == 0)
return 0;
Arrays.sort(a);
int previous = a[0];
int popular = a[0];
int count = 1;
int maxCount = 1;
for (int i = 1; i < a.length; i++)
{
if (a[i] == previous)
count++;
else
{
if (count > maxCount)
{
popular = a[i];
maxCount = count;
}
previous = a[i];
count = 1;
}
}
return count > maxCount ? a[a.length-1] : popular;
} - Cpublic int findPopular(int[] a)
{
if (a == null || a.length == 0)
return 0;
Arrays.sort(a);
int previous = a[0];
int popular = a[0];
int count = 1;
int maxCount = 1;
for (int i = 1; i < a.length; i++)
{
if (a[i+1] == previous)
count++;
else
{
if (count > maxCount)
{
popular = a[i-1];
maxCount = count;
}
previous = a[i];
count = 1;
}
}
return count > maxCount ? a[a.length-1] : popular;
} - Dpublic int findPopular(int[] a)
{
if (a == null || a.length == 0)
return 0;
Arrays.sort(a);
int previous = a[0];
int popular = a[0];
int count = 1;
int maxCount = 1;
for (int i = 1; i < a.length; i++)
{
if (a[i+2] == previous)
count++;
else
{
if (count > maxCount)
{
popular = a[i-1];
maxCount = count;
}
previous = a[i];
count = 1;
}
}
return count > maxCount ? a[a.length-1] : popular;
}
- Apublic int findPopular(int[] a)
10Which of the following is a disadvantage of linear search?
- ARequires more space
- BGreater time complexities compared to other searching algorithms
- CNot easy to understand
- DNot easy to implement
11Is there any difference in the speed of execution between linear serach(recursive) vs linear search(lterative)?
- ABoth execute at same speed
- BLinear search(recursive) is faster
- CLinear search(Iterative) is faster
- DCant be said
12Is the space consumed by the linear search(recursive) and linear search(iterative) same?
- ANo, recursive algorithm consumes more space
- BNo, recursive algorithm consumes less space
- CYes
- DNothing can be said
13What is the worst case runtime of linear search(recursive) algorithm?
- AO(n)
- BO(nlogn)
- CO(n^2)
- DO(nx)
14Linear search(recursive) algorithm used in _____________
- AWhen the size of the dataset is low
- BWhen the size of the dataset is large
- CWhen the dataset is unordered
- DNever used
15The array is as follows: 1,2,3,6,8,10. At what time the element 6 is found? (By using linear search(recursive) algorithm)
- A4th call
- B3rd call
- C6th call
- D5th call
16The array is as follows: 1,2,3,6,8,10. Given that the number 17 is to be searched. At which call it tells that there’s no such element? (By using linear search(recursive) algorithm)
- A7th call
- B9th call
- C17th call
- DThe function calls itself infinite number of times
17What is the best case runtime of linear search(recursive) algorithm on an ordered set of elements?
- AO(1)
- BO(n)
- CO(logn)
- DO(nx)
18Which of the following code snippet performs linear search recursively?
- Afor(i=0;i<n;i++)
{
if(a[i]==key)
printf("element found");
} - BLinearSearch(int[] a, n,key)
{
if(n<1)
return False
if(a[n]==key)
return True
else
LinearSearch(a,n-1,key)
} - CLinearSearch(int[] a, n,key)
{
if(n<1)
return True
if(a[n]==key)
return False
else
LinearSearch(a,n-1,key)
} - DLinearSearch(int[] a, n,key)
{
if(n<1)
return False
if(a[n]==key)
return True
else
LinearSearch(a,n+1,key)
}
- Afor(i=0;i<n;i++)
19Can linear search recursive algorithm and binary search recursive algorithm be performed on an unordered list?
- ABinary search can’t be used
- BLinear search can’t be used
- CBoth cannot be used
- DBoth can be used
20What is the recurrence relation for the linear search recursive algorithm?
- AT(n-2)+c
- B2T(n-1)+c
- CT(n-1)+c
- DT(n+1)+c
21What is the advantage of recursive approach than an iterative approach?
- AConsumes less memory
- BLess code and easy to implement
- CConsumes more memory
- DMore code has to be written
22Choose the appropriate code that does binary search using recursion.
- Apublic static int recursive(int arr[], int low, int high, int key)
{
int mid = low + (high - low)/2;
if(arr[mid] == key)
{
return mid;
}
else if(arr[mid] < key)
{
return recursive(arr,mid+1,high,key);
}
else
{
return recursive(arr,low,mid-1,key);
}
} - Bpublic static int recursive(int arr[], int low, int high, int key)
{
int mid = low + (high + low)/2;
if(arr[mid] == key)
{
return mid;
}
else if(arr[mid] < key)
{
return recursive(arr,mid-1,high,key);
}
else
{
return recursive(arr,low,mid+1,key);
}
} - Cpublic static int recursive(int arr[], int low, int high, int key)
{
int mid = low + (high - low)/2;
if(arr[mid] == key)
{
return mid;
}
else if(arr[mid] < key)
{
return recursive(arr,mid,high,key);
}
else
{
return recursive(arr,low,mid-1,key);
}
} - Dpublic static int recursive(int arr[], int low, int high, int key)
{
int mid = low + ((high - low)/2)+1;
if(arr[mid] == key)
{
return mid;
}
else if(arr[mid] < key)
{
return recursive(arr,mid,high,key);
}
else
{
return recursive(arr,low,mid-1,key);
}
}
- Apublic static int recursive(int arr[], int low, int high, int key)
23Given an input arr = {2,5,7,99,899}; key = 899; What is the level of recursion?
- A5
- B2
- C3
- D4
24Given an array arr = {45,77,89,90,94,99,100} and key = 99; what are the mid values(corresponding array elements) in the first and second levels of recursion?
- A90 and 99
- B90 and 94
- C89 and 99
- D89 and 94
25What is the worst case complexity of binary search using recursion?
- AO(nlogn)
- BO(logn)
- CO(n)
- DO(n2)
26What is the average case time complexity of binary search using recursion?
- AO(nlogn)
- BO(logn)
- CO(n)
- DO(n2)
27Which of the following is not an application of binary search?
- ATo find the lower/upper bound in an ordered sequence
- BUnion of intervals
- CDebugging
- DTo search in unordered list
28Choose among the following code for an iterative binary search.
- Apublic static int iterative(int arr[], int key)
{
int low = 0;
int mid = 0;
int high = arr.length-1;
while(low <= high)
{
mid = low + (high + low)/2;
if(arr[mid] == key)
{
return mid;
}
else if(arr[mid] < key)
{
low = mid - 1;
}
else
{
high = mid + 1;
}
}
return -1;
} - Bpublic static int iterative(int arr[], int key)
{
int low = 0;
int mid = 0;
int high = arr.length-1;
while(low <= high)
{
mid = low + (high - low)/2;
if(arr[mid] == key)
{
return mid;
}
else if(arr[mid] < key)
{
low = mid + 1;
}
else
{
high = mid - 1;
}
}
return -1;
} - Cpublic static int iterative(int arr[], int key)
{
int low = 0;
int mid = 0;
int high = arr.length-1;
while(low <= high)
{
mid = low + (high + low)/2;
if(arr[mid] == key)
{
return mid;
}
else if(arr[mid] < key)
{
low = mid + 1;
}
else
{
high = mid - 1;
}
}
return -1;
} - Dpublic static int iterative(int arr[], int key)
{
int low = 0;
int mid = 0;
int high = arr.length-1;
while(low <= high)
{
mid = low + (high - low)/2;
if(arr[mid] == key)
{
return mid;
}
else if(arr[mid] < key)
{
low = mid - 1;
}
else
{
high = mid + 1;
}
}
return -1;
}
- Apublic static int iterative(int arr[], int key)
29Binary Search can be categorized into which of the following?
- ABrute Force technique
- BDivide and conquer
- CGreedy algorithm
- DDynamic programming
30Given an array arr = {5,6,77,88,99} and key = 88; How many iterations are done until the element is found?
- A1
- B3
- C4
- D2
31Given an array arr = {45,77,89,90,94,99,100} and key = 100; What are the mid values(corresponding array elements) generated in the first and second iterations?
- A90 and 99
- B90 and 100
- C89 and 94
- D94 and 99
32 What is the time complexity of binary search with iteration?
- AO(nlogn)
- BO(logn)
- CO(n)
- DO(n2)
33Which algorithmic technique does Fibonacci search use?
- ABrute force
- BDivide and Conquer
- CGreedy Technique
- DBacktracking
34Choose the recursive formula for the Fibonacci series.(n>=1)
- AF(n) = F(n+1) + F(n+2)
- BF(n) = F(n) + F(n+1)
- CF(n) = F(n-1) + F(n-2)
- DF(n) = F(n-1) – F(n-2)
35Write a function for the Fibonacci search method.
- Apublic static int fibSearch(final int key, final int[] a)
{
int low = 0;
int high = a.length - 1;
int fibCurrent = 1;
int fibPrev = 1;
int N = a.length;
while (low <= high)
{
while(fibCurrent < N)
{
int tmp = fibCurrent + fibPrev;
fibPrev = fibCurrent;
fibCurrent = tmp;
N = N - (fibCurrent - fibPrev);
}
final int mid = low + (high - low) - (fibCurrent + fibPrev);
if (key < a[mid]) high = mid - 1;
else if (key > a[mid]) low = mid + 1;
else return mid;
}
return -1;
} - Bpublic static int fibSearch(final int key, final int[] a)
{
int low = 0;
int high = a.length - 1;
int fibCurrent = 1;
int fibPrev = 1;
int N = a.length;
while (low <= high)
{
int tmp = fibCurrent + fibPrev;
fibPrev = fibCurrent;
fibCurrent = tmp;
N = N - (fibCurrent - fibPrev);
final int mid = low + (high - low) - (fibCurrent + fibPrev);
if (key < a[mid]) high = mid - 1;
else if (key > a[mid]) low = mid + 1;
else return mid;
}
return -1;
} - Cpublic static int fibSearch(final int key, final int[] a)
{
int low = 0;
int high = a.length - 1;
int fibCurrent = 1;
int fibPrev = 1;
int N = a.length;
while (low <= high)
{
while(fibCurrent < N)
{
int tmp = fibCurrent + fibPrev;
fibPrev = fibCurrent;
fibCurrent = tmp;
N = N - (fibCurrent - fibPrev);
}
final int mid = low + (high - low) - (fibCurrent + fibPrev);
if (key < a[mid]) low = mid + 1;
else if (key > a[mid]) high = mid - 1;
else return mid;
}
} - Dpublic static int fibSearch(final int key, final int[] a)
{
int low = 0;
int high = a.length - 1;
int fibCurrent = 1;
int fibPrev = 1;
int N = a.length;
while (low <= high)
{
while(fibCurrent < N)
{
int tmp = fibCurrent + fibPrev;
fibPrev = fibCurrent;
fibCurrent = tmp;
N = N - (fibCurrent - fibPrev);
}
final int mid = low + (high - low) - (fibCurrent + fibPrev);
if (key < a[mid]) low = mid - 1;
else if (key > a[mid]) high = mid - 1;
else return mid;
}
}
- Apublic static int fibSearch(final int key, final int[] a)
36What is the time complexity of Fibonacci Search?
- AO(logn)
- BO(n)
- CO(n^2)
- DO(nlogn)
37Which of the following is not an advantage of Fibonacci Search?
- AWhen the element being searched for has a non uniform access storage
- BCan be used in magnetic tapes
- CCan be used for large arrays which do not fit in the CPU cache or in the RAM
- DIt can be applied efficiently on unsorted arrays
38What is the length of the step in jump search?
- An
- Bn/2
- Csqrt(n)
- D1
39Select the code snippet for Jump Search.
- Apublic int jumpSearch(int arr[], int key)
{
int size = arr.length;
int step = floor(sqrt(size));
int prev = 0;
while (arr[(step > size ? step : size)] < key)
{
prev = step;
step += floor(sqrt(size));
if (step >= size)
{
return -1;
}
}
while (arr[prev] < key)
{
prev++;
if (prev == (step < size ? step : size))
{
return -1;
}
}
if (arr[prev] == key)
{
return prev;
}
return -1;
} - Bpublic int jumpSearch(int arr[], int key)
{
int size = arr.length;
int step = floor(sqrt(size));
int prev = 0;
while (arr[(step < size ? step : size)] < key)
{
prev = step;
step += floor(sqrt(size));
if (step >= size)
{
return -1;
}
}
while (arr[prev] < key)
{
prev++;
if (prev == (step < size ? step : size))
{
return -1;
}
}
if (arr[prev] == key)
{
return prev;
}
return -1;
} - Cpublic int jumpSearch(int arr[], int key)
{
int size = arr.length;
int step = floor(sqrt(size));
int prev = 0;
while (arr[(step > size ? step : size)] < key)
{
prev = step;
step += floor(sqrt(size));
if (step >= size)
{
return -1;
}
}
while (arr[prev] > key)
{
prev++;
if (prev == (step < size ? step : size))
{
return -1;
}
}
if (arr[prev] == key)
{
return prev;
}
return -1;
} - Dpublic int jumpSearch(int arr[], int key)
{
int size = arr.length;
int step = floor(sqrt(size));
int prev = 0;
while (arr[(step > size ? step : size)] < key)
{
prev = step;
step += floor(sqrt(size));
if (step <= size)
{
return -1;
}
}
while (arr[prev] > key)
{
prev++;
if (prev == (step < size ? step : size))
{
return -1;
}
}
if (arr[prev] == key)
{
return prev;
}
return -1;
}
- Apublic int jumpSearch(int arr[], int key)
40What is the time complexity of Jump Search?
- AO(logn)
- BO(n)
- CO(sqrt(n))
- DO(nlogn)
41Exponential search algorithm requires which of the following condition to be true?
- Aarray should be sorted
- Barray should have not be sorted
- Carray should have a less than 128 elements
- Darray should be partially sorted
42Which of the following searching algorithm is used with exponential sort after finding the appropriate range?
- ALinear search
- BBinary search
- CJump search
- DFibonacci Search
43Exponential search has ____________
- Aneither an exponential space complexity nor exponential time complexity
- Bexponential time complexity but a linear space complexity
- Cexponential space complexity but a linear time complexity
- Dboth exponential time and space complexity
44Choose the correct while loop statement from the following that finds the range where are the element being search is present (x is the element being searched in an array arr of size n)?
- Awhile (i < n && arr[i] <= x)
i = i*2; - Bwhile (i < n && arr[i] <= x)
i = i/2; - Cwhile (arr[i] <= x)
i = i/2; - Dwhile (i < n)
i = i*2;
- Awhile (i < n && arr[i] <= x)
45What is the time complexity of exponential sort?
- AO(n)
- BO(2n)
- CO(n log n)
- DO(log n)
46What is the auxiliary space requirement of an exponential sort when used with iterative binary search?
- AO(n)
- BO(2^n)
- CO(1)
- DO(log n)
47What is the auxiliary space requirement of the exponential sort when used with recursive binary search?
- AO(n)
- BO(2^n)
- CO(1)
- DO(log n)
48Which of the following searching algorithm is fastest?
- Ajump search
- Bexponential search
- Clinear search
- Dall are equally fast
49In which of the following case jump search will be preferred over exponential search?
- Ajumping backwards takes significantly more time than jumping forward
- Bjumping forward takes significantly more time than jumping backwards
- Cwhen the given array is very large in size
- Dwhen the given array is very small in size
50Best case of the exponential search will have time complexity of?
- AO(1)
- BO(n)
- CO(log n)
- DO(n log n)
51Which of the following code correctly represent exponential search?
- Aint expSearch(int arr[], int n, int x)
{
if (arr[0] == x)
return 0;
int i = 1;
while (i < n && arr[i] <= x)
i = i*2;
return binarySearch(arr, i/2, min(i, n-1), x);
//applies binary search in the calculated range
} - Bint expSearch(int arr[], int n, int x)
{
if (arr[0] == x)
return 0;
int i = 1;
while (i < n && arr[i] <= x)
i = i*2;
return binarySearch(arr, i, min(i, n-1), x);
//applies binary search in the calculated range
} - Cint expSearch(int arr[], int n, int x)
{
if (arr[0] == x)
return 0;
int i = 1;
while (i < n && arr[i] <= x)
i = i/2;
return binarySearch(arr, i/2, min(i, n-1), x);
//applies binary search in the calculated range
} - Dint expSearch(int arr[], int n, int x)
{
if (arr[0] == x)
return 0;
int i = 1;
while (i < n && arr[i] <= x)
i = i*2;
return binarySearch(arr, i/2, max(i, n-1), x);
//applies binary search in the calculated range
}
- Aint expSearch(int arr[], int n, int x)
52Jump search has a better time complexity than the exponential search.
- Atrue
- Bfalse
53Exponential search performs better than binary search when the element being searched is present near the starting point of the array.
- Atrue
- Bfalse
54Choose the incorrect statement about exponential search from the following.
- AExponential search is an in place algorithm
- BExponential search has a greater time complexity than binary search
- CExponential search performs better than binary search when the element being searched is present near the starting point of the array
- DJump search has a greater time complexity than an exponential search
55Which of the following is not an alternate name of exponential search?
- ALogarithmic search
- BDoubling search
- CGalloping search
- DStruzik search
56How many passes does an insertion sort algorithm consist of?
- AN
- BN-1
- CN+1
- DN^2
57Which of the following algorithm implementations is similar to that of an insertion sort?
- ABinary heap
- BQuick sort
- CMerge sort
- DRadix sort
58What is the average case running time of an insertion sort algorithm?
- AO(N)
- BO(N log N)
- CO(log N)
- DO(N^2)
59Any algorithm that sorts by exchanging adjacent elements require O(n^2) on average
- ATrue
- BFalse
60What is the average number of inversions in an array of N distinct numbers?
- AN(N-1)/4
- BN(N+1)/2
- CN(N-1)/2
- DN(N-1)/3
61What is the running time of an insertion sort algorithm if the input is pre-sorted?
- AO(N^2)
- BO(N log N)
- CO(N)
- DO(M log N)
62What will be the number of passes to sort the elements using insertion sort?
14, 12,16, 6, 3, 10- A6
- B5
- C7
- D1
63For the following question, how will the array elements look like after second pass?
34, 8, 64, 51, 32, 21- A8, 21, 32, 34, 51, 64
- B8, 32, 34, 51, 64, 21
- C8, 34, 51, 64, 32, 21
- D8, 34, 64, 51, 32, 21
64Which of the following real time examples is based on insertion sort?
- Aarranging a pack of playing cards
- Bdatabase scenarios and distributes scenarios
- Carranging books on a library shelf
- Dreal-time systems
65 In C, what are the basic loops required to perform an insertion sort?
- Ado- while
- Bif else
- Cfor and while
- Dfor and if
66Binary search can be used in an insertion sort algorithm to reduce the number of comparisons.
- ATrue
- BFalse
67Which of the following options contain the correct feature of an insertion sort algorithm?
- Aanti-adaptive
- Bdependable
- Cstable, not in-place
- Dstable, adaptive
68Which of the following sorting algorithms is the fastest for sorting small arrays?
- AQuick sort
- BInsertion sort
- CShell sort
- DHeap sort
69For the best case input, the running time of an insertion sort algorithm is?
- ALinear
- BBinary
- CQuadratic
- DDepends on the input
70Which of the following examples represent the worst case input for an insertion sort?
- Aarray in sorted order
- Barray sorted in reverse order
- Cnormal unsorted array
- Dlarge array
71Which of the following is correct with regard to insertion sort?
- Ainsertion sort is stable and it sorts In-place
- Binsertion sort is unstable and it sorts In-place
- Cinsertion sort is stable and it does not sort In-place
- Dinsertion sort is unstable and it does not sort In-place
72Which of the following sorting algorithm is best suited if the elements are already sorted?
- AHeap Sort
- BQuick Sort
- CInsertion Sort
- DMerge Sort
73The worst case time complexity of insertion sort is O(n2). What will be the worst case time complexity of insertion sort if the correct position for inserting element is calculated using binary search?
- AO(nlogn)
- BO(n^2)
- CO(n)
- DO(logn)
74Insertion sort is an example of an incremental algorithm.
- ATrue
- BFalse
75Consider the code given below, which runs insertion sort:
void insertionSort(int arr[], int array_size)
{
int i, j, value;
for (i = 1; i < array_size; i++)
{
value = arr[i];
j = i;
while (________ )
{
arr[j] = arr[j − 1];
j = j − 1;
}
arr[j] = value;
}
}
Which condition will correctly implement the while loop?- A(j > 0) || (arr[j − 1] > value)
- B(j > 0) && (arr[j − 1] > value)
- C(j > 0) && (arr[j + 1] > value)
- D(j > 0) && (arr[j + 1] < value)
76Which of the following is good for sorting arrays having less than 100 elements?
- AQuick Sort
- BSelection Sort
- CMerge Sort
- DInsertion Sort
77Consider an array of length 5, arr[5] = {9,7,4,2,1}. What are the steps of insertions done while running insertion sort on the array?
- A7 9 4 2 1 4 7 9 2 1 2 4 7 9 1 1 2 4 7 9
- B9 7 4 1 2 9 7 1 2 4 9 1 2 4 7 1 2 4 7 9
- C7 4 2 1 9 4 2 1 9 7 2 1 9 7 4 1 9 7 4 2
- D7 9 4 2 1 2 4 7 9 1 4 7 9 2 1 1 2 4 7 9
78Statement 1: In insertion sort, after m passes through the array, the first m elements are in sorted order.
Statement 2: And these elements are the m smallest elements in the array.- ABoth the statements are true
- BStatement 1 is true but statement 2 is false
- CStatement 1 is false but statement 2 is true
- DBoth the statements are false
79In insertion sort, the average number of comparisons required to place the 7th element into its correct position is ____
- A9
- B4
- C7
- D14
80Which of the following is not an exchange sort?
- ABubble Sort
- BQuick Sort
- CPartition-exchange Sort
- DInsertion Sort
81What is an in-place sorting algorithm?
- AIt needs O(1) or O(logn) memory to create auxiliary locations
- BThe input is already sorted and in-place
- CIt requires additional storage
- DIt requires additional space
82 In the following scenarios, when will you use selection sort?
- AThe input is already sorted
- BA large file has to be sorted
- CLarge values need to be sorted with small keys
- DSmall values need to be sorted with large keys
83 What is the worst case complexity of selection sort?
- AO(nlogn)
- BO(logn)
- CO(n)
- DO(n^2)
84Select the appropriate code that performs selection sort.
- Aint min;
for(int j=0; j<arr.length-1; j++)
{
min = j;
for(int k=j+1; k<=arr.length-1; k++)
{
if(arr[k] < arr[min])
min = k;
}
int temp = arr[min];
arr[min] = arr[j];
arr[j] = temp;
} - Bint min;
for(int j=0; j<arr.length-1; j++)
{
min = j;
for(int k=j+1; k<=arr.length; k++)
{
if(arr[k] < arr[min])
min = k;
}
int temp = arr[min];
arr[min] = arr[j];
arr[j] = temp;
} - Cint min;
for(int j=0; j<arr.length-1; j++)
{
min = j;
for(int k=j+1; k<=arr.length-1; k++)
{
if(arr[k] > arr[min])
min = k;
}
int temp = arr[min];
arr[min] = arr[j];
arr[j] = temp;
} - Dint min;
for(int j=0; j<arr.length-1; j++)
{
min = j;
for(int k=j+1; k<=arr.length; k++)
{
if(arr[k] > arr[min])
min = k;
}
int temp = arr[min];
arr[min] = arr[j];
arr[j] = temp;
}
- Aint min;
85What is the advantage of selection sort over other sorting techniques?
- AIt requires no additional storage space
- BIt is scalable
- CIt works best for inputs which are already sorted
- DIt is faster than any other sorting technique
86What is the average case complexity of selection sort?
- AO(nlogn)
- BO(logn)
- CO(n)
- DO(n^2)
87What is the disadvantage of selection sort?
- AIt requires auxiliary memory
- BIt is not scalable
- CIt can be used for small keys
- DIt takes linear time to sort the elements
88The given array is arr = {3,4,5,2,1}. The number of iterations in bubble sort and selection sort respectively are __________
- A5 and 4
- B4 and 5
- C2 and 4
- D2 and 5
89The given array is arr = {1,2,3,4,5}. (bubble sort is implemented with a flag variable)The number of iterations in selection sort and bubble sort respectively are __________
- A5 and 4
- B1 and 4
- C0 and 4
- D4 and 1
90What is the best case complexity of selection sort?
- AO(nlogn)
- BO(logn)
- CO(n)
- DO(n^2)
91What is an external sorting algorithm?
- AAlgorithm that uses tape or disk during the sort
- BAlgorithm that uses main memory during the sort
- CAlgorithm that involves swapping
- DAlgorithm that are considered ‘in place’
92What is an internal sorting algorithm?
- AAlgorithm that uses tape or disk during the sort
- BAlgorithm that uses main memory during the sort
- CAlgorithm that involves swapping
- DAlgorithm that are considered ‘in place’
93What is the worst case complexity of bubble sort?
- AO(nlogn)
- BO(logn)
- CO(n)
- DO(n^2)
94Select the appropriate code that performs bubble sort.
- Afor(int j=arr.length-1; j>=0; j--)
{
for(int k=0; k<j; k++)
{
if(arr[k] > arr[k+1])
{
int temp = arr[k];
arr[k] = arr[k+1];
arr[k+1] = temp;
}
}
} - Bfor(int j=arr.length-1; j>=0; j--)
{
for(int k=0; k<j; k++)
{
if(arr[k] < arr[k+1])
{
int temp = arr[k];
arr[k] = arr[k+1];
arr[k+1] = temp;
}
}
} - Cfor(int j=arr.length; j>=0; j--)
{
for(int k=0; k<j; k++)
{
if(arr[k] > arr[k+1])
{
int temp = arr[k];
arr[k] = arr[k+1];
arr[k+1] = temp;
}
}
} - Dfor(int j=arr.length; j>=0; j--)
{
for(int k=0; k<j; k++)
{
if(arr[k] > arr[k+2])
{
int temp = arr[k];
arr[k] = arr[k+1];
arr[k+1] = temp;
}
}
}
- Afor(int j=arr.length-1; j>=0; j--)
95What is the average case complexity of bubble sort?
- AO(nlogn)
- BO(logn)
- CO(n)
- DO(n^2)
96Which of the following is not an advantage of optimised bubble sort over other sorting techniques in case of sorted elements?
- AIt is faster
- BConsumes less memory
- CDetects whether the input is already sorted
- DConsumes less time
97The given array is arr = {1, 2, 4, 3}. Bubble sort is used to sort the array elements. How many iterations will be done to sort the array?
- A4
- B2
- C1
- D0
98How can you improve the best case efficiency in bubble sort? (The input is already sorted)
- Aboolean swapped = false;
for(int j=arr.length-1; j>=0 && swapped; j--)
{
swapped = true;
for(int k=0; k<j; k++)
{
if(arr[k] > arr[k+1])
{
int temp = arr[k];
arr[k] = arr[k+1];
arr[k+1] = temp;
swapped = false;
}
}
} - Bboolean swapped = true;
for(int j=arr.length-1; j>=0 && swapped; j--)
{
swapped = false;
for(int k=0; k<j; k++)
{
if(arr[k] > arr[k+1])
{
int temp = arr[k];
arr[k] = arr[k+1];
arr[k+1] = temp;
}
}
} - Cboolean swapped = true;
for(int j=arr.length-1; j>=0 && swapped; j--)
{
swapped = false;
for(int k=0; k<j; k++)
{
if(arr[k] > arr[k+1])
{
int temp = arr[k];
arr[k] = arr[k+1];
arr[k+1] = temp;
swapped = true;
}
}
} - Dboolean swapped = true;
for(int j=arr.length-1; j>=0 && swapped; j--)
{
for(int k=0; k<j; k++)
{
if(arr[k] > arr[k+1])
{
int temp = arr[k];
arr[k] = arr[k+1];
arr[k+1] = temp;
swapped = true;
}
}
}
- Aboolean swapped = false;
99What is the best case efficiency of bubble sort in the improvised version?
- AO(nlogn)
- BO(logn)
- CO(n)
- DO(n^2)
100The given array is arr = {1,2,4,3}. Bubble sort is used to sort the array elements. How many iterations will be done to sort the array with improvised version?
- A4
- B2
- C1
- D0
101Merge sort uses which of the following technique to implement sorting?
- Abacktracking
- Bgreedy algorithm
- Cdivide and conquer
- Ddynamic programming
102What is the average case time complexity of merge sort?
- AO(n log n)
- BO(n^2)
- CO(n^2 log n)
- DO(n log n^2)
103What is the auxiliary space complexity of merge sort?
- AO(1)
- BO(n)
- CO(log n)
- DO(n log n)
104Merge sort can be implemented using O(1) auxiliary space.
- ATrue
- BFalse
105What is the worst case time complexity of merge sort?
- AO(n log n)
- BO(n^2)
- CO(n^2 log n)
- DO(n log n^2)
106Which of the following method is used for sorting in merge sort?
- Amerging
- Bpartitioning
- Cselection
- Dexchanging
107What will be the best case time complexity of merge sort?
- AO(n log n)
- BO(n^2)
- CO(n^2 log n)
- DO(n log n^2)
108 Which of the following is not a variant of merge sort?
- Ain-place merge sort
- Bbottom up merge sort
- Ctop down merge sort
- Dlinear merge sort
109Choose the incorrect statement about merge sort from the following?
- Ait is a comparison based sort
- Bit is an adaptive algorithm
- Cit is not an in place algorithm
- Dit is stable algorithm
110Which of the following is not in place sorting algorithm by default?
- Amerge sort
- Bquick sort
- Cheap sort
- Dinsertion sort
111Which of the following is not a stable sorting algorithm?
- AQuick sort
- BCocktail sort
- CBubble sort
- DMerge sort
112Which of the following stable sorting algorithm takes the least time when applied to an almost sorted array?
- AQuick sort
- BInsertion sort
- CSelection sort
- DMerge sort
113Merge sort is preferred for arrays over linked lists.
- ATrue
- BFalse
114Which of the following sorting algorithm makes use of merge sort?
- Atim sort
- Bintro sort
- Cbogo sort
- Dquick sort
115Choose the correct code for merge sort.
- Avoid merge_sort(int arr[], int left, int right)
{
if (left > right)
{
int mid = (right-left)/2;
merge_sort(arr, left, mid);
merge_sort(arr, mid+1, right);
merge(arr, left, mid, right); //function to merge sorted arrays
}
} - Bvoid merge_sort(int arr[], int left, int right)
{
if (left < right)
{
int mid = left+(right-left)/2;
merge_sort(arr, left, mid);
merge_sort(arr, mid+1, right);
merge(arr, left, mid, right); //function to merge sorted arrays
}
} - Cvoid merge_sort(int arr[], int left, int right)
{
if (left < right)
{
int mid = left+(right-left)/2;
merge(arr, left, mid, right); //function to merge sorted arrays
merge_sort(arr, left, mid);
merge_sort(arr, mid+1, right);
}
} - Dvoid merge_sort(int arr[], int left, int right)
{
if (left < right)
{
int mid = (right-left)/2;
merge(arr, left, mid, right); //function to merge sorted arrays
merge_sort(arr, left, mid);
merge_sort(arr, mid+1, right);
}
}
- Avoid merge_sort(int arr[], int left, int right)
116Which of the following sorting algorithm does not use recursion?
- Aquick sort
- Bmerge sort
- Cheap sort
- Dbottom up merge sort
117Merge sort uses which of the following algorithm to implement sorting?
- Abacktracking
- Bgreedy algorithm
- Cdivide and conquer
- Ddynamic programming
118What is the average case time complexity of standard merge sort?
- AO(n log n)
- BO(n^2)
- CO(n^2 log n)
- DO(n log n^2)
119What is the auxiliary space complexity of standard merge sort?
- AO(1)
- BO(log n)
- CO(n)
- DO(n log n)
120What is the space complexity of in place merge sort?
- AO(1)
- BO(n)
- CO(log n)
- DO(n log n)
121What is the average time complexity of in place merge sort when we use the following function for merging?
void in_place_merge(int arr[], int l, int middle, int r)
{
int start2 = middle + 1;
if (arr[middle] <= arr[start2])
{
return;
}
while (l <= middle && start2 <= r)
{
if (arr[l] <= arr[start2])
{
l++;
}
else
{
int val = arr[start2];
int index = start2;
while (index != l)
{
arr[index] = arr[index - 1];
index--;
}
arr[l] = val;
l++;
middle++;
start2++;
}
}
}- AO(n log n)
- BO(n^2)
- CO(n^2 log n)
- DO(n log n^2)
122Merge sort uses which of the following method to implement sorting?
- Amerging
- Bpartitioning
- Cselection
- Dexchanging
123In place merge sort has same time complexity as standard merge sort.
- ATrue
- BFalse
124In-place merge sort is a stable sort.
- ATrue
- BFalse
125Choose the incorrect statement about merge sort from the following?
- Aboth standard merge sort and in-place merge sort are stable
- Bstandard merge sort has greater time complexity than in-place merge sort
- Cstandard merge sort has greater space complexity than in-place merge sort
- Din place merge sort has O(log n) space complexity
126Choose the correct function from the following that implements merging in in-place merge sort.
- Avoid in_place_merge(int arr[], int l, int middle, int r)
{
int start2 = middle + 1;
if (arr[middle] <= arr[start2])
{
return;
}
while (l <= middle+1 && start2 <= r)
{
if (arr[l] <= arr[start2])
{
l++;
}
else
{
int val = arr[start2];
int index = start2;
while (index != l)
{
arr[index] = arr[index - 1];
index--;
}
arr[l] = val;
l++;
middle++;
start2++;
}
}
} - Bvoid in_place_merge(int arr[], int l, int middle, int r)
{
int start2 = middle + 1;
if (arr[middle] <= arr[start2])
{
return;
}
while (l <= middle && start2 <= r)
{
if (arr[l] <= arr[start2])
{
l++;
}
else
{
int val = arr[start2];
int index = start2;
while (index != l)
{
arr[index] = arr[index - 1];
index--;
}
arr[l] = val;
l++;
middle++;
start2++;
}
}
} - Cvoid in_place_merge(int arr[], int l, int middle, int r)
{
int start2 = middle + 1;
if (arr[middle] <= arr[start2])
{
return;
}
while (l <= middle+1 && start2 <= r)
{
if (arr[l] >= arr[start2])
{
l++;
}
else
{
int val = arr[start2];
int index = start2;
while (index != l)
{
arr[index] = arr[index - 1];
index--;
}
arr[l] = val;
l++;
middle++;
start2++;
}
}
} - Dvoid in_place_merge(int arr[], int l, int middle, int r)
{
int start2 = middle + 1;
if (arr[middle] >= arr[start2])
{
return;
}
while (l <= middle && start2 <= r)
{
if (arr[l] <= arr[start2])
{
l++;
}
else
{
int val = arr[start2];
int index = start2;
while (index != r)
{
arr[index] = arr[index - 1];
Index++;
}
arr[l] = val;
l++;
middle++;
start2++;
}
}
}
- Avoid in_place_merge(int arr[], int l, int middle, int r)
127Merge sort uses which of the following algorithm to implement sorting?
- Abacktracking
- Bgreedy algorithm
- Cdivide and conquer
- Ddynamic programming
128What is the average case time complexity of standard merge sort?
- AO(n log n)
- BO(n^2)
- CO(n^2 log n)
- DO(n log n^2)
129What is the auxiliary space complexity of standard merge sort?
- AO(1)
- BO(log n)
- CO(n)
- DO(n log n)
130What is the auxiliary space complexity of bottom up merge sort?
- AO(1)
- BO(n)
- CO(log n)
- DO(n log n)
131What is the average time complexity of bottom up merge sort?
- AO(n log n)
- BO(n^2)
- CO(n^2 log n)
- DO(n log n^2)
132Merge sort uses which of the following method to implement sorting?
- Amerging
- Bpartitioning
- Cselection
- Dexchanging
133Bottom up merge sort uses recursion.
- ATrue
- BFalse
134Bottom up merge sort is a stable sort.
- ATrue
- BFalse
135Choose the correct statement about bottom up merge sort from the following?
- Abottom up merge sort has greater time complexity than standard merge sort
- Bbottom up merge sort has lesser time complexity than standard merge sort
- Cbottom up merge sort saves auxiliary space required on call stack
- Dbottom up merge sort uses recursion.
136Choose the correct option from the following that represents bottom up merge sort function?
- Avoid mergesort(int Arr[], int temp[], int low, int high)
{
for (int m = 1; m <= high - low; m = 2*m)
{
for (int i = low; i < high; i += 2*m)
{
int left = i;
int mid = i + m - 1;
int right = min(i + 2*m - 1, high);
merge(Arr, temp, left, mid, right);
}
}
} - Bvoid mergesort(int Arr[], int temp[], int low, int high)
{
for (int m = 1; m <= high - low; m = 2*m)
{
for (int i = low; i < high; i += m)
{
int left = i;
int mid = i + m - 1;
int right = min(i + 2*m - 1, high);
merge(Arr, temp, left, mid, right);
}
}
} - Cvoid mergesort(int Arr[], int temp[], int low, int high)
{
for (int m = 1; m <= high - low; m = m)
{
for (int i = low; i < high; i += 2*m)
{
int left = i;
int mid = i + m - 1;
int right = min(i + 2*m - 1, high);
merge(Arr, temp, left, mid, right);
}
}
} - Dvoid mergesort(int Arr[], int temp[], int low, int high)
{
for (int m = 1; m <= high - low; m = 2*m)
{
for (int i = low; i < high; i += 2*m)
{
int left = i;
int mid = i + m - 1;
int right = min(i + m - 1, high);
merge(Arr, temp, left, mid, right);
}
}
}
- Avoid mergesort(int Arr[], int temp[], int low, int high)
137Which of the following sorting algorithms is the fastest?
- AMerge sort
- BQuick sort
- CInsertion sort
- DShell sort
138Quick sort follows Divide-and-Conquer strategy.
- ATrue
- BFalse
139What is the worst case time complexity of a quick sort algorithm?
- AO(N)
- BO(N log N)
- CO(N^2)
- DO(log N)
140Which of the following methods is the most effective for picking the pivot element?
- Afirst element
- Blast element
- Cmedian-of-three partitioning
- Drandom element
141Find the pivot element from the given input using median-of-three partitioning method.
8, 1, 4, 9, 6, 3, 5, 2, 7, 0.- A8
- B7
- C9
- D6
142Which is the safest method to choose a pivot element?
- Achoosing a random element as pivot
- Bchoosing the first element as pivot
- Cchoosing the last element as pivot
- Dmedian-of-three partitioning method
143What is the average running time of a quick sort algorithm?
- AO(N^2)
- BO(N)
- CO(N log N)
- DO(log N)
144Which of the following sorting algorithms is used along with quick sort to sort the sub arrays?
- AMerge sort
- BShell sort
- CInsertion sort
- DBubble sort
145Quick sort uses join operation rather than merge operation.
- ATrue
- BFalse
146How many sub arrays does the quick sort algorithm divide the entire array into?
- Aone
- BTwo
- CThree
- DFour
147Which is the worst method of choosing a pivot element?
- Afirst element as pivot
- Blast element as pivot
- Cmedian-of-three partitioning
- Drandom element as pivot
148Which among the following is the best cut-off range to perform insertion sort within a quick sort?
- AN=0-5
- BN=5-20
- CN=20-30
- DN>30
149Quick sort is a __________
- Agreedy algorithm
- Bdivide and conquer algorithm
- Cdynamic programming algorithm
- Dbacktracking algorithm
150What is the worst case time complexity of the Quick sort?
- AO(nlogn)
- BO(n)
- CO(n^3)
- DO(n^2)
151Apply Quick sort on a given sequence 7 11 14 6 9 4 3 12. What is the sequence after first phase, pivot is first element?
- A6 4 3 7 11 9 14 12
- B6 3 4 7 9 14 11 12
- C7 6 14 11 9 4 3 12
- D7 6 4 3 9 14 11 12
152The best case behaviour occurs for quick sort is, if partition splits the array of size n into __________
- An/2 : (n/2) – 1
- Bn/2 : n/3
- Cn/4 : 3n/2
- Dn/4 : 3n/4
153Quick sort is a stable sorting algorithm.
- ATrue
- BFalse
154Consider the Quick sort algorithm in which the partitioning procedure splits elements into two sub-arrays and each sub-array contains at least one-fourth of the elements. Let T(n) be the number of comparisons required to sort array of n elements. Then T(n)<=?
- AT(n) <= 2 T(n/4) + cn
- BT(n) <= T(n/4) + T(3n/4) + cn
- CT(n) <= 2 T(3n/4) + cn
- DT(n) <= T(n/3) + T(3n/4) + cn
155Consider the Quick sort algorithm which sorts elements in ascending order using the first element as pivot. Then which of the following input sequence will require a maximum number of comparisons when this algorithm is applied on it?
- A22 25 56 67 89
- B52 25 76 67 89
- C22 25 76 67 50
- D52 25 89 67 76
156A machine needs a minimum of 200 sec to sort 1000 elements by Quick sort. The minimum time needed to sort 200 elements will be approximately __________
- A60.2 sec
- B45.54 sec
- C31.11 sec
- D20 sec
157Which one of the following sorting algorithm is best suited to sort an array of 1 million elements?
- ABubble sort
- BInsertion sort
- CMerge sort
- DQuick sort
158Quick sort is a space-optimised version of ____
- ABubble sort
- BSelection sort
- CInsertion sort
- DBinary tree sort
159QuickSort can be categorized into which of the following?
- ABrute Force technique
- BDivide and conquer
- CGreedy algorithm
- DDynamic programming
160Select the appropriate recursive call for QuickSort.(arr is the array, low is the starting index and high is the ending index of the array, partition returns the pivot element, we will see the code for partition very soon)
- Apublic static void quickSort(int[] arr, int low, int high)
{
int pivot;
if(high>low)
{
pivot = partition(arr, low, high);
quickSort(arr, low, pivot-1);
quickSort(arr, pivot+1, high);
}
} - Bpublic static void quickSort(int[] arr, int low, int high)
{
int pivot;
if(high<low)
{
pivot = partition(arr, low, high);
quickSort(arr, low, pivot-1);
quickSort(arr, pivot+1, high);
}
} - Cpublic static void quickSort(int[] arr, int low, int high)
{
int pivot;
if(high>low)
{
pivot = partition(arr, low, high);
quickSort(arr, low, pivot);
quickSort(arr, pivot, high);
}
} - Dpublic static void quickSort(int[] arr, int low, int high)
{
int pivot;
if(high>low)
{
pivot = partition(arr, low, high);
quickSort(arr, low, pivot);
quickSort(arr, pivot+2, high);
}
}
- Apublic static void quickSort(int[] arr, int low, int high)
161What is the worst case complexity of QuickSort?
- AO(nlogn)
- BO(logn)
- CO(n)
- DO(n^2)
162What is a randomized QuickSort?
- AThe leftmost element is chosen as the pivot
- BThe rightmost element is chosen as the pivot
- CAny element in the array is chosen as the pivot
- DA random number is generated which is used as the pivot
163Which of the following code performs the partition operation in QuickSort?
- Aprivate static int partition(int[] arr, int low, int high)
{
int left, right, pivot_item = arr[low];
left = low;
right = high;
while(left > right)
{
while(arr[left] <= pivot_item)
{
left++;
}
while(arr[right] > pivot_item)
{
right--;
}
if(left < right)
{
swap(arr, left, right);
}
}
arr[low] = arr[right];
arr[right] = pivot_item;
return right;
} - Bprivate static int partition(int[] arr, int low, int high)
{
int left, right, pivot_item = arr[low];
left = low;
right = high;
while(left <= right)
{
while(arr[left] <= pivot_item)
{
left++;
}
while(arr[right] > pivot_item)
{
right--;
}
if(left < right)
{
swap(arr, left, right);
}
}
arr[low] = arr[right];
arr[right] = pivot_item;
return right;
} - Cprivate static int partition(int[] arr, int low, int high)
{
int left, right, pivot_item = arr[low];
left = low;
right = high;
while(left <= right)
{
while(arr[left] > pivot_item)
{
left++;
}
while(arr[right] <= pivot_item)
{
right--;
}
if(left < right)
{
swap(arr, left, right);
}
}
arr[low] = arr[right];
arr[right] = pivot_item;
return right;
} - Dprivate static int partition(int[] arr, int low, int high)
{
int left, right, pivot_item = arr[low];
left = low;
right = high;
while(left > right)
{
while(arr[left] > pivot_item)
{
left++;
}
while(arr[right] <= pivot_item)
{
right--;
}
if(left < right)
{
swap(arr, left, right);
}
}
arr[low] = arr[right];
arr[right] = pivot_item;
return right;
}
- Aprivate static int partition(int[] arr, int low, int high)
164What is the best case complexity of QuickSort?
- AO(nlogn)
- BO(logn)
- CO(n)
- DO(n2)
165The given array is arr = {2,3,4,1,6}. What are the pivots that are returned as a result of subsequent partitioning?
- A1 and 3
- B3 and 1
- C2 and 6
- D6 and 2
166What is the average case complexity of QuickSort?
- AO(nlogn)
- BO(logn)
- CO(n)
- DO(n^2)
167The given array is arr = {2,6,1}. What are the pivots that are returned as a result of subsequent partitioning?
- A1 and 6
- B6 and 1
- C2 and 6
- D1
168Which of the following is not true about QuickSort?
- Ain-place algorithm
- Bpivot position can be changed
- Cadaptive sorting algorithm
- Dcan be implemented as a stable sort
Information
- Description
- Computer Science Quiz on Exam Algo Practice, created by Nikholas Pcenicni on 21/04/2022.
- Author
- Nikholas Pcenicni
- Language
- English
- Views
- 4
- Tags
- Rating
- No ratings yet Rate this quiz