Page 116 - Computer science 868 Class 12
P. 116

Step 5:  return value.
                 Step 6:  Stop.
              c.  Displaying the contents in stack

                 Step 1:  Start.
                 Step 2:  Initialise variable i to top.
                 Step 3:  Repeat steps 3 and 4 while i >= 0.
                 Step 4:  Display array[i].
                 Step 5:  Decrease i by 1.
                 Step 6:  Stop.


              3.5.9 Algorithms on operations in QUEUE
              Queue is a data structure that follows FIFO (First in first out principle). [Queue is covered in detail in the later part of
              this book]

              Problem 21:
              a.  Pushing data into queue assuming front and rear is 0
                 Step 1:  Start.

                 Step 2:   If rear = size then print “Queue full .. overflow”, and go to step 5.
                 Step 3:  Set array[top] = number
                 Step 4:  Increment rear by 1.
                 Step 5:  Stop.
              b.  Popping data from Queue

                 Step 1:  Start.
                 Step 2:  If front = rear then return -999.
                 Step 3:  Store value = array[front].

                 Step 4:  Increment front  by 1.
                 Step 5:  return value.
                 Step 6:  Stop.
              c.  Displaying the contents in Queue
                 Step 1:  Start.

                 Step 2:  Initialise variable i to front.
                 Step 3:  Repeat steps 3 and 4 while i < rear.
                 Step 4:  Display array[i].
                 Step 5:  Increase i by 1.

                 Step 6:  Stop.

              3.5.10 Algorithms on operations in LINKED LIST
              A linked list is a linear data structure that has two parts namely the data and the address of the next node to which it
              is connected. Linked list elements are not stored at a contiguous location. [It is discussed in detail in the later part of
              the book]

              A linked list is a linear data structure where elements are not stored at a contiguous location. Instead, the elements
              are linked using pointers.



                114114  Touchpad Computer Science-XII
   111   112   113   114   115   116   117   118   119   120   121