Pageviews

Tuesday, 28 July 2020

+2].3-Data Structures and Operators Previous Questions Chapter wise


                             PLUS TWO  COMPUTER SCIENCE


                    Second Year Computer Science Previous Questions Chapter wise ..

                                                  Chapter 2.Data Structures and Operators

                                       






1. Attempting to insert in an already full stack leads to _________


   Ans. Overflow

2. Explain how push operation is done in a stack. 

      Push Operation is the process of inserting a new data item into the stack at Top position. Once the stack is full and if we attempt to insert an item, an impossible situation arises, known as stack overflow

3. Linked list usually do not have the problem of overflow. Discuss. 

           Linked list is a dynamic data structure.It grows as when new data are added in the list and shrinks whenever new data is removed from the list.The memory allocation takesplace during the execution time just when new item inserted in the list.So linked list do not face over.

4. Write two advantages of linked list over arrays. 

         The principal benefit of a linked list over a conventional array is that the list elements can be easily inserted or removed without reallocation or reorganization of the entire structure because the data items need not be stored contiguously in memory or on disk, while restructuring an array at run-time is a much more .

5. Consider the following cases:

 (i) Paper cups are arranged on a dining table one above the other.

 (ii) Many people are waiting in a row to tickets for a cinema. Identify and compare the data structures that you know in connection with the above mentioned contexts. 

6. Queue follows the _______ principle. 

    Ans. FIFO

7. How does stack overflow and underflow occur? 

        Once the stack is full and if we attempt to insert an item, an impossible situation arises, known as stack overflow. Pop Operation is the process of deleting an element from the top of a stack. If we try to delete an item from an empty stack, an unfavorable situation arises, known as stack underflow.

 8. Write a procedure to implement traversal operation in a linked list. 

          Step 1: Get the address of the first node from START and store it in Temp.

        Step 2: Using the address in Temp, get the data of the first node and store in Val. 

        Step 3: Also get the content of the link part of this node (i.e., the address of the next node) and store it in Temp.

  Step 4: If the content of Temp is not NULL, go to step 2; 

    otherwise stop

 9. Name the data structure that follows LIFO principle.

 (a) stack (b) queue (c) array (d) linked list 

      Ans. a

 10. Write an algorithm to perform insertion operation in a Queue. 


          Algorithm for Insertion: 

Assume that Q[N] is an array of queue with size N and FRONT and REAR denote the front and rear positions of the queue.
 Let VAL contains the data to be added into the queue.

      Start

  1: If (REAR == -1) Then //Empty status checking

          2: FRONT = REAR = 0 

          3: Q[REAR] = VAL 

          4: Else If (REAR < N-1) Then //Space availability checking

          5: REAR = REAR + 1

         6: Q[REAR] = VAL 

         7: Else 

         8: Print "Queue Overflow "

         9: End of If

            Stop 


11. Name the data structure where memory  allocation is done only at the time of  execution.

      Ans. Dynamic data structure.

12. Write an algorithm to add a new item in to the stack?

            Assume that STACK[N] is an array of stack with size N and TOS denotes the top position of the stack. Let VAL contains the data to be added into the stack. 

       Start

1: If (TOS < N-1) Then //Space availability checking (Overflow)

        2: TOS = TOS + 1 

      3: STACK[TOS] = VAL 

        4: Else 

       5: Print "Stack Overflow "

       6: End of If

         Stop