SlideShare a Scribd company logo
Step 1:You need to run the JAVA programs in sections 3.3 and 3.5 for selection sort and
insertion sort. You need to attach the output results.
Step 2: You need to modify these two programs, save them, submit them, and add some
comments and explanations to them to sort the list elements from high to low value. The index
should be IndexHighest instead IndexSmallest.
Step3: Run the modified programs and print out the results and submit them.
In the end, you need the running results for original JAVA programs (selection and insertion sort
JAVA programs), the two modified programs to sort the values from high to low value for
selection and insertion sorts, and the results for the modified programs.
This program uses the selection sort algorithm to sort an array. The code has been modified to
also calculate how many item comparisons are done. You can try running the program with
different arrays to see how the total number of comparisons changes (or doesn't change).
CODE 3.3 ---
import java.util.Arrays;
public class SelectionSortDemo {
private static int selectionSort(int[] numbers) {
// A variable to hold the number of item comparisons
int comparisons = 0;
for (int i = 0; i < numbers.length - 1; i++) {
// Find index of smallest remaining element
int indexSmallest = i;
for (int j = i + 1; j < numbers.length; j++) {
comparisons++;
if (numbers[j] < numbers[indexSmallest]) {
indexSmallest = j;
}
}
// Swap numbers[i] and numbers[indexSmallest]
int temp = numbers[i];
numbers[i] = numbers[indexSmallest];
numbers[indexSmallest] = temp;
}
return comparisons;
}
public static void main(String[] args) {
// Create an array of numbers to sort
int[] numbers = { 10, 2, 78, 4, 45, 32, 7, 11 };
// Display the contents of the array
System.out.println("UNSORTED: " + Arrays.toString(numbers));
// Call the selectionSort method
int comparisons = selectionSort(numbers);
// Display the sorted contents of the array
System.out.println("SORTED: " + Arrays.toString(numbers));
System.out.println("Total comparisons: " + comparisons);
}
}
CODE 3.5 ---
import java.util.Arrays;
public class InsertionSortDemo {
private static void insertionSort(int[] numbers) {
for (int i = 1; i < numbers.length; i++) {
int j = i;
while (j > 0 && numbers[j] < numbers[j - 1]) {
// Swap numbers[j] and numbers [j - 1]
int temp = numbers[j];
numbers[j] = numbers[j - 1];
numbers[j - 1] = temp;
j--;
}
}
}
public static void main(String[] args) {
// Create an array of numbers to sort
int[] numbers = { 10, 2, 78, 4, 45, 32, 7, 11 };
// Display the contents of the array
System.out.println("UNSORTED: " + Arrays.toString(numbers));
// Call the insertionSort method
insertionSort(numbers);
// Display the sorted contents of the array
System.out.println("SORTED: " + Arrays.toString(numbers));
}
}

More Related Content

Similar to Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf

9 Arrays
9 Arrays9 Arrays
07+08slide.pptx
07+08slide.pptx07+08slide.pptx
07+08slide.pptx
MURADSANJOUM
 
Arrays and function basic c programming notes
Arrays and function basic c programming notesArrays and function basic c programming notes
Arrays and function basic c programming notes
GOKULKANNANMMECLECTC
 
Object Oriented Programming Using C++: C++ STL Programming.pptx
Object Oriented Programming Using C++: C++ STL Programming.pptxObject Oriented Programming Using C++: C++ STL Programming.pptx
Object Oriented Programming Using C++: C++ STL Programming.pptx
RashidFaridChishti
 
6_Array.pptx
6_Array.pptx6_Array.pptx
6_Array.pptx
shafat6712
 
Chapter2pp
Chapter2ppChapter2pp
Chapter2pp
J. C.
 
An Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: ArraysAn Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: Arrays
Martin Chapman
 
Write a program that will test a name) method no sorting routine from.docx
 Write a program that will test a name) method no sorting routine from.docx Write a program that will test a name) method no sorting routine from.docx
Write a program that will test a name) method no sorting routine from.docx
ajoy21
 
Array assignment
Array assignmentArray assignment
Array assignment
Ahmad Kamal
 
arrays-120712074248-phpapp01
arrays-120712074248-phpapp01arrays-120712074248-phpapp01
arrays-120712074248-phpapp01
Abdul Samee
 
[ITP - Lecture 15] Arrays & its Types
[ITP - Lecture 15] Arrays & its Types[ITP - Lecture 15] Arrays & its Types
[ITP - Lecture 15] Arrays & its Types
Muhammad Hammad Waseem
 
