1. declare a place to stack,
is a struct with the elements are
array (data storage) and variable (for
determine the initial position of the stack).
2. declare the maximum data (using constant declarations max)
3. for those functions in the stack
- Is Empty (to check whether the stack is empty)
how:
* If the position of = - 1 is empty
- Isfull (to check whether the stack is full)
how:
* If the position is filled = max
- Push (insert data)
how:
* Check whether empty or full call an empty function and full function
* If it is empty or not full then fill in the data, by the way: raise the level of position 1 (position + +), fill in the data on the index to the position
- Pop (take a stack / data)
how:
* Checks whether the stack is loaded or not
by calling an empty function.
* If empty = 0 (filled stack) then take, by way of lowered one level position (position -)
- Clear (to clear the contents of the stack)
how:
* Checks whether the stack is loaded or not
by calling an empty function.
* If empty = 0 (filled stack) then clean the stack with the way: position = -1
- Display the contents of the stack
how:
* Checks whether the stack is loaded or not
by calling an empty function.
* If empty = 0 (filled stack) then show it by: looping a number of positions (starting from last position of the stack until the position = 0)
4. call the function names that have been declared when needed
source: STMIK AMIKOM YOGYAKARTA
0 komentar
Posting Komentar