• edited by
351 views
0 0 votes

The procedure operates on three arrays $\text{A} [0 \dots 99], \text{B}[0 \dots 99]$ and $\text{C} [0 \dots 99],$ which are initialized with integer values.

procedure mystery () {
    for (i=0; i<100; i++) {C[i] = A[i];}
    p=99;
    for (i=0; i<100; i++) {
        B[p] = C[0];
        p = p-1;
        for (j=1; j<100; j++){
            C[j - 1] = C[j];
        }
    }
}

When the procedure terminates, which of the following statements can be asserted about the array $\text{C}?$

  1. It contains the elements of $\text{A}$ sorted in ascending order
  2. It contains the elements of $\text{A}$ sorted in descending order
  3. All value are equal to $\text{A}[99]$
  4. All value are equal to $\text{A}[0]$

Please log in or register to answer this question.

Position:
Show:

Related questions

1 1 vote
1 1 answer
435
435 views
admin asked Jul 22, 2022
435 views
If the milkman doesn’t deliver milk or the geyser doesn’t work, then Akash will be late for school and lunch will be cooked late. Suppose lunch was actually cooked on tim...
0 0 votes
0 0 answers
303
303 views
admin asked Jul 22, 2022
303 views
Let $\text{L}$ be the language over $\left \{ a, b \right \}$ that contains the same number of occurrences of $a$ and $b$. Which of the following languages is regular?$\t...
0 0 votes
0 0 answers
295
295 views
admin asked Jul 22, 2022
295 views
Which of the following regular expressions represents binary strings that are multiples of $3?$ Note that we consider the leftmost bit to be the most significant.$((11)0^...
0 0 votes
0 0 answers
438
438 views
admin asked Jul 22, 2022
438 views
Consider the following statements about finite simple graphs $\text{G}$ :If each vertex of a graph $\text{G}$ has degree at least $2$ then $\text{G}$ contains a cycle as ...