OA. free
Free
Sirionlabs, Inc Core Computer Science Data Structures & Algorithms Medium

Determine the output array x after executing the following pseudo-code on the given input...

Sirionlabs, Inc technical mcq question, verified with a worked answer. Free to practise - no sign-up.

Determine the output array $x$ after executing the following pseudo-code on the given input array.

Input:

HackArr[] = {1, 1, 5, 5, 2, 2, 7}

Pseudo-code:

N = length of HackArr
for i from 1 to N-1 do
    j = i
    while (j > 0) and (HackArr[j] < HackArr[j-1]) do
        k = HackArr[j]
        HackArr[j] = HackArr[j-1]
        HackArr[j-1] = k
        j = j - 1
    end-do
end-for

Assume 0-based indexing and space-separated formatting for the output array.

Choose one option.
Show answer & explanation
Answer: A. 1 1 2 2 5 5 7

Accurate technical and quantitative evaluation based on foundational principles.

Step-by-step Derivation:
Step 1: Formulate problem conditions.
Step 2: Apply logical deduction.
Step 3: Conclude correct option.