SlideShare a Scribd company logo
SORTING ALGORITHM GRAPHICAL 
METHOD 
Made by- 
Shantanu 
BCA-V sem. 
Guided by 
Mr. Sanjeev Kumar Singh
INTRODUCTION 
• Sorting of an array is the process of arranging the data present is an 
array in a particular manner either by ascending or descending order. 
• A sorting algorithm is an algorithm that puts elements of a list in a 
certain order. 
• The most used orders are numerical order and lexicographical order.
WHAT DOES SORTS DO? 
I am taking an example:- 
Take: [6,24,10,76,35,0,37] 
Make the above pattern into this:[0,6,10,24,35,37,76]
OBJECTIVE 
The main objective of my project is to graphically show sorting 
algorithm by arranging the records in ascending order. 
The language used in my project is .NET .
BASIC FLOW DIAGRAM 
USER 
SELECTION 
OF SORTING 
ALGORITHM 
SORTED ARRAY 
OUTPUT BY 
GRAPHICAL 
REPRESENTATION
SORTING METHODS 
The popular sorting methods are: 
• Bubble sort 
• Selection sort 
• Insertion sort 
• Merge sort 
• Quick sort
HOW FAST CAN WE SORT? 
• Selection Sort, Bubble Sort, Insertion Sort : 
O(n2) 
• Heap Sort, Merge sort : 
O(n log n) 
• Quicksort : 
• Average: O(n log n) 
• Best: O(n log n) or O(n)
BUBBLE SORT 
• Bubble Sort works by comparing each element of the list with the 
element next to it and swapping them if required. With each pass, the 
largest of the list is "bubbled" to the end of the list whereas the 
smaller values sink to the bottom.
ILLUSTRATION OF BUBBLE SORT 
Consider the following array of four items: 
Now I will sort this array using bubble sort: 
FIRST ITERATION : 
1st pass: 
90 45 70 15 
90 45 70 15 
45 90 70 15
2nd pass: 
3rd pass: 
SECOND ITERATION : 
1st pass: 
2nd pass: 
45 70 90 15 
45 70 15 90 
45 70 15 90 
45 70 15 90 
45 15 70 90
THIRD ITERATION : 
1st pass: 
45 15 70 90 
15 45 70 90 
As seen from the above illustration , that for four elements, we need 
three iterations . It means that if there are n elements then there will 
be n-1 iterations.
IMPLIMENTATION IN C 
void BubbleSort(int a[], int array_size) 
{ 
int i, j, temp; 
for (i = 0; i < (array_size - 1); ++i) 
{ 
for (j = 0; j < array_size - 1 - i; ++j ) 
{ 
if (a[j] > a[j+1]) 
{ 
temp = a[j+1]; 
a[j+1] = a[j]; 
a[j] = temp; 
} 
} 
} 
}
SELECTION SORT 
• The idea of Selection Sort is rather simple. It basically determines the 
minimum (or maximum) of the list and swaps it with the element at 
the index where its supposed to be. The process is repeated such that 
the nth minimum (or maximum) element is swapped with the 
element at the (n-1)th index of the list.
ILLUSTRATION OF SELECTION SORT 
Consider the following array of four items: 
Now I will sort this array using selection sort: 
1st pass: 
2nd pass: 
3rd pass: 
90 45 70 15 
15 90 45 70 
15 45 90 70 
15 45 70 90
IMPLIMENTATION IN C 
for(i=0;i<=10;i++) 
{ 
for(j=i+1;j<=10;j++) 
{ 
if(a[i]>a[j]) 
{ 
t=a[i]; 
a[i]=a[j]; 
a[j]=t; 
} 
} 
}
INSERTION SORT 
The Insertion Sort algorithm is a commonly used algorithm. In this type 
of sorting algorithm , the array is divided into two parts : the sorted 
and unsorted array. The very first element of the array is treated as 
sorted array and the rest of array is treated as the unsorted array . For 
sorting, first of all the first element of the unsorted array is inserted in 
the sorted array. After that the second element is inserted . The 
process continues till the last element of the unsorted array is inserted 
in the sorted array
ILLUSTRATION OF INSERTION SORT 
Consider the following array of four items: 
90 45 70 15 
90 
45 
70 
15 
Sorted Array 
Unsorted Array
After 1st iteration: 
45 
90 
70 
15 
After 2nd iteration: 
Sorted Array 
Unsorted Array 
45 
70 
90 
15 
Sorted Array 
Unsorted Array
After 3rd iteration: 
15 
45 
70 
90 
Sorted Array 
From the above illustration , we see that for an array of four elements , 
we need to process the array three times to get the sorted array. It 
means that if there are n elements then there will be n-1 iterations.
IMPLIMENTATION IN C 
void insertionSort(int a[], int array_size) 
{ 
int i, j, index; 
for (i = 1; i < array_size; ++i) 
{ 
index = a[i]; 
for (j = i; j > 0 && a[j-1] > index; j--) 
{ 
a[j] = a[j-1]; 
} 
a[j] = index; 
} 
}
THANK YOU

