Topic — Add New » Posts Last Poster Freshness
tcs interview question 2 kartik 9 months

how bubble sort has an order of complexity of o(n) in best case give the analysis?

Sort the deck of cards with 5 different colors 5 10 months

Perform the in-place sort on a deck of cards with 5 different colors. Deck having n number of cards and we don't know the exact number of cards of each color.

e.g Lets desk having sequence of card as

Original deck:
BLACK WHITE BLUE RED BLUE WHITE YELLOW RED BLACK YELLOW

Sorted deck:
BLACK BLACK BLUE BLUE WHITE WHITE YELLOW YELLOW RED RED

Amazon Interview Question for Software Engineer/Developer about Algorithms, Arrays 2 smritedua 11 months

You are given an array of positive integers. Convert it to a sorted array with minimum cost (minimum number of operations). Only valid operation are
1) Decrement -> cost = 1
2) Delete an element completely from the array -> cost = value of element

For example:
4,3,5,6, -> cost 1 //cost is 1 to make 4->3
10,3,11,12 -> cost 3 // cost 3 to remove 3

Amazon
time taken by quicksort 3 jpchaandy 11 months

if a file size is n=1000 takes 5ms for sorting using quicksort algorithm then approximately how much time would it take to sorta file of size n=1000000000?(assume all data r in main memory and elements are such that worst case of quicksort doesn't occur)
(a) 1500000ms
(b) 15ms
(c) 150000ms
(d) none of these

Sorting algo question 2 kewl_coder 12 months

Consider below two sorting algorithms
a) Try out all possible different orderings of these elements, and stop when in one such ordering, all elements are sorted in increasing order.
b) Search for the smallest of the n elements, and put it as first one in a new list. From the remaining n-1 elements, search again the smallest one and put it as second in the new list. Continue until all elements are (sorted) in the new list.

What is the complexity of these algorithms; are they...

Quick sort 2 kapil 1 year

Consider an increasingly sorted array 1,2,3..n . Let the number of comparisons needed be C1.
Now consider the decreasingly sorted array n,n-1,n-2,...n. Let the no of comparisons needed be C2.
Now how C1 and C2 are related?
a)C1<C2
b)C1>C2
c)C1=C2
d)can't say for arbitrary n.

why quicksort is not stable 2 1 year

Why the legacy implementation of QuickSort is not stable? Would somebody please show with an example?

Quick sort performance 1 satya 1 year

Why Quicksort is practically efficient? Why is it called cache friendly?

A sorting algo question 2 1 year

How would you sort an input array with the restriction that you cannot access any element more than twice?

when does worst case of Heap Sort occur 2 1 year

For what kind of input, Heap sort takes maximum time?

Quick sort V/S Heap sort 3 1 year

I have read at many place that Quick sort is better than heap sort. I can't understand why it is so as heap sort has guaranteed O(nlog(n)) while for quick sort there can be a worst case in which the order becomes O(n^2).

Anagram 5 1 year

Given two strings, find whether they are anagrams to each other?

Amazon Interview Question for Software Engineer/Developer about Algorithms, Arrays 3 1 year

Given an array of n elements and an integer k where k<n. The array is already sorted in groups of size k. So elements {a[0], ..... a[k] and a[k+1] ..... a[n] are already sorted. Give an algorithm to sort in O(n) time and O(1) space.

Amazon
Amazon Interview Question for Software Engineer/Developer about Arrays 2 yogi 1 year

Given two sorted array and in the second array u have as many extra space as no of elements in first array.
you have to sort the second array which will contain all the element from first array also.
Do it in O(n) time complexity without using any extra space.

Amazon
Like arrays, can linked list be sorted in O(nLogn) time? 2 2 years

If yes, then which sorting algorithm should be used?