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
Ad

More Related Content

What's hot (20)

Data Structures- Part4 basic sorting algorithms
Data Structures- Part4 basic sorting algorithmsData Structures- Part4 basic sorting algorithms
Data Structures- Part4 basic sorting algorithms
Abdullah Al-hazmy
 
Searching algorithms
Searching algorithmsSearching algorithms
Searching algorithms
Trupti Agrawal
 
Data structures and algorithms - sorting algorithms
Data structures and algorithms - sorting algorithmsData structures and algorithms - sorting algorithms
Data structures and algorithms - sorting algorithms
Abimbola Idowu
 
Sorting Algorithm
Sorting AlgorithmSorting Algorithm
Sorting Algorithm
Abu Shaik saurab
 
Sorting
SortingSorting
Sorting
Ghaffar Khan
 
Data Structures - Searching & sorting
Data Structures - Searching & sortingData Structures - Searching & sorting
Data Structures - Searching & sorting
Kaushal Shah
 
Sorting ppt
Sorting pptSorting ppt
Sorting ppt
Hassan Mustafa
 
Lect11 Sorting
Lect11 SortingLect11 Sorting
Lect11 Sorting
ryokollll
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
Mohammed Hussein
 
Best,worst,average case .17581556 045
Best,worst,average case .17581556 045Best,worst,average case .17581556 045
Best,worst,average case .17581556 045
university of Gujrat, pakistan
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
Maher Alshammari
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
Pranay Neema
 
Chapter 14 Searching and Sorting
Chapter 14 Searching and SortingChapter 14 Searching and Sorting
Chapter 14 Searching and Sorting
MuhammadBakri13
 
Sorting Techniques
Sorting TechniquesSorting Techniques
Sorting Techniques
Rafay Farooq
 
Different types of Shoring Algorithms with Animation
Different types of Shoring Algorithms with AnimationDifferent types of Shoring Algorithms with Animation
Different types of Shoring Algorithms with Animation
Zakaria Hossain
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
Delowar Hossain
 
Sorting Algorithm
Sorting AlgorithmSorting Algorithm
Sorting Algorithm
Al Amin
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
Lovely Professional University
 
Sorting algorithm
Sorting algorithmSorting algorithm
Sorting algorithm
Balaji Nangare
 
Algorithm & data structures lec4&5
Algorithm & data structures lec4&5Algorithm & data structures lec4&5
Algorithm & data structures lec4&5
Abdul Khan
 
Data Structures- Part4 basic sorting algorithms
Data Structures- Part4 basic sorting algorithmsData Structures- Part4 basic sorting algorithms
Data Structures- Part4 basic sorting algorithms
Abdullah Al-hazmy
 
Data structures and algorithms - sorting algorithms
Data structures and algorithms - sorting algorithmsData structures and algorithms - sorting algorithms
Data structures and algorithms - sorting algorithms
Abimbola Idowu
 
Data Structures - Searching & sorting
Data Structures - Searching & sortingData Structures - Searching & sorting
Data Structures - Searching & sorting
Kaushal Shah
 
Lect11 Sorting
Lect11 SortingLect11 Sorting
Lect11 Sorting
ryokollll
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
Pranay Neema
 
Chapter 14 Searching and Sorting
Chapter 14 Searching and SortingChapter 14 Searching and Sorting
Chapter 14 Searching and Sorting
MuhammadBakri13
 
Sorting Techniques
Sorting TechniquesSorting Techniques
Sorting Techniques
Rafay Farooq
 
Different types of Shoring Algorithms with Animation
Different types of Shoring Algorithms with AnimationDifferent types of Shoring Algorithms with Animation
Different types of Shoring Algorithms with Animation
Zakaria Hossain
 
Sorting Algorithm
Sorting AlgorithmSorting Algorithm
Sorting Algorithm
Al Amin
 
Algorithm & data structures lec4&5
Algorithm & data structures lec4&5Algorithm & data structures lec4&5
Algorithm & data structures lec4&5
Abdul Khan
 

Viewers also liked (20)

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

Similar to sorting algorithm graphical method (20)

Bin Sorting And Bubble Sort By Luisito G. Trinidad
Bin Sorting And Bubble Sort By Luisito G. TrinidadBin Sorting And Bubble Sort By Luisito G. Trinidad
Bin Sorting And Bubble Sort By Luisito G. Trinidad
LUISITO TRINIDAD
 
