Recent questions tagged sorting

233
views
1 answers
1 votes
How to approach this type of questions?
263
views
1 answers
1 votes
In quick sort, n numbers the (n/10)th element is selected as pivot using n^2 sortimng time complexity what will be the time complexity of quick sort is.....a)O(nlogn)b)O(n^2)c)O(n^3)d)O(n)
336
views
1 answers
0 votes
For flag based approach in Bubble sort we can check first by a flag if the list is sorted or not in O(n), and if it is sorted, then no need to sort ... the same concept applicable to selection sort? Why it never comes down from O(n$^2$)?
1.1k
views
1 answers
0 votes
Consider the following sorting algorithms:Bubble sortInsertion sortSelection sortWhich ONE among the following choices of sorting algorithms sorts the numbers in the array $[4,3,2,1,5]$ ... $\text{(ii)}$ and $\text{(iii)}$ only
3.3k
views
2 answers
2 votes
Let $\text{A}$ be an array containing integer values. The distance of $\text{A}$ is defined as the minimum number of elements in $\text{A}$ that must be replaced with ... order. The distance of the array $[2,5,3,1,4,2,6]$ is ___________.
3.1k
views
1 answers
3 votes
​​​​​An array $[82,101,90,11,111,75,33,131,44,93]$ is heapified. Which one of the following options represents the first three elements in the heapified array?$82,90,101$82,11,93$131,11,93$131,111,90$
518
views
0 answers
0 votes
Consider an n element array which is to be sorted either in ascending or descending order. The given restriction is only one pass will be used for completely ... be the worst time complexity?Is this related to bubble sort algorithm or not?
713
views
2 answers
2 votes
Consider the following array$: [32, 33, 5, 2, 14, -4, 22, 39, 34, -9].$ We apply a certain sorting algorithm and observe that the ... applied?Merge sort (top-down approach)Bubble sortQuicksort (Using First element as pivot)Insertion sort
190
views
0 answers
0 votes
Given the array \( [4, 3, 2, 1, 5] \), which of the following sorting algorithms can successfully sort the array in exactly two passes?Bubble SortInsertion Sort Selection SortMerge Sort
721
views
2 answers
5 votes
Consider an array that has $10$ distinct elements. Suppose we use randomized quicksort (with the pivot chosen uniformly at random). What is the probability that the ... of the chosen pivot. The pivot itself is not part of any subarray.
460
views
1 answers
3 votes
Here is an array of ten integers$: 5389170264$Suppose we run MergeSort on this array. What is the number in the $7$th position of the partially sorted array after the outermost two ... $ in its $7$th position.)$3$1$2$4$
651
views
1 answers
8 votes
An inversion in an array $a$ is a pair of array indices $(i, j)$ such that $i<j$ but $a[i]>a[j]$.What is the maximum number of inversions that can be eliminated by the following program ... $6$9$20$
240
views
1 answers
0 votes
Worst case time complexity of heap sort for n elementsO(nlogn)O(logn)O^2O(n)
212
views
1 answers
1 votes
Which of the following is true for a sorted list with ' $n$ ' elements?Insertion in a sorted array takes constant time.Insertion in a sorted linear linked list takes ... sorted linear linked list can be done in $\mathrm{O}(\log n)$ time.
369
views
1 answers
1 votes
#include <stdio.h>void SSort(int [], int);void swap(int *,int*);int main() { int arr[] = {5,4,3,2,1,0}; int n = sizeof(arr)/sizeof(arr[0]) ... sort algorithm. But the output of the algo is: 0 0 0 0 0 0. Where is the problem ?
1.3k
views
2 answers
0 votes
Binary search is performed on a sorted array of n elements. The search key is not in the array and falls between the elements at positions m and m+1 (where 1 ≤ m < n). How ... . ceil(log(n))b. floor(log(n))c. ceil(log(m))d. floor(log(m))
472
views
1 answers
0 votes
Consider the set of 4 -digit positive integers. How many of them have their digits in :-a) strictly decreasing order ?b) non decreasing order ?c) non increasing order ?
321
views
0 answers
0 votes