Showing posts with label sorting. Show all posts
Showing posts with label sorting. Show all posts

May 22, 2015

Sorting Tutorial

What is Sorting ? Why Sorting?

Sotring is an algorithms  that arranges the elements of a list in certain order.it can be in ascending , descending or any other fashion.sometimes sorting reduces the problem complexity.we can reduce the search complexity.

Classification  categories of sorting ?

1.Number of Comparision 
2.Number of Swap
3.Memory Usages
4.By Recursion
5.Adaptability

Other ways are :
1.INTERNAL(uses main memory only) 
2.EXTERNAL SORT(uses external memory ).

3. others








Bubble Sort

Bubble Sort is the simplest sorting algorithm. It works by iterating the input from the first to last.Comparing each pair and swapping them if needed. Bubble sort continues until no swapping needed.it got its name  from the way smaller elements "bubble"  to the top of the list.

April 11, 2015

Sorting : Tournament sort algorithm

Question:Given a team of N players. How many minimum games are required to  find kth best player in O(n+klog(n)) ?

March 18, 2015

Nagarro :Resort the array taking absolute value of negative numbers

Question: You are given a sorted array containing both negative and positive values. Resort the array taking absolute value of negative numbers. Your complexity should be O(n)
 Ex. A = {-8,-5,-3,-1,3,6,9} Expected Output: {-1,-3,3,-5,6,-8,9}