SlideShare a Scribd company logo
1 of 3
Download to read offline
Solution
:
Selection Sort after two iterations:
1 14 8 9 5 16 2
1 2 14 9 8 16 5
program:
class Sorting
{
public static void main(String args[])
{
int a[]=new int[]{8,14,2,9,5,16,1};
int i,j,k;
for(i=0;i<2;i++)
{
for(j=i+1;j<7;j++)
{
if(a[i]>a[j])
{
int temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
for(k=0;k<7;k++)
{
System.out.print(a[k]+" ");
}
System.out.println();
}
}
}
INsertion Sort: after 2 iterations
8 14 2 9 5 16 1
2 8 14 9 5 16 1
class Sorting
{
public static void main(String args[])
{
int a[]=new int[]{14,8,2,9,5,16,1};
int i,j,k;
for (j = 1; j < 7; j++) {
int temp = a[j];
i = j-1;
while ( (i > -1) && ( a [i] > temp ) ) {
a [i+1] = a [i];
i--;
}
a[i+1] = temp;
for(k=0;k<7;k++)
{
System.out.print(a[k]+" ");
}
System.out.println();
}
}
}
Bubble Sort: after 1 Iteration:
8 2 9 5 14 1 16
class Sorting
{
public static void main(String args[])
{
int a[]=new int[]{14,8,2,9,5,16,1};
int i,j,k,temp;
for(i=0; i < 7; i++){
for(j=1; j < (7-i); j++){
if(a[j-1] > a[j]){
//swap the elements!
temp = a[j-1];
a[j-1] = a[j];
a[j] = temp;
}
}
for(k=0;k<7;k++)
{
System.out.print(a[k]+" ");
}
System.out.println();
}
}
}

More Related Content

Similar to SolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdf

java slip for bachelors of business administration.pdf
java slip for bachelors of business administration.pdfjava slip for bachelors of business administration.pdf
java slip for bachelors of business administration.pdfkokah57440
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...MaruMengesha
 
Hello, I need some assistance in writing a java program THAT MUST US.pdf
Hello, I need some assistance in writing a java program THAT MUST US.pdfHello, I need some assistance in writing a java program THAT MUST US.pdf
Hello, I need some assistance in writing a java program THAT MUST US.pdfFashionColZone
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfeyewatchsystems
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple ProgramsUpender Upr
 
Inheritance and-polymorphism
Inheritance and-polymorphismInheritance and-polymorphism
Inheritance and-polymorphismUsama Malik
 
81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programsAbhishek Jena
 
Kotlin Perfomance on Android / Александр Смирнов (Splyt)
Kotlin Perfomance on Android / Александр Смирнов (Splyt)Kotlin Perfomance on Android / Александр Смирнов (Splyt)
Kotlin Perfomance on Android / Александр Смирнов (Splyt)Ontico
 
PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf
 PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf
PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdfapexelectronices01
 
Trace the following part of codes step by step- Show exactly what it w.docx
Trace the following part of codes step by step- Show exactly what it w.docxTrace the following part of codes step by step- Show exactly what it w.docx
Trace the following part of codes step by step- Show exactly what it w.docxgtameka
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iiiNiraj Bharambe
 
QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory archana singh
 
Computer java programs
Computer java programsComputer java programs
Computer java programsADITYA BHARTI
 
java program assigment -2
java program assigment -2java program assigment -2
java program assigment -2Ankit Gupta
 

Similar to SolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdf (20)

Java file
Java fileJava file
Java file
 
Java file
Java fileJava file
Java file
 
java slip for bachelors of business administration.pdf
java slip for bachelors of business administration.pdfjava slip for bachelors of business administration.pdf
java slip for bachelors of business administration.pdf
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
 
Hello, I need some assistance in writing a java program THAT MUST US.pdf
Hello, I need some assistance in writing a java program THAT MUST US.pdfHello, I need some assistance in writing a java program THAT MUST US.pdf
Hello, I need some assistance in writing a java program THAT MUST US.pdf
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
 
.net progrmming part2
.net progrmming part2.net progrmming part2
.net progrmming part2
 
Java practical
Java practicalJava practical
Java practical
 
Insertion Sort Code
Insertion Sort CodeInsertion Sort Code
Insertion Sort Code
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
Inheritance and-polymorphism
Inheritance and-polymorphismInheritance and-polymorphism
Inheritance and-polymorphism
 
81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs
 
Kotlin Perfomance on Android / Александр Смирнов (Splyt)
Kotlin Perfomance on Android / Александр Смирнов (Splyt)Kotlin Perfomance on Android / Александр Смирнов (Splyt)
Kotlin Perfomance on Android / Александр Смирнов (Splyt)
 
PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf
 PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf
PrintDiamond.javaimport java.util.Scanner;class PrintDiamond.pdf
 
Trace the following part of codes step by step- Show exactly what it w.docx
Trace the following part of codes step by step- Show exactly what it w.docxTrace the following part of codes step by step- Show exactly what it w.docx
Trace the following part of codes step by step- Show exactly what it w.docx
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iii
 
QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory
 
Computer java programs
Computer java programsComputer java programs
Computer java programs
 
Java oops features
Java oops featuresJava oops features
Java oops features
 
java program assigment -2
java program assigment -2java program assigment -2
java program assigment -2
 

More from annaimobiles

The equation you should use is just a variation of the PV formula.pdf
 The equation you should use is just a variation of the PV formula.pdf The equation you should use is just a variation of the PV formula.pdf
The equation you should use is just a variation of the PV formula.pdfannaimobiles
 
True short double stranded mRNA are involved in initiating the inte.pdf
  True short double stranded mRNA are involved in initiating the inte.pdf  True short double stranded mRNA are involved in initiating the inte.pdf
True short double stranded mRNA are involved in initiating the inte.pdfannaimobiles
 
Yes, it would react similarly, since boric oxide .pdf
                     Yes, it would react similarly, since boric oxide .pdf                     Yes, it would react similarly, since boric oxide .pdf
Yes, it would react similarly, since boric oxide .pdfannaimobiles
 
sol Solution A,D,E Crenation Solution B Hemol.pdf
                     sol  Solution A,D,E Crenation Solution B Hemol.pdf                     sol  Solution A,D,E Crenation Solution B Hemol.pdf
sol Solution A,D,E Crenation Solution B Hemol.pdfannaimobiles
 
please post the figure.... .pdf
                     please post the figure....                       .pdf                     please post the figure....                       .pdf
please post the figure.... .pdfannaimobiles
 
Intermediate species means species that have 2 ch.pdf
                     Intermediate species means species that have 2 ch.pdf                     Intermediate species means species that have 2 ch.pdf
Intermediate species means species that have 2 ch.pdfannaimobiles
 
In primitive cells atoms are present at the corne.pdf
                     In primitive cells atoms are present at the corne.pdf                     In primitive cells atoms are present at the corne.pdf
In primitive cells atoms are present at the corne.pdfannaimobiles
 
Hg2+ is more water soluble, methyl mercury HgCH3+.pdf
                     Hg2+ is more water soluble, methyl mercury HgCH3+.pdf                     Hg2+ is more water soluble, methyl mercury HgCH3+.pdf
Hg2+ is more water soluble, methyl mercury HgCH3+.pdfannaimobiles
 
HCl is a polar-covalent compound and also Acetoni.pdf
                     HCl is a polar-covalent compound and also Acetoni.pdf                     HCl is a polar-covalent compound and also Acetoni.pdf
HCl is a polar-covalent compound and also Acetoni.pdfannaimobiles
 
for a compound to be soluble in water 1. it shou.pdf
                     for a compound to be soluble in water  1. it shou.pdf                     for a compound to be soluble in water  1. it shou.pdf
for a compound to be soluble in water 1. it shou.pdfannaimobiles
 
e) II and III have the loest, equal stability .pdf
                     e) II and III have the loest, equal stability .pdf                     e) II and III have the loest, equal stability .pdf
