Welcome to our community

Be a part of something great, join today!

Question about Algorithm

Joystar1977

Active member
Jul 24, 2013
119
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.
 

Evgeny.Makarov

Well-known member
MHB Math Scholar
Jan 30, 2012
2,492

Joystar1977

Active member
Jul 24, 2013
119
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.
 

Evgeny.Makarov

Well-known member
MHB Math Scholar
Jan 30, 2012
2,492
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.
 

Joystar1977

Active member
Jul 24, 2013
119
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.

Sincerely,

Joystar1977