CP PPT_Unit IV computer programming in c.pdf
CP PPT_Unit IV computer programming in c.pdfCP PPT_Unit IV computer programming in c.pdf
CP PPT_Unit IV computer programming in c.pdf
saneshgamerz
 
Decimal Long Double Double Double. Represents double-precision floating-point...
Decimal Long Double Double Double. Represents double-precision floating-point...Decimal Long Double Double Double. Represents double-precision floating-point...
Decimal Long Double Double Double. Represents double-precision floating-point...
Anwar Patel
 
03_sorting123456789454545454545444543.ppt
03_sorting123456789454545454545444543.ppt03_sorting123456789454545454545444543.ppt
03_sorting123456789454545454545444543.ppt
ssuser7b9bda1
 
03_sorting and it's types with example .ppt
03_sorting and it's types with example .ppt03_sorting and it's types with example .ppt
03_sorting and it's types with example .ppt
vanshii9976
 
Algorithms - "Chapter 2 getting started"
Algorithms - "Chapter 2 getting started"Algorithms - "Chapter 2 getting started"
Algorithms - "Chapter 2 getting started"
Ra'Fat Al-Msie'deen
 
Sorting_Algoritm-computee-scienceggn.pdf
Sorting_Algoritm-computee-scienceggn.pdfSorting_Algoritm-computee-scienceggn.pdf
Sorting_Algoritm-computee-scienceggn.pdf
Mohammed472103
 
Topic20Arrays_Part2.ppt
Topic20Arrays_Part2.pptTopic20Arrays_Part2.ppt
Topic20Arrays_Part2.ppt
adityavarte
 
Bubble sort, Selection sort SORTING .pptx
Bubble sort, Selection sort SORTING .pptxBubble sort, Selection sort SORTING .pptx
Bubble sort, Selection sort SORTING .pptx
Kalpana Mohan
 
sorting and its types
sorting and its typessorting and its types
sorting and its types
SIVASHANKARIRAJAN
 
CSEG1001Unit 3 Arrays and Strings
CSEG1001Unit 3 Arrays and StringsCSEG1001Unit 3 Arrays and Strings
CSEG1001Unit 3 Arrays and Strings
Dhiviya Rose
 
sorting1.pptx
sorting1.pptxsorting1.pptx
sorting1.pptx
AJAYVISHALRP
 
07-sorting.ppt for insertion sort and bubble sorting technquies
07-sorting.ppt for insertion sort and bubble sorting technquies07-sorting.ppt for insertion sort and bubble sorting technquies
07-sorting.ppt for insertion sort and bubble sorting technquies
shalinishankar0221
 
Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)
Hossain Md Shakhawat
 
Data Structures 6
Data Structures 6Data Structures 6
Data Structures 6
Dr.Umadevi V
 
Java presentation on insertion sort
Java presentation on insertion sortJava presentation on insertion sort
Java presentation on insertion sort
_fahad_shaikh
 
Arrays
ArraysArrays
Arrays
Aman Agarwal
 
Cis435 week01
Cis435 week01Cis435 week01
Cis435 week01
ashish bansal
 
Unit6 C
Unit6 C Unit6 C
Unit6 C
arnold 7490
 
Algorithms and Data Structures - Parahyangan Catholic University Credit Lionov
Algorithms and Data Structures - Parahyangan Catholic University Credit LionovAlgorithms and Data Structures - Parahyangan Catholic University Credit Lionov
Algorithms and Data Structures - Parahyangan Catholic University Credit Lionov
Pratik Parmar
 
Bin Sorting And Bubble Sort By Luisito G. Trinidad
Bin Sorting And Bubble Sort By Luisito G. TrinidadBin Sorting And Bubble Sort By Luisito G. Trinidad
Bin Sorting And Bubble Sort By Luisito G. Trinidad
LUISITO TRINIDAD
 
CP PPT_Unit IV computer programming in c.pdf
CP PPT_Unit IV computer programming in c.pdfCP PPT_Unit IV computer programming in c.pdf
CP PPT_Unit IV computer programming in c.pdf
saneshgamerz
 
Decimal Long Double Double Double. Represents double-precision floating-point...
Decimal Long Double Double Double. Represents double-precision floating-point...Decimal Long Double Double Double. Represents double-precision floating-point...
Decimal Long Double Double Double. Represents double-precision floating-point...
Anwar Patel
 
