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");
       }
    }

Leave a reply

required

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre user="" computer="" escaped="">