Question: which option is always true? why? Consider the following pseudocode: A is an array of real numbers, indexed from 1 to n n leftarrow length
which option is always true? why?
Consider the following pseudocode: A is an array of real numbers, indexed from 1 to n n leftarrow length (A); for j leftarrow to ([n/2]) do k = n + 1 - j; A [j] leftarrow A[j] + A[k]; A[k] leftarrow A[j] - A[k]; A[j] leftarrow A[j] - A[k]; Which of the following invariants are true at the end of every iteration of the for loop? The sub-array .A[1...j] contains its original contents in the same order The sub-array A[1...j] contains the original contents of sub-array A[(n + 1 - j)...n] in reverse order. The sub-array A[1...j] contains its original contents in reverse order. The sub-array A[(n + 1 - j)...n] contains its original contents in the same order. The sub-array A[(n+1 - j)...n] contains the original contents of sub-array A[1...j] in reverse order. The sub-array A[(n + 1 - j)...n] contains its original contents in reverse order
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
