MHB Discrete Mathematics Vcomparisons

AI Thread Summary
The discussion revolves around the concept of "v-comparisons" in the context of sorting algorithms, particularly Bubble Sort. Participants express confusion about the term "v-comparisons," which is not widely recognized in discrete mathematics. A user seeks clarification on the number of comparisons needed to sort a specific list of numbers: 7, 12, 5, 22, 13, and 32. It is established that the maximum number of comparisons for a list of six numbers is five, as each pass in Bubble Sort reduces the number of comparisons needed. The conversation emphasizes the importance of context in questions and suggests that threads should be self-contained to avoid confusion. Additionally, it is noted that the maximum number of comparisons can vary based on whether the sorting algorithm is optimized, with the unoptimized version performing a total of n(n-1)/2 comparisons. The discussion highlights the need for clarity in terminology and the mechanics of sorting algorithms.
Joystar77
Messages
122
Reaction score
0
How many vcomparisons did you actually need?
 
Technology news on Phys.org
Joystar1977 said:
How many vcomparisons did you actually need?
n. (Smile)

Do you seriously believe one can answer this question without knowing the context, in particular, what v-comparisons are? This is not a universally accepted term in discrete mathematics, as far as I know.
 
I will rephrase the question Evgeny. Makarov. When having the following numbers: 7, 12, 5, 22, 13, and 32 how many vcomparisons did I actually need?

Is it true that 12 vcomparisons is what I would actually need. If this is not correct, then can you explain this to me? I have a learning disability and so its hard for me to grasp the concepts and understand the material at times.

Another question I have when having the following numbers: 7, 12, 5, 22, 13, and 32 what is the maximum number of comparisons required for a list of 6 numbers?

The maximum number of comparisons required for a list of 6 numbers would be 5 comparisons. If this is not correct, then can you please explain this to me?
 
Joystar1977 said:
I will rephrase the question Evgeny. Makarov. When having the following numbers: 7, 12, 5, 22, 13, and 32 how many vcomparisons did I actually need?
Do you need to sort this sequence? You still have not said what v-comparisons are.

As a general advice, you should ask questions in such a way that individual threads are self-contained. One thread should not require a context from a different thread. If you do rely on another thread, you should post a link there. Even if two threads were asked at the same time, after several replies they may be separated by other threads in the list of recent posts, so it is is no longer obvious that they may be related. Also, different threads may be read by different people. I believe this is a rule not just on this forum.

Joystar1977 said:
Another question I have when having the following numbers: 7, 12, 5, 22, 13, and 32 what is the maximum number of comparisons required for a list of 6 numbers?

The maximum number of comparisons required for a list of 6 numbers would be 5 comparisons. If this is not correct, then can you please explain this to me?
I believe this question is being discussed in https://driven2services.com/staging/mh/index.php?threads/5719/.
 
Oh, I did not understand you Evgeny.Makarov. I was just rephrasing the question because this is a term that my instructor apparently uses in Discrete Mathematics. You said that it wasn't an appropriate term used in Discrete Mathematics. There are 5 questions listed under my assignment for Question 1 and it goes through like this as follows:

Use Bubble Sort to sort the list: 7, 12, 5, 22, 13, 32

a. Which number is definitely in its correct position at the end of the first pass?

b. How does the number of comparisons required change as the pass number increases?

c. How does the algorithm know when the list is sorted?

d. What is the maximum number of comparisons required for a list of 6 numbers?

e. How many vcomparisons did I actually need?

I am trying to figure out what the vcomparisons are also.
Joystar1977

Evgeny.Makarov said:
Do you need to sort this sequence? You still have not said what v-comparisons are.

As a general advice, you should ask questions in such a way that individual threads are self-contained. One thread should not require a context from a different thread. If you do rely on another thread, you should post a link there. Even if two threads were asked at the same time, after several replies they may be separated by other threads in the list of recent posts, so it is is no longer obvious that they may be related. Also, different threads may be read by different people. I believe this is a rule not just on this forum.

I believe this question is being discussed in https://driven2services.com/staging/mh/index.php?threads/5719/.
 
Joystar1977 said:
d. What is the maximum number of comparisons required for a list of 6 numbers?

e. How many vcomparisons did I actually need?
This may be a typo. The question may ask for the actual number of comparisons for this concrete list as opposed to the the maximum number of comparisons over all lists of 6 numbers.

First you need to figure out the details of the algorithm: whether the number of comparisons decreases from pass to pass or not. The fact is that after the first pass, the largest number is at the end of the array, and there is no use of comparing it. Therefore, the second pass may use $n-2$ comparisons instead of $n-1$ for the first pass, and the number of comparisons may decrease by 1 with each pass. However, there is no harm in making these extra comparisons.

Thus, in the unoptimized version of the algorithm, each pass makes $n-1$ comparisons for an array of $n$ numbers. In the optimized version, which you seem to have, there are $n-1$ comparisons for the first pass, $n-2$ for the second pass, and so on. Therefore, the maximum total number of comparosins is $(n-1)+(n-2)+\dots+1=n(n-1)/2$ (the sum of an arithmetic progression). For an actual list, the algorithm may discover sooner that the list is sorted, and the number of comparisons may be smaller.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top