single stack

Contoh Single Stack

Contoh Single Stack

ciri2 single stack :

  1. kosong : top = -1
  2. penuh : top = n-1
  3. bisa diisi : top < n-1
  4. ada isinya : top > -1

kondisi awal :

top1 = -1;

algoritma dasar single stack :

  1. PUSH
    top = top + 1;
    s[top] = x;
  2. POP
    x = s[top];
    top = top - 1;

algoritma lengkap single stack :

  1. PUSH
    void PUSH(void){
      if(top &lt; n -1 ){
          top = top + 1;
          s[top] = x
        }else{
          printf("stack penuh");
        }
    }
  2. POP
    void PUSH(void){
      if (top&gt;-1){
           x = s[top];
           top = top - 1;
       }else{
           printf("stack kosong");
       }
    }

Bookmarks:
  • Facebook
  • Google Bookmarks
  • Digg
  • LinkedIn
  • Twitter

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.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre user="" computer="" escaped="">