More Related Content

PPT
Sorting Algorithms
multimedia9
 
PPTX
Sorting algorithms
Trupti Agrawal
 
PPSX
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
Dharmendra Prasad
 
PPT
Hub 102 - Lesson 5 - Algorithm: Sorting & Searching
Tiểu Hổ
 
PPT
Sorting Seminar Presentation by Ashin Guha Majumder
Ashin Guha Majumder
 
PPTX
Sorting algorithms
Eleonora Ciceri
 
PDF
Sorting
Zaid Shabbir
 
DOC
Insertion sort
Dorina Isaj
 
Sorting Algorithms
multimedia9
 
Sorting algorithms
Trupti Agrawal
 
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
Dharmendra Prasad
 
Hub 102 - Lesson 5 - Algorithm: Sorting & Searching
Tiểu Hổ
 
Sorting Seminar Presentation by Ashin Guha Majumder
Ashin Guha Majumder
 
Sorting algorithms
Eleonora Ciceri
 
Sorting
Zaid Shabbir
 
Insertion sort
Dorina Isaj
 

What's hot (20)

PPT
Data Structures- Part4 basic sorting algorithms
Abdullah Al-hazmy
 
PPT
Searching algorithms
Trupti Agrawal
 
PDF
Data structures and algorithms - sorting algorithms
Abimbola Idowu
 
ODP
Sorting Algorithm
Abu Shaik saurab
 
PPT
Sorting
Ghaffar Khan
 
PPT
Data Structures - Searching & sorting
Kaushal Shah
 
PPTX
Sorting ppt
Hassan Mustafa
 
PPT
Lect11 Sorting
ryokollll
 
PDF
Sorting Algorithms
Mohammed Hussein
 
DOCX
Best,worst,average case .17581556 045
university of Gujrat, pakistan
 
PPTX
Sorting algorithms
Maher Alshammari
 
PPTX
Sorting Algorithms
Pranay Neema
 
PDF
Chapter 14 Searching and Sorting
MuhammadBakri13
 
PPT
Sorting Techniques
Rafay Farooq
 
PPTX
Different types of Shoring Algorithms with Animation
Zakaria Hossain
 
PPT
Insertion sort
Delowar Hossain
 
PPTX
Sorting Algorithm
Al Amin
 
PDF
Sorting algorithm
Balaji Nangare
 
PPTX
Algorithm & data structures lec4&5
Abdul Khan
 
Data Structures- Part4 basic sorting algorithms
Abdullah Al-hazmy
 
Searching algorithms
Trupti Agrawal
 
Data structures and algorithms - sorting algorithms
Abimbola Idowu
 
Sorting Algorithm
Abu Shaik saurab
 
Sorting
Ghaffar Khan
 
Data Structures - Searching & sorting
Kaushal Shah
 