03_sorting123456789454545454545444543.ppt
03_sorting123456789454545454545444543.ppt03_sorting123456789454545454545444543.ppt
03_sorting123456789454545454545444543.ppt
ssuser7b9bda1
 
03_sorting and it's types with example .ppt
03_sorting and it's types with example .ppt03_sorting and it's types with example .ppt
03_sorting and it's types with example .ppt
vanshii9976
 
Algorithms - "Chapter 2 getting started"
Algorithms - "Chapter 2 getting started"Algorithms - "Chapter 2 getting started"
Algorithms - "Chapter 2 getting started"
Ra'Fat Al-Msie'deen
 
Sorting_Algoritm-computee-scienceggn.pdf
Sorting_Algoritm-computee-scienceggn.pdfSorting_Algoritm-computee-scienceggn.pdf
Sorting_Algoritm-computee-scienceggn.pdf
Mohammed472103
 
Topic20Arrays_Part2.ppt
Topic20Arrays_Part2.pptTopic20Arrays_Part2.ppt
Topic20Arrays_Part2.ppt
adityavarte
 
Bubble sort, Selection sort SORTING .pptx
Bubble sort, Selection sort SORTING .pptxBubble sort, Selection sort SORTING .pptx
Bubble sort, Selection sort SORTING .pptx
Kalpana Mohan
 
CSEG1001Unit 3 Arrays and Strings
CSEG1001Unit 3 Arrays and StringsCSEG1001Unit 3 Arrays and Strings
CSEG1001Unit 3 Arrays and Strings
Dhiviya Rose
 
07-sorting.ppt for insertion sort and bubble sorting technquies
07-sorting.ppt for insertion sort and bubble sorting technquies07-sorting.ppt for insertion sort and bubble sorting technquies
07-sorting.ppt for insertion sort and bubble sorting technquies
shalinishankar0221
 
Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)
Hossain Md Shakhawat
 
Java presentation on insertion sort
Java presentation on insertion sortJava presentation on insertion sort
Java presentation on insertion sort
_fahad_shaikh
 
Algorithms and Data Structures - Parahyangan Catholic University Credit Lionov
Algorithms and Data Structures - Parahyangan Catholic University Credit LionovAlgorithms and Data Structures - Parahyangan Catholic University Credit Lionov
Algorithms and Data Structures - Parahyangan Catholic University Credit Lionov
Pratik Parmar
 
Ad

Recently uploaded (20)

Grade 3 - English - Printable Worksheet (PDF Format)
Grade 3 - English - Printable Worksheet  (PDF Format)Grade 3 - English - Printable Worksheet  (PDF Format)
Grade 3 - English - Printable Worksheet (PDF Format)
Sritoma Majumder
 
APM Midlands Region April 2025 Sacha Hind Circulated.pdf
APM Midlands Region April 2025 Sacha Hind Circulated.pdfAPM Midlands Region April 2025 Sacha Hind Circulated.pdf
APM Midlands Region April 2025 Sacha Hind Circulated.pdf
Association for Project Management
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Sugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptxSugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptx
Dr. Renu Jangid
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Introduction-to-Communication-and-Media-Studies-1736283331.pdf
Introduction-to-Communication-and-Media-Studies-1736283331.pdfIntroduction-to-Communication-and-Media-Studies-1736283331.pdf
Introduction-to-Communication-and-Media-Studies-1736283331.pdf
james5028
 
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
Engage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdfEngage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdf
TechSoup
 
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
Nguyen Thanh Tu Collection
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
Grade 3 - English - Printable Worksheet (PDF Format)
Grade 3 - English - Printable Worksheet  (PDF Format)Grade 3 - English - Printable Worksheet  (PDF Format)
Grade 3 - English - Printable Worksheet (PDF Format)
Sritoma Majumder
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Sugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptxSugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptx
Dr. Renu Jangid
 
Introduction-to-Communication-and-Media-Studies-1736283331.pdf
Introduction-to-Communication-and-Media-Studies-1736283331.pdfIntroduction-to-Communication-and-Media-Studies-1736283331.pdf
Introduction-to-Communication-and-Media-Studies-1736283331.pdf
james5028
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
Engage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdfEngage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdf
TechSoup
 
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
BỘ ĐỀ TUYỂN SINH VÀO LỚP 10 TIẾNG ANH - 25 ĐỀ THI BÁM SÁT CẤU TRÚC MỚI NHẤT, ...
Nguyen Thanh Tu Collection
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 

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; } }