Question

1. The bubble sort: a. Finds the smallest value and exchanges it with the first value,...

1. The bubble sort:

a. Finds the smallest value and exchanges it with the first value, then continues with the second value, third value, etc.

b. Is a system of comparisons and exchanges of adjacent elements to move the largest to the bottom of the selected group of values.

c. Is a system of comparisons and exchanges of elements that are non-adjacent. The gap is halved at each pass.

d. None of the above.

For the following array answer Q2

Element Values

1 15

2 23

3 17

4 12

5 65

2.Use the selection exchange method to show the first pass (chose one):

a. 12, 17, 23, 15, 65

b. 12, 23, 17, 15, 65

c. 15, 17, 12, 23, 65

d. 17, 15, 12, 23, 65

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

\color{red}\underline{Question\;1:}

Bubble \;sort \;is \;a \;system \;of \;comparisons \;and \;exchanges

\;of \;adjacent \;elements \;to \;move \;the \;largest \;to \;the \;bottom

\;of \;the \;selected \;group \;of \;values.\;

\color{blue}\underline{Answer:}

Option\;b

\color{red}\underline{Question\;2:}

\;Selection \;exchange \;method \;to \;show \;the \;first \;pass \;swaps \;15 \;and \;12.\;

So, \;array \;becomes \;12, \;23, \;17, \;15, \;65.\;

\color{blue}\underline{Answer:}

b. \;12, \;23, \;17, \;15, \;65\;

Add a comment
Know the answer?
Add Answer to:
1. The bubble sort: a. Finds the smallest value and exchanges it with the first value,...
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
  • Write in C++ (Bubble Sort) implement the bubble sort algorithm - another simple yet inefficient s...

    Write in C++ (Bubble Sort) implement the bubble sort algorithm - another simple yet inefficient sorting technique. its called bubble sort or sinking sort because smaller values gradually "bubble" their way to the top of the array like air bubbles rising in water, while the larger values sink to the bottom of the array. the technique uses nested loops to make several passes through the array. each pass compares successive pairs of elements. if a pair is in increasing order,...

  • Selection Sort is a common algorithm to sort the elements of an array. First, it scans...

    Selection Sort is a common algorithm to sort the elements of an array. First, it scans the elements of the array to find the smallest value and places it at index 0, thus creating a sorted “subarray” of size 1 that contains the smallest value. Then it scans the remaining unsorted values for the new smallest value and places it at index 1, creating a sorted subarray of size 2 that contains the 2 smallest values. It continues in this...

  • //bubble sort implementation// Fig 6.15 with simplified convention for the for loop. #define _CRT...

    //bubble sort implementation// Fig 6.15 with simplified convention for the for loop. #define _CRT_SECURE_NO_WARNINGS //for windows os only #include <stdio.h> #include <stdlib.h> // Fig. 6.15: fig06_15.c // Sorting an array's values into ascending order. #include <stdio.h> #define SIZE 10 // function main begins program execution int main(void) {    // initialize a    int a[SIZE] = { 2, 6, 4, 8, 10, 12, 89, 68, 45, 37 };    printf("Data items in original order");    // output original array    for (int i = 0;...

  • 11:10 PM No SIM mycourselink.lakeheadu.ca Modify the following bubble sort program to improve its performance I...

    11:10 PM No SIM mycourselink.lakeheadu.ca Modify the following bubble sort program to improve its performance I Fig. 6.15: fig06 15.c 2 Sorting an array's values into ascending order. Finclude <stdio.h> 4 #define SIZE 10 6 function main begins program execution 7 int main(void) 9 initialize a lo int a CSIZEJ 12, 6, 4, 8, 10, 12, 89, 68, 45, 37) 12 putsc Data items in original order output original array IS for (size t i 0; i SIZE ++i) a[i])...

  • You will create a dimple Bubble Sort program to sort a string of random integers or...

    You will create a dimple Bubble Sort program to sort a string of random integers or text. Please read instructions and examples Please show screenshot of proof that the code works in the C program ECE 216 Programming Project 2 The Bubble Sort You will create a simple Bubble Sort program to sort a string of random integers or text or whatever you can punch in from the keyboard. For the input data, you will input a string of single...

  • in C please 20. Change the bubble sort algorithm (Program 12-5) as follows: Use two directional...

    in C please 20. Change the bubble sort algorithm (Program 12-5) as follows: Use two directional bubbling in each pass. In the first bubbling, the smallest ele. ment is bubbled up; in the second bubbling, the largest element is bubbled I down. This sort is known as the shaker sort. 12-5 Bubble Sort (continued) // Statements // Each iteration is one sort pass for (int current = 0, sorted = 0; current <= last && !sorted; current++) for (int walker...

  • Selection Sort, which works by finding the smallest value in the unsorted part of the collection,...

    Selection Sort, which works by finding the smallest value in the unsorted part of the collection, and exchanging it with the next unsorted value until the collection is sorted: int selectionArray = {10, 23, 95, 48, 8}; Using the following format WITH NO SPACES in the entire line, type in what the array looks like for at the end of each pass. [        ,         ,         ,         ,         ]

  • 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...

  • Bubble Sort Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent...

    Bubble Sort Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order. Example: First Pass: ( 5 1 4 2 8 ) –> ( 1 5 4 2 8 ), Here, algorithm compares the first two elements, and swaps since 5 > 1. ( 1 5 4 2 8 ) –> ( 1 4 5 2 8 ), Swap since 5 > 4 ( 1 4 5 2 8...

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