Sorting ppt
Hassan Mustafa
 
Lect11 Sorting
ryokollll
 
Sorting Algorithms
Mohammed Hussein
 
Best,worst,average case .17581556 045
university of Gujrat, pakistan
 
Sorting algorithms
Maher Alshammari
 
Sorting Algorithms
Pranay Neema
 
Chapter 14 Searching and Sorting
MuhammadBakri13
 
Sorting Techniques
Rafay Farooq
 
Different types of Shoring Algorithms with Animation
Zakaria Hossain
 
Insertion sort
Delowar Hossain
 
Sorting Algorithm
Al Amin
 
Sorting algorithm
Balaji Nangare
 
Algorithm & data structures lec4&5
Abdul Khan
 
Ad

Viewers also liked (20)

PPTX
Sorting Algorithms
zhaokatherine
 
PPT
Chapter 11 - Sorting and Searching
Eduardo Bergavera
 
PDF
Sorting (introduction)
Arvind Devaraj
 
PPTX
Parallel sorting algorithm
Richa Kumari
 
PPT
Sorting algorithms v01
Dusan Vuckovic
 
PPT
មេរៀនៈ Data Structure and Algorithm in C/C++
Ngeam Soly
 
PPTX
Introduction to datastructure and algorithm
Pratik Mota
 
PPT
Insertion sort
aditya raj
 
PPTX
Bucket sort- A Noncomparision Algorithm
Krupali Mistry
 
PDF
Insertion Sort Algorithm
Gail Carmichael
 
PPTX
Insertion Sort
Brett Duncan
 
PPT
Introduction of data structure
eShikshak
 
PPT
Counting Sort and Radix Sort Algorithms
Sarvesh Rawat
 
PPT
4.2 bst
Krish_ver2
 
PPTX
Insertion sort
almaqboli
 
PDF
Binary Search - Design & Analysis of Algorithms
Drishti Bhalla
 
PDF
Binary Search Algorithm
Anastasia Jakubow
 
PPTX
Was There A Darwinian Revolution
John Lynch
 
PDF
A history of science (volume 1)
Dipoceanov Esrever
 
KEY
Ancient Ideas of Creation & Evolution
John Lynch
 
Sorting Algorithms
zhaokatherine
 
Chapter 11 - Sorting and Searching
Eduardo Bergavera
 
Sorting (introduction)
Arvind Devaraj
 
Parallel sorting algorithm
Richa Kumari
 
Sorting algorithms v01
Dusan Vuckovic
 
មេរៀនៈ Data Structure and Algorithm in C/C++
Ngeam Soly
 
Introduction to datastructure and algorithm
Pratik Mota
 
Insertion sort
aditya raj
 
Bucket sort- A Noncomparision Algorithm
Krupali Mistry
 
Insertion Sort Algorithm
Gail Carmichael
 
Insertion Sort
Brett Duncan
 
Introduction of data structure
eShikshak
 
Counting Sort and Radix Sort Algorithms
Sarvesh Rawat
 
4.2 bst
Krish_ver2
 
Insertion sort
almaqboli
 
Binary Search - Design & Analysis of Algorithms
Drishti Bhalla
 
Binary Search Algorithm
Anastasia Jakubow
 
Was There A Darwinian Revolution
John Lynch
 
A history of science (volume 1)
Dipoceanov Esrever
 
Ancient Ideas of Creation & Evolution
John Lynch
 
Ad

Similar to sorting algorithm graphical method (20)

PPTX
DSA-sortijejjejjdjjdjdjjsjsjsjsjsjsjng.pptx
suryatom5775
 
DOCX
Sorting
BHARATH KUMAR
 
PPT
358 33 powerpoint-slides_14-sorting_chapter-14
sumitbardhan
 
PPTX
Sorting-Algorithms-A-Comprehensive-Guide.pptx
ReemEmad26
 
PPTX
Sorting method data structure
sunilchute1
 
PPTX
Data structure.pptx
SajalFayyaz
 
