FPSC- Programmer (BS-17) - PMD High Yield - 2026 — Test 4
Page 1 of 3
Question 1
Which expression tests whether a positive integer x is a power of 2?
FPSC- Programmer (BS-17) - PMD High Yield - 2026
Question 2
A routine to find the minimum of an array starts with min = 0. When does it give a wrong answer?
FPSC- Programmer (BS-17) - PMD High Yield - 2026
Question 3
Approximately how many comparisons does the best algorithm need to find both the minimum and the maximum of n elements?
FPSC- Programmer (BS-17) - PMD High Yield - 2026
Question 4
In C, given int j = 0;, what is j after the expression (0 > 1) & (j++ > 0)?
FPSC- Programmer (BS-17) - PMD High Yield - 2026
Question 5
In C, which statement is TRUE about if (a > b); { max = a; }?
FPSC- Programmer (BS-17) - PMD High Yield - 2026
Question 6
How many times does 'Hi' print?
for (i = 0; i < 3; i++)
for (j = 0; j < 3; j++)
if (j == 1) break;
else printf("Hi");
FPSC- Programmer (BS-17) - PMD High Yield - 2026
Question 7
What is the time complexity of this code?
for (i = 1; i < n; i *= 2)
for (j = 0; j < i; j++)
x++;
FPSC- Programmer (BS-17) - PMD High Yield - 2026
Question 8
What is the time complexity of this code?
for (i = 0; i < n; i++)
for (j = 0; j < i; j++)
x++;
FPSC- Programmer (BS-17) - PMD High Yield - 2026
Question 9
What does Big-Omega (Ω) notation express?
FPSC- Programmer (BS-17) - PMD High Yield - 2026
Question 10
Which of these functions grows fastest as n becomes large?
FPSC- Programmer (BS-17) - PMD High Yield - 2026