Stacks and Queues Help Center

Learn more

Warning: The hard deadline has passed. You can attempt it, but you will not get credit for it. You are welcome to try it as a learning exercise.

To specify an array or sequence of values in an answer, separate the values in
the sequence by whitespace. For example, if the question asks for the first
ten powers of two (starting at 1), then the following answer is acceptable:

1 2 4 8 16 32 64 128 256 512

If you wish to discuss a particular question and answer in the forums, please
post the entire question and answer, including the seed (which can be used by
the course staff to uniquely identify the question) and the explanation (which
contains the correct answer).

Question 1

(seed = 468996)
Suppose that an intermixed sequence of 10 push and 10 pop operations are performed
on a LIFO stack. The push operations add the values 0 through 9 to the stack, in the
order given; the intermixed pop operations delete and print out the return values
Which of the following output sequence(s) could occur? Check all that apply.

Question 2

(seed = 773965)
Suppose that an intermixed sequence of 10 enqueue and 10 dequeue operations are performed
on a FIFO queue. The enqueue operations add the values 0 through 9 to the data structure,
in the order given; the dequeue operations delete and print out the return values.
Which of the following output sequence(s) could occur? Check all that apply.

Question 3

(seed = 873095)
Consider an object of type MysteryBox that stores N items of type int
in an array items[] of length N.

public class MysteryBox {
private int N;
private int[] items;

...
}

Using the 64-bit memory cost model from the lecture, how many bytes does it use as a function of N?
Include all memory referenced by the object and use tilde notation to simplify your answer.
For example, enter ~ 4N if the number of bytes as a function of N is 4N + 32.
    
You cannot submit your work until you agree to the Honor Code. Thanks!