Beginner Computer Science Coding- Stacks -- 2
$10-30 USD
着払い
The stack is a commonly used data structure in computer science. It is an arrangement of data where the last item to be added is the first one to be removed. Think of it as a stack of papers. As you stack papers up, you remove them in the reverse order from which they were added.
There are two basic operations for a stack – push and pop. You will see them in the class below. Push is to add an item to the stack and pop must remove an item from the stack. Before we look at the code below, let me suggest that there are at least two boundary conditions that you must address.
• One cannot pop from an empty stack as there is nothing to pop
• One cannot push to a full stack as there is no more room
This assignment is to implement an integer stack as a class using an array. You must also create a main function to test your implementation. I have provided the class structure below to help you get started. You are required to use this structure for this assignment.
This solution uses tos as the array index to define the stack. When you push you should increment the tos and when you pop you should decrement tos. I suggest that you don’t change the value of tos during the show function as this will really screw you up.
Without further discussion you will find the code for the Stack class on the following page.
#define MAXSIZE 10 //set maximum size of stack to 10 integers
//You probably will want to add an include or two here
class Stack{
private:
int stack[MAXSIZE]; //integer array for your stack
int tos; //array index to top of stack
bool isEmpty(){ if (tos==-1) return true; return false;}
bool isFull(){if (tos == MAXSIZE-1) return true; return false;}
public:
Stack(){tos=-1;} //constructor-initialize tos to -1
//if tos == -1 then stack is empty
void push(int i); //Add i to top of stack;
int pop(); //Remove and return value from top of stack
void show(); //output the stack
};
//your code for push, pop, show, and main goes here
プロジェクトID: #6856076
プロジェクトについて
アワード:
I only ask for 10$. 5$ as initial payment, 5$ as final. The work will be done within 24 hours. If the price and the deadline is acceptable for you, then feel free to contact me for further discussion.
8人のフリーランサーが、平均$37 で、この仕事に入札しています。
Hi. I've read your description, and this is what i'd done at school. I want to help you. I can do this right away. Thank you.
Hi there, I've already read and understood the project description, and I'm sure I can complete this one for you. So really hope to have chance to work with you, thanks for your consideration! Regards.
I can give you this in few minutes if you want me to do this please ping me. Your work is already done I will send you the screenshot of the working code. Regards
I have extensive experience in C,C++ programming. I can easily & reliably do your job with lowest cost & minimum time. Message me.
Hello, We are expertise Dotnet using VB.net and C#, We also make forms like an international design, Not like classic brown style, But if you want then we can do that too. Our logic are always clear and codes are alway もっと
I'm an experienced programmer and also have a good knowledge of data structures. So, I think I'm eligible for this job.