0
$\begingroup$

The problem and solution of interest is described here: What does > mean in this TAOCP solution?

Can anyone explain following points in that solution:

  1. How exactly we can build (x[i], x[i+2]) for 1 <= i <= N-2 ?
  2. What exactly means "merge G with it"? Provide exact algorithm for merging these two files.
  3. How steps 1-4 are executed? Is it:

    if (condition 1) {
        ....
    }
    if (condition 2) {
        ....
    }
    if (condition 3) {
        ....
    }
    if (condition 4) {
        ....
    }
    

    or

    if (condition 1) {
        ....
    }
    else if (condition 2) {
        ....
    }
    else if (condition 3) {
        ....
    }
    else if (condition 4) {
        ....
    }
    

    ?

$\endgroup$
  • $\begingroup$ The title you have chosen is not well suited to representing your question. Please take some time to improve it; we have collected some advice here. Thank you! $\endgroup$ – Raphael Jan 24 '17 at 18:44
1
$\begingroup$
  1. With a for loop that steps through the array and creates a new pair from the $i$th and $(i+2)$th elements, for each $i$.

  2. The same as the merge step in merge sort.

  3. There are no "otherwise"s in the statement in English, so there should be no else statements.

$\endgroup$
  • $\begingroup$ possible to explain with an example of sorting {(b,c),(a,b),(d,e),(c,d)}? $\endgroup$ – noman pouigt Jan 25 '17 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.