
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
![Write a program that counts the number of basic steps needed for sorting an array of integer
numbers.
Implement the Selection Sort algorithm, and the Insertion Sort algorithm (and as challenge: the
BubbleSort algorithm).
Use the following methods:
public static void insertionSort(int array[]) and
public static void selectionSort(int array[]).
Challenge: public static void bubbleSort(int array[]).
Each method sorts the array given as parameter. It also counts and prints the number of
comparison steps and the number of swap operations needed. You may re-use your code from
the previous lab.
In the main method, test and compare each algorithm with the following inputs:
1. an array of random numbers as input (use the same array for both algorithms!)
(You can use the following numbers: 4, 2, 9, 6, 23, 12, 34, 0, 1, 76
or create your own, big array with 1,000 elements or more)
2. an array that is already sorted
3. an array that is sorted in reverse order.
Remember this:
• an array gets changed inside of a method. So, make a copy of the original array and use
the copy as argument for each sorting method. Each method needs its own copy.
Submit your program and your comparison results (as online text below) for input cases
1, 2 and 3.](https://content.bartleby.com/qna-images/question/36591f5f-f09d-438b-8d4f-237adb008b97/51a9a94b-e8f5-43f6-b112-ac0fc65d74cf/r0ys4ej_thumbnail.png)
Transcribed Image Text:Write a program that counts the number of basic steps needed for sorting an array of integer
numbers.
Implement the Selection Sort algorithm, and the Insertion Sort algorithm (and as challenge: the
BubbleSort algorithm).
Use the following methods:
public static void insertionSort(int array[]) and
public static void selectionSort(int array[]).
Challenge: public static void bubbleSort(int array[]).
Each method sorts the array given as parameter. It also counts and prints the number of
comparison steps and the number of swap operations needed. You may re-use your code from
the previous lab.
In the main method, test and compare each algorithm with the following inputs:
1. an array of random numbers as input (use the same array for both algorithms!)
(You can use the following numbers: 4, 2, 9, 6, 23, 12, 34, 0, 1, 76
or create your own, big array with 1,000 elements or more)
2. an array that is already sorted
3. an array that is sorted in reverse order.
Remember this:
• an array gets changed inside of a method. So, make a copy of the original array and use
the copy as argument for each sorting method. Each method needs its own copy.
Submit your program and your comparison results (as online text below) for input cases
1, 2 and 3.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 7 steps with 5 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- A basic iterator offers all the following operations except Group of answer choices 1. Except nothing, it can do all of the listed operations. 2. Get the item at the current iteration 3. Return an array of all items 4. Determine if there are more items 5. Go to the next itemarrow_forwardJavaarrow_forward1. Write a program that calls a method that takes a character array as a parameter (you can initialize an array in the main method) and returns the number of vowels in the array. Partial program is given below. public class CountVowels{ public static void main(String[] args){ char[] arr= System.out.print("There are "+vowels(arr)+" vowels in the array");arrow_forward
- Please help with this java problemarrow_forwardThe programming language used is Javaarrow_forwardWrite a Java method (do not write a class, only the method) with the following signature: Return type: void Parameters: 2D integer array Name: printDiagonal Implement the method code that will print out the values of the 2D array along the Diagonal from left to right. For example, if the array had the following values: 56 78 98 21 33 55 98 44 11 The method should print to the console: 56,33,11 The above 2D array example is only given for you to understand the problem Do not hard code the values in your solution or assume the array is the same as the given data. Your method should work for all 2D integer arrays.arrow_forward
- Javaarrow_forwardWrite a Java program that reads an integer N from the user and declares an integer array of size N. It then inputs N non-negative integers from the user into the array and do the following: 1. Finds and prints the minimum, maximum, sum, and average of the numbers. 2. Displays array data as a histogram – graphically by plotting each numeric value as a bar of asterisks (+) as shown in the example diagram. This is somehow similar to Lab11 Sample output Enter the size of array: 9 Enter 9 integer values: 10 19 5 14 Minimum = Maximum = 19 = 68 = 7.55 Sum Average ========== Histogram: ======= Element Ua lue 10 19 Histogran T T T Arial v T = ABC 3 (12pt) II Comarrow_forwardJavaarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education