Beginner Computer Science Coding- Stacks

Ακυρώθηκε Αναρτήθηκε Dec 12, 2014 Πληρώθηκε κατά την παράδοση
Ακυρώθηκε Πληρώθηκε κατά την παράδοση

#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

FORGOT TO ADD THIS. I APOLOGIZE IN ADVANCE

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.

Γλώσσα Προγραμματισμού C Προγραμματισμός C++ CSS HTML5 Visual Basic

Ταυτότητα Εργασίας: #6856055

Σχετικά με την εργασία

3 προτάσεις Απομακρυσμένη εργασία Ενεργό Dec 12, 2014

3 freelancers κάνουν προσφορές κατά μέσο όρο $43 για αυτή τη δουλειά

hbxfnzwpf

I am very proficient in c, c++. I have 15 years c++ developing experience now, and I have worked for 5 years. My work is online game developing, and mainly focus on server side, the language is c++ under linux. I used Περισσότερα

$50 USD σε 1 μέρα
(55 Αξιολογήσεις)
6.0
pavellint

A proposal has not yet been provided

$50 USD σε 1 μέρα
(4 Αξιολογήσεις)
4.8
Softeria

A proposal has not yet been provided

$30 USD σε 0 μέρες
(2 Αξιολογήσεις)
1.0