PPTX
Different Searching and Sorting Methods.pptx
Minakshee Patil
 
PDF
465659705-15-DSA-PPT-Sorting-Techniques-I.pdf
anushasanapathi1
 
PPTX
Lecture 11.2 : sorting
Vivek Bhargav
 
PPTX
Unit vii sorting
Tribhuvan University
 
PPT
Sorting algorithums > Data Structures & Algorithums
Ain-ul-Moiz Khawaja
 
PPTX
CSPC/ PPS Sorting methods
Ankur Srivastava
 
PDF
Sorting
Kariman Karm Gabaa
 
PPTX
Sorting Algorithms to arrange data in particular format
itsusamazahid
 
PPTX
SORTING techniques.pptx
Dr.Shweta
 
PPTX
Insertion Sorting
FarihaHabib123
 
PPT
Sorting algorithms
CHANDAN KUMAR
 
PPTX
sorting1.pptx
AJAYVISHALRP
 
PPT
Insert Sort & Merge Sort Using C Programming
chandankumar364348
 
PPTX
Different Sorting tecniques in Data Structure
Tushar Gonawala
 
DSA-sortijejjejjdjjdjdjjsjsjsjsjsjsjng.pptx
suryatom5775
 
Sorting
BHARATH KUMAR
 
358 33 powerpoint-slides_14-sorting_chapter-14
sumitbardhan
 
Sorting-Algorithms-A-Comprehensive-Guide.pptx
ReemEmad26
 
Sorting method data structure
sunilchute1
 
Data structure.pptx
SajalFayyaz
 
Different Searching and Sorting Methods.pptx
Minakshee Patil
 
465659705-15-DSA-PPT-Sorting-Techniques-I.pdf
anushasanapathi1
 
Lecture 11.2 : sorting
Vivek Bhargav
 
Unit vii sorting
Tribhuvan University
 
Sorting algorithums > Data Structures & Algorithums
Ain-ul-Moiz Khawaja
 
CSPC/ PPS Sorting methods
Ankur Srivastava
 
Sorting Algorithms to arrange data in particular format
itsusamazahid
 
SORTING techniques.pptx
Dr.Shweta
 
Insertion Sorting
FarihaHabib123
 
Sorting algorithms
CHANDAN KUMAR
 
sorting1.pptx
AJAYVISHALRP
 
Insert Sort & Merge Sort Using C Programming
chandankumar364348
 
Different Sorting tecniques in Data Structure
Tushar Gonawala
 

Recently uploaded (20)

PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PDF
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
Congenital Hypothyroidism pptx
AneetaSharma15
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PPTX
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PDF
Wings of Fire Book by Dr. A.P.J Abdul Kalam Full PDF
hetalvaishnav93
 
PDF
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
PPT
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
PPTX
Strengthening open access through collaboration: building connections with OP...
Jisc
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PPTX
How to Manage Global Discount in Odoo 18 POS
Celine George
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Congenital Hypothyroidism pptx
AneetaSharma15
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Wings of Fire Book by Dr. A.P.J Abdul Kalam Full PDF
hetalvaishnav93
 
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
Strengthening open access through collaboration: building connections with OP...
Jisc
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
How to Manage Global Discount in Odoo 18 POS
Celine George
 

