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

Related posts:

  1. double ended queue ciri2 double ended queue : kosong : L = R...
  2. single stack ciri2 single stack : kosong : top = -1 penuh...
  3. double stack ciri2 double stack : stack 1 kosong : top1 =...
  4. linked list hitung jumlah simpul : Q = FIRST; Jum = 1;...
  5. dml (data manipulation language) dalam sql Data Manipulation Language (DML) SELECT Menampilkan sebagian atau seluruh isi...

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="">