single stack
ciri2 single stack :
- kosong : top = -1
- penuh : top = n-1
- bisa diisi : top < n-1
- ada isinya : top > -1
kondisi awal :
top1 = -1;
algoritma dasar single stack :
- PUSH
top = top + 1; s[top] = x;
- POP
x = s[top]; top = top - 1;
algoritma lengkap single stack :
- PUSH
void PUSH(void){ if(top < n -1 ){ top = top + 1; s[top] = x }else{ printf("stack penuh"); } }
- POP
void PUSH(void){ if (top>-1){ x = s[top]; top = top - 1; }else{ printf("stack kosong"); } }
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