sorting algorithm graphical method

  • 1. SORTING ALGORITHM GRAPHICAL METHOD Made by- Shantanu BCA-V sem. Guided by Mr. Sanjeev Kumar Singh
  • 2. INTRODUCTION • Sorting of an array is the process of arranging the data present is an array in a particular manner either by ascending or descending order. • A sorting algorithm is an algorithm that puts elements of a list in a certain order. • The most used orders are numerical order and lexicographical order.
  • 3. WHAT DOES SORTS DO? I am taking an example:- Take: [6,24,10,76,35,0,37] Make the above pattern into this:[0,6,10,24,35,37,76]
  • 4. OBJECTIVE The main objective of my project is to graphically show sorting algorithm by arranging the records in ascending order. The language used in my project is .NET .
  • 5. BASIC FLOW DIAGRAM USER SELECTION OF SORTING ALGORITHM SORTED ARRAY OUTPUT BY GRAPHICAL REPRESENTATION
  • 6. SORTING METHODS The popular sorting methods are: • Bubble sort • Selection sort • Insertion sort • Merge sort • Quick sort
  • 7. HOW FAST CAN WE SORT? • Selection Sort, Bubble Sort, Insertion Sort : O(n2) • Heap Sort, Merge sort : O(n log n) • Quicksort : • Average: O(n log n) • Best: O(n log n) or O(n)
  • 8. BUBBLE SORT • Bubble Sort works by comparing each element of the list with the element next to it and swapping them if required. With each pass, the largest of the list is "bubbled" to the end of the list whereas the smaller values sink to the bottom.
  • 9. ILLUSTRATION OF BUBBLE SORT Consider the following array of four items: Now I will sort this array using bubble sort: FIRST ITERATION : 1st pass: 90 45 70 15 90 45 70 15 45 90 70 15
  • 10. 2nd pass: 3rd pass: SECOND ITERATION : 1st pass: 2nd pass: 45 70 90 15 45 70 15 90 45 70 15 90 45 70 15 90 45 15 70 90
  • 11. THIRD ITERATION : 1st pass: 45 15 70 90 15 45 70 90 As seen from the above illustration , that for four elements, we need three iterations . It means that if there are n elements then there will be n-1 iterations.
  • 12. IMPLIMENTATION IN C void BubbleSort(int a[], int array_size) { int i, j, temp; for (i = 0; i < (array_size - 1); ++i) { for (j = 0; j < array_size - 1 - i; ++j ) { if (a[j] > a[j+1]) { temp = a[j+1]; a[j+1] = a[j]; a[j] = temp; } } } }
  • 13. SELECTION SORT • The idea of Selection Sort is rather simple. It basically determines the minimum (or maximum) of the list and swaps it with the element at the index where its supposed to be. The process is repeated such that the nth minimum (or maximum) element is swapped with the element at the (n-1)th index of the list.
  • 14. ILLUSTRATION OF SELECTION SORT Consider the following array of four items: Now I will sort this array using selection sort: 1st pass: 2nd pass: 3rd pass: 90 45 70 15 15 90 45 70 15 45 90 70 15 45 70 90
  • 15. IMPLIMENTATION IN C for(i=0;i<=10;i++) { for(j=i+1;j<=10;j++) { if(a[i]>a[j]) { t=a[i]; a[i]=a[j]; a[j]=t; } } }
  • 16. INSERTION SORT The Insertion Sort algorithm is a commonly used algorithm. In this type of sorting algorithm , the array is divided into two parts : the sorted and unsorted array. The very first element of the array is treated as sorted array and the rest of array is treated as the unsorted array . For sorting, first of all the first element of the unsorted array is inserted in the sorted array. After that the second element is inserted . The process continues till the last element of the unsorted array is inserted in the sorted array
  • 17. ILLUSTRATION OF INSERTION SORT Consider the following array of four items: 90 45 70 15 90 45 70 15 Sorted Array Unsorted Array
  • 18. After 1st iteration: 45 90 70 15 After 2nd iteration: Sorted Array Unsorted Array 45 70 90 15 Sorted Array Unsorted Array
  • 19. After 3rd iteration: 15 45 70 90 Sorted Array From the above illustration , we see that for an array of four elements , we need to process the array three times to get the sorted array. It means that if there are n elements then there will be n-1 iterations.
  • 20. IMPLIMENTATION IN C void insertionSort(int a[], int array_size) { int i, j, index; for (i = 1; i < array_size; ++i) { index = a[i]; for (j = i; j > 0 && a[j-1] > index; j--) { a[j] = a[j-1]; } a[j] = index; } }