View the step-by-step solution to:

IT 24 - Data Structures PROGRAMMING ASSIGNMENT Choose the implementation you want to work with (one-dimensional array or linear/singly-linked list)

IT 24 – Data Structures

PROGRAMMING ASSIGNMENT
Choose the implementation you want to work with (one-dimensional array or linear/singly-linked list)

Write a program that does the basic stack operations:
1. Create the stack
- if the stack has not been created yet, go on with the initialization
- if the stack exists, output a warning message to the user if he/she wants to continue with the deletion of the data items stored in the stack

2. Push an element into the stack
- for an array implementation, be sure to check first for a full stack before storing the data item into the stack (output a “stack overflow” message if the stack is full)
- if the stack is not full, output a message to the user once the data item has been properly stored

3. Pop an element from the stack
- for both implementations, be sure to check first for an empty stack before proceeding with this operation
- output a “stack underflow” message if the stack is empty
- if the stack is not empty, proceed with the deletion and return the value of the data item to the calling function
- output the value of the data item that was popped out from the stack

4. Take a peek at the top of the stack
- Just tell the user what the element is on top of the stack

5. Display the contents of the stack
- although this is not part of the stack operations, you need this to check if the elements/data items were inserted correctly

Take note that the following user-defined stack functions need to be in your program:
CreateStack
FullStack
EmptyStack
Push
Pop
Peek

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question