Comp 122 lab 6 lab report and source code
Comp 122 lab 6 lab report and source codeComp 122 lab 6 lab report and source code
Comp 122 lab 6 lab report and source code
pradesigali1
 
ch07-arrays.ppt
ch07-arrays.pptch07-arrays.ppt
ch07-arrays.ppt
Mahyuddin8
 
Develop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdfDevelop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdf
leventhalbrad49439
 
Intro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technologyIntro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technology
worldchannel
 
COM1407: Arrays
COM1407: ArraysCOM1407: Arrays
COM1407: Arrays
Hemantha Kulathilake
 
16-sorting.ppt
16-sorting.ppt16-sorting.ppt
16-sorting.ppt
18Gunaalanpg
 
object oriented programming java lectures
object oriented programming java lecturesobject oriented programming java lectures
object oriented programming java lectures
MSohaib24
 
Write a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdfWrite a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdf
fashioncollection2
 
Java Programming
Java ProgrammingJava Programming
Java Programming
Nanthini Kempaiyan
 

Similar to Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf (20)

9 Arrays
9 Arrays9 Arrays
9 Arrays
 
07+08slide.pptx
07+08slide.pptx07+08slide.pptx
07+08slide.pptx
 
Arrays and function basic c programming notes
Arrays and function basic c programming notesArrays and function basic c programming notes
Arrays and function basic c programming notes
 
Object Oriented Programming Using C++: C++ STL Programming.pptx
Object Oriented Programming Using C++: C++ STL Programming.pptxObject Oriented Programming Using C++: C++ STL Programming.pptx
Object Oriented Programming Using C++: C++ STL Programming.pptx
 
6_Array.pptx
6_Array.pptx6_Array.pptx
6_Array.pptx
 
Chapter2pp
Chapter2ppChapter2pp
Chapter2pp
 
An Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: ArraysAn Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: Arrays
 
Write a program that will test a name) method no sorting routine from.docx
 Write a program that will test a name) method no sorting routine from.docx Write a program that will test a name) method no sorting routine from.docx
Write a program that will test a name) method no sorting routine from.docx
 
Array assignment
Array assignmentArray assignment
Array assignment
 
arrays-120712074248-phpapp01
arrays-120712074248-phpapp01arrays-120712074248-phpapp01
arrays-120712074248-phpapp01
 
[ITP - Lecture 15] Arrays & its Types
[ITP - Lecture 15] Arrays & its Types[ITP - Lecture 15] Arrays & its Types
[ITP - Lecture 15] Arrays & its Types
 
Comp 122 lab 6 lab report and source code
Comp 122 lab 6 lab report and source codeComp 122 lab 6 lab report and source code
Comp 122 lab 6 lab report and source code
 
ch07-arrays.ppt
ch07-arrays.pptch07-arrays.ppt
ch07-arrays.ppt
 
Develop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdfDevelop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdf
 
Intro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technologyIntro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technology
 
COM1407: Arrays
COM1407: ArraysCOM1407: Arrays
COM1407: Arrays
 
16-sorting.ppt
16-sorting.ppt16-sorting.ppt
16-sorting.ppt
 
object oriented programming java lectures
object oriented programming java lecturesobject oriented programming java lectures
object oriented programming java lectures
 
Write a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdfWrite a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdf
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 

More from aloeplusint

Starware Software was founded last year to develop software for gami.pdf
Starware Software was founded last year to develop software for gami.pdfStarware Software was founded last year to develop software for gami.pdf
Starware Software was founded last year to develop software for gami.pdf
aloeplusint
 
Some obstacles in Project Development. One of the main goals of Proj.pdf
Some obstacles in Project Development. One of the main goals of Proj.pdfSome obstacles in Project Development. One of the main goals of Proj.pdf
Some obstacles in Project Development. One of the main goals of Proj.pdf
aloeplusint
 
Sophocles Enterprises had the following pretax income (loss) over it.pdf
Sophocles Enterprises had the following pretax income (loss) over it.pdfSophocles Enterprises had the following pretax income (loss) over it.pdf
Sophocles Enterprises had the following pretax income (loss) over it.pdf
aloeplusint
 
Solve using java and using this Singly linked list classpublic cl.pdf
Solve using java and using this Singly linked list classpublic cl.pdfSolve using java and using this Singly linked list classpublic cl.pdf
Solve using java and using this Singly linked list classpublic cl.pdf
aloeplusint
 
