SlideShare a Scribd company logo
Group no. 6 
• Shoaib Manzoor 23 
• Mureed Hussain 43 
• Muhammad Sajjad 24 
• Jahanzeb Shaukat 46 
• Usman Nasir 12
SORTING
What is sorting? 
The process in which we arrange collection 
of items in ascending or descending order is 
called sorting.
Types of sorting 
There are many kinds of sorting but here we 
will discuss only three types: 
• Bubble Sort 
• Selection Sort 
• Merge Sort
Bubble Sort 
Shoaib Manzoor
Algorithm 
• for I=1 to n 
• for j=1 to N-I 
• if list[j] > list[j+1] 
• swap(list[j], list[j+1])
Source Code (C++) 
Void main(int list[10]) 
{ 
for(int i = 0 ; i < 10 ; i++) 
{ 
for (int j = 0 ; j < i ; j++) 
{ 
if (list[j] > list [j + 1]) 
{ 
m = list[j]; 
list[j] = list[j+ 1] 
list[j + 1] = m; 
} 
} 
} 
}
Selection Sort 
Mureed Hussain
• The selection sort is a combination of searching and 
sorting. 
• In selection sort, sorting is done after selecting a 
particular smallest or largest element from an array 
and shifted it to a particular location in an array. 
• During each pass, the unsorted element with the 
smallest (or largest) value is moved to its proper 
position in the array. 
• Let's look at our same table of elements using a 
selection sort for ascending order:
Array 40 50 60 10 30 20 
1-pass 10 50 60 40 30 20 
2-pass 10 20 60 40 30 50 
3-pass 10 20 30 40 60 50 
4-pass 10 20 30 40 60 50 
5-pass 10 20 30 40 50 60 
• The number of times the sort passes through the 
• In the selection sort, the inner loop finds the next 
smallest (or largest) value and the outer loop places that 
value into its proper location. 
• Lets watch a visualizer which will give you a basic idea 
of a selection sort. 
• Please co-operate.
Algorithm 
For (i=1 to n) 
m = i 
for j = i+1 to n 
if list[j] < list[m] 
m=j 
if m != j 
swap(list[i] , list[m])
MERGE SORT 
Muhammad Sajjad 
& Usman Nasir
Algorithm 
Function merge_sort(list) 
if length of list < 2 
return list 
left = empty list 
right = empty list 
m = length of list / 2 
for i = 1 to m 
append list i to left 
for j = m + 1 to length of list 
append list j to right 
return merge (merge_sort(left)); 
merge _sort (right)
function merge ( left , right ) 
i = 1 
j = 1 
result = empty list 
while i <= length of left 
and j <= length of right 
if left i < right j 
append left i to result 
i = i +1 
else 
append right j to result 
j = j + 1 
for k = i to length of left 
append left k to result 
for k = j to length of right 
append right k to result 
return result
Thank You

More Related Content

What's hot

Data Structures - Lecture 8 [Sorting Algorithms]
Data Structures - Lecture 8 [Sorting Algorithms]Data Structures - Lecture 8 [Sorting Algorithms]
Data Structures - Lecture 8 [Sorting Algorithms]
Muhammad Hammad Waseem
 
Sorting
SortingSorting
Sorting
Zaid Shabbir
 
Sorting
SortingSorting
Sorting
BHARATH KUMAR
 
Selection sorting
Selection sortingSelection sorting
Selection sorting
Himanshu Kesharwani
 
Sorting ppt
Sorting pptSorting ppt
Sorting ppt
Hassan Mustafa
 
Sorting techniques
Sorting techniquesSorting techniques
Sorting techniques
Lovely Professional University
 
Sorting
SortingSorting
Sorting
Jasmine Chen
 
Shell sorting
Shell sortingShell sorting
Shell sorting
TUC
 
Sorting algorithms v01
Sorting algorithms v01Sorting algorithms v01
Sorting algorithms v01
Dusan Vuckovic
 
Relations and functions (Mariam)
Relations and functions (Mariam)Relations and functions (Mariam)
Relations and functions (Mariam)
Mariam Bosraty
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
Gokul Hari
 
Searching Sorting
Searching SortingSearching Sorting
Searching Sorting
guest2cb109
 
Sorting
SortingSorting
Sorting
Samsil Arefin
 
Sorting
SortingSorting
Selection sort
Selection sortSelection sort
Selection sort
smlagustin
 
