Homework 6
This homework is due on Sunday.
Datastructures and Dynamic Arrays Multiple Choice (4 points each)
1. Which of the following correctly declares an
array?
2. What is the index number of the last element of
an array with 29 elements?
3. Which of the following is a two-dimensional
array?
4. Which of the following correctly accesses the
seventh element stored in foo, an array with 100 elements?
5. Which of the following gives the memory address
of the first element in array foo?
6. (30 points) Implement a stack using an array. Let the user specify the size of the array to use.
You will need to specify the functions push and pop that make the array behave like a stack.
You must handle attempts to add items to the stack when the array is full, but you can handle that case however you wish.
7. (30 points) Implement a queue using an array.
You will need to specify the functions push and pop that make the array behave like a queue.
You must handle attempts to add items to the queue when the array is full, but you can handle that case however you wish.
|