SQL was created at IBM in the 1970s. Why was SQL createdSQL was .pdf
SQL was created at IBM in the 1970s. Why was SQL createdSQL was .pdfSQL was created at IBM in the 1970s. Why was SQL createdSQL was .pdf
SQL was created at IBM in the 1970s. Why was SQL createdSQL was .pdf
aloeplusint
 
SQL- Write a select statement that returns the Freight cost from.pdf
SQL- Write a select statement that returns the Freight cost from.pdfSQL- Write a select statement that returns the Freight cost from.pdf
SQL- Write a select statement that returns the Freight cost from.pdf
aloeplusint
 
Some of our most basic questions about the history of life concern w.pdf
Some of our most basic questions about the history of life concern w.pdfSome of our most basic questions about the history of life concern w.pdf
Some of our most basic questions about the history of life concern w.pdf
aloeplusint
 
Southeastern Oklahoma State Universitys business program has the fa.pdf
Southeastern Oklahoma State Universitys business program has the fa.pdfSoutheastern Oklahoma State Universitys business program has the fa.pdf
Southeastern Oklahoma State Universitys business program has the fa.pdf
aloeplusint
 
Sorensen Systems Inc. is expected to pay a $2.50 dividend at year en.pdf
Sorensen Systems Inc. is expected to pay a $2.50 dividend at year en.pdfSorensen Systems Inc. is expected to pay a $2.50 dividend at year en.pdf
Sorensen Systems Inc. is expected to pay a $2.50 dividend at year en.pdf
aloeplusint
 
Subject Computer Architecture & Organization Q-4 Assume that .pdf
Subject Computer Architecture & Organization  Q-4 Assume that .pdfSubject Computer Architecture & Organization  Q-4 Assume that .pdf
Subject Computer Architecture & Organization Q-4 Assume that .pdf
aloeplusint
 
Subject Management Information System Please complete the four qu.pdf
Subject Management Information System Please complete the four qu.pdfSubject Management Information System Please complete the four qu.pdf
Subject Management Information System Please complete the four qu.pdf
aloeplusint
 
Subject Computer Architecture & Organization i. Show the con.pdf
Subject Computer Architecture & Organization  i. Show the con.pdfSubject Computer Architecture & Organization  i. Show the con.pdf
Subject Computer Architecture & Organization i. Show the con.pdf
aloeplusint
 
Solve the following balance and income sheet for this specialty hosp.pdf
Solve the following balance and income sheet for this specialty hosp.pdfSolve the following balance and income sheet for this specialty hosp.pdf
Solve the following balance and income sheet for this specialty hosp.pdf
aloeplusint
 
Su clase se ha ofrecido como voluntaria para trabajar por el Refer�n.pdf
Su clase se ha ofrecido como voluntaria para trabajar por el Refer�n.pdfSu clase se ha ofrecido como voluntaria para trabajar por el Refer�n.pdf
Su clase se ha ofrecido como voluntaria para trabajar por el Refer�n.pdf
aloeplusint
 
Su compa��a de TI es responsable de crear programas de virus de soft.pdf
Su compa��a de TI es responsable de crear programas de virus de soft.pdfSu compa��a de TI es responsable de crear programas de virus de soft.pdf
Su compa��a de TI es responsable de crear programas de virus de soft.pdf
aloeplusint
 
Study the cladogram above and match the names of the five organisms .pdf
Study the cladogram above and match the names of the five organisms .pdfStudy the cladogram above and match the names of the five organisms .pdf
Study the cladogram above and match the names of the five organisms .pdf
aloeplusint
 
study of tension, compression, and shear and compare those three dir.pdf
study of tension, compression, and shear and compare those three dir.pdfstudy of tension, compression, and shear and compare those three dir.pdf
study of tension, compression, and shear and compare those three dir.pdf
aloeplusint
 
Start Program like this Chapter 7 Validate Password import.pdf
Start Program like this  Chapter 7 Validate Password import.pdfStart Program like this  Chapter 7 Validate Password import.pdf
Start Program like this Chapter 7 Validate Password import.pdf
aloeplusint
 
Students may research the local Aboriginal andor Torres Strait Isla.pdf
Students may research the local Aboriginal andor Torres Strait Isla.pdfStudents may research the local Aboriginal andor Torres Strait Isla.pdf
Students may research the local Aboriginal andor Torres Strait Isla.pdf
aloeplusint
 