Matrix
MatrixMatrix
Matrix
Deepak Kumar
 
Sorting (introduction)
 Sorting (introduction) Sorting (introduction)
Sorting (introduction)
Arvind Devaraj
 
Arrays searching-sorting
Arrays searching-sortingArrays searching-sorting
Arrays searching-sorting
Ajharul Abedeen
 
Sorting
SortingSorting
Shell sort
Shell sortShell sort
Shell sort
Rajendran
 

What's hot (20)

Data Structures - Lecture 8 [Sorting Algorithms]
Data Structures - Lecture 8 [Sorting Algorithms]Data Structures - Lecture 8 [Sorting Algorithms]
Data Structures - Lecture 8 [Sorting Algorithms]
 
Sorting
SortingSorting
Sorting
 
Sorting
SortingSorting
Sorting
 
Selection sorting
Selection sortingSelection sorting
Selection sorting
 
Sorting ppt
Sorting pptSorting ppt
Sorting ppt
 
Sorting techniques
Sorting techniquesSorting techniques
Sorting techniques
 
Sorting
SortingSorting
Sorting
 
Shell sorting
Shell sortingShell sorting
Shell sorting
 
Sorting algorithms v01
Sorting algorithms v01Sorting algorithms v01
Sorting algorithms v01
 
Relations and functions (Mariam)
Relations and functions (Mariam)Relations and functions (Mariam)
Relations and functions (Mariam)
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
 
Searching Sorting
Searching SortingSearching Sorting
Searching Sorting
 
Sorting
SortingSorting
Sorting
 
Sorting
SortingSorting
Sorting
 
Selection sort
Selection sortSelection sort
Selection sort
 
Matrix
MatrixMatrix
Matrix
 
Sorting (introduction)
 Sorting (introduction) Sorting (introduction)
Sorting (introduction)
 
Arrays searching-sorting
Arrays searching-sortingArrays searching-sorting
Arrays searching-sorting
 
Sorting
SortingSorting
Sorting
 
Shell sort
Shell sortShell sort
Shell sort
 

Similar to Sorting (Bubble,Merge,Selection sort)

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
 
Selection sort 1
Selection sort 1Selection sort 1
Selection sort 1
asmhemu
 
sorting and its types
sorting and its typessorting and its types
sorting and its types
SIVASHANKARIRAJAN
 
Sorting_Algoritm-computee-scienceggn.pdf
Sorting_Algoritm-computee-scienceggn.pdfSorting_Algoritm-computee-scienceggn.pdf
Sorting_Algoritm-computee-scienceggn.pdf
Mohammed472103
 
Selection sort
Selection sortSelection sort
Selection sort
zahraa F.Muhsen
 
Dsa – data structure and algorithms sorting
Dsa – data structure and algorithms  sortingDsa – data structure and algorithms  sorting
Dsa – data structure and algorithms sorting
sajinis3
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
Maher Alshammari
 
Sorting and hashing concepts
Sorting and hashing conceptsSorting and hashing concepts
Sorting and hashing concepts
LJ Projects
 
Sorting and hashing concepts
Sorting and hashing conceptsSorting and hashing concepts
Sorting and hashing concepts
LJ Projects
 
Data Structure Searching.pptx
Data Structure Searching.pptxData Structure Searching.pptx
Data Structure Searching.pptx
SourabhTaneja4
 
