The final value of Q in the following flowchart is most nearly:
A. 0
B. 1
C. 3
D. 5
answer (D)
J=3
k=2
Q=1
i=0
while Q≤j
Q=Q+2
K=KxQ
i=i+1
else
end
disp(Q)
for i=0
Q_(i=0)=1
j=3
for i=1
Q_(i=1)=Q_(i=0)+2=1+2=3
j=3
T.a.T. Q=J and Q is not greater than J
for i=2
Q_(i=2)=Q_(i=1)+2=3+2=5
j=3
Therefore Q=5 and J=3 and Q>J
Given a complete binary search tree consisting of 15 elements, the height of the tree is:
A. 15
B. 8
C. 7
D. 3
The following pseudocode, which has a worst-case timing of $$O(n^2)$$, is what type of classical sort algorithm?
A. Bubble sort
B. Insertion sort
C. Merge sort
D. Quick sort
The following function counts down starting at Y. What number does the countdown return if it is called with Y= 10?
A. -1
B. 0
C. 1
D. 10