This action might not be possible to undo. Are you sure you want to continue?

Presentation By G.Gopi Krishna Reddy

Sorting

• The Process of rearranging the elements so that they are in ascending order or descending order is called sorting. • Example: arranging of numbers, student records. very essential for searching the dictionaries, telephone directories.

Properties

The two Main properties of sorting techniques are: • Stable: If the sorting algorithm preserves the relative order of any two equal elements,then the sorting algorithm is stable. • In Place: If an algorithm does not require an extra memory space except for few memory units,then the algorithm is said to be in place.

Sorting Algorithms

Various sorting algorithms are Bubble Sort Selection Sort Insertion Sort Quick Sort Merge Sort

Bubble Sort

• This is one of the most simplest sorting technique and most straight forward method of sorting. • In this sorting technique, the adjacent elements in the list are compared and exchanged if they are out of order. • This is also called as Sinking Sort

**Time Complexity(Bubble sort)
**

• The time complexity of bubble sort in all three cases (best,average & worst)is

T(n) = θ(n^2)

Which is not efficient compare to other sorting techniques.

Selection Sort

• In this technique first we find the smallest item in the list and we exchange it with the first item. • Next,obtain the second smallest item in the list & exchange it with the second element and so on. • Since, the next least item is selected and exchanged appropriately so that elements are finally sorted ,this technique is called Selection Sort

**Time Complexity(Selection sort)
**

• The time complexity of selection sort in all three cases (best,average&worst) is

T(n) = θ(n^2)

Which is not efficient compare to other sorting techniques.

Insertion Sort

• In this technique the given list is divided into two parts:sorted part(left) &unsorted part(right). • The unsorted elements can be placed any of the positions in the sorted part so that elements towards left of boundary are sorted. • As each item is inserted towards the sorted left part, the boundary moves to the right decreasing the unsorted list. • Finally,once the boundary moves to the right most position,the elements towards the left of boundary represent the sorted list.

**Time Complexity(Insertion sort)
**

• The Time complexity of insertion sort is: Worst case: T(n) = O(n^2) Average case: Best case:

T(n) = θ(n^2)

T(n) = Ω(n)

Quick sort

• In quick sort, partition the array into two parts such that elements towards left of key element are less than key element and elements towards right of key element are greater than key element. • Sort the left part of the array recursively. • Sort the right part of the array recursively.

**Time Complexity(Quick sort)
**

• The time complexity of Quick sort is: Worst case: T(n) = O(n log n) Average case: Best case:

T(n) = O(n log n) T(n) = θ(nlog2n)

Merge sort

• In merge sort, a given array of elements is divided into two parts. • The left part of the array as well as the right part of the array is sorted recursively. • Later, the sorted left part and the sorted right part are finally merged into a single sorted vector. • The process of merging of two sorted vectors into a single sorted vector is called simple merge.

**Time complexity(Merge sort)
**

• The time complexity of Merge sort in all three cases (best,average&worst) is:

T(n) = θ(nlog2n)

Conclusion

• By comparing all the sorting techniques Merge sort time complexity is less in all three cases (time consuming is less). • So, Merge sort is the most efficient technique when compare to all other sorting techniques.

THANK YOU

- Types of Binary Tree
- An empirical comparison of the runtime of five sorting algorithms
- data structure objective questions
- Sample Questions
- Aspiring Minds Model Paper Solved
- Sorting Algorithms
- B TREE TUTORIAL PPT
- Sorting Algorithms
- DBMS
- a complete guide for building a AVL Tree
- AMCAT Test Syllabus
- C program for Binary Search Tree
- DBMS-B+ and B trees
- Multiple Choice Question of Computer Networking
- COCOMO(Gopi GN)
- MCQ's of Operating System (OS)
- Greedy Method
- 62744932 Amcat Sample Paper
- multiple choice questions - OS,DS,N/W,DBMS ,CO,C,C++
- Microprocessor 8085 - notes
- 114 Handy Formulae for Quantitative Aptitude Problems
- Data Structures Cheat Sheet
- B+ TREE TUTORIAL PPT
- Some Important programs on Strings(in C)
- Syntax Directed Translation
- GN
- DIFFERENCE BETWEEN TIGHTLY COUPLED AND LOOSELY COUPLED MULTIPROCESSOR
- Sorting Algorithms Report
- 50756667 Data Structure Objective Questions
- Intelligence Bureau Assistant Central Intelligence Officer Grade II Executive Exam Sample Paper[1]
- Comparison of All Sorting Algorithms

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue reading from where you left off, or restart the preview.

scribd