Page 194 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 194

Unit 11: Operations and Applications of Queues




          11.  The allocation of memory for a particular resources are maintained in queue.     Notes
          12.  An operating system does not makes use of a queue for scheduling processes or jobs.
          13.  Queue is used when data is transferred synchronously between two processes.
          14.  When a resource like CPU is shared between among multiple consumers, a queue solves
               the hatchet.
          15.  All the input output calls made by the disk to and from the memory are handled by a stack.




             Case Study  C Program to Enqueue and Dequeue in a
                         Circular Queue using Singly Linked List

             #include<stdio.h>
             #include<conio.h>
             #include<alloc.h>
             typedef struct nodes
             {
                 int x;
                 struct nodes *next;
             }node;
             //Function Declarations
             void enqueue(node **,node **, int);//Use call by reference node **
             is pointer to pointer
             int dequeue(node **,node **);
             void display(node *);
             void main()
             {
                    node *front=NULL, *rear=NULL;
                    int choice,element;
                    clrscr();
                    do
                   {
                        printf("\n1. Enqueue\n2. Dequeue\n3.Print Linked
             List\n4.Exit\nChoice : ");
                        scanf("%d",&choice);
                        switch(choice)
                        {
                            case 1:
                                     printf("Enter the element to insert : ");
                                     scanf("%d",&element);




                                                                                 Contd...



                                           LOVELY PROFESSIONAL UNIVERSITY                                   187
   189   190   191   192   193   194   195   196   197   198   199