Created 07/04/03; revised 05/29/15


QUIZ on Stacks


Instructions: For each question, choose the single best answer. Make your choice by clicking on its button. You can change your answers at any time. When the quiz is graded, the correct answers will appear in the box after each question.


1. What phrase matches how a stack behaves?

A.    First In First Out
B.    First Out First In
C.    Last In First Out
D.    Last In Last Out

2. Adding an item to a stack is called:

A.    pop
B.    push
C.    insert
D.    add

3. Removing an item from the top of the stack is called:

A.    pop
B.    push
C.    remove
D.    delete

4. Assume that the stack pointer has already been set up. Which of the following code fragments PUSHES a word of data from register $t0?

A.   
subu  $sp,$sp,4
lw    $t0,($sp)
B.   
addu $sp,$sp,4
lw   $t0,($sp)
C.   
sw    $t0,($sp)
subu  $sp,$sp,4
D.   
subu  $sp,$sp,4
sw    $t0,($sp)

5. As data is added to the MIPS stack, how does it grow?

A.    It grows upward toward higher addresses.
B.    In grows downward toward lower addresses.
C.    It grows toward the address in the stack pointer.
D.    It grows in whichever direction is available.

6. Assume that the stack pointer has already been set up and that the stack contains data. Which of the following code fragments POPS a word of data to register $t0?

A.   
sw    $t0,($sp)
addu  $sp,$sp,4
B.   
lw    $t0,($sp)
subu  $sp,$sp,4
C.   
lw    $t0,($sp)
addu  $sp,$sp,4
D.   
addu  $sp,$sp,4
lw    $t0,($sp)

7. How much total virtual memory is available with a MIPS processor?

A.    32 Megabytes
B.    512 Megabytes
C.    2 Gigabytes
D.    4 Gigabytes

8. Does the stack contain data that was declared in the .data section of a program?

A.    No. That goes in the data segment of memory.
B.    No. That goes in the text segment of memory.
C.    Yes. The stack contains all the data of the program.
D.    Yes. The .data section goes in the start of the stack.

9. What does the instruction lbu $t0,string do?

A.    It copies a word of memory from symbolic address string into $t0.
B.    It copies one byte of memory from symbolic address string into the low order byte $t0, leaving the other bytes of $t0 unchanged.
C.    It copies one byte of memory from symbolic address string into the low order byte $t0, and zeros the remaining bytes of $t0.
D.    It copies one byte of memory from symbolic address string into the low order byte $t0, and extends bit 7 into the remaining bytes of $t0.

10. Must a stack-based algorithm (such as string reversal) start out with an empty stack?

A.    No. The algorithm is not affected by data already on the stack.
B.    No. The algorithm will clear old data left on the stack.
C.    Yes. If there is data already on the stack it will be inappropriately used.
D.    Yes. Each program must have its own stack.

The number you got right:       Percent Correct:       Letter Grade:   


Click here

If you have returned here from another page, or have re-loaded this page, you will need to click again on each of your choices for the grading program to work correctly. You may want to press the SHIFT KEY while clicking to clear the old answers.