(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting
Fadhil Ismail
 
sorting and searching.pptx
sorting and searching.pptxsorting and searching.pptx
sorting and searching.pptx
ParagAhir1
 
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 algorithm graphical method
sorting algorithm graphical method sorting algorithm graphical method
sorting algorithm graphical method
Shantanu Mishra
 
search_sort.ppt
search_sort.pptsearch_sort.ppt
search_sort.ppt
SwatiHans10
 
03 Linear Arrays Memory Representations .pdf
03 Linear Arrays Memory Representations .pdf03 Linear Arrays Memory Representations .pdf
03 Linear Arrays Memory Representations .pdf
KkSingh64
 
Python.pdf
Python.pdfPython.pdf
Python.pdf
TanTran598844
 
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
 
Abstract Algebra and Category Theory
Abstract Algebra and Category Theory Abstract Algebra and Category Theory
Abstract Algebra and Category Theory
Naveenkumar Muguda
 
searching in data structure.pptx
searching in data structure.pptxsearching in data structure.pptx
searching in data structure.pptx
chouguleamruta24
 

Similar to Sorting (Bubble,Merge,Selection sort) (20)

Bubble sort, Selection sort SORTING .pptx
Bubble sort, Selection sort SORTING .pptxBubble sort, Selection sort SORTING .pptx
Bubble sort, Selection sort SORTING .pptx
 
Selection sort 1
Selection sort 1Selection sort 1
Selection sort 1
 
sorting and its types
sorting and its typessorting and its types
sorting and its types
 
Sorting_Algoritm-computee-scienceggn.pdf
Sorting_Algoritm-computee-scienceggn.pdfSorting_Algoritm-computee-scienceggn.pdf
Sorting_Algoritm-computee-scienceggn.pdf
 
Selection sort
Selection sortSelection sort
Selection sort
 
Dsa – data structure and algorithms sorting
Dsa – data structure and algorithms  sortingDsa – data structure and algorithms  sorting
Dsa – data structure and algorithms sorting
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 
Sorting and hashing concepts
Sorting and hashing conceptsSorting and hashing concepts
Sorting and hashing concepts
 
Sorting and hashing concepts
Sorting and hashing conceptsSorting and hashing concepts
Sorting and hashing concepts
 
Data Structure Searching.pptx
Data Structure Searching.pptxData Structure Searching.pptx
Data Structure Searching.pptx
 
(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting
 
sorting and searching.pptx
sorting and searching.pptxsorting and searching.pptx
sorting and searching.pptx
 
Algorithms - "Chapter 2 getting started"
Algorithms - "Chapter 2 getting started"Algorithms - "Chapter 2 getting started"
Algorithms - "Chapter 2 getting started"
 
sorting algorithm graphical method
sorting algorithm graphical method sorting algorithm graphical method
sorting algorithm graphical method
 
search_sort.ppt
search_sort.pptsearch_sort.ppt
search_sort.ppt
 
03 Linear Arrays Memory Representations .pdf
03 Linear Arrays Memory Representations .pdf03 Linear Arrays Memory Representations .pdf
03 Linear Arrays Memory Representations .pdf
 
Python.pdf
Python.pdfPython.pdf
Python.pdf
 
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...
 
Abstract Algebra and Category Theory
Abstract Algebra and Category Theory Abstract Algebra and Category Theory
Abstract Algebra and Category Theory
 
searching in data structure.pptx
searching in data structure.pptxsearching in data structure.pptx
searching in data structure.pptx
 

More from oDesk

Multiprocessor Scheduling
Multiprocessor SchedulingMultiprocessor Scheduling
Multiprocessor Scheduling
oDesk
 
1G, 2G, 3G, 4G, 5G. Best topic for telecom presentation
1G, 2G, 3G, 4G, 5G. Best topic for telecom presentation1G, 2G, 3G, 4G, 5G. Best topic for telecom presentation
1G, 2G, 3G, 4G, 5G. Best topic for telecom presentation
oDesk
 
Formation of a Company
Formation of a Company Formation of a Company
Formation of a Company
oDesk
 
Online Testing (Examination) System
Online Testing (Examination) SystemOnline Testing (Examination) System
Online Testing (Examination) System
oDesk
 
Global Warming (full topic, Causes, impacts,Solution etc.)
Global Warming (full topic, Causes, impacts,Solution etc.)Global Warming (full topic, Causes, impacts,Solution etc.)
Global Warming (full topic, Causes, impacts,Solution etc.)
oDesk
 
Customer Relationship Management
Customer Relationship  ManagementCustomer Relationship  Management
Customer Relationship Management
oDesk
 

More from oDesk (6)

Multiprocessor Scheduling
Multiprocessor SchedulingMultiprocessor Scheduling
Multiprocessor Scheduling
 
1G, 2G, 3G, 4G, 5G. Best topic for telecom presentation
1G, 2G, 3G, 4G, 5G. Best topic for telecom presentation1G, 2G, 3G, 4G, 5G. Best topic for telecom presentation
1G, 2G, 3G, 4G, 5G. Best topic for telecom presentation
 
Formation of a Company
Formation of a Company Formation of a Company
Formation of a Company
 
Online Testing (Examination) System
Online Testing (Examination) SystemOnline Testing (Examination) System
Online Testing (Examination) System
 
Global Warming (full topic, Causes, impacts,Solution etc.)
Global Warming (full topic, Causes, impacts,Solution etc.)Global Warming (full topic, Causes, impacts,Solution etc.)
Global Warming (full topic, Causes, impacts,Solution etc.)
 
Customer Relationship Management
Customer Relationship  ManagementCustomer Relationship  Management
Customer Relationship Management
 

Recently uploaded

06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
Timothy Spann
 
Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......
Sachin Paul
 
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
74nqk8xf
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
Timothy Spann
 
Global Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headedGlobal Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headed
vikram sood
 
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Aggregage
 
Challenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more importantChallenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more important
Sm321
 
Experts live - Improving user adoption with AI
Experts live - Improving user adoption with AIExperts live - Improving user adoption with AI
Experts live - Improving user adoption with AI
jitskeb
 
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
nuttdpt
 
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
v7oacc3l
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
aqzctr7x
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
javier ramirez
 
Influence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business PlanInfluence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business Plan
jerlynmaetalle
 
一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理
zsjl4mimo
 
My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.
rwarrenll
 
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data LakeViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
Walaa Eldin Moustafa
 
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
g4dpvqap0
 
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataPredictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Kiwi Creative
 
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdfUdemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Fernanda Palhano
 
End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
Lars Albertsson
 

Recently uploaded (20)

06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
 
Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......
 
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
 
Global Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headedGlobal Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headed
 
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
 
Challenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more importantChallenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more important
 
Experts live - Improving user adoption with AI
Experts live - Improving user adoption with AIExperts live - Improving user adoption with AI
Experts live - Improving user adoption with AI
 
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
 
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
 
Influence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business PlanInfluence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business Plan
 
一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理
 
My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.
 
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data LakeViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
 
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
 
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataPredictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
 
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdfUdemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
 
End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
 

Sorting (Bubble,Merge,Selection sort)

  • 1.
  • 2.
  • 3. Group no. 6 • Shoaib Manzoor 23 • Mureed Hussain 43 • Muhammad Sajjad 24 • Jahanzeb Shaukat 46 • Usman Nasir 12
  • 5. What is sorting? The process in which we arrange collection of items in ascending or descending order is called sorting.
  • 6. Types of sorting There are many kinds of sorting but here we will discuss only three types: • Bubble Sort • Selection Sort • Merge Sort
  • 8. Algorithm • for I=1 to n • for j=1 to N-I • if list[j] > list[j+1] • swap(list[j], list[j+1])
  • 9. Source Code (C++) Void main(int list[10]) { for(int i = 0 ; i < 10 ; i++) { for (int j = 0 ; j < i ; j++) { if (list[j] > list [j + 1]) { m = list[j]; list[j] = list[j+ 1] list[j + 1] = m; } } } }
  • 11. • The selection sort is a combination of searching and sorting. • In selection sort, sorting is done after selecting a particular smallest or largest element from an array and shifted it to a particular location in an array. • During each pass, the unsorted element with the smallest (or largest) value is moved to its proper position in the array. • Let's look at our same table of elements using a selection sort for ascending order:
  • 12. Array 40 50 60 10 30 20 1-pass 10 50 60 40 30 20 2-pass 10 20 60 40 30 50 3-pass 10 20 30 40 60 50 4-pass 10 20 30 40 60 50 5-pass 10 20 30 40 50 60 • The number of times the sort passes through the • In the selection sort, the inner loop finds the next smallest (or largest) value and the outer loop places that value into its proper location. • Lets watch a visualizer which will give you a basic idea of a selection sort. • Please co-operate.
  • 13. Algorithm For (i=1 to n) m = i for j = i+1 to n if list[j] < list[m] m=j if m != j swap(list[i] , list[m])
  • 14. MERGE SORT Muhammad Sajjad & Usman Nasir
  • 15. Algorithm Function merge_sort(list) if length of list < 2 return list left = empty list right = empty list m = length of list / 2 for i = 1 to m append list i to left for j = m + 1 to length of list append list j to right return merge (merge_sort(left)); merge _sort (right)
  • 16. function merge ( left , right ) i = 1 j = 1 result = empty list while i <= length of left and j <= length of right if left i < right j append left i to result i = i +1 else append right j to result j = j + 1 for k = i to length of left append left k to result for k = j to length of right append right k to result return result
  • 17.