e) II and III have the loest, equal stability .pdfannaimobiles
 
wait doingSolutionwait doing.pdf
wait doingSolutionwait doing.pdfwait doingSolutionwait doing.pdf
wait doingSolutionwait doing.pdfannaimobiles
 
TRUE The Reynolds number of falling 2.5 micrometer flyash particles .pdf
TRUE The Reynolds number of falling 2.5 micrometer flyash particles .pdfTRUE The Reynolds number of falling 2.5 micrometer flyash particles .pdf
TRUE The Reynolds number of falling 2.5 micrometer flyash particles .pdfannaimobiles
 
the electron rich molecule is a central Xe with 4 F singlebonded.pdf
the electron rich molecule is a central Xe with 4 F singlebonded.pdfthe electron rich molecule is a central Xe with 4 F singlebonded.pdf
the electron rich molecule is a central Xe with 4 F singlebonded.pdfannaimobiles
 
The given formulae themselves are explicit. Explicit means direct i..pdf
The given formulae themselves are explicit. Explicit means direct i..pdfThe given formulae themselves are explicit. Explicit means direct i..pdf
The given formulae themselves are explicit. Explicit means direct i..pdfannaimobiles
 
The answer is Meiosis, It occurs in human body at reporductive organ.pdf
The answer is Meiosis, It occurs in human body at reporductive organ.pdfThe answer is Meiosis, It occurs in human body at reporductive organ.pdf
The answer is Meiosis, It occurs in human body at reporductive organ.pdfannaimobiles
 
