Sort 85 14 26 according to the bubbling algorithm and describe the sorting process

Updated on technology 2024-05-10
11 answers
  1. Anonymous users2024-02-10

    Bubbling sorting. A set of integers is arranged from smallest to largest and stored back in the original storage area.

    Algorithm: Compare the two adjacent numbers, and adjust the small one to the front.

    Data structure: Variable n: The number of numbers in this group, entered from the keyboard.

    One-dimensional array a: Hold the n numbers (a[1],...a[n-1],a[n]) cyclic variables i=1, j=1

    Block diagram: j = 1, as long as the number of external loops j is not to n-1 times.

    i=1, as long as the number of internal loops i is not completed.

    y a[i]>a[i+1] n

    a[i] a[i+1]

    i=i+1j=j+1

    Output ordered a[1]--a[n].

    main( )

    int a[ 100] ,n , i , j , t ;

    scanf(“%d”, n) ;

    for( i=1 ; i<=n ; i++)scanf(“%d”, a[i])

    for( j=1; j<=n-1; j++)for( i=1 ; i<=n-j ;i++) small ones pop up.

    if (a[i]>a[i+1]) sinks the most.

    for( i=1 ; i<=n ; i++)printf(“%d ”,a[i] )

  2. Anonymous users2024-02-09

    #include

    void main()

    int i,t,j,a[10];

    for(i=0;i<10;i++)

    scanf("%d",&a[i]);Enter the number you want to sort.

    printf("");

    for(j=0;j<=2;j++) to achieve 2 comparisons.

    for(i=0;i<2-j;i++) 2-j comparisons per trip.

    if(a[i]>a[i+1]) Comparison of two adjacent numbers.

    t=a[i];

    a[i]=a[i+1];

    a[i+1]=t;

    for(i=0;i<3;i++)

    printf("%4d",a[i]);Outputs an ordered array.

    printf("");

  3. Anonymous users2024-02-08

    Start from the beginning, compare each number with the number after it, and if it is greater or less, the position is swapped.

  4. Anonymous users2024-02-07

    Knowing the sequence {8,7,4,6,5,2,3,1,9}, the process of sorting the sequence from small to large by the bubbling sorting method is:

  5. Anonymous users2024-02-06

    874652319 746523189 465231789 462315789 423156789 231456789 213456789 123456789 (this is from small to large, you can also go from large to small).

  6. Anonymous users2024-02-05

    The (130,20,98,15,67,3) macro bureaus were sorted by the bubble sorting method, and the result of the second land chaos was ().

    Correct answers: 3, 15, 130, 20, 98, 67

  7. Anonymous users2024-02-04

    Summary. Hello dear, 10The integers 10, 25, 2, 61, 23, 4, 15, 7, 29, and 34 were arranged in descending order by bubbling sorting algorithm. First of all, we have to be clear about the idea of bubbling sorting:

    Each time you sort, compare two numbers, and put the larger number behind, so that you can sort nine times. As for how many times each sort is compared, you can summarize it by giving three or four examples. It's worth noting that there are two loop controls, one is the outer one that controls each sort, and the inner layer controls the number of comparisons in each sort.

    Knowing this, the bubbling sort can be remembered very deeply. When you can't think of a solution to use the algorithm rules that have been summarized by your predecessors, you must deeply understand the idea and meaning of the algorithm, and in addition, you must operate it with your hands, so that you can use it for yourself next time.

    10.The integers 10, 25, 2, 61, 23, 4, 15, 7, 29, and 34 are arranged in descending order from the smallest to the largest.

    Hello dear, 10The integers 10, 25, 2, 61, 23, 4, 15, 7, 29, and 34 are arranged vertically from smallest to largest by bubbling sorting algorithm. First of all, we have to be clear about the idea of bubbling sorting: each time you sort, compare two numbers, and put the larger number behind, so that you can arrange nine times.

    As for how many times each sort is compared, you can summarize it by giving three or four examples. It is worth noting that there are two loop controls, one is the outer control for each sort, and the inner layer controls the number of times the ratio is compared in each sort. Knowing this, the bubbling sort can be remembered very deeply.

    When you can't think of a solution to use the algorithm rules that have been summarized by your predecessors, you must deeply understand the idea and meaning of the algorithm, and in addition, you must operate Yu Bifeng with your hands, so that you can use it for yourself next time.

  8. Anonymous users2024-02-03

    Summary. First of all, the basic idea of the bubble sorting algorithm is to do this by constantly comparing adjacent elements, and if the elements in front are greater than the elements in behind, then swapping their positions until the entire sequence is sorted. Now, let's sort 5, 16, 8, 32, 90 using bubbling sorting:

    1.First round comparison: compare 5 and 16, 8 and 16, 16 and 32, 32 and 90 to get sequences 5, 8, 16, 32, second round comparison:

    Compare 5 and 8, 8 and 16, 16 and 32 to get sequences 5, 8, 16, 32, 3rd round comparison: compare 5 and 8, 8 and 16 to get sequences 5, 8, 16, 32, 4th round comparison: compare 5 and 8 to get sequences 5, 8, 16, 32, 90.

    In the end, we get the sorted sequences: 5, 8, 16, 32, 90.

    Use bubbling sort to sort 5, 16, 8, 32, 90.

    First of all, the basic idea of the bubble sorting algorithm is to do this by constantly comparing adjacent elements, and if the elements in front are greater than the elements in behind, then swapping their positions until the entire sequence is sorted. Now, let's sort 5, 16, 8, 32, 90 using bubbling sorting: 1

    The first round of comparison: compare 5 and 16, 8 and the vertical cover 16, 16 and spring 32, 32 and 90 to get the sequence 5, 8, 16, 32, the second round of comparison: compare 5 and 8, 8 and 16, 16 and 32 to get the sequence 5, 8, 16, 32, the third round of comparison:

    Compare 5 and 8, 8 and 16 to get sequences 5, 8, 16, 32, 4th round comparison: compare 5 and 8 to get sequences 5, 8, 16, 32, 90. Eventually, we get the sequence after the state order:

    **Implementation: def bubble sort(lst): n = len(lst) for i in range(n):

    for j in range(0, n-i-1): if lst[j] >lst[j+1]: lst[j], lst[j+1] =lst[j+1], lst[j] return lstlst = 5,16,8,32,90]sorted_lst = bubble_sort(lst)print(sorted_lst)``

  9. Anonymous users2024-02-02

    Write out the results of the first round of the process of sorting the keyword sequence with bubbling sorting.

    Kiss <>

    Hello <>

    Write out the results of the first round of the process of sorting the keyword sequence with bubbling sort as follows: Initial: 54, 23, 89, 48, 64, 50, 25, 90, 34 1:

    23,48,54,64,89),50,25,90,34 5:(23,48,50,54,Beam Mill 64,89) Slag Cleaning,25,90,34 6:(23,25,48,50,Adan54,64,89),90,34 7:

  10. Anonymous users2024-02-01

    Here's the process of sorting a given sequence of numbers in ascending order using the bubbling sort algorithm:

    Starting with the first element of the sequence, compare the sizes of two adjacent elements, and swap their positions if the previous element is larger than the one of the posterior elements.

    The first group is traversed and the sequence becomes: 122, 124, 126, 118, 128, 130, 132, 135

    Continue to traverse the remaining elements in the sequence, repeating the comparison and swapping operations described above.

    After the second traversal the sequence becomes: 122, 118, 124, 126, 128, 130, 132, 135

    Continue to traverse the remaining elements in the sequence, repeating the above comparison and exchange operations.

    After the third traversal the sequence becomes: 118, 122, 124, 126, 128, 130, 132, 135

    Because the sequence is already in ascending order after the third traversal, the sorting is complete.

    Therefore, the result of sorting a given sequence of numbers in ascending order according to the bubbling sorting algorithm is: 118, 122, 124, 126, 128, 130, 132, 135.

  11. Anonymous users2024-01-31

    Select Sort:

    First Round: 16, 9, 28, 45, 35, 8, 6 Second Round: 16, 9, 28, 45, 35, 8, 6 Third Round:

    16, 35, 28, 45, 9, 8, 6 Fourth round: 45, 35, 28, 16, 9, 8, 6 end bubbling sort:

    First Round: 16, 28, 9, 35, 8, 45, 6 Second Round: 28, 16, 35, 9, 45, 8, 6 Third Round:

    28, 35, 16, 45, 9, 8, 6 Fourth round: 35, 28, 45, 16, 9, 8, 6 Fifth round: 45, 35, 28, 16, 9, 8, 6 end.

Related questions
5 answers2024-05-10

Not necessarily. First, if the company has a loss in the current year and the accumulated undistributed profit is also a loss, the company cannot pay dividends to the shareholders. The reasons are: >>>More

7 answers2024-05-10

Atlanta Hawks, Charlotte Hornets, Miami Heat, Orlando Magic, Washington Wizards, Chicago Bulls, Cleveland Cavaliers, Detroit Pistons, Indiana Pacers, Milwaukee Bucks, Boston Celtics, Brooklyn Nets, New York Knicks, Philadelphia 76ers, Toronto Raptors, Golden State Warriors, Denver Nuggets, Dallas Mavericks, Los Angeles Clippers, Minnesota Timberwolves, Houston Rockets, Los Angeles Lakers, Oklahoma City Thunder, Memphis Grizzlies, Phoenix Suns, Portland Trail Blazers, New Orleans Pelicans, Sacramento Kings, Utah Jazz, San Antonio Spurs.

9 answers2024-05-10

In the process of borrowing money, we all need to pay a certain remuneration for the funds we use, that is, the interest on the loan. On the premise of safety, we naturally want the interest to be as small as possible, but there are also some borrowers who fall into the trap of financial fraud just for the sake of "low interest rates". So how can you find a reliable and reliable borrowing platform with low interest rates? >>>More

6 answers2024-05-10

Smashing household appliances such as computers and televisions because of family conflicts is generally not considered a crime and will not be sentenced. >>>More

6 answers2024-05-10

When I smelled the smoke, I wanted to vomit, so I successfully quit.