Data structures and Pseudocode

 



1.Suppose a queue is implemented using a linked list and its front node and rear nodes are tracked by two tracked by two reference variables. which of these reference variables will change into a NONEMPTY queue?

  ans: both will change


2.How much time will be required to generate all the connected components in an undirected graph G with 

  “n” vertices and “e” edges when the graph is represented by an adjacency list?

   ans: o(e+n)


3.Let A, B, C, D, E be sorted sequences having lengths 20,24,30,35,50 respectively, they are to be merged into a single sequence by merging together two sequences at a time. How many comparisons are needed in the worst case by the optimal algorithm?

  ans: 358


4.If a node having two children is deleted from a binary tree, it is replaced by its;

  ans: inorder successor


5.With the following details given about a binary tree, find out the maximum number of nodes in the given tree.

   Height of a binary tree = 5 Nods at level 1= 4

  ans: 63


6.Which data structure is used while transforming infix expressions to postfix expressions?

  ans: stack


7.Consider an array A with 5 elements ;


  A={2,8,5,6,1}


  Person X wants to sort the array in ascending order, for which he is using bubble sort. How will the array look like three passes?

  ans: 21568


8.Consider the following arithmetic expression written in infix notation:


  A + (B*C)

 

  Find the postfix expression of the above expression.

  ans: ABC*+


9.Consider a stack of integers. The stack is allocated 30 memory cells. It is given that stack overflow occurs at the 7th push operation occupied memory cells before the push operations were performed?

 ans: 24


10.Which of the following sorting techniques uses a priority queue?

   ans: Heapsort


11.What will be the output of the following pseudocode?


  Integer p, q, r


   Set p = 4, q = 6, r = 8

   q = 3 + q

   for(each r from 4 to 5)

   p = 6 + p

   q = (q + q) + p

   End for

   Print p + q

   ans: 88


12.2.Consider the statements are given below


 


   1. In the X data structure, the items are popped in the same order in which they are pushed


    2. In the Y data structure, the items are popped in the opposite of the order in which they were pushed.


 


    Identify X and Y.


     ans: X-queue, Y-stack



13.What will be the output of the following pseudocode?

   1. Integer a, b, c

    2.set a-7,b-4,c-8

     3.if((a+b) > (c- a))

     4.c=a

      5. End if

     6.Print a + b + c

  ans:18


14.Consider the following types of queues


1. Deque 4

2. Priority queue

3. Circular queue

Which of the above queues is also called ring buffer?

 ans:3


15.Alex was explaining a data structure, X to his students. To explain X, he asked the students to consider a scenario in which there is a straight line of people in front of a 

  billing counter where the person that came first is served first. What is the data structure X being taught by Alex?

 ans: queue


16.what will be the output of the pseudocode?

  1. Integer a, b, c

   2. Set a = 1, b = 6, c = 5

    3. c = 2 + b

    4. a = b + c

    5. b = (a + c) + b

     6. Print a + b + c

  ans: 50


17.Fill in the blank with a suitable option

    When all data is placed in memory, then sorting is called ………sorting

  ans: bucket


18.Consider the following sorting techniques

1. Radix Sort

2. Quicksort 

Which of the above sorting techniques use(s) hardware cache

 

ans:1 only


19.Consider an array of integers A-(1,2,3). The following operations are performed

1) 3 is appended

2) 2 is appended. 

3) 1 is appended.

Calculate the value of A[-2]+A[2] after all the operations have been performed.


ans: 5


20.What will be the output of the following pseudocode?

1. Integer p, q, r

2. Set p = 1, q = 8, r = 6

3. if (8<p OR q<p)

4.r = (p + 1) + p 

5.q = (q + 10) + q

6. End if

7.Print p + q + r


ans: 15


21.Consider an array of integers A={1,2,3). The following operations are performed on the army.

1) 3 is appended.

2) the Last element is deleted.

3) 2 is appended.

4) the Last element is deleted.

5) 1 is appended.

Calculate the value of A[-2]+A[2] after all the operations have been performed

 ans: 0


22.Which class of sorting algorithms can handle massive amounts of data?

  ans : external sorting


23.After the above operations have been performed, dequeue operation is performed n times such that the number of elements is the same. What will be the sum of all elements present in the resultant queue?


   ans: 19

24.A stack is implemented using an array arr = {1, 2, 1, 2, 3). What would be the order of popped elements, 

  if it is given that the last element of the array is inserted first in the stack?

 ans: 12123


Post a Comment

Previous Post Next Post