SlideShare a Scribd company logo
1 of 4
Download to read offline
I am asked to provide the testing cases for the following code, I would appreciate the help!
Thank you!
/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;
public class Sorting {
private static int n;
public static void main(String[] args) {
int[] arr = readFile("Data.txt");
// Bubble sort
long startTime = System.nanoTime();
bubbleSort(arr);
long endTime = System.nanoTime();
System.out.println("Bubble sort time: " + (endTime - startTime) + " nanoseconds");
// Selection sort
startTime = System.nanoTime();
selectionSort(arr);
endTime = System.nanoTime();
System.out.println("Selection sort time: " + (endTime - startTime) + " nanoseconds");
// Insertion sort
startTime = System.nanoTime();
insertionSort(arr);
endTime = System.nanoTime();
System.out.println("Insertion sort time: " + (endTime - startTime) + " nanoseconds");
// Merge sort
startTime = System.nanoTime();
mergeSort(arr);
endTime = System.nanoTime();
System.out.println("Merge sort time: " + (endTime - startTime) + " nanoseconds");
// Quick sort
startTime = System.nanoTime();
quickSortTime = quickSort(arr, 0, arr.length-1);
endTime = System.nanoTime();
System.out.println("Quick sort time: " + (endTime - startTime) + " nanoseconds");
}
private static int[] readFile(String filename) {
int[] arr = null;
try {
File file = new File(filename);
Scanner scanner = new Scanner(file);
n = scanner.nextInt();
arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = scanner.nextInt();
}
scanner.close();
} catch (FileNotFoundException e) {
System.out.println("File not found: " + filename);
System.exit(0);
}
return arr;
}
private static void bubbleSort(int[] arr) {
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}
private static void selectionSort(int[] arr) {
for (int i = 0; i < n - 1; i++) {
int minIndex = i;
for (int j = i + 1; j < n; j++) {
if (arr[j] < arr[minIndex]) {
minIndex = j;
}
}
int temp = arr[i];
arr[i] = arr[minIndex];
arr[minIndex] = temp;
}
}
private static void insertionSort(int[] arr) {
for (int i = 1; i < n; i++) {
int key = arr[i];
int j = i - 1;
while (j >= 0 && arr[j] > key) {
arr[j + 1] = arr[j];
j--;
}
arr[j + 1] = key;
}
}
private static void mergeSortHelper(int[] arr, int left, int right) {
if (left < right) {
int mid = (left + right) / 2;
mergeSortHelper(arr, left, mid);
mergeSortHelper(arr, mid+1, right);
merge(arr, left, mid, right);
}
}
private static void merge(int[] arr, int left, int mid, int right) {
int[] temp = new int[right-left+1];
int i = left, j = mid+1, k = 0;
while (i <= mid && j <= right) {
if (arr[i] <= arr[j]) {
temp[k++] = arr[i++];
} else {
temp[k++] = arr[j++];
}
}
while (i <= mid) {
temp[k++] = arr[i++];
}
while (j <= right) {
temp[k++] = arr[j++];
}
for (i = left, k = 0; i <= right; i++, k++) {
arr[i] = temp[k];
}
}
public static long mergeSort(int[] arr) {
long startTime = System.nanoTime();
mergeSortHelper(arr, 0, arr.length-1);
long endTime = System.nanoTime();
return endTime - startTime;
}
private static long quickSort(int[] arr, int low, int high) {
long startTime = System.nanoTime();
if (low < high) {
int pivotIndex = partition(arr, low, high);
quickSort(arr, low, pivotIndex - 1);
quickSort(arr, pivotIndex + 1, high);
}
long endTime = System.nanoTime();
return endTime - startTime;
}
private static int partition(int[] arr, int low, int high) {
int pivot = arr[high];
int i = low - 1;
for (int j = low; j < high; j++) {
if (arr[j] < pivot) {
i++;
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
int temp = arr[i+1];
arr[i+1] = arr[high];
arr[high] = temp;
return i+1;
}
}
Testing strategy. Describe the test cases that you include for testing your five different algorithms.
Enumerate your test cases, e.g., unordered data, sorted data, duplicates, reverse order data.

More Related Content

Similar to I am asked to provide the testing cases for the following co.pdf

(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docxdorisc7
 
java-introduction.pdf
java-introduction.pdfjava-introduction.pdf
java-introduction.pdfDngTin307322
 
DS LAB RECORD.docx
DS LAB RECORD.docxDS LAB RECORD.docx
DS LAB RECORD.docxdavinci54
 
Write a program (any language) to randomly generate the following se.pdf
Write a program (any language) to randomly generate the following se.pdfWrite a program (any language) to randomly generate the following se.pdf
Write a program (any language) to randomly generate the following se.pdfarchanaemporium
 
What is the proper pseudocode for the following java codeimport j.pdf
What is the proper pseudocode for the following java codeimport j.pdfWhat is the proper pseudocode for the following java codeimport j.pdf
What is the proper pseudocode for the following java codeimport j.pdfartimagein
 
write a program that given a list of 20 integers, sorts them accordi.pdf
write a program that given a list of 20 integers, sorts them accordi.pdfwrite a program that given a list of 20 integers, sorts them accordi.pdf
write a program that given a list of 20 integers, sorts them accordi.pdfarmcomputers
 
Sorting programs
Sorting programsSorting programs
Sorting programsVarun Garg
 
TilePUzzle class Anderson, Franceschi public class TilePu.docx
 TilePUzzle class Anderson, Franceschi public class TilePu.docx TilePUzzle class Anderson, Franceschi public class TilePu.docx
TilePUzzle class Anderson, Franceschi public class TilePu.docxKomlin1
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdfakkhan101
 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semesterDOSONKA Group
 
An introduction to Google test framework
An introduction to Google test frameworkAn introduction to Google test framework
An introduction to Google test frameworkAbner Chih Yi Huang
 
COA_remaining_lab_works_077BCT033.pdf
COA_remaining_lab_works_077BCT033.pdfCOA_remaining_lab_works_077BCT033.pdf
COA_remaining_lab_works_077BCT033.pdfJavedAnsari236392
 
VTU DSA Lab Manual
VTU DSA Lab ManualVTU DSA Lab Manual
VTU DSA Lab ManualAkhilaaReddy
 
What will be the output from the following code if the user enters 4.pdf
What will be the output from the following code if the user enters 4.pdfWhat will be the output from the following code if the user enters 4.pdf
What will be the output from the following code if the user enters 4.pdfanavmuthu
 
Here is the code- I can't get it to work- I need a function that finds.pdf
Here is the code- I can't get it to work- I need a function that finds.pdfHere is the code- I can't get it to work- I need a function that finds.pdf
Here is the code- I can't get it to work- I need a function that finds.pdfdoshirajesh75
 
C346_PA3_W12srccommonBaseThread.javaC346_PA3_W12srccommonB.docx
C346_PA3_W12srccommonBaseThread.javaC346_PA3_W12srccommonB.docxC346_PA3_W12srccommonBaseThread.javaC346_PA3_W12srccommonB.docx
C346_PA3_W12srccommonBaseThread.javaC346_PA3_W12srccommonB.docxhumphrieskalyn
 
QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory archana singh
 
Please read the comment ins codeExpressionTree.java-------------.pdf
Please read the comment ins codeExpressionTree.java-------------.pdfPlease read the comment ins codeExpressionTree.java-------------.pdf
Please read the comment ins codeExpressionTree.java-------------.pdfshanki7
 

Similar to I am asked to provide the testing cases for the following co.pdf (20)

(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
 
Java
JavaJava
Java
 
java-introduction.pdf
java-introduction.pdfjava-introduction.pdf
java-introduction.pdf
 
DS LAB RECORD.docx
DS LAB RECORD.docxDS LAB RECORD.docx
DS LAB RECORD.docx
 
Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6
 
Write a program (any language) to randomly generate the following se.pdf
Write a program (any language) to randomly generate the following se.pdfWrite a program (any language) to randomly generate the following se.pdf
Write a program (any language) to randomly generate the following se.pdf
 
What is the proper pseudocode for the following java codeimport j.pdf
What is the proper pseudocode for the following java codeimport j.pdfWhat is the proper pseudocode for the following java codeimport j.pdf
What is the proper pseudocode for the following java codeimport j.pdf
 
write a program that given a list of 20 integers, sorts them accordi.pdf
write a program that given a list of 20 integers, sorts them accordi.pdfwrite a program that given a list of 20 integers, sorts them accordi.pdf
write a program that given a list of 20 integers, sorts them accordi.pdf
 
Sorting programs
Sorting programsSorting programs
Sorting programs
 
TilePUzzle class Anderson, Franceschi public class TilePu.docx
 TilePUzzle class Anderson, Franceschi public class TilePu.docx TilePUzzle class Anderson, Franceschi public class TilePu.docx
TilePUzzle class Anderson, Franceschi public class TilePu.docx
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdf
 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semester
 
An introduction to Google test framework
An introduction to Google test frameworkAn introduction to Google test framework
An introduction to Google test framework
 
COA_remaining_lab_works_077BCT033.pdf
COA_remaining_lab_works_077BCT033.pdfCOA_remaining_lab_works_077BCT033.pdf
COA_remaining_lab_works_077BCT033.pdf
 
VTU DSA Lab Manual
VTU DSA Lab ManualVTU DSA Lab Manual
VTU DSA Lab Manual
 
What will be the output from the following code if the user enters 4.pdf
What will be the output from the following code if the user enters 4.pdfWhat will be the output from the following code if the user enters 4.pdf
What will be the output from the following code if the user enters 4.pdf
 
Here is the code- I can't get it to work- I need a function that finds.pdf
Here is the code- I can't get it to work- I need a function that finds.pdfHere is the code- I can't get it to work- I need a function that finds.pdf
Here is the code- I can't get it to work- I need a function that finds.pdf
 
C346_PA3_W12srccommonBaseThread.javaC346_PA3_W12srccommonB.docx
C346_PA3_W12srccommonBaseThread.javaC346_PA3_W12srccommonB.docxC346_PA3_W12srccommonBaseThread.javaC346_PA3_W12srccommonB.docx
C346_PA3_W12srccommonBaseThread.javaC346_PA3_W12srccommonB.docx
 
QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory
 
Please read the comment ins codeExpressionTree.java-------------.pdf
Please read the comment ins codeExpressionTree.java-------------.pdfPlease read the comment ins codeExpressionTree.java-------------.pdf
Please read the comment ins codeExpressionTree.java-------------.pdf
 

More from acecomputertcr

Review and analyze the following RFP below at httpswwwe.pdf
Review and analyze the following RFP below at httpswwwe.pdfReview and analyze the following RFP below at httpswwwe.pdf
Review and analyze the following RFP below at httpswwwe.pdfacecomputertcr
 
What is the worst choice of split ratio Training set Test .pdf
What is the worst choice of split ratio Training set  Test .pdfWhat is the worst choice of split ratio Training set  Test .pdf
What is the worst choice of split ratio Training set Test .pdfacecomputertcr
 
VAKA 32 Ufuk Danmanlk Patti Smith Horizon Consultingin .pdf
VAKA 32  Ufuk Danmanlk  Patti Smith Horizon Consultingin .pdfVAKA 32  Ufuk Danmanlk  Patti Smith Horizon Consultingin .pdf
VAKA 32 Ufuk Danmanlk Patti Smith Horizon Consultingin .pdfacecomputertcr
 
Turner Syndrome occurs when an individual inherits one X chr.pdf
Turner Syndrome occurs when an individual inherits one X chr.pdfTurner Syndrome occurs when an individual inherits one X chr.pdf
Turner Syndrome occurs when an individual inherits one X chr.pdfacecomputertcr
 
The random variable M has PMF PMmc41m0m0123else .pdf
The random variable M has PMF PMmc41m0m0123else .pdfThe random variable M has PMF PMmc41m0m0123else .pdf
The random variable M has PMF PMmc41m0m0123else .pdfacecomputertcr
 
Subject S1 has the clearance Secret C0C1C2C3 Which .pdf
Subject S1 has the clearance Secret C0C1C2C3 Which .pdfSubject S1 has the clearance Secret C0C1C2C3 Which .pdf
Subject S1 has the clearance Secret C0C1C2C3 Which .pdfacecomputertcr
 
The following utility function represents Roses preference .pdf
The following utility function represents Roses preference .pdfThe following utility function represents Roses preference .pdf
The following utility function represents Roses preference .pdfacecomputertcr
 
Nesmith Corporations outstanding bonds have a 1000 par va.pdf
Nesmith Corporations outstanding bonds have a 1000 par va.pdfNesmith Corporations outstanding bonds have a 1000 par va.pdf
Nesmith Corporations outstanding bonds have a 1000 par va.pdfacecomputertcr
 
Given the table below assuming that there are only 9 resour.pdf
Given the table below assuming that there are only 9 resour.pdfGiven the table below assuming that there are only 9 resour.pdf
Given the table below assuming that there are only 9 resour.pdfacecomputertcr
 
Practice Questions PV and FV Formulae YOU MAY USE A FIN.pdf
Practice Questions PV and FV   Formulae   YOU MAY USE A FIN.pdfPractice Questions PV and FV   Formulae   YOU MAY USE A FIN.pdf
Practice Questions PV and FV Formulae YOU MAY USE A FIN.pdfacecomputertcr
 
please explain and list every step using commands from ste.pdf
please explain and list every step using commands from ste.pdfplease explain and list every step using commands from ste.pdf
please explain and list every step using commands from ste.pdfacecomputertcr
 
Each student is required to post a response to problem CP12.pdf
Each student is required to post a response to problem CP12.pdfEach student is required to post a response to problem CP12.pdf
Each student is required to post a response to problem CP12.pdfacecomputertcr
 
During the year the following transactions occurred Feb 1.pdf
During the year the following transactions occurred Feb 1.pdfDuring the year the following transactions occurred Feb 1.pdf
During the year the following transactions occurred Feb 1.pdfacecomputertcr
 
Oilpartz Ltdnin sahibi Dave McDonald ceketini kard ve masa.pdf
Oilpartz Ltdnin sahibi Dave McDonald ceketini kard ve masa.pdfOilpartz Ltdnin sahibi Dave McDonald ceketini kard ve masa.pdf
Oilpartz Ltdnin sahibi Dave McDonald ceketini kard ve masa.pdfacecomputertcr
 
Match Perverse incentives that encourage risky behavior by .pdf
Match Perverse incentives that encourage risky behavior by .pdfMatch Perverse incentives that encourage risky behavior by .pdf
Match Perverse incentives that encourage risky behavior by .pdfacecomputertcr
 
Let E and F be two events in a sample space Which of the fo.pdf
Let E and F be two events in a sample space Which of the fo.pdfLet E and F be two events in a sample space Which of the fo.pdf
Let E and F be two events in a sample space Which of the fo.pdfacecomputertcr
 
Escenarios Escenario bsico 4 Mark y Sue Malone Notas de la.pdf
Escenarios Escenario bsico 4 Mark y Sue Malone Notas de la.pdfEscenarios Escenario bsico 4 Mark y Sue Malone Notas de la.pdf
Escenarios Escenario bsico 4 Mark y Sue Malone Notas de la.pdfacecomputertcr
 
Find the mixed strategy Nash equilibrium of this game In it.pdf
Find the mixed strategy Nash equilibrium of this game In it.pdfFind the mixed strategy Nash equilibrium of this game In it.pdf
Find the mixed strategy Nash equilibrium of this game In it.pdfacecomputertcr
 
In business research the relationship between the researche.pdf
In business research the relationship between the researche.pdfIn business research the relationship between the researche.pdf
In business research the relationship between the researche.pdfacecomputertcr
 
Helen invested 100 shares of a Japanese corporation at the p.pdf
Helen invested 100 shares of a Japanese corporation at the p.pdfHelen invested 100 shares of a Japanese corporation at the p.pdf
Helen invested 100 shares of a Japanese corporation at the p.pdfacecomputertcr
 

More from acecomputertcr (20)

Review and analyze the following RFP below at httpswwwe.pdf
Review and analyze the following RFP below at httpswwwe.pdfReview and analyze the following RFP below at httpswwwe.pdf
Review and analyze the following RFP below at httpswwwe.pdf
 
What is the worst choice of split ratio Training set Test .pdf
What is the worst choice of split ratio Training set  Test .pdfWhat is the worst choice of split ratio Training set  Test .pdf
What is the worst choice of split ratio Training set Test .pdf
 
VAKA 32 Ufuk Danmanlk Patti Smith Horizon Consultingin .pdf
VAKA 32  Ufuk Danmanlk  Patti Smith Horizon Consultingin .pdfVAKA 32  Ufuk Danmanlk  Patti Smith Horizon Consultingin .pdf
VAKA 32 Ufuk Danmanlk Patti Smith Horizon Consultingin .pdf
 
Turner Syndrome occurs when an individual inherits one X chr.pdf
Turner Syndrome occurs when an individual inherits one X chr.pdfTurner Syndrome occurs when an individual inherits one X chr.pdf
Turner Syndrome occurs when an individual inherits one X chr.pdf
 
The random variable M has PMF PMmc41m0m0123else .pdf
The random variable M has PMF PMmc41m0m0123else .pdfThe random variable M has PMF PMmc41m0m0123else .pdf
The random variable M has PMF PMmc41m0m0123else .pdf
 
Subject S1 has the clearance Secret C0C1C2C3 Which .pdf
Subject S1 has the clearance Secret C0C1C2C3 Which .pdfSubject S1 has the clearance Secret C0C1C2C3 Which .pdf
Subject S1 has the clearance Secret C0C1C2C3 Which .pdf
 
The following utility function represents Roses preference .pdf
The following utility function represents Roses preference .pdfThe following utility function represents Roses preference .pdf
The following utility function represents Roses preference .pdf
 
Nesmith Corporations outstanding bonds have a 1000 par va.pdf
Nesmith Corporations outstanding bonds have a 1000 par va.pdfNesmith Corporations outstanding bonds have a 1000 par va.pdf
Nesmith Corporations outstanding bonds have a 1000 par va.pdf
 
Given the table below assuming that there are only 9 resour.pdf
Given the table below assuming that there are only 9 resour.pdfGiven the table below assuming that there are only 9 resour.pdf
Given the table below assuming that there are only 9 resour.pdf
 
Practice Questions PV and FV Formulae YOU MAY USE A FIN.pdf
Practice Questions PV and FV   Formulae   YOU MAY USE A FIN.pdfPractice Questions PV and FV   Formulae   YOU MAY USE A FIN.pdf
Practice Questions PV and FV Formulae YOU MAY USE A FIN.pdf
 
please explain and list every step using commands from ste.pdf
please explain and list every step using commands from ste.pdfplease explain and list every step using commands from ste.pdf
please explain and list every step using commands from ste.pdf
 
Each student is required to post a response to problem CP12.pdf
Each student is required to post a response to problem CP12.pdfEach student is required to post a response to problem CP12.pdf
Each student is required to post a response to problem CP12.pdf
 
During the year the following transactions occurred Feb 1.pdf
During the year the following transactions occurred Feb 1.pdfDuring the year the following transactions occurred Feb 1.pdf
During the year the following transactions occurred Feb 1.pdf
 
Oilpartz Ltdnin sahibi Dave McDonald ceketini kard ve masa.pdf
Oilpartz Ltdnin sahibi Dave McDonald ceketini kard ve masa.pdfOilpartz Ltdnin sahibi Dave McDonald ceketini kard ve masa.pdf
Oilpartz Ltdnin sahibi Dave McDonald ceketini kard ve masa.pdf
 
Match Perverse incentives that encourage risky behavior by .pdf
Match Perverse incentives that encourage risky behavior by .pdfMatch Perverse incentives that encourage risky behavior by .pdf
Match Perverse incentives that encourage risky behavior by .pdf
 
Let E and F be two events in a sample space Which of the fo.pdf
Let E and F be two events in a sample space Which of the fo.pdfLet E and F be two events in a sample space Which of the fo.pdf
Let E and F be two events in a sample space Which of the fo.pdf
 
Escenarios Escenario bsico 4 Mark y Sue Malone Notas de la.pdf
Escenarios Escenario bsico 4 Mark y Sue Malone Notas de la.pdfEscenarios Escenario bsico 4 Mark y Sue Malone Notas de la.pdf
Escenarios Escenario bsico 4 Mark y Sue Malone Notas de la.pdf
 
Find the mixed strategy Nash equilibrium of this game In it.pdf
Find the mixed strategy Nash equilibrium of this game In it.pdfFind the mixed strategy Nash equilibrium of this game In it.pdf
Find the mixed strategy Nash equilibrium of this game In it.pdf
 
In business research the relationship between the researche.pdf
In business research the relationship between the researche.pdfIn business research the relationship between the researche.pdf
In business research the relationship between the researche.pdf
 
Helen invested 100 shares of a Japanese corporation at the p.pdf
Helen invested 100 shares of a Japanese corporation at the p.pdfHelen invested 100 shares of a Japanese corporation at the p.pdf
Helen invested 100 shares of a Japanese corporation at the p.pdf
 

Recently uploaded

Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactisticshameyhk98
 
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
 
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
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
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
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationNeilDeclaro1
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
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
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 

Recently uploaded (20)

Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
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
 
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...
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
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
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
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)
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 

I am asked to provide the testing cases for the following co.pdf

  • 1. I am asked to provide the testing cases for the following code, I would appreciate the help! Thank you! /-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/ import java.io.File; import java.io.FileNotFoundException; import java.util.Arrays; import java.util.Scanner; public class Sorting { private static int n; public static void main(String[] args) { int[] arr = readFile("Data.txt"); // Bubble sort long startTime = System.nanoTime(); bubbleSort(arr); long endTime = System.nanoTime(); System.out.println("Bubble sort time: " + (endTime - startTime) + " nanoseconds"); // Selection sort startTime = System.nanoTime(); selectionSort(arr); endTime = System.nanoTime(); System.out.println("Selection sort time: " + (endTime - startTime) + " nanoseconds"); // Insertion sort startTime = System.nanoTime(); insertionSort(arr); endTime = System.nanoTime(); System.out.println("Insertion sort time: " + (endTime - startTime) + " nanoseconds"); // Merge sort startTime = System.nanoTime(); mergeSort(arr); endTime = System.nanoTime(); System.out.println("Merge sort time: " + (endTime - startTime) + " nanoseconds"); // Quick sort startTime = System.nanoTime(); quickSortTime = quickSort(arr, 0, arr.length-1); endTime = System.nanoTime(); System.out.println("Quick sort time: " + (endTime - startTime) + " nanoseconds"); } private static int[] readFile(String filename) { int[] arr = null; try { File file = new File(filename); Scanner scanner = new Scanner(file);
  • 2. n = scanner.nextInt(); arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = scanner.nextInt(); } scanner.close(); } catch (FileNotFoundException e) { System.out.println("File not found: " + filename); System.exit(0); } return arr; } private static void bubbleSort(int[] arr) { for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - i - 1; j++) { if (arr[j] > arr[j + 1]) { int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } } } } private static void selectionSort(int[] arr) { for (int i = 0; i < n - 1; i++) { int minIndex = i; for (int j = i + 1; j < n; j++) { if (arr[j] < arr[minIndex]) { minIndex = j; } } int temp = arr[i]; arr[i] = arr[minIndex]; arr[minIndex] = temp; } } private static void insertionSort(int[] arr) { for (int i = 1; i < n; i++) { int key = arr[i]; int j = i - 1; while (j >= 0 && arr[j] > key) { arr[j + 1] = arr[j];
  • 3. j--; } arr[j + 1] = key; } } private static void mergeSortHelper(int[] arr, int left, int right) { if (left < right) { int mid = (left + right) / 2; mergeSortHelper(arr, left, mid); mergeSortHelper(arr, mid+1, right); merge(arr, left, mid, right); } } private static void merge(int[] arr, int left, int mid, int right) { int[] temp = new int[right-left+1]; int i = left, j = mid+1, k = 0; while (i <= mid && j <= right) { if (arr[i] <= arr[j]) { temp[k++] = arr[i++]; } else { temp[k++] = arr[j++]; } } while (i <= mid) { temp[k++] = arr[i++]; } while (j <= right) { temp[k++] = arr[j++]; } for (i = left, k = 0; i <= right; i++, k++) { arr[i] = temp[k]; } } public static long mergeSort(int[] arr) { long startTime = System.nanoTime(); mergeSortHelper(arr, 0, arr.length-1); long endTime = System.nanoTime(); return endTime - startTime; } private static long quickSort(int[] arr, int low, int high) { long startTime = System.nanoTime(); if (low < high) {
  • 4. int pivotIndex = partition(arr, low, high); quickSort(arr, low, pivotIndex - 1); quickSort(arr, pivotIndex + 1, high); } long endTime = System.nanoTime(); return endTime - startTime; } private static int partition(int[] arr, int low, int high) { int pivot = arr[high]; int i = low - 1; for (int j = low; j < high; j++) { if (arr[j] < pivot) { i++; int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } int temp = arr[i+1]; arr[i+1] = arr[high]; arr[high] = temp; return i+1; } } Testing strategy. Describe the test cases that you include for testing your five different algorithms. Enumerate your test cases, e.g., unordered data, sorted data, duplicates, reverse order data.