dc

Views:
 
Category: Entertainment
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

Sorting : 

By:- Kumar siddharth bansal - 100101114 Mansi mahajan -100101126 Anadi vats- 100101030 Jishnu v. nair - 100101100 Anele kingsley .c- 100101033 Emiri Charles Ugo - 100101085 Johnson Barimlenea Dandy- 100101102 Sorting

What is sorting???: 

What is sorting??? Sorting is the process of putting a list or a group of items in a specific order. Some common sorting criteria are: alphabetical or numerical.

Shell sort: 

Shell sort Use increment sequence h 1 , h 2 , …h t . After phase using increment h k , a[i] <= a[i+ h k ] for each h k for i = h k to a.size () tmp = a[i] for j = i j >= h k && tmp < a[j- h k ] j-= h k a[j] = a[j- h k ] a[j] = tmp

Bubble sort: 

Bubble sort This algorithm sorts the array A with the N elements. 1. Initialise Set I=0 2. Repeat steps 3 to 5 until I<N 3. Set J=0 4. Repeat step 5 until J<N-i-1 5. If A[J]> A[J+1] then Set temp= A[J] Set A[J]=A[J+1] Set A[J+1]= temp END IF 6. exit

Quick sort: 

Quick sort Quicksort ( a,l,h ) Where a : represents the list of elements. l: represents the position of the first element in the list (only at the starting point , it’s value changes during the execution of the function) . h: represents the position of the last element in the list. 1: (Initially) low=l high=h key=a[(1+h)/2] { for middle element of the list} 2: Repeat through step 7 while (low <=high) 3: Repeat 4 while (a([low]<key) 4: low=low+1 5: Repeat 6 while (a([high]<key)) 6: high=high-1

PowerPoint Presentation: 

7: if(low<=high) (a) temp=a[low] (b) a[low]=a[high] (c) a[high]=temp (d) low=low+1 (e) high=high-1 8: if(l<high) Quick_sort ( a,l,high ) 9: if(low<h) Quick_sort ( a,low,h ) 10: Exit

Selection sort: 

Selection sort 1. Repeat steps 2 & 3 for k=1,2,…,n-1: 2. Call min( a,k,n,loc ). 3. [Interchange a[k] and a[ loc ].] Set temp: = a[k] a[k]= a[ loc ] a[ loc ]= temp [END OF STEP 1] 4. Exit

Radix sort: 

Radix sort 1. Find the largest element of the array. 2. Find the total number of digits num in the largets digit. set digit = num 3. Repeat steps 4,5 for pass=1 to num 4.Initialise buckets for i=1 to (n-1) Set num =obtain digit number pass of a[i] Put a[i] in bucket number digit [END OF FOR LOOP] 5. Calculate all numbers from the bucket in order. 6. Exit.

Merge sort: 

Merge sort If the list is of length 0 or 1, then it is already sorted. Otherwise: Divide the unsorted list into two sublists of about half the size. Sort each sublist recursively by re-applying the merge sort. Mergr the two sublists back into one sorted list. Merge sort incorporates two main ideas to improve its runtime: A small list will take fewer steps to sort than a large list. Fewer steps are required to construct a sorted list from two sorted lists than from two unsorted lists. For example, you only have to traverse each list once if they're already sorted.

Heap sort: 

Heap sort The heap data structure is an array object which can be easily visualized as a complete binary tree. There is a one to one correspondence between elements of the array and nodes of the tree. The tree is completely filled on all levels except possibly the lowest, which is filled from the left upto a point. All nodes of heap also satisfy the relation that the key values at each node is at least as large as the value at its children

ALGORITHM: 

ALGORITHM The user inputs the size of the heap (within the specified limit). The program generates a corresponding binary tree with the nodes having randomly generated key values Build heap operation: Let n be the number of nodes in the tree and I be the key of a tree. For this, the program uses operation heapify , when Heapify is called both the left and right subtree of the I are heaps. The function of heapify is to let I settle down to a position (by swapping itself with the larger of its children, whenever the heap property is not satisfied) till the heap property is satisfied in the tree which was rooted at i. Remove maximum element: The program removes the largest element of the heap (the root) by swapping it with the last element. The program executes Heapify (new root) so that the resultig tree satisfies the heap property Goto step iii till heap is empty