Stevie es un hombre ocupado. El viaja mucho. Usa las palabras entre .pdf
Stevie es un hombre ocupado. El viaja mucho. Usa las palabras entre .pdfStevie es un hombre ocupado. El viaja mucho. Usa las palabras entre .pdf
Stevie es un hombre ocupado. El viaja mucho. Usa las palabras entre .pdf
aloeplusint
 

More from aloeplusint (20)

Starware Software was founded last year to develop software for gami.pdf
Starware Software was founded last year to develop software for gami.pdfStarware Software was founded last year to develop software for gami.pdf
Starware Software was founded last year to develop software for gami.pdf
 
Some obstacles in Project Development. One of the main goals of Proj.pdf
Some obstacles in Project Development. One of the main goals of Proj.pdfSome obstacles in Project Development. One of the main goals of Proj.pdf
Some obstacles in Project Development. One of the main goals of Proj.pdf
 
Sophocles Enterprises had the following pretax income (loss) over it.pdf
Sophocles Enterprises had the following pretax income (loss) over it.pdfSophocles Enterprises had the following pretax income (loss) over it.pdf
Sophocles Enterprises had the following pretax income (loss) over it.pdf
 
Solve using java and using this Singly linked list classpublic cl.pdf
Solve using java and using this Singly linked list classpublic cl.pdfSolve using java and using this Singly linked list classpublic cl.pdf
Solve using java and using this Singly linked list classpublic cl.pdf
 
SQL was created at IBM in the 1970s. Why was SQL createdSQL was .pdf
SQL was created at IBM in the 1970s. Why was SQL createdSQL was .pdfSQL was created at IBM in the 1970s. Why was SQL createdSQL was .pdf
SQL was created at IBM in the 1970s. Why was SQL createdSQL was .pdf
 
SQL- Write a select statement that returns the Freight cost from.pdf
SQL- Write a select statement that returns the Freight cost from.pdfSQL- Write a select statement that returns the Freight cost from.pdf
SQL- Write a select statement that returns the Freight cost from.pdf
 
Some of our most basic questions about the history of life concern w.pdf
Some of our most basic questions about the history of life concern w.pdfSome of our most basic questions about the history of life concern w.pdf
Some of our most basic questions about the history of life concern w.pdf
 
Southeastern Oklahoma State Universitys business program has the fa.pdf
Southeastern Oklahoma State Universitys business program has the fa.pdfSoutheastern Oklahoma State Universitys business program has the fa.pdf
Southeastern Oklahoma State Universitys business program has the fa.pdf
 
Sorensen Systems Inc. is expected to pay a $2.50 dividend at year en.pdf
Sorensen Systems Inc. is expected to pay a $2.50 dividend at year en.pdfSorensen Systems Inc. is expected to pay a $2.50 dividend at year en.pdf
Sorensen Systems Inc. is expected to pay a $2.50 dividend at year en.pdf
 
Subject Computer Architecture & Organization Q-4 Assume that .pdf
Subject Computer Architecture & Organization  Q-4 Assume that .pdfSubject Computer Architecture & Organization  Q-4 Assume that .pdf
Subject Computer Architecture & Organization Q-4 Assume that .pdf
 
Subject Management Information System Please complete the four qu.pdf
Subject Management Information System Please complete the four qu.pdfSubject Management Information System Please complete the four qu.pdf
Subject Management Information System Please complete the four qu.pdf
 
Subject Computer Architecture & Organization i. Show the con.pdf
Subject Computer Architecture & Organization  i. Show the con.pdfSubject Computer Architecture & Organization  i. Show the con.pdf
Subject Computer Architecture & Organization i. Show the con.pdf
 
Solve the following balance and income sheet for this specialty hosp.pdf
Solve the following balance and income sheet for this specialty hosp.pdfSolve the following balance and income sheet for this specialty hosp.pdf
Solve the following balance and income sheet for this specialty hosp.pdf
 
Su clase se ha ofrecido como voluntaria para trabajar por el Refer�n.pdf
Su clase se ha ofrecido como voluntaria para trabajar por el Refer�n.pdfSu clase se ha ofrecido como voluntaria para trabajar por el Refer�n.pdf
Su clase se ha ofrecido como voluntaria para trabajar por el Refer�n.pdf
 
Su compa��a de TI es responsable de crear programas de virus de soft.pdf
Su compa��a de TI es responsable de crear programas de virus de soft.pdfSu compa��a de TI es responsable de crear programas de virus de soft.pdf
Su compa��a de TI es responsable de crear programas de virus de soft.pdf
 
Study the cladogram above and match the names of the five organisms .pdf
Study the cladogram above and match the names of the five organisms .pdfStudy the cladogram above and match the names of the five organisms .pdf
Study the cladogram above and match the names of the five organisms .pdf
 
study of tension, compression, and shear and compare those three dir.pdf
study of tension, compression, and shear and compare those three dir.pdfstudy of tension, compression, and shear and compare those three dir.pdf
study of tension, compression, and shear and compare those three dir.pdf
 
Start Program like this Chapter 7 Validate Password import.pdf
Start Program like this  Chapter 7 Validate Password import.pdfStart Program like this  Chapter 7 Validate Password import.pdf
Start Program like this Chapter 7 Validate Password import.pdf
 
Students may research the local Aboriginal andor Torres Strait Isla.pdf
Students may research the local Aboriginal andor Torres Strait Isla.pdfStudents may research the local Aboriginal andor Torres Strait Isla.pdf
Students may research the local Aboriginal andor Torres Strait Isla.pdf
 
Stevie es un hombre ocupado. El viaja mucho. Usa las palabras entre .pdf
Stevie es un hombre ocupado. El viaja mucho. Usa las palabras entre .pdfStevie es un hombre ocupado. El viaja mucho. Usa las palabras entre .pdf
Stevie es un hombre ocupado. El viaja mucho. Usa las palabras entre .pdf
 

Recently uploaded

Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 

Recently uploaded (20)

Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 

Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf

  • 1. Step 1:You need to run the JAVA programs in sections 3.3 and 3.5 for selection sort and insertion sort. You need to attach the output results. Step 2: You need to modify these two programs, save them, submit them, and add some comments and explanations to them to sort the list elements from high to low value. The index should be IndexHighest instead IndexSmallest. Step3: Run the modified programs and print out the results and submit them. In the end, you need the running results for original JAVA programs (selection and insertion sort JAVA programs), the two modified programs to sort the values from high to low value for selection and insertion sorts, and the results for the modified programs. This program uses the selection sort algorithm to sort an array. The code has been modified to also calculate how many item comparisons are done. You can try running the program with different arrays to see how the total number of comparisons changes (or doesn't change). CODE 3.3 --- import java.util.Arrays; public class SelectionSortDemo { private static int selectionSort(int[] numbers) { // A variable to hold the number of item comparisons int comparisons = 0; for (int i = 0; i < numbers.length - 1; i++) { // Find index of smallest remaining element int indexSmallest = i; for (int j = i + 1; j < numbers.length; j++) { comparisons++; if (numbers[j] < numbers[indexSmallest]) { indexSmallest = j; } } // Swap numbers[i] and numbers[indexSmallest] int temp = numbers[i]; numbers[i] = numbers[indexSmallest]; numbers[indexSmallest] = temp; } return comparisons;
  • 2. } public static void main(String[] args) { // Create an array of numbers to sort int[] numbers = { 10, 2, 78, 4, 45, 32, 7, 11 }; // Display the contents of the array System.out.println("UNSORTED: " + Arrays.toString(numbers)); // Call the selectionSort method int comparisons = selectionSort(numbers); // Display the sorted contents of the array System.out.println("SORTED: " + Arrays.toString(numbers)); System.out.println("Total comparisons: " + comparisons); } } CODE 3.5 --- import java.util.Arrays; public class InsertionSortDemo { private static void insertionSort(int[] numbers) { for (int i = 1; i < numbers.length; i++) { int j = i; while (j > 0 && numbers[j] < numbers[j - 1]) { // Swap numbers[j] and numbers [j - 1] int temp = numbers[j]; numbers[j] = numbers[j - 1]; numbers[j - 1] = temp; j--; } } } public static void main(String[] args) { // Create an array of numbers to sort int[] numbers = { 10, 2, 78, 4, 45, 32, 7, 11 };
  • 3. // Display the contents of the array System.out.println("UNSORTED: " + Arrays.toString(numbers)); // Call the insertionSort method insertionSort(numbers); // Display the sorted contents of the array System.out.println("SORTED: " + Arrays.toString(numbers)); } }