Page 113 - DCAP407_DATA_STRUCTURE
P. 113

Data Structure



                                          Output:
                                          When you run the program, the following output is obtained:
                                          1.   Create List

                                          2.   Add at beginning
                                          3.   Add after
                                          4.   Display
                                          5.   Exit
                                          Enter your choice: 1
                                          Enter the number of nodes you want to add: 2

                                          Enter the element: 10 20
                                          1.   Create List
                                          2.   Add at beginning
                                          3.   Add after
                                          4.   Display
                                          5.   Exit
                                          Enter your choice: 4
                                          List is: 10 20

                                          1.   Create List
                                          2.   Add at beginning
                                          3.   Add after
                                          4.   Display
                                          5.   Exit
                                          Enter your choice: 3

                                          Enter the element: 30
                                          Enter the position after which you want to insert the element:2
                                          1.   Create List
                                          2.   Add at beginning
                                          3.   Add after
                                          4.   Display
                                          5.   Exit

                                          Enter your choice: 4
                                          List is: 10 20 30
                                          In this example:
                                          1.   A list named  node  is created with a data field named value  and link field
                                              named *link

                                          2.   Four functions are created namely, createlist(), add_beginning(), add_after()
                                              and  Display().  The user has to select the appropriate function  to be
                                              performed.





                          106                     LOVELY PROFESSIONAL UNIVERSITY
   108   109   110   111   112   113   114   115   116   117   118