Recent questions tagged sorting

1.1k
views
2 answers
0 votes
8.3k
views
1 answers
5 votes
You are given an array of 64 elements, minimum number of comparisons required to find out second largest element among all will be _______.
3.1k
views
2 answers
2 votes
To merge two lists of size m and n, how many comparisons we need to perform in the worst case and best case respectively ?a) m+n-1 and m+n-1b)m+n+1 and max ... +n-1 and min(m,n) can someone give the worst case and best case with examples ?
704
views
1 answers
4 votes
Consider two arrays A[] and B[],if arrays A is in increasing order and array B is in decreasing order is input to join a algorithm. the output is an array C[1......2n] ... for join algorithm to join two array?A) O(n2)B)O(n)C)O(1)D)O(nlogn)
1.4k
views
1 answers
5 votes
In general merge sort is not considered in-place sorting technique. Because an auxiliary array is used. If we will try to do it in-place in array data ... and merging data) ?Please share your valuable opinion. It will be great help.
927
views
1 answers
2 votes
Suppose A is sorted array and some of the elements are duplicates what is the best upper bound to find out the number of elements that are equal to any given key 'k'.
707
views
0 answers
2 votes
If we are asked to find best comparison based sorting algorithm to sort n numbers having d digit's and in the range from [1-k].If I say it is quick sort ... wrong ?OR in general we do sorting on these type of numbers using Radix sort only ?
642
views
0 answers
0 votes
IS 2 way merge sort and normal merge sort is same.in which we have to use bottom-up merging approach by taking 2-2 element inside the list.if 5-way merge ... -5 elements from bottom to up for merging.if I am wrong please let me correct!
454
views
1 answers
0 votes
In sorted array of size n time required to verify if there exist 2 number a and b such that a+ b = s in worst case Where s is a constant.
1.0k
views
1 answers
4 votes
Quick-sort is run on two inputs shown below to sort in ascending order taking first element as pivoti) 1,2,3, nii) n,n−1,n−2, ,2,1Let S1 and S2 be ... S2 related ?ii) How will the answer change if the pivot is changed to middle element ?
881
views
2 answers
3 votes
Given a 2D array X[m][n] which has m rows and n columns. The array X is row wise and column wise sorted (i.e) each individula row and column is sorted. What is the complexity to ... arraya)O(m*n)b)O(m2) or O(n2)c)O(log2(m*n))d)O(m+n)
1.6k
views
1 answers
4 votes
True or FalseMerge sort on Linked list takes O(nlogn)
510
views
1 answers
2 votes
An array A' of length n contains numbers {0, 1, 2}, numbers are present in array in arbitrary order.The best sorting algorithms, takes 250 units ... minimum time required by algorithm on same hardware __________ (Rounded off to integers).
2.7k
views
4 answers
4 votes
Consider bottom-up merge sort working on 'n' elements. Assume 'n' is a power of 2. The minimum number of comparisons in order to get sorted list is(A) (n log n) / 2(B) n lon n - n + 1(C) n log n(D) n log n + n
449
views
1 answers
1 votes
646
views
1 answers
1 votes
Could anyone describe how the partitioning algorithm vary when the pivot is varied ?In Cormen , last element is taken as pivot . Suppose I took first ... element or 3 rd element as pivot then how the partitioning algorithm will change.
1.9k
views
2 answers
2 votes
Consider the following code which sort all elements of an array A' in descending order.Which of the following will represents correct value of X, Y, Z in ... it is aranging in ascending order.And option D is doing what question is saying.
912
views
2 answers
1 votes
1. Is bucket sort always stable or does it depend on the sorting subroutine used by bucket sort toe sort the buckets?2. Bucket sort is always NOT inplace.Is this correct?
2.5k
views
1 answers
1 votes
What is the ascending wise order of sorting algorithms which takes least time and least space to sort the elements?
1.7k
views
3 answers
3 votes
"Quick sort has good cache performance" , Can anyone explain this statement.How is cache related to quick sort.I searched for this over the internet but could not find a good article.
679
views
1 answers
1 votes
Given an unsorted array. The array has this property that every element in array is at most k distance from its position in sorted array where k is a ... be easily modified for sorting this array and what is the obtainable time complexity ?
5.9k
views
3 answers
3 votes
suppose there are 4 sorted lists of n/4 elements each. if we merge these list into a single sorted list of n elements, for the n=400 number of key comparisons in the worst case using an efficient algorithm is
269
views
1 answers
1 votes
What could be the best algorithm from the following when the time complexity is measured based bon the number of swaps performed by the sorting algorithm?1. Selection sort2. Insertion sort3. Bubble sort4. None of these
1.4k
views
1 answers
3 votes
When array is already sorted in reverse order then what will be the recurrence relation for number of swaps on array of n elements using quick sort?
773
views
2 answers
2 votes
HOW NO. OF LEVELS IS LOG N + 1 CAN ANYONE HELP ME , how to solve this and get log n + 1
825
views
0 answers
4 votes
When an array is to be sorted, It may happen that some data values start out being in the same position where they should end up. For example in the array which is originally {40, -1, 33 ... only (b) i & iii (c) i & ii (d) ii & iii
324
views
1 answers
1 votes
array has n elements and we need to sort them in non decreasing order as follows. first find minimum, remove this element from the array and find minimum of ... and so on until array becomes emplty . In best case how many comparisons needed
350
views
1 answers
1 votes
Array of 1 to n^6 , which algorithm can be used to sort in linear time?a) not possibleB)radixc)countingd)quick
1.0k
views
0 answers
1 votes
will A[i+1]=key; in the insertion sort be counted as a movement in best case?
758
views
1 answers
1 votes
What is the ans and give reason