circular queue

Contoh Circular Queue

Contoh Circular Queue

ciri2 circular queue :

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

kondisi awal :

f = 0;
r = -1;
counter = 0;

algoritma dasar circular queue :

  1. INSERT
       R = (R+1) % n;
       Q[R] = X;
       Counter++;
  2. DELETE
       X = Q[F];
       F =(F+1) % n;
       Counter--;

algoritma lengkap circular queue :

  1. INSERT
    void INSERT(void){
        if(Counter &lt; n){
            R = (R+1) % n;
            Q[R] = X;
            Counter++;
        }else{
            printf("antrian penuh");
        }
    }
  2. DELETE
    void DELETE(void){
        if(Counter &gt; 0){
            X = Q[F];
            F = (F+1) % n;
            Counter--;
       }else{
            printf("antrian 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="">