Question

JAVA Programming Add debug statements to the Java code in Question 1 to show the list...

JAVA Programming

Add debug statements to the Java code in Question 1 to show the list values after each completing cycle of the sorting process. Run your program with an array of size 10 {27,28,9,6,15,18,33,30,-4,-1} and complete the following tables. Add rows to the tables if you need them.

Cycle

Bubble Sort

0

27

28

9

6

15

18

33

30

-4

-1

1

27

9

6

15

18

28

30

-4

-1

33

2

3

4

5

6

7

8

9

30

-4

-1

1

2

3

4

5

6

7

0 0
Add a comment Improve this question Transcribed image text
Answer #1

cycle Bubble Sort

0   27 28 9 6 15 18 33 30 -4 -1
1   27 9 6 15 18 28 30 -4 -1 33
2   9 6 15 18 27 28 -4 -1 30 33
3   6 9 15 18 27 -4 -1 28 30 33
4   6 9 15 18 -4 -1 27 28 30 33
5   6 9 15 -4 -1 18 27 28 30 33
6   6 9 -4 -1 15 18 27 28 30 33
7   6 -4 -1 9 15 18 27 28 30 33
8   -4 -1 6 9 15 18 27 28 30 33
9   -4 -1 6 9 15 18 27 28 30 33
10   -4 -1 6 9 15 18 27 28 30 33

Add a comment
Know the answer?
Add Answer to:
JAVA Programming Add debug statements to the Java code in Question 1 to show the list...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • . Run your program with an array of size 10 {27,28,9,6,15,18,33,30,-4,-1} and complete the following tables....

    . Run your program with an array of size 10 {27,28,9,6,15,18,33,30,-4,-1} and complete the following tables. Add rows to the tables if you need them. Cycle Selection Sort 0 27 28 9 6 15 18 33 30 -4 -1 1 2 3 4 5 6 7

  • 2) Sorting (a) (5 pts) In a Merge Sort of 8 elements, the Merge function gets...

    2) Sorting (a) (5 pts) In a Merge Sort of 8 elements, the Merge function gets called 7 times. Consider a Merge Sort being executed on the array shown below. What does the array look like right AFTER the sixth call to the Merge function completes? نرا index value 0 40 2 12 4 11 5 99 6 31 7 16 27 18 0 1 2 زيا 4 5 6 7 Index Value (b) (5 pts) Consider sorting the array...

  • in Java programming Using IF statement, write a program that prints multiplication table for 1-10. Sample...

    in Java programming Using IF statement, write a program that prints multiplication table for 1-10. Sample Program Output. 1     2     3     4     5     6     7     8     9     10       1     1     2     3     4     5     6     7     8     9     10       2     2     4     6     8     10    12    14    16    18    20       3     3     6     9     12    15    18    21    24    27    30       4     4     8     12    16    20    24    28    32    36    40       5     5     10   ...

  • Written in Java Your job is to produce a program that sorts a list of numbers...

    Written in Java Your job is to produce a program that sorts a list of numbers in ascending order. Your program will need to read-in, from a file, a list of integers – at which point you should allow the user an option to choose to sort the numbers in ascending order via one of the three Sorting algorithms that we have explored. Your program should use the concept of Polymorphism to provide this sorting feature. As output, you will...

  • Chapter 7 Exercise 18, Introduction to Java Programming, Tenth Edition Y. Daniel Liang. Please write your...

    Chapter 7 Exercise 18, Introduction to Java Programming, Tenth Edition Y. Daniel Liang. Please write your own code. 7.18 (Bubble sort) Write a sort method that uses the bubble-sort algorithm. The bubblesort algorithm makes several passes through the array. On each pass, successive neighboring pairs are compared. If a pair is not in order, its values are swapped; otherwise, the values remain unchanged. The technique is called a bubble sort or sinking sort because the smaller values gradually “bubble” their...

  • The answer need to write in C programming. QUESTION 2 Write a program using array to...

    The answer need to write in C programming. QUESTION 2 Write a program using array to generate a multiplication table based on the user's input. For example if user enter 5 as input then a multiply table for 1 to 5 is printed as output as shown in Figure Q2. There are three main steps in this program which are: Print rows (a) (b) Print columns Print multiplication of data inside table (c) Select C:\example1 \bin\Debuglexample 1.exe enter the value...

  • C++ Sorting and Searching 1. Mark the following statements as true or false. a. A sequential...

    C++ Sorting and Searching 1. Mark the following statements as true or false. a. A sequential search of a list assumes that the list elements are sorted in ascending order. b. A binary search of a list assumes that the list is sorted. 2. Consider the following list: 63 45 32 98 46 57 28 100 Using a sequential search, how many comparisons are required to determine whether the following items are in the list or not? (Recall that comparisons...

  • Java We did in lecture, and explain your answer briefly. Problem 4: Sorting practice 14 points;...

    Java We did in lecture, and explain your answer briefly. Problem 4: Sorting practice 14 points; 2 points for each part individual-only Important: When answering these questions, make sure to apply the versions of these algorithms that were discussed in lecture. The Java code for each algorithm can be found in our Sort class. Given the following array: {14, 7, 27, 13, 24, 20, 10, 33 1. If the array were sorted using selection sort, what would the array look...

  • Please come up with an array of 9 random integers then sort the array. Show the...

    Please come up with an array of 9 random integers then sort the array. Show the contents of the array each time a sorting algorithm changes it while sorting the array into ascending order. The 6 sorting algorithm we are using are: 1. Selection Sort 3 points 2. Insertion Sort 3 points 3. Shell Sort 6 points 4. Bubble Sort 3 points 5. Merge Sort 10 points 6. Quick Sort 10 points It is OK to do this assignment on...

  • Programming language: Java Home Work No.2 due 09.11.2019 either ascending or descending SORTING: An array is...

    Programming language: Java Home Work No.2 due 09.11.2019 either ascending or descending SORTING: An array is said to be ordered if its values order. In an ascending ordered array, the value of each element is less than or equal to the value of the next element. That is, [each element] <= [next element]. A sort is an algorithm for ordering an array. Of the many different techniques for sorting an array we discuss the bubble sort It requires the swapping...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT