Assessment Tutorial 1 Questions & Solns

ASSESSMENT TUTORIAL – 1
1.      After each iteration in bubble sort

A - at least one element is at its sorted position.
B - one less comparison is made in the next iteration.
C - Both A & B are true.
D - Neither A or B are true.
2.      node.next ->node.next.next; will make

A - node.next inaccessible
B - node.next.next inaccessible
C - this node inaccessible
D - none of the above

3.      In a circular linked list

A - There is no beginning and no end.
B -  Components are arranged hierarchically.
C -  Forward and backward traversal within the list is permitted.
D - None of the above

4.      What is the output of following function for start pointing to first node of following linked list?
1->2->3->4->5->6
void fun(struct node* start)
{
if(start == NULL)
return;
printf("%d  ", start->data);

if(start->next != NULL )
fun(start->next->next);
printf("%d  ", start->data);
}
A - 1 4 6 6 4 1
B - 1 3 5 1 3 5
C - 1 2 3 5
D - 1 3 5 5 3 1

5.      In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is

A - log 2 n
B - n/2
C - log 2 n – 1
D – n

6.      Given the integer (size 2 bytes) 2-dimensional  array , which stores in row major order, Find the address of a [1] [3]
Note:  Array subscript starts for 0 and base address is 1000

10
60
30
55
20
90
80
65
50
40
75
79





A.1014B.    1012       C.    1022      D.    1020
7.      What will be the content in the stack after operation g
                                           I.            S.push(7);
                                        II.            S.push(20);
                                     III.            S.push(35);
                                     IV.            S.pop();
                                        V.            S.push(14);
                                     VI.            S.pop();
                                  VII.            S.pop();

                        A.    7        B.    Underflow       C.    Empty      D.    14

8.      Consider the following stack of size 5. Top=2.  Stack: A,B,C. Describe the stack when the following operations take place:
                                                    I.            D is pushed
                                                   II.            E  is pushed
                                                  III.            Pop the element
                                                 IV.            F  is pushed
                                                   V.            G  is pushed
                                                VI.            Pop the element 
What will be the output of the operation f 
                        A - G  
                        B - Overflow error 
                        C - Underflow error 
                         D –F

9.      Let A B C D E be the input sequence.  Find the invalid  output sequence by performing stack operations
                                                              i.      E  D    C    B    A
                                                            ii.      A     B    C    D    E
                                                          iii.      B     A    E    C    D
                                                          iv.      C     B    A    D    E

A - i
B - ii
C - iii
D – iv

10.  What does the following Algorithm do?
 
Step 1: Check whether list is Empty (head == NULL)
Step 2: If it is Empty then, display 'List is Empty!!! Deletion is not             possible' and  terminate the function.
Step 3: If it is Not Empty then, define two Node pointers 'temp1' and        'temp2' and initialize 'temp1' with head.
Step 4: Check whether list has only one Node (temp1 → next == head)
Step 5: If it is TRUE. Then, set head = NULL and delete temp1. And       terminate from  the function. (Setting Empty list condition)
Step 6: If it is FALSE. Then, set 'temp2 = temp1 ' and move temp1 to        its next    node. Repeat the same until temp1 reaches to the last    node in the             list. (until temp1 → next == head)
Step 7: Set temp2 → next head and delete temp1.

A - Deleting from End of the list
B - Deleting from Beginning of the list
C - Deleting from selected node of the list
D –None of the above
11.  A single array A[1..MAXSIZE] is used to implement two stacks. The two stacks grow from opposite ends of the array. Variables top1 and top 2 (top1< top 2) point to the location of the topmost element in each of the stacks. If the space is to be used efficiently, the condition for “stack full” is
            (a) top1 = MAXSIZE/2) and (top2 = MAXSIZE/2+1)
            (b) top1 + top2 = MAXSIZE
            (c) (top1 = MAXSIZE/2) or (top2 = MAXSIZE)
            (d) top1 = top2 -1

            Ans: d
12.  The postfix form of A*B+C/D is
            (A) *AB/CD+                                     (B) AB*CD/+
            (C) A*BC+/D                                     (D) ABCD+/*

            Ans:b

13.  Let the following circular queue can accommodate maximum six elements with the
            following data  front = 2 rear = 4 queue = _______; L, M, N, ___, ___. What will happen             after ADD O operation takes place?
           
            (A) front = 2 rear = 5  queue = ______; L, M, N, O, ___
            (B) front = 3 rear = 5  queue = L, M, N, O, ___
            (C) front = 3 rear = 4  queue = ______; L, M, N, O, ___
            (D) front = 2 rear = 4  queue = L, M, N, O, ___
           
            Ans:A
14.  What is the postfix form of the following prefix *+ab–cd
            (A) ab+cd–*                           (B) abc+*–
            (C) ab+*cd–                           (D) ab+*cd–
           
            Ans:A

15.  Answer of following postfix expression: 2,3,10+*8,2/-

            a. 20                b. 22                c. 23                d. 24

Comments