Structure of HemoglobinHemoglobin is a chromo protein and is found.pdf
Structure of HemoglobinHemoglobin is a chromo protein and is found.pdfStructure of HemoglobinHemoglobin is a chromo protein and is found.pdf
Structure of HemoglobinHemoglobin is a chromo protein and is found.pdfannaimobiles
 
Starch agar consists of starch. The secretion of amylase enzyme by s.pdf
Starch agar consists of starch. The secretion of amylase enzyme by s.pdfStarch agar consists of starch. The secretion of amylase enzyme by s.pdf
Starch agar consists of starch. The secretion of amylase enzyme by s.pdfannaimobiles
 
Solution find the solution below and please give the feedback and p.pdf
Solution find the solution below and please give the feedback and p.pdfSolution find the solution below and please give the feedback and p.pdf
Solution find the solution below and please give the feedback and p.pdfannaimobiles
 

More from annaimobiles (20)

The equation you should use is just a variation of the PV formula.pdf
 The equation you should use is just a variation of the PV formula.pdf The equation you should use is just a variation of the PV formula.pdf
The equation you should use is just a variation of the PV formula.pdf
 
True short double stranded mRNA are involved in initiating the inte.pdf
  True short double stranded mRNA are involved in initiating the inte.pdf  True short double stranded mRNA are involved in initiating the inte.pdf
True short double stranded mRNA are involved in initiating the inte.pdf
 
Yes, it would react similarly, since boric oxide .pdf
                     Yes, it would react similarly, since boric oxide .pdf                     Yes, it would react similarly, since boric oxide .pdf
Yes, it would react similarly, since boric oxide .pdf
 
spontaneous .pdf
                     spontaneous                                      .pdf                     spontaneous                                      .pdf
spontaneous .pdf
 
sol Solution A,D,E Crenation Solution B Hemol.pdf
                     sol  Solution A,D,E Crenation Solution B Hemol.pdf                     sol  Solution A,D,E Crenation Solution B Hemol.pdf
sol Solution A,D,E Crenation Solution B Hemol.pdf
 
please post the figure.... .pdf
                     please post the figure....                       .pdf                     please post the figure....                       .pdf
please post the figure.... .pdf
 
Intermediate species means species that have 2 ch.pdf
                     Intermediate species means species that have 2 ch.pdf                     Intermediate species means species that have 2 ch.pdf
Intermediate species means species that have 2 ch.pdf
 
In primitive cells atoms are present at the corne.pdf
                     In primitive cells atoms are present at the corne.pdf                     In primitive cells atoms are present at the corne.pdf
In primitive cells atoms are present at the corne.pdf
 
Hg2+ is more water soluble, methyl mercury HgCH3+.pdf
                     Hg2+ is more water soluble, methyl mercury HgCH3+.pdf                     Hg2+ is more water soluble, methyl mercury HgCH3+.pdf
Hg2+ is more water soluble, methyl mercury HgCH3+.pdf
 
HCl is a polar-covalent compound and also Acetoni.pdf
                     HCl is a polar-covalent compound and also Acetoni.pdf                     HCl is a polar-covalent compound and also Acetoni.pdf
HCl is a polar-covalent compound and also Acetoni.pdf
 
for a compound to be soluble in water 1. it shou.pdf
                     for a compound to be soluble in water  1. it shou.pdf                     for a compound to be soluble in water  1. it shou.pdf
for a compound to be soluble in water 1. it shou.pdf
 
e) II and III have the loest, equal stability .pdf
                     e) II and III have the loest, equal stability .pdf                     e) II and III have the loest, equal stability .pdf
e) II and III have the loest, equal stability .pdf
 
wait doingSolutionwait doing.pdf
wait doingSolutionwait doing.pdfwait doingSolutionwait doing.pdf
wait doingSolutionwait doing.pdf
 
TRUE The Reynolds number of falling 2.5 micrometer flyash particles .pdf
TRUE The Reynolds number of falling 2.5 micrometer flyash particles .pdfTRUE The Reynolds number of falling 2.5 micrometer flyash particles .pdf
TRUE The Reynolds number of falling 2.5 micrometer flyash particles .pdf
 
the electron rich molecule is a central Xe with 4 F singlebonded.pdf
the electron rich molecule is a central Xe with 4 F singlebonded.pdfthe electron rich molecule is a central Xe with 4 F singlebonded.pdf
the electron rich molecule is a central Xe with 4 F singlebonded.pdf
 
The given formulae themselves are explicit. Explicit means direct i..pdf
The given formulae themselves are explicit. Explicit means direct i..pdfThe given formulae themselves are explicit. Explicit means direct i..pdf
The given formulae themselves are explicit. Explicit means direct i..pdf
 
The answer is Meiosis, It occurs in human body at reporductive organ.pdf
The answer is Meiosis, It occurs in human body at reporductive organ.pdfThe answer is Meiosis, It occurs in human body at reporductive organ.pdf
The answer is Meiosis, It occurs in human body at reporductive organ.pdf
 
Structure of HemoglobinHemoglobin is a chromo protein and is found.pdf
Structure of HemoglobinHemoglobin is a chromo protein and is found.pdfStructure of HemoglobinHemoglobin is a chromo protein and is found.pdf
Structure of HemoglobinHemoglobin is a chromo protein and is found.pdf
 
Starch agar consists of starch. The secretion of amylase enzyme by s.pdf
Starch agar consists of starch. The secretion of amylase enzyme by s.pdfStarch agar consists of starch. The secretion of amylase enzyme by s.pdf
Starch agar consists of starch. The secretion of amylase enzyme by s.pdf
 
Solution find the solution below and please give the feedback and p.pdf
Solution find the solution below and please give the feedback and p.pdfSolution find the solution below and please give the feedback and p.pdf
Solution find the solution below and please give the feedback and p.pdf
 

Recently uploaded

AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonhttgc7rh9c
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfNirmal Dwivedi
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptxJoelynRubio1
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use CasesTechSoup
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 

Recently uploaded (20)

AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdfOur Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 

SolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdf

  • 1. Solution : Selection Sort after two iterations: 1 14 8 9 5 16 2 1 2 14 9 8 16 5 program: class Sorting { public static void main(String args[]) { int a[]=new int[]{8,14,2,9,5,16,1}; int i,j,k; for(i=0;i<2;i++) { for(j=i+1;j<7;j++) { if(a[i]>a[j]) { int temp=a[i]; a[i]=a[j]; a[j]=temp; } } for(k=0;k<7;k++) { System.out.print(a[k]+" "); } System.out.println(); } } } INsertion Sort: after 2 iterations 8 14 2 9 5 16 1 2 8 14 9 5 16 1 class Sorting
  • 2. { public static void main(String args[]) { int a[]=new int[]{14,8,2,9,5,16,1}; int i,j,k; for (j = 1; j < 7; j++) { int temp = a[j]; i = j-1; while ( (i > -1) && ( a [i] > temp ) ) { a [i+1] = a [i]; i--; } a[i+1] = temp; for(k=0;k<7;k++) { System.out.print(a[k]+" "); } System.out.println(); } } } Bubble Sort: after 1 Iteration: 8 2 9 5 14 1 16 class Sorting { public static void main(String args[]) { int a[]=new int[]{14,8,2,9,5,16,1}; int i,j,k,temp; for(i=0; i < 7; i++){ for(j=1; j < (7-i); j++){ if(a[j-1] > a[j]){ //swap the elements!
  • 3. temp = a[j-1]; a[j-1] = a[j]; a[j] = temp; } } for(k=0;k<7;k++) { System.out.print(a[k]+" "); } System.out.println(); } } }