Consider the following operations on an initially empty stack:
Push 10
Push 20
Pop
Push 30
Pop
Push 40
What is the final content of the stack?
A stack operates on a Last-In, First-Out (LIFO) principle. Carefully follow the sequence of push and pop operations to track the stack's content.
10, 40
40, 20
40, 10
30, 40
Stack Operations Breakdown
- Push 10: Stack = [10]
- Push 20: Stack = [10, 20]
- Pop: Removes 20, Stack = [10]
- Push 30: Stack = [10, 30]
- Pop: Removes 30, Stack = [10]
- Push 40: Stack = [10, 40]
Thus, the final content of the stack is [10, 40].
Which of the following is true about the binary search algorithm when applied to a sorted array?
Given a pipeline with 5 stages, the delay for each stage is as follows:
\[ \begin{array}{|c|c|} \hline \textbf{Stage} & \textbf{Delay (ns)} \\ \hline 1 & 250 \\ 2 & 150 \\ 3 & 100 \\ 4 & 200 \\ 5 & 50 \\ \hline \end{array} \]The buffer delay is 10 ns. Find the time for \( n = 1000 \) instructions.
What is the output of the following C code?
void foo(int *p, int x) { *p = x; } void main() { int *z; int a = 20, b = 25; z = a; // Incorrect: Should be z = a; foo(z, b); printf("%d", a); }
Issue: The statement z = a;
is invalid because a
is an integer, and z
is a pointer.
Which of the following is the greatest? \[ 0.6, \ 0.666, \ \frac{5}{6}, \ \frac{2}{3} \]
Consider the following C code:
int main() { sum = 0; for (n = 1; n < 3; n++) { n++; sum += g(f(n)); } printf("%d", sum); } int g(n) { return 10 + n; } int f(n) { return g(2 * n); }
What is the output?