Page 553 - Computer science 868 Class 12
P. 553

Step 2: Set temporary pointer to the first node
                        Step 3: Repeat steps 4 and 5 until the pointer reaches null. Display product, exit
                        Step 4: Accumulate the product by accessing each node
                        Step 5: Move pointer to the next node Step
                        Step 6: End algorithm
                        METHOD:

                       void Product_Node (Node str)
                       {
                       int s=1;
                       while (str!=null)
                       {
                        s=s*str.n;
                       str=str.next;
                       }
                       System.out.println(“Product=”+s);
                       }
                        (b) Answer the following questions from the diagram of a Binary Tree given below:        [ISC 2020]
                                                                   A


                                                            F            C


                                                         G     H            B


                                                            I     D      E      J

                     Ans.  In linear queue, insertion is done from the rear end, and deletion is done from the front end. In circular queue, the
                         insertion and deletion can take place from any end.
                           (i)  Write the post-order traversal of the left subtree of the above structure.
                     Ans.  post-order traversal of the left subtree - G I D H F
                          (ii)  State the degree of the Nodes E and H.                                           [ISC 2020]
                     Ans.  Degree of E = 0 and Degree of H = 2
                          (iii)  Mention the external nodes of the right subtree.                                [ISC 2020]
                     Ans. The external nodes of the right subtree are E and J.
                    9.  Convert the following infix notation to prefix form: (X + Y) / (Z * W / V)               [ISC 2020]
                   Ans.  Infix to Prefix : (X + Y) / (Z * W / V)
                        = +XY / ( * Z W / V )
                        = +XY / /*ZWV
                        = /+XY/*ZWV
                        = /+XY/*ZWV
                    10.  Convert the following infix notation to postfix form:                                   [ISC 2019]
                        (A + B * C) – (E * F / H) + J
                   Ans.  (A + B * C) – (E * F / H) + J
                        = (A + (BC*)) – ((EF*) / H) + J
                        = (ABC *+) – (EF * H/) + J
                        = (ABC *+ EF * H/-) + J
                        = ABC*+ EF * H / – J*
                   11.  State the difference between internal nodes and external nodes of a binary tree structure.   [ISC 2019]
                   Ans.  An internal node (also known as an inner node, inode for short, or branch node) is any node of a tree that has child nodes.
                       Similarly, an external node (also known as an outer node, leaf node, or terminal node) is any node that does not have child nodes.
                       Internal nodes are not leaf nodes whereas external nodes are leaf nodes.


                                                                                                                       551
                                                                                                       Data Structures  551
   548   549   550   551   552   553   554   555   556   557   558