One method of processing data using the method of computing the Stack. Stack is a data structure which generally is First In Last Out (Philo) or First In Last Serve. Keywords: Stack, Philo, First In Last Serve.
In the world of programming data structures represent something familiar. Very useful data structures once when we need a method of data processing. We know, FIFO, LIFO, and so on. Looks like we deserve grateful to the thinkers who have successfully spawned the idea.
One method of computing the data processing is to use the Stack method, in the Indonesian language usually called the stack. The main principle of the stack is LIFO, Last In First Out, meaning the last data entered will be processed or executed first. In this stack we will find some basic operations of the push operation, this operation serves to enter data into the stack, kemudia pop operations whose function is to execute the last data entry (can be said to remove data from stack structure). Optional operations that we encounter are often isEmpty, serves to check whether the stack is still in clean condition or empty, isEmpty opposed kemudia the isFull that serves to check whether all the memory array has been allocated for stack management. But if we use dynamic pattern stack, isFull operations are not necessary because this dyanamic pattern d.alam no memory allocation restrictions. Then the optional operations that we encounter are usually destroy the function to empty the stack and display that will display the entire contents of the array.
Stack can be used in some programs such as programs for the conversion of decimal to binary, check palyndrome, reverse word, and so on. But this time we will only discuss the implementation of the stack on the Palindrome.
Application stack on a variety of programming languages especially procedural programming languages such as C language has 2 types of solutions, namely static and dynamic static stack. Static stack is a stack or stacks which have defined the contents of the stack. But in the java programming language this can be overcome if the stack is already full so we can update with a new stack definition, in this case we can use a vector or upgrade an existing array. While dynamic stack is a stack by using the principle of linked list, therefore the full stack problem can be overcome from the beginning.
Implementation of Language C (static):
#include
#include
#include
#include
#include
typedef char datatype;
const int MAXSIZE = 100;
struct Stack{
datatype Data[MAXSIZE];
int Top;
};
Stack S;
void Initialize(){
S.Top = -1;
}
bool IsEmpty(){
if(S.Top==-1) return true;
return false;
}
bool IsFull(){
if(S.Top==MAXSIZE-1) return true;
else return false;
}
void Push(datatype n){
if(IsFull()){
gotoxy((80-strlen(“Stack sudah penuh”))/2,10);
cout<<”Stack sudah penuh”;
}while((menu<1)>4));
clrscr();
switch(menu)
{
case 1:
gotoxy((80-strlen(“Masukkan karakter:”))/2,2);
cout<<”Masukkan karakter:”; gotoxy((80-strlen(” “))/2,4); cin>>c;
Push(c);
gotoxy((80-strlen(“Data telah dimasukkan ke stack”))/2,6);
cout<<”Data telah dimasukkan ke stack”; getch(); goto first; case 2: gotoxy((80-strlen(“Data yang di ambil:”))/2,2); cout<<”Data yang di ambil:”; gotoxy((80-strlen(“c”))/2,4); cout<
if(toupper(c)==’Y')
{
Destroy();
goto first;
}
else
goto first;
case 5:
gotoxy((80-strlen(“Terima kasih”))/2,10);
cout<<”Terima kasih”; getch(); exit(0); } getch(); }



0 comments: STACK IMPLEMENTATION PROGRAMMING
Post a Comment