CMPS-2020 - Programming II - Data structures and algorithms
Stack Coding Exercise
---------------------
Use of a stack.
Get the starting program...
Go to your Odin 2020/a/ folder.
Copy the following program into your folder.
/home/fac/gordon/public_html/2020/a/stackfill.cpp
The program already works by filling an array with characters.
The filling process is displayed as it goes.
Assignment: Fill the array using a stack.
1. Prompt the user for an array index to start in the array.
2. Push that index to your stack.
3. If stack is empty, end the program, otherwise continue the steps below.
4. Pop the stack. Store it in a variable named x.
5. Store your fill-character at index x of your array.
6. Push the two neighboring indexes of x to the stack.
push x - 1
push x + 1
Warning:
Do not push an invalid array index.
Do not push an index that has already been filled with a character.
7. Go to step 3.
Note: your program will loop from step-3 to step-7.
Due: Friday 4/9/2021 at 6pm