MHB How can an algorithm determine if a list is sorted?

  • Thread starter Thread starter Joystar77
  • Start date Start date
  • Tags Tags
    Algorithm
AI Thread Summary
The discussion centers on how sorting algorithms, specifically Bubble Sort, determine when a list is sorted. It is clarified that an algorithm cannot conclude that a list is sorted until it completes a full pass through the array without any swaps. The example used is the array (7, 12, 5, 22, 13, 32), which illustrates the sorting process. Additionally, there is a brief exploration of the concept of an array, emphasizing its role in mathematics as an orderly arrangement of numbers or objects. The conversation highlights the importance of precise terminology in discussing algorithms and arrays, with participants expressing appreciation for the clarification of these concepts.
Joystar77
Messages
122
Reaction score
0
The question is as follows: "How does the algorithm know when the list is sorted?"

Is this the correct answer to this question: The array is already sorted, but an algorithm does not know if it is completed. The algorithm need one whole pass without any swap to know it is sorted.
 
Technology news on Phys.org
Joystar1977 said:
The question is as follows: "How does the algorithm know when the list is sorted?"
Which algorithm and array do you have in mind?
 
I thought of the algorithm as follows:

Bubble Sorting the list of numbers: 7, 12, 5, 22, 13, 32

7, 12, 5, 22, 13, 32
12, 7, 5, 22, 13, 32
12, 5, 7, 22, 13, 32
5, 12, 7, 22, 13, 32
5, 7, 12, 22, 13, 32

In math, an array refers to a set of numbers or objects that will follow a specific pattern. An array is an orderly arrangement, often in rows, columns or a matrix. Arrays are used in multiplication and division as it shows a great visual to show how multiplication can be shown as repeated addition and division can be shown as fair shares.
There are many authentic examples of arrays that help with the understanding of how using arrays can help students to see efficient strategies. Is this true about what an array means? There are no definitions in my textbook or examples given about what an array really is. Please let me know if this is correct.
 
I wasn't asking for the definition of an array in general. Since you used "the list" and "the algorithm" in the OP, I was wondering what those specific things are. So, the array is (7, 12, 5, 22, 13, 32) and the algorithm is Bubble sort.

The array is already sorted, but an algorithm does not know if it is completed. The algorithm need one whole pass without any swap to know it is sorted.
I would not say, "The array is already sorted" without specifying which array. You could say, "During the last pass, the array is already sorted, but an algorithm does not know it. The algorithm needs one whole pass without any swap to know the array is sorted". I agree with this statement.
 
Thank you Evgeny. Makarov! I am getting used to brand new terms, because I notice in different mathematics courses such as prealgebra, beginning algebra, and intermediate algebra there are other mathematical terms used. Again, thanks for helping me with this and thoroughly explaining the material. I truly and really appreciate it.
Joystar1977
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Back
Top