Articles

STACK

In Materi, Struktrur Data on January 7, 2011 by khalifrinaldi

Stack or the heap is a collection of objects that use the principle of LIFO (Last In First Out), ie the data entered will terakhr first out of the stack. Stack is implemented as a representation can be hooked or kontigu (with table fix).
Stack Feature:

* Element TOP (top) unknown
* Penisipan and removal of elements is always done at TOP
* LIFO

Use of Stack:
* Calculation of arithmetic expressions (Postfix)
* Backtraking algorithm (trace back)
* Recursive algorithm

Stack operating normally:
1. Push (input E: typeelmt, input / output data: stack) add an element to the stack
2. Pop (input / output data: stack, the output E: typeelmt): remove an element stack
3. IsEmpty ()
4. IsFull ()
5. and another selector beberapas

Stack APPLICATION ON DATA STRUCTURE

In the world of computers, use of the stack (the stack) is a matter that is commonly used as for determining the memory address, the placement of space data and other applications. As part of the data structure, the application stack is also used for various purposes such as testing sentence palindrome, testers parentheses (matching parentheses), and also functions as a conversion from infix notation into the notation postfix.
In arithmetic, infix notation is a notation that puts the operator in the middle of two operands while Postfix notation is a notation that puts the operator after two operands. Use infix notation is common used in arithmetic compared with the use of Postfix notation, but the machine compiling Postfix notation is a notation that is used to perform a computation.
Stack Operations

In its use of a stack has several operations that can be applied as a stack, the addition of eleme onto the stack, menghapusan element of the stack, and other operations associated with the stack. The basic operations of a stack are:

a) Create (Stack)
Create operation (Stack) is used to create a new stack with the name stack, which is the value of the current element stack is made is NOEL (S) = 0, TOP (S) = NULL (not defined)

b) isEmpty (Stack)
This operation is an operation to check the contents of a stack to be empty or contain. This operation has 2 (two), boolean conditions, namely:

a. True if the stack is empty or it can be said NOEL (S) = 0
b.False if the stack is empty or not in condition to be said NOEL (S)> 0

c) Push (Stack, Element)
This operation is an operation to add one element to the value of X on top of one stack, so that the position TOP (S) would be worth x, application of a push operation pasa stack S will result in overflow if the NOEL (S) the stack has a maximum value.

d) Pop (Stack)
This operation serves to remove one element from the stack S, so that the position NOEL (S) will be reduced by one element, and TOP (S) will change. The pop operation can cause the condition stack underflow, if an S which are the minimum conditions imposed in the pop operation.
Postfix infix notation and

An arithmetic calculation usually associated with operands and operators. Operand is a character or element whose value is operated with the assistance of an operator untuik produces a solution.

Suppose that if given a second arithmetic expression * 3, then the element ‘two’ and element ‘three’ is the operand of these expressions and elements of ‘*’ is the operator of multiplication of two operands which produces a solution. An arithmetic expression can be divided into three forms of notation calculations are:

1) prefix notation, if the operator is placed before the two operands
2) infix notation, if the operator is placed between the two operands
3) postfix notation, if the operator is placed after the two operands

Their use in everyday life is a notation infix arithmetic notation most widely used to express a artimatik calculation compared with the other two notations will be but Postfix notation is a notation used by the compilation engine on a computer with intent to facilitate the process of coding, so that compilation engine requires expression stack for the translation process.

Operation and Operation and basic functions on the stack
a. Test empty stack

StackEmpty function (S: Stack) → Boolean
Empty stack {TEST: Sending true, if the stack is empty, false if the stack is not empty}
Declaration
Description
return (Top (S) = Nil)

b. Making an empty stack

Procedure CreateEmptyS (Output S: Stack)
{K. Beginning: arbitrary,
K. End: a stack S is empty ready to wear undefined
Process: Create an empty stack}
Declaration
Description
Top (S) ← Nil

c. The addition of an element on the stack (Push)

procedure Push @ (Input / Output S: Stack Input P:
address)
{Adding a new element at the TOP of a Stack, with elements known to the address}
K. {Early: Stack may be empty, defining P (that is defining the information, Next (P)} = Nile
{K. End: Top (S) is P}
Declaration
Description
Insert the first element {}
Next (P) ← TOP (S)
TOP (S) ← P

procedure Push (Input / Output S: Stack Input E: InfoType)
{Adds a new element to the TOP of a stack, with the element of known information}
{K. Initial: Stack possibly empty, E terdefenisi, address allocation always succeed}
{K. End: TOP (S) contains E)
Declaration
Q: address
Description
Allocation (P) {allocation of obtaining successful}
Info (P) ← E
{Insert the first element}
Next (P) ← TOP (S)
TOP (S) ← P

c. Elimination of an element in the stack (Pop)

procedure PopStack @ (Input / Output S: Stack
Output P: address)
{K. Early: Stack not empty
K. End: Address element of Top (S) are stored in P, so that information is accessible via the P
Process: Removing the element stack, the stack not be empty and may be empty}
Declaration
Description
TOP ← P (S)
TOP (S) ← Next (TOP (S))

PopStack procedure (Input / Output S: Stack
Output E: InfoType)
{K. Early: Stack not empty
K. Final: Address element of Top (S) are stored in E, addresses the long didealokasi TOP
Process: Removing the element stack, the stack not be empty and may be empty}
Declaration
Q: address
Description
TOP ← P (S)
E ← info (P)
TOP (S) ← Next (TOP (S))
Deallocation (P)

Leave a comment

Design a site like this with WordPress.com
Get started