Page 149 - DCAP407_DATA_STRUCTURE
P. 149

Data Structure



                                                 rear_insert(num, Q, &R, &COUNT);
                                                 break;
                                               case 2: front_delete(Q, &F, &COUNT);
                                                 break;
                                               case 3: display(Q, F, COUNT);
                                                 break;
                                                default: exit(0);
                                              }
                                               }
                                          }
                                          Output:
                                          1.  Insert at rear end
                                          2.  Delete at front end
                                          3.  Display

                                          4.  Exit
                                          1
                                          Enter the number to be inserted
                                          50
                                          1.  Insert at rear end
                                          2.  Delete at front end
                                          3.  Display
                                          4.  Exit

                                          1
                                          Enter the number to be inserted
                                          60
                                          1.  Insert at rear end
                                          2.  Delete at front end
                                          3.  Display

                                          4.  Exit
                                          3
                                          The contents of the queue are 50 60
                                          1.  Insert at rear end
                                          2.  Delete at front end
                                          3.  Display
                                          4.  Exit
                                          2

                                          The element deleted is 50
                                          In this example:
                                          1.  The header files are included and a constant value 5 is defined for variable
                                              SIZE using #define statement. The SIZE defines the size of the queue.







                          142                     LOVELY PROFESSIONAL UNIVERSITY
   144   145   146   147   148   149   150   151   152   153   154