You are on page 1of 1233

Final FDS PDF Verified by Sergio

Unit -1

Data structure And Algoritm

1. ______is the first step in solving the problem

A. Understanding the Problem

B. Identify the Problem

C. Evaluate the Solution

D. None of these

Answer: - B

2. There are ______steps to solve the problem

A. Seven

B. Four

C. Six

D. Two

Answer: - C

3. Last step in process of problem solving is to

A. design a solution
B. define a problem
C. practicing the solution
D. organizing the data

Ans-C

4. Thing to keep in mind while solving a problem is

A. input data
B. output data
C. stored data
D. all of above

Ans-D

5.Sequence of statements are shown in order which are from

A. left to right
B. right to left
C. top to down
D. down to top

Ans-A

6.Algorithm is made up of

A. sequence to print data


B. selection
C. repetition
D. all of above

Ans-D

7. Program statement in programming language 'PASCAL' usually


ends with a

A. colon
B. semicolon
C. comma
D. apostrophe

Ans-B

8. Set of diagrams and notes that accompany program


implementation are known as

A. program execution
B. program planning
C. program documentation
D. program existence
Ans-C

9. The branch of computer that deals with heuristic types of problem


is called _________________.

A. system software

B. real time software

C. artificial intelligence

D. none of these

Answer:- C

10. The main measure for efficiency algorithm are-

A. Processor and Memory

B. Complexity and Capacity

C. Data and Space

D. Time and space

Answer:- D

11. Examples of O(1) algorithms are______________.

A. Multiplying two numbers.

B. assigning some value to a variable

C. displaying some integer on console

D. All of the above

Answer:- D

12. The time complexity of binary search is________.

A. O(1)
B. O(log n)

C. O(n)

D. O(n logn)

Answer:- B

13. The time complexity of linear search is________.

A. O(1)

B. O(log n)

C. O(n)

D. O(n logn)

Answer:- C
14. Two main measures for the efficiency of an algorithm are
A. Processor and memory
B. Complexity and capacity
C. Time and space
D. Data and space
Answer:- C
15. Which of the following case does not exist in complexity theory?
A. Best case
B. Worst case
C. Average case
D. Null case
Answer:- D
16. The recurrence relation capturing the optimal execution time of
the Towers of Hanoi problem with n discs is
A. T(n) = 2T(n - 2) + 2
B. T(n) = 2T(n - 1) + n
C. T(n) = 2T(n/2) + 1
D. T(n) = 2T(n - 1) + 1
Answer:- D

17. Any input or output operation of program flowcharts are shown in


symbol of

A. circle
B. trapezoid
C. rhombus
D. parallelogram

Ans-D

18. To show selection in Jackson method, circle is drawn around


choices at the

A. top right of page


B. top left of page
C. bottom right of page
D. bottom left of page

Ans.A

19 What is the asymptotic complexity in terms of n?


A. O(nlog n)
B. O(n)
C. O( n)
D. O(log n)
E. O(n^2 )
Answer:- D
.
20. Two main measures for the efficiency of an algorithm are

a. Processor and memory


b. Complexity and capacity
c. Time and space
d. Data and space
Ans: c

21. Which of the following case does not exist in complexity theory

a. Best case
b. Worst case
c. Average case
d. Null case
Ans: d

22. The complexity of merge sort algorithm is

a. O(n)
b. O(log n)
c. O(n2)
d. O(n log n)
Ans d
23.Which of the following data structure is linear data structure?

a. Trees
b. Graphs
c. Arrays
d. None of above
Ans c

24. Finding the location of the element with a given value is:

a. Traversal
b. Search
c. Sort
d. None of above
Ans : b

25.. Linked lists are best suited

a. for relatively permanent collections of data


b. for the size of the structure and the data in the structure are
constantly changing
c. for both of above situation
d. for none of above situation
Ans : b

26. All variables used in any program must be declared first in

A. FIX statement
B. VAR statement
C. REF statement
D. REP statement

Ans-B

27. Symbol which is drawn for repetition in top right of particular


step is classified as
A. division
B. addition
C. subtraction
D. multiplication

Ans-D

28. The operation of processing each element in the list is known as

a. Sorting
b. Merging
c. Inserting
d. Traversal
Ans : d

29. Third step in producing a program is to

A. test the program


B. debug a program
C. calculate costs
D. both A and B

Ans-D

30. 32. Which of the following data structure is not linear data
structure?

a. Arrays
b. Linked lists
c. Both of above
d. None of above
Ans D
Answer

Answer
Answer

Answer

swer

Answer

Answer
UNIT-2 ARRAY

1.Array is a …………

A.Linear data structure.

B.Non linear data structure.

C.Complex Data structure.

D.None of the above.

Ans-A

2.The memory addres of the first element of an array is called……..

A.floor address.

B.foudation array.

C.first address.

D.base address.

Ans-D

3.The parameter passing mechanism for an array is……………..

A.Call by value.

B.call by reference.

C.Call by result.

D.None of the above

Ans-B

4…………….Is the following data structure are indexed Structure.

A.linked list.

B.linear array.

C.both of the above.

D.None of the above.

Ans-B.

5.Two dimensional Arrays are called ………… .

A.table arrays
B.Matrix Arrays .

C.Bothe oaf the above.

D.one of the above.

Ans.C

6……………Data structure store the homogenous data elements,

A.Arrays

B.Records.

C.Pointer.

D.None.

Ans-A

7……………. Is the data structure is not linear data structure.

A.Arrays.

B.Linkesd list

C.Both of the above.

D.None of the above.

Ans-D

8……………is the linear data structure.

A. Trees,
B. Graphs.
C. Arrays.
D. None of the above.

Ans-C

9.Finding the location of the element given value is……..

A . Traversal.

B . Search.

C. Sort.

D. None of the above.

Ans-B

10. What are the application af array….


A. Sparse matrix.

B. Orded list,

C.Bothe A &B.

D.none.

Ans-C

11.Sparse matrix is a matrix………

A. which contin very all non-zero element.

B .which contin very few non-zero element.

C.which contain very all zero element.

D.which contains all negative elements.

Ans-B

12.time complexity of fast transprse algorithm of sparse matrix .

A. O(n).

B, O(log n).

C.O(n^2).

D.O(n log n).

Ans.A

13.Time complexty of simple Transporse algorithm of Sparse matrix is…………

A.O(n).

B.O(log n).

C.O(n^2 ).

D.O(n log n).

Ans.C

14.In fast transporse algorithm of in first step……………….

A.Number of element in Zero column.

B.Number of element in each column.

C.count no of rows.
D.Count number of columns.

Ans-A

15.The smallest element of an array index is called as …………

A.Upper bound

B.Lower bound

C.range.

D.Extraction

Ans-B

16.When new data are to be inserted into a data structure but there is no available space this
situation is usually called……

A.underflow

B.overflow

C.housefull

D.saturated.

17.What will be the value of war[2][1][0]?

A.5.

B.7.

C.9.

D.11.

Ans.D

18.which of the following is not possible with an array in C porgraming with an array in c programing
language ……

A.Decleration

B.Defination.

C.Dynamic Alloaction.

D.Array of string.

Ans-C

19.index of array in C progarming lang start from…..


A.0

B.1

C.either 0 or 1

D.undefind

Ans-A

20.which of the following data structure cant be store the non homogenous data elements

A.Arrays

B.Record

C.Pointer

D.Stack

Ans-A

21.the use of pointer to refer element of a data structure in which elements are logically adjacent
is….

A.pointer

B.linked Allocaton

C.stack.

D.queue

Ans-B

22.Arrays are the best data structures……

A.for relative perment coolecton of data.

B.for the size of the structure and the data in the structure and the data in the structure are
consatnltly changing.

C.for both of the above situatin.

D.for non of the above situation.

Ans-A

24.A --------- does not keep track of addres of every element in the list.

A.Stack

B.String
C.Linear array.

D.Queue.

Ans-C

25.The memory address of the first element of an array is called …..

A.floor addres

B. Foundatin address,

C.First Address.

D.base address.

Ans-D

26.Two dimensional array are also called……

A.table arrays

B.matrix array

C.both of the above

D. none of the above

Ans-C

27.An array element are always stored in………….memory location.

A.Sequense.

B.Random

C,Sequential and Random

D.None of the above

Ans-A

28.Size of array need not be specified ,when……..

A.initialsation is a part of definattion

B.it is a declaration

C.it is formal parameter

D.All of these

Ans-D
29.Array passed as an argument to a function is inerprested as….

A.Address of the array.

B.Value of the first element of the array.

C.Address of the first element of the array.

D.Number of element of the array.

Ans.C

30.The extra key inseted at the end of the array is called a

A.End key

B.Stop key

C.Sential

D.Transposition

Ans-C
Data Structure Multiple Choice Questions & Answers Pdf

Question: 1

A data structure in which linear sequence is maintained by


pointers is known as

(A) Array

(B) Stack

(C) Linked list

(D) Pointer-based data structure

Ans: C

Linked list

Question: 2

Which of the following data structure works on the principle of


First Come First Serve?

(A) Priority queue

(B) Heap

(C) Stack

(D) Queue

Ans: D

Queue
Question: 3

A ____ is a linear collection of self-referential structures, called


nodes, connected by pointer links.

(A) Queue

(B) Linked list

(C) Tree

(D) Stack

Ans: B

Linked list

Question: 4

A queue where all elements have equal priority is a

(A) ILFO data structure

(B) LILO data structure

(C) FIFO data structure

(D) LIFO data structure

Ans: C

FIFO data structure

Question: 5

A file that is only read by a program is known as ____


(A) Input file

(B) Temporary file

(C) Work file

(D) Input/output file

Ans: A

Input file
Data Structure Objective Questions & Answers Pdf

Question: 1

Which of the following sorting algorithm is the slowest?

(A) Bubble sort

(B) Heap sort

(C) Shell sort

(D) Quick sort

Ans: A

Bubble sort

Question: 2

Which of the following data structure can be used to represent


many-to-many relation?

(A) B-tree

(B) Binary tree

(C) Graph

(D) All of above

Ans: C

Graph

Question: 3
Which of the following statement is not true about linked lists?

(A) Element in a linked list, if it is sorted, can be quickly searched


by applying binary search technique

(B) Elements are not necessarily stored in contiguous locations

(C) Insertions and deletions can be performed efficiently as


compared to arrays

(D) Linked list is a dynamic structure

Ans: A

Element in a linked list, if it is sorted, can be quickly searched by


applying binary search technique

Question: 4

Which of the following is not a linear data structure?

(A) Stack

(B) Queue

(C) Linked list

(D) Binary tree

Ans: D

Binary tree

Question: 5
Which of the following data structure permits insertion and
deletion operations only on one end of the structure?

(A) Linked list

(B) Array

(C) Stack

(D) Queue

Ans: C

Stack
Data Structure Questions & Answers Pdf

Question: 1

Which of the following data structure is more appropriate to


represent a heap?

(A) Two-dimensional array

(B) Doubly linked list

(C) Linear Array

(D) Linked list

Ans: C

Linear Array

Question: 2

Minimum number of fields in each node of a doubly linked list is


____

(A) 2

(B) 3

(C) 4

(D) None of the above

Ans: B

3
Question: 3

A graph in which all vertices have equal degree is known as ____

(A) Complete graph

(B) Regular graph

(C) Multi graph

(D) Simple graph

Ans: A

Complete graph

Question: 4

A vertex of in-degree zero in a directed graph is called a/an

(A) Root vertex

(B) Isolated vertex

(C) Sink

(D) Articulation point

Ans: C

Sink

Question: 5

A graph is a tree if and only if graph is

(A) Directed graph


(B) Contains no cycles

(C) Planar

(D) Completely connected

Ans: B

Contains no cycles
Data Structure Quiz Questions & Answers Pdf

Question: 1

A data structure in which linear sequence is maintained by


pointers is known as

Linked list

Question: 2

Which of the following data structure works on the principle of


First Come First Serve?

Queue

Question: 3

A ____ is a linear collection of self-referential structures, called


nodes, connected by pointer links.

Linked list

Question: 4

A queue where all elements have equal priority is a

FIFO data structure

Question: 5

A file that is only read by a program is known as ____

Input file

Question: 6
Which of the following sorting algorithm is the slowest?

Bubble sort

Question: 7

Which of the following data structure can be used to represent


many-to-many relation?

Graph

Question: 8

Which of the following statement is not true about linked lists?

Element in a linked list, if it is sorted, can be quickly searched by


applying binary search technique

Question: 9

Which of the following is not a linear data structure?

Binary tree

Question: 10

Which of the following data structure permits insertion and


deletion operations only on one end of the structure?

Stack
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

Data Structure MCQ


1) How can we describe an array in the best possible way?

a. The Array shows a hierarchical structure.

b. Arrays are immutable.

c. Container that stores the elements of similar types

d. The Array is not a data structure

Hide Answer Workspace

Answer: c

Explanation: The answer is c because array stores the elements in a


contiguous block of memory of similar types. Therefore, we can say
that array is a container that stores the elements of similar types.

2) Which of the following is the correct way of declaring an array?

a. int javatpoint[10];

b. int javatpoint;

c. javatpoint{20};

d. array javatpoint[10];

Hide Answer Workspace

Answer: a

Explanation: The answer is a because int specifies the type of the


array, javatpoint is the name of the array, and 10 is the size of the
array enclosed within the square brackets.

3) How can we initialize an array in C language?

https://www.javatpoint.com/data-structure-mcq 1/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

a. int arr[2]=(10, 20)

b. int arr(2)={10, 20}

c. int arr[2] = {10, 20}

d. int arr(2) = (10, 20)

Hide Answer Workspace

Answer: c

Explanation: The answer is c because the values assigned to the array


must be enclosed within a curly bracket.

4) Which of the following is the advantage of the array data structure?

a. Elements of mixed data types can be stored.

b. Easier to access the elements in an array

c. Index of the first element starts from 1.

d. Elements of an array cannot be sorted

Hide Answer Workspace

Answer: b

Explanation: The answer is b because the elements in an array are


stored in a contiguous block of memory, so it is easier to access the
elements of an array through indexing.

5) Which of the following highly uses the concept of an array?

a. Binary Search tree

b. Caching

c. Spatial locality
https://www.javatpoint.com/data-structure-mcq 2/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

d. Scheduling of Processes

Hide Answer Workspace

Answer: c

Explanation: The answer is c, i.e., Spatial locality. Here, spatial locality


means that the instruction accessed recently, then the nearby memory
location would be accessed in the next iteration. As we know that in an
array, all the elements are stored in a contiguous block of memory, so
spatial locality is accessed quickly.

6) Which of the following is the disadvantage of the array?

a. Stack and Queue data structures can be implemented through an


array.

b. Index of the first element in an array can be negative

c. Wastage of memory if the elements inserted in an array are lesser


than the allocated size

d. Elements can be accessed sequentially.

Hide Answer Workspace

Answer: c

Explanation: The answer is c. For example, if we have an array of size


10 elements and we have inserted only 5 elements in an array then
there is a wastage of 5 memory blocks which cannot be utilized by
another variable.

7) What is the output of the below code?

#include <stdio.h>

int main()

int arr[5]={10,20,30,40,50};

printf("%d", arr[5]);

return 0;

a. Garbage value

b. 10

c. 50

https://www.javatpoint.com/data-structure-mcq 3/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

d. None of the above

Hide Answer Workspace

Answer: a

Explanation: The answer is a because the indexing in an array starts


from 0, so it starts from arr[0] to arr[4]. If we try to access arr[5] then
the garbage value will be printed.

8) Which one of the following is the size of int arr[9] assuming that int
is of 4 bytes?

a. 9

b. 36

c. 35

d. None of the above

Hide Answer Workspace

Answer: b

Explanation: The answer is b because the size of int type data is 4


bytes. The array stores 9 elements, so the size of the array is 9*4=36
bytes.

9) Which one of the following is the process of inserting an element in


the stack?

a. Insert

b. Add

c. Push

d. None of the above

Hide Answer Workspace

Answer: c

Explanation: The answer is c. In stack, the process of inserting an


element is known as a push operation.

10) When the user tries to delete the element from the empty stack
then the condition is said to be a ____

https://www.javatpoint.com/data-structure-mcq 4/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

a. Underflow

b. Garbage collection

c. Overflow

d. None of the above

Hide Answer Workspace

Answer: a

Explanation: The answer is a. Underflow is a condition that occurs


when user tries to implement the pop operation in the empty stack.

11) If the size of the stack is 10 and we try to add the 11th element in
the stack then the condition is known as___

a. Underflow

b. Garbage collection

c. Overflow

d. None of the above

Hide Answer Workspace

Answer: c

Explanation: The answer is c because the stack is full with its 10


elements, and inserting one more element in a stack will lead to the
stack overflow.

12) Which one of the following is not the application of the stack data
structure

a. String reversal

b. Recursion

c. Backtracking

d. Asynchronous data transfer

Hide Answer Workspace

Answer: d

Explanation: The answer is d. The first three options are the stack
applications, but option d is not a stack application. The queue data
structure is used for synchronization between the processes.

https://www.javatpoint.com/data-structure-mcq 5/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

13) Which data structure is mainly used for implementing the recursive
algorithm?

a. Queue

b. Stack

c. Binary tree

d. Linked list

Hide Answer Workspace

Answer: b

Explanation: The answer is b. Recursion means calling the function


itself again. Stack is used to maintain the previous records of the
function.

14) Which data structure is required to convert the infix to prefix


notation?

a. Stack

b. Linked list

c. Binary tree

d. Queue

Hide Answer Workspace

Answer: a

Explanation: The answer is a, i.e., stack. Stack is a data structure


used to reverse the order of the operators in the expression. It is also
used as a storage structure that stores all the operators and print all
the operators when all the operands have appeared.

15) Which of the following is the infix expression?

a. A+B*C

b. +A*BC

c. ABC+*

d. None of the above

Hide Answer Workspace

Answer: a

https://www.javatpoint.com/data-structure-mcq 6/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

Explanation: The answer is a, i.e., A+B*C because, in infix notation,


all the operators appear between the operands.

16) Which of the following is the prefix form of A+B*C?

a. A+(BC*)

b. +AB*C

c. ABC+*

d. +A*BC

Hide Answer Workspace

Answer: d

Explanation: The answer is d. The prefix notation means all the


operators that appear before operand.

To convert the infix expression into a prefix expression, we will move


the operator to the left of the parenthesis as shown in the below figure.

17) Which of the following is not the correct statement for a stack data
structure?

a. Arrays can be used to implement the stack

b. Stack follows FIFO

c. Elements are stored in a sequential manner

d. Top of the stack contains the last inserted element

Hide Answer Workspace

Answer: b

Explanation: The answer is b because Stack does not follow FIFO. It


follows LIFO.

18) If the elements '1', '2', '3' and '4' are added in a stack, so what
would be the order for the removal?

a. 1234

b. 2134

c. 4321

d. None of the above

Hide Answer Workspace


https://www.javatpoint.com/data-structure-mcq 7/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

Answer: c

Explanation: The answer is c because stack follows LIFO, which means


that the element inserted at the last will be removed first.

19) What is the outcome of the prefix expression +, -, *, 3, 2, /, 8, 4,


1?

a. 12

b. 11

c. 5

d. 4

Hide Answer Workspace

Answer: c

Explanation: Reverse of the prefix expression: 1, 4, 8, /, 2, 3, *, -, +

Reading of Top of the Stack representation


prefix stack

1 1

4 4

https://www.javatpoint.com/data-structure-mcq 8/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

8 8

/ (8/4)

2 2

https://www.javatpoint.com/data-structure-mcq 9/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

3 3

* (2*3)

- (2*3) - (8/4)

+ (2*3) - (8/4)
+1

https://www.javatpoint.com/data-structure-mcq 10/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

The infix expression of the above prefix expression is:

(2*3) - (8/4) +1

6 -2 +1 = 5

20) The minimum number of stacks required to implement a stack is


__

a. 1

b. 3

c. 2

d. 5

Hide Answer Workspace

Answer: c

Explanation: The answer is 2. In Queue, one stack is required for the


enqueue operation, and another stack will be used for the dequeue
operation. The first stack is considered as the input stack whereas the
second stack is considered as the output stack.

21) Which one of the following node is considered the top of the stack
if the stack is implemented using the linked list?

a. First node

b. Second node

c. Last node

d. None of the above

Hide Answer Workspace

Answer: a

Explanation: The answer is a, i.e., First node. As we know, that last


inserted element in the stack is considered as the top of the stack.
Whenever the element is added to the linked list, it is always added at
the beginning of the list. Therefore, we can say that the first node in
the linked list is considered as the top of the stack.

22) Consider the following stack implemented using stack.

#define SIZE 11

struct STACK

https://www.javatpoint.com/data-structure-mcq 11/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

int arr[SIZE];

int top=-1;

What would be the maximum value of the top that does not cause the
overflow of the stack?

a. 8

b. 9

c. 11

d. 10

Hide Answer Workspace

Answer: d

Explanation: The answer is 10. The maximum size of the array is 11;
therefore, we can insert 11 elements in the stack. The top value is
initialized by -1, and on every insertion, the top value gets
incremented.

23) What is another name for the circular queue among the following
options?

a. Square buffer

b. Rectangle buffer

c. Ring buffer

d. None of the above

Hide Answer Workspace

Answer: c

Explanation: The circular queue is also known as a ring buffer. In a


circular queue, the last element is connected back to the first element
of the queue that forms a circle. Therefore, the structure of a circular
queue is also known as a ring structure.

24) If the elements '1', '2', '3' and '4' are inserted in a queue, what
would be order for the removal?

a. 1234

b. 4321

https://www.javatpoint.com/data-structure-mcq 12/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

c. 3241

d. None of the above

Hide Answer Workspace

Answer: a

Explanation: The answer is a, i.e., 1234. The queue follows the FIFO
principle in which the element inserted first will be removed first.

25) A list of elements in which enqueue operation takes place from one
end, and dequeue operation takes place from one end is__

a. Binary tree

b. Stack

c. Queue

d. Linked list

Hide Answer Workspace

Answer: c

Explanation: The answer is Queue. Queue is a data structure in which


insertion takes place from one end, and deletion takes place from one
end.

26) Which of the following principle does Queue use?

a. LIFO principle

b. FIFO principle

c. Linear tree

d. Ordered array

Hide Answer Workspace

Answer: b

Explanation: The answer is FIFO principle. Here, FIFO stands for First-
In-First-Out. It means that the element which is inserted first will also
be removed first.

27) Which one of the following is not the type of the Queue?

a. Linear Queue ⇧

https://www.javatpoint.com/data-structure-mcq 13/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

b. Circular Queue

c. Double ended Queue

d. Single ended Queue

Hide Answer Workspace

Answer: d

Explanation: The answer is d. i.e., single ended queue. Queue has two
ends in which one end is used for the insertion and another end is used
for the deletion. Therefore, it is not possible for the Queue to have a
single ended queue.

28) Which one of the following is the overflow condition if linear queue
is implemented using an array with a size MAX_SIZE?

a. rear = front

b. rear = front+1

c. rear=MAX_SIZE -1

d. rear = MAX_SIZE

Hide Answer Workspace

Answer: c

Explanation: The answer is c, i.e., rear=MAX_SIZE-1. As the size of


the array is MAX_SIZE, so we can insert the elements till MAX_SIZE-1.
If we try to insert the elements of size MAX_SIZE or more than
MAX_SIZE in a queue, then it leads to the overflow condition.

29) Which one of the following is the overflow condition if a circular


queue is implemented using array having size MAX?

a. rear= MAX-1

b. rear=MAX

c. front=(rear+1) mod max

d. None of the above

Hide Answer Workspace

Answer: c

Explanation: The answer is c, i.e., front=(rear+1) mod max. The


overflow condition for the linear queue is rear =MAX-1 as there is no

space left in the Queue if rear = MAX-1. On the other hand, in a circular
https://www.javatpoint.com/data-structure-mcq 14/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

queue, the overflow condition is front=(rear+1) mod max because the


last element is connected to the first element in a circular queue.

30) The time complexity of enqueue operation in Queue is __

a. O(1)

b. O(n)

c. O(logn)

d. O(nlogn)

Hide Answer Workspace

Answer: a

Explanation: The answer is a, i.e., O(1). In Queue, the insertion is


performed at the rear end, which is directly accessible; therefore, it
takes O(1) time to insert an element in a Queue.

31) Which of the following that determines the need for the Circular
Queue?

a. Avoid wastage of memory

b. Access the Queue using priority

c. Follows the FIFO principle

d. None of the above

Hide Answer Workspace

Answer: a

Explanation: The answer is a, i.e., Avoid wastage of memory. In a


linear queue, there are chances of wastage of memory because if the
rear is pointing to the last element whereas the front is pointing to the
element other than the first element; it means that spaces allocated
before the front are free, but it cannot be reused as rear cannot be
incremented. In contrast, the last element is connected to the first
element in a circular queue; if initial spaces are vacant, then rear can
be incremented by using the statement (rear+1) mod max where max
is the size of the array. Therefore, we conclude that the circular queue
avoids wastage of memory.

32) Which one of the following is the correct way to increment the rear
end in a circular queue?

https://www.javatpoint.com/data-structure-mcq 15/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

a. rear =rear+1

b. (rear+1) % max

c. (rear % max) + 1

d. None of the above

Hide Answer Workspace

Answer: b

Explanation: The answer is b. It ensures that the rear will have the
value from 0 to max-1; if the rear end points to the last position, and
we increment the rear end using (rear+1) % max, then rear will point
to the first position in the queue.

33) Consider the following code.

int fun()

if(isEmpty())

return -10;

else

int n;

n= q[front];

front++;

return n;

Which operation does the above code perform?

a. Enqueue

b. Dequeue

c. Return the front element

d. Both b and c

Hide Answer Workspace

Answer: d

https://www.javatpoint.com/data-structure-mcq 16/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

Explanation: The answer is d because two operations are performed in


the above code. The first one is returning the value of the front with the
help of the statement n=q[front], and the second operation is dequeue
(deleting an element) by using the statement front++.

34) In the linked list implementation of queue, where will the new
element be inserted?

a. At the middle position of the linked list

b. At the head position of the linked list

c. At the tail position of the linked list

d. None of the above

Hide Answer Workspace

Answer: c

Explanation: The answer is c. If the queue is implemented using


linked list, then the new element will be inserted at the tail position of
the linked list as Queue follows FIFO principle in which new element will
always be added at the end of the Queue.

35) How many Queues are required to implement a Stack?

a. 3

b. 2

c. 1

d. 4

Hide Answer Workspace

Answer: b

Explanation: The answer is b because one queue is required to


perform the push operation while the other queue is used to perform
the pop operation.

36) Which one of the following is not the application of the Queue data
structure?

a. Resource shared between various systems

b. Data is transferred asynchronously

c. Load balancing

https://www.javatpoint.com/data-structure-mcq 17/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

d. Balancing of symbols

Hide Answer Workspace

Answer: d

Explanation:

The answer is d. The options a, b, and c are the applications of the


Queue data structure while option d, i.e., balancing of symbols is not
the application of the Queue data structure. The option a, i.e., resource
shared between various system is the application of the Queue data
structure as it allows to align all the requests for the resource in a
queue. The option b, i.e., data is transferred asynchronously is a
application of the Queue data structure. Here asynchronously means
that the data received at the different rate as sent.

The option c, i.e., load balancing is also an application of the Queue


data structure because all the requests from the client are stored in the
Queue, and it distributes the requests to the client one by one.

The option d, i.e., balancing of symbols is an application of the stack


data structure.

37) Which of the following option is true if implementation of Queue is


from the linked list?

a. In enqueue operation, new nodes are inserted from the beginning and
in dequeue operation, nodes are removed from the end.

b. In enqueue operation, new nodes are inserted from the end and in
dequeue operation, nodes are deleted from the beginning.

c. In enqueue operation, new nodes are inserted from the end and in
dequeue operation, nodes are deleted from the end.

d. Both a and b

Hide Answer Workspace

Answer: d

Explanation: The answer is d. As we know that Queue has two ends,


i.e., one for the insertion and another one for the deletion. If Queue is
implemented using Linked list then it can be done in either of the ways.

38) The necessary condition to be checked before deletion from the


Queue is__

a. Overflow

https://www.javatpoint.com/data-structure-mcq 18/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

b. Underflow

c. Rear value

d. Front value

Hide Answer Workspace

Answer: b

Explanation: The answer is b, i.e., Underflow. Before deleting an


element from the Queue, we first need to check whether the Queue is
empty or not.

39) Which data structure is the best for implementing a priority queue?

a. Stack

b. Linked list

c. Array

d. Heap

Hide Answer Workspace

Answer: d

Explanation: The answer is d, i.e., Heap. All the data structures that
are given in the above options can be used to implement a priority
queue but the most efficient way of implementing a priority queue is
heap data structure.

40) Which of the following principle is used if two elements in the


priority queue have the same priority?

a. LIFO

b. FIFO

c. Linear tree

d. None of the above

Hide Answer Workspace

Answer: b

Explanation: The answer is b, i.e., FIFO. In a priority queue, if two or


more elements have the same priority then they are arranged based on
the FIFO principle.

https://www.javatpoint.com/data-structure-mcq 19/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

41) Which of the following statement is not true regarding the priority
queue?

a. Processes with different priority can be easily handled

b. Easy to implement

c. Deletion is easier

d. None of the above

Hide Answer Workspace

Answer: c

Explanation: The answer is c. i.e., deletion is easier. In worst case, the


deletion is not easier as we have to traverse to the n elements until the
element to be removed is not found.

42) A linear data structure in which insertion and deletion operations


can be performed from both the ends is___

a. Queue

b. Deque

c. Priority queue

d. Circular queue

Hide Answer Workspace

Answer: b

Explanation: The answer is b, i.e., Deque. The deque is a data


structure in which both insertion and deletion can be performed from
both the ends whereas, in Queue, insertion can be done from one end
and deletion can be performed from another end.

43) In the Deque implementation using singly linked list, what would
be the time complexity of deleting an element from the rear end?

a. O(1)

b. O(n2)

c. O(n)

d. O(nlogn)

Hide Answer Workspace

Answer: O(n) ⇧

https://www.javatpoint.com/data-structure-mcq 20/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

Explanation: The answer is O(n) because we need to traverse till the n


element to delete the element from the rear end.

44) Which of the following data structure allows you to insert the
elements from both the ends while deletion from only one end?

a. Input-restricted queue

b. Output-restricted queue

c. Priority queue

d. None of the above

Hide Answer Workspace

Answer: b

Explanation: The answer is b. The output-restricted queue is one of


the types of the Deque data structure in which insertion is allowed from
both the ends but the deletion is allowed from only one end.

45) What would be the output after performing the following operations
in a Deque?

Insertfront(10);

Insertfront(20);

Insertrear(30);

Insertrear(40);

Deletefront();

Insertfront(50);

Deleterear();

Display();

a. 10, 20, 30

b. 50, 10, 30

c. 40, 20, 30

d. None of the above

Hide Answer Workspace

Answer: b

Explanation:

The answer is b.

Let's dry run the above code.
https://www.javatpoint.com/data-structure-mcq 21/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

When insertfront(10) is called, deque would be:

10

When insertfront(20) is called, the deque would be:

20 10

When insertrear(30) is called, the deque would be:

20 10 30

When insertrear(40) is called, the deque would be:

20 10 30 40

When deletefront() is called, the deque would be:

10 30 40

When insertfront(50) is called, the deque would be:

50 10 30 40

When deleterear() is called, the deque would be:

50 10 30

46) In a circular queue implementation using array of size 5, the array


index starts with 0 where front and rear values are 3 and 4
respectively. Determine the array index at which the insertion of the
next element will take place.

a. 5

b. 0

c. 1

d. 2

Hide Answer Workspace

Answer: b

Explanation: The answer is b, i.e., 0. As it is mentioned in the


question that the size of the array is 5; therefore, the range would be
from 0 to 4. In a circular queue, the last element is connected to the
first element; the value of rear is 4 so when we increment the value

then it will point to the 0th position of the array.

47) If circular queue is implemented using array having size MAX_SIZE


in which array index starts with 0, front points to the first element in
the queue, and rear points to the last element in the queue. Which one

https://www.javatpoint.com/data-structure-mcq 22/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

of the following conditions used to specify that the circular queue is


empty?

a. Front=rear= -1

b. Front=rear=0

c. Front=rear+1

d. None of the above

Hide Answer Workspace

Answer: a

Explanation: The answer is a, i.e., front=rear= -1. When the circular


queue is empty means that no element is available in the queue then
the front and rear are initialized with a -1 value.

48) Consider the implementation of the singly linked list having the
head pointer only in the representation. Which of the following
operations can be performed in O(1) time?

i) Deletion of the last node in the linked list


ii) Insertion at the front of the linked list
iii) Deletion of the first node in the linked list
iv) Insertion at the end of the linked list

a. ii

b. both ii and iii

c. both i and iv

d. both i and ii

Hide Answer Workspace

Answer: b

Explanation: The answer is b. As it is mentioned in the above question


that there is only head pointer pointing to the front node in the list so it
will take O(1) time to insert at the front as well as to delete the first
node from the list. If we try to insert the node at the end or delete the
last node then it will take O(n) time as we need to traverse till the n
elements.

49) What would be the time complexity if user tries to insert the
element at the end of the linked list (head pointer is known)?

a. O(1)

b. O(n)
https://www.javatpoint.com/data-structure-mcq 23/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

c. O(logn)

d. O(nlogn)

Hide Answer Workspace

Answer: b

Explanation: The answer is b, i.e., O(n). As it is mentioned in the


above question that head pointer is known, so to insert the node at the
end of the linked list; we have to traverse till the nth node. Therefore,
the time complexity would be O(n).

50) Which of the following is the time complexity to search an element


in the linked list?

a. O(1)

b. O(n)

c. O(logn)

d. O(nlogn)

Hide Answer Workspace

Answer: O(n)

Explanation: The answer is O(n). The worst-case time complexity to


search an element in the linked list is O(n) because if we have to find
the last element then we need to traverse till the nth node.

51) Consider the following code

struct node

int data;

struct node *next;

node ptr;

Which one of the following is the correct option to create a new node?

a. ptr= (node*)malloc(sizeof(node*))

b. ptr=(node)malloc(sizeof(node))

c. ptr=(node*)malloc(sizeof(node))

d. None of the above


https://www.javatpoint.com/data-structure-mcq 24/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

Hide Answer Workspace

Answer: c

Explanation: The answer is c, i.e., ptr=(node*)malloc(sizeof(node)).


In this statement, we have used a malloc() function for allocating the
memory to the node and ptr is a pointer variable that will point to the
newly created node.

52) Which of the following statement is not true about the doubly
linked list?

a. We can traverse in both the directions.

b. It requires extra space

c. Implementation of doubly linked list is easier than the singly linked


list

d. It stores the addresses of the next and the previous node

Hide Answer Workspace

Answer: c

Explanation: The answer is c. The implementation of doubly linked list


is complex as compared to singly linked list as it needs to store the
addresses of the two nodes, i.e., the previous and the next node. If we
insert or delete the node from the doubly linked list then it needs to
adjust two pointers, previous and the next pointer.

53) What is the maximum number of children that a node can have in
a binary tree?

a. 3

b. 1

c. 4

d. 2

Hide Answer Workspace

Answer: d

Explanation: The answer is d. The binary tree can contain utmost two
children.

https://www.javatpoint.com/data-structure-mcq 25/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

54) Which one of the following techniques is not used in the Binary
tree?

a. Randomized traversal

b. Preorder traversal

c. Postorder traversal

d. Inorder traversal

Hide Answer Workspace

Answer: a

Explanation: The answer is a. The binary tree contains three traversal


techniques, preorder, postorder and inorder traversal.

55) Which of the following options is not true about the Binary Search
tree?

a. The value of the left child should be less than the root node

b. The value of the right child should be greater than the root node.

c. The left and right sub trees should also be a binary search tree

d. None of the above

Hide Answer Workspace

Answer: d

Explanation: The answer is d. All the three options, i.e., a, b and c are
true for the binary search tree. In binary search tree, the left child
should be less than the root node and the right child should be greater
than the value of the root node.

56) How can we define a AVL tree?

a. A tree which is binary search tree and height balanced tree.

b. A tree which is a binary search tree but unbalanced tree.

c. A tree with utmost two children

d. A tree with utmost three children

Hide Answer Workspace

Answer: a

Explanation: The answer is a. An AVL tree is a binary search tree and



height balanced tree.
https://www.javatpoint.com/data-structure-mcq 26/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

57) Why do we prefer Red Black tree over AVL tree?

a. Red Black trees are not strictly balanced

b. Red black tree requires lesser rotations than AVL tree.

c. AVL tree needs more space to store the balance factor.

d. Both b and c

Hide Answer Workspace

Answer: d

Explanation: The answer is d. Red Black tree requires fewer rotations


for inserting or deleting the node whereas AVL tree requires multiple
rotations to balance the tree. AVL tree stores balance factor per node
that requires space whereas Red Black tree stores 1-bit information.

58) Which of the following satisfies the property of the Red Black tree?

a. A tree which is a binary search tree but not strictly balanced tree.

b. A node must be either Red or Black in color and root node must be
black.

c. A tree with maximum three children

d. Both a and b

Hide Answer Workspace

Answer: d

Explanation: The answer is d. Red black tree is a binary search tree


but it is not a strictly balanced tree like AVL tree. In Red Black tree, a
node must be either in Black or Red in color and root node must be in
Black color.

59) What would be the color of newly created node while inserting a
new element in a Red black tree?

a. Black, if the new node is not a root node

b. Red, if the new node is not a root node

c. Black, if the new node is a root node

d. Both b and c

Hide Answer Workspace


https://www.javatpoint.com/data-structure-mcq 27/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

Answer: d

Explanation: The answer is d. The property of Red Black tree is that if


the newly created node is a root node then the color of the node would
be Black otherwise the color of the node would be Red.

60) Identify the AVL tree among the following options?

a. A

b. C

c. Both A and C

d. B

https://www.javatpoint.com/data-structure-mcq 28/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

Hide Answer Workspace

Answer: c

Explanation: The answer is c. Both A and C are the AVL trees but B is
not a AVL tree. As we know that balance factor of every node in AVL
tree should be either -1, 0 or 1. But in case of B, the balance factor of
node 80 is 2, so it is not a AVL tree.

← Prev Next →

For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

Learn Latest Tutorials

SoapUI RPA Manual T.

Cucumber Appium PostgreSQL


Solr MongoDB Gimp

https://www.javatpoint.com/data-structure-mcq 29/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

Verilog Teradata PhoneGap

Preparation

Aptitude Logical Verbal Ability


Reasoning
Aptitude Verbal A.
Reasoning

Interview Company
Questions Interview
Questions
Interview
Company

Trending Technologies

Artificial AWS Tutorial Selenium


Intelligence tutorial
Tutorial AWS
Selenium
AI

Cloud tutorial Hadoop ReactJS


tutorial Tutorial
Cloud
Hadoop ReactJS

Data Science Angular 7 Blockchain


Tutorial Tutorial Tutorial

D. Science Angular 7 Blockchain

Git Tutorial Machine DevOps


Learning Tutorial Tutorial
Git
ML DevOps

B.Tech / MCA

DBMS tutorial

DBMS
https://www.javatpoint.com/data-structure-mcq 30/31
3/23/2021 Data Structure MCQ (Multiple Choice Questions) - javatpoint

Data DAA tutorial


Structures
tutorial DAA

DS

Operating Computer Compiler


System tutorial Network tutorial Design tutorial

OS C. Network Compiler D.

Computer Discrete Ethical


Organization and Mathematics Hacking Tutorial
Architecture Tutorial
E. Hacking
COA D. Math.

Computer Software html tutorial


Graphics Tutorial Engineering
Tutorial Web Tech.
C. Graphics
Software E.

Cyber Automata C Language


Security tutorial Tutorial tutorial

Cyber Sec. Automata C

C++ tutorial Java tutorial .Net


Framework
C++ Java tutorial

.Net

Python tutorial List of Control


Programs Systems tutorial
Python
Programs Control S.

Data Mining
Tutorial

Data Mining

https://www.javatpoint.com/data-structure-mcq 31/31
3/23/2021 Data Structures Algorithms Online Quiz - Tutorialspoint

Data Structures Algorithms Online Quiz

Following quiz provides Multiple Choice Questions (MCQs) related to Data Structures
Algorithms. You will have to read all the given answers and click over the correct answer. If you
are not sure about the answer then you can check the answer using Show Answer button. You
can use Next Quiz button to check new set of questions in the quiz.

Q 1 - A complete graph can have

A - n2 spanning trees

B - nn - 2 spanning trees

C - nn + 1 spanning trees

D - nn spanning trees

Answer : B

Explanation

At maximum, a complete graph can have nn - 1 spanning trees.

Hide Answer

Q 2 - Stack is used for

A - CPU Resource Allocation

https://www.tutorialspoint.com/data_structures_algorithms/data_structures_algorithms_online_quiz.htm 1/4
3/23/2021 Data Structures Algorithms Online Quiz - Tutorialspoint

B - Breadth First Traversal

C - Recursion

D - None of the above

Answer : C

Explanation

Recursive procedures use stacks to execute the result of last executed procedural call.

Show Answer

Q 3 - The following formular is of

left_subtree (keys) ≤ node (key) ≤ right_subtree (keys)

A - Bianry Tree

B - Complete Binary Tree

C - Binary Search Tree

D - All of the above

Show Answer

Q 4 - What could be the worst case height of an AVL tree?

A - 0.97 log n

B - 2.13 log n

C - 1.44 log n

D - n2 log n

Show Answer

https://www.tutorialspoint.com/data_structures_algorithms/data_structures_algorithms_online_quiz.htm 2/4
3/23/2021 Data Structures Algorithms Online Quiz - Tutorialspoint

Q 5 - 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.

Show Answer

Q 6 - How many swaps are required to sort the given array using bubble sort - { 2, 5, 1,
3, 4}

A-4

B-5

C-6

D-7

Show Answer

Q 7 - Which of these alogrithmic approach tries to achieve localized optimum solution −

A - Greedy approach

B - Divide and conquer approach

C - Dynamic approach

D - All of the above

Show Answer

Q 8 - Which of the following algorithm cannot be desiged without recursion −

A - Tower of Hanoi

B - Fibonacci Series

https://www.tutorialspoint.com/data_structures_algorithms/data_structures_algorithms_online_quiz.htm 3/4
3/23/2021 Data Structures Algorithms Online Quiz - Tutorialspoint

C - Tree Traversal

D - None of the above

Show Answer

Q 9 - If locality is a concern, you can use _______ to traverse the graph.

A - Breadth First Search

B - Depth First Search

C - Either BFS or DFS

D - None of the above!

Hide Answer

Q 10 - The worst case complexity of binary search matches with −

A - interpolation search

B - linear search

C - merge sort

D - none of the above

Hide Answer

New Quiz

https://www.tutorialspoint.com/data_structures_algorithms/data_structures_algorithms_online_quiz.htm 4/4
Data Structure Multiple Choice Questions & Answers Pdf

Question: 1

A data structure in which linear sequence is maintained by


pointers is known as

(A) Array

(B) Stack

(C) Linked list

(D) Pointer-based data structure

Ans: C

Linked list

Question: 2

Which of the following data structure works on the principle of


First Come First Serve?

(A) Priority queue

(B) Heap

(C) Stack

(D) Queue

Ans: D

Queue
Question: 3

A ____ is a linear collection of self-referential structures, called


nodes, connected by pointer links.

(A) Queue

(B) Linked list

(C) Tree

(D) Stack

Ans: B

Linked list

Question: 4

A queue where all elements have equal priority is a

(A) ILFO data structure

(B) LILO data structure

(C) FIFO data structure

(D) LIFO data structure

Ans: C

FIFO data structure

Question: 5

A file that is only read by a program is known as ____


(A) Input file

(B) Temporary file

(C) Work file

(D) Input/output file

Ans: A

Input file
Data Structure Objective Questions & Answers Pdf

Question: 1

Which of the following sorting algorithm is the slowest?

(A) Bubble sort

(B) Heap sort

(C) Shell sort

(D) Quick sort

Ans: A

Bubble sort

Question: 2

Which of the following data structure can be used to represent


many-to-many relation?

(A) B-tree

(B) Binary tree

(C) Graph

(D) All of above

Ans: C

Graph

Question: 3
Which of the following statement is not true about linked lists?

(A) Element in a linked list, if it is sorted, can be quickly searched


by applying binary search technique

(B) Elements are not necessarily stored in contiguous locations

(C) Insertions and deletions can be performed efficiently as


compared to arrays

(D) Linked list is a dynamic structure

Ans: A

Element in a linked list, if it is sorted, can be quickly searched by


applying binary search technique

Question: 4

Which of the following is not a linear data structure?

(A) Stack

(B) Queue

(C) Linked list

(D) Binary tree

Ans: D

Binary tree

Question: 5
Which of the following data structure permits insertion and
deletion operations only on one end of the structure?

(A) Linked list

(B) Array

(C) Stack

(D) Queue

Ans: C

Stack
Data Structure Questions & Answers Pdf

Question: 1

Which of the following data structure is more appropriate to


represent a heap?

(A) Two-dimensional array

(B) Doubly linked list

(C) Linear Array

(D) Linked list

Ans: C

Linear Array

Question: 2

Minimum number of fields in each node of a doubly linked list is


____

(A) 2

(B) 3

(C) 4

(D) None of the above

Ans: B

3
Question: 3

A graph in which all vertices have equal degree is known as ____

(A) Complete graph

(B) Regular graph

(C) Multi graph

(D) Simple graph

Ans: A

Complete graph

Question: 4

A vertex of in-degree zero in a directed graph is called a/an

(A) Root vertex

(B) Isolated vertex

(C) Sink

(D) Articulation point

Ans: C

Sink

Question: 5

A graph is a tree if and only if graph is

(A) Directed graph


(B) Contains no cycles

(C) Planar

(D) Completely connected

Ans: B

Contains no cycles
Data Structure Quiz Questions & Answers Pdf

Question: 1

A data structure in which linear sequence is maintained by


pointers is known as

Linked list

Question: 2

Which of the following data structure works on the principle of


First Come First Serve?

Queue

Question: 3

A ____ is a linear collection of self-referential structures, called


nodes, connected by pointer links.

Linked list

Question: 4

A queue where all elements have equal priority is a

FIFO data structure

Question: 5

A file that is only read by a program is known as ____

Input file

Question: 6
Which of the following sorting algorithm is the slowest?

Bubble sort

Question: 7

Which of the following data structure can be used to represent


many-to-many relation?

Graph

Question: 8

Which of the following statement is not true about linked lists?

Element in a linked list, if it is sorted, can be quickly searched by


applying binary search technique

Question: 9

Which of the following is not a linear data structure?

Binary tree

Question: 10

Which of the following data structure permits insertion and


deletion operations only on one end of the structure?

Stack
UNIT-1
Marks distribution for Unit 1

4 + 4+ 2 +2 +1 = 13 Marks (Only 2 Question will be asked for 4 marks , 2 Questions will be asked for 2 Marks,
1 Question will be asked for 1 Mark )
Syllabus for Unit-1

Algorithms- Problem Solving, Introduction to Algorithms, Characteristics of algorithms, Algorithm design


tools: Pseudo code and flowchart, Analysis of Algorithms, Complexity of algorithms- Space complexity, Time
complexity, Asymptotic notation- Big-O, Theta and Omega, standard measures of efficiency.
Data Structures- Data structure, Abstract Data Types (ADT), Concept of linear and Non-linear, static and
dynamic, persistent and ephemeral data structures, and relationship among data, data structure, and algorithm,
From Problem to Program.
Algorithmic Strategies- Introduction to algorithm design strategies- Divide and Conquer, and Greedy strategy.
Recurrence relation - Recurrence Relation, Linear Recurrence Relations, With constant Coefficients,
Homogeneous Solutions. Solving recurrence relations
Reference Book:

• “Fundamentals of Algorithmics”, Brassard & Bratley, ISBN 13-9788120311312


Id 1
Question The most common data types are..............
A Numeric, character, and logical.
B Array, integer and float
C Variable, Character and logical
D main, float and print
Answer A
Marks 2

Id 2
Question Numeric data include...........
A Double and Float
B integers and real numbers

C long int and short int


D None of these
Answer B
Marks 2

Id 3
Question Range for Positive & Negative Integers numbers are.......
A 4,792 or -637
B 5,297 or -376
C 9724 or -367
D 3,297 or -376
Answer B
Marks 2

Page 1
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Id 4
Question structure chart Or interactivity chart Shows -----------------
A input, the processing, and the output;
B a beginning analysis of the problem
C overall layout or structure of the solution;
D a language like solution
Answer C
Marks 2
Unit 1

Id 5
Question IPO chart, shows -----------------
A a language like solution
B a beginning analysis of the problem
C overall layout or structure of the solution;
D input, the processing, and the output;
Answer Correct Option D
Marks 2
Unit 1

Id 6
Question pseudo code shows --------------
A input, the processing, and the output;
B a beginning analysis of the problem
C overall layout or structure of the solution;
D a language like solution
Answer Correct Option D
Marks 2
Unit 1

Id 7
Question ---------------shows the relationship between the modules and the data needed for the
modules.
A coupling diagram and Data Dictionary
B IPO chart
C interactivity chart
D pseudo code
Answer Correct Option A
Marks 2
Unit 1

Page 2
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Id 8
Question Identify the correct sequence of problem analysis chart.
A 1)Given Data, 2)Solution Alternatives,3)Processing Required , 4)Required Results
B 1) Given Data, 2) Required Results , 3) Processing Required , 4)Solution Alternatives
C 1)Processing Required, 2) Required Results , 3)Given Data, 4)Solution Alternatives
D 1) Given Data, 2) Required Results , 3) Solution Alternatives, 4)Processing Required
Answer Correct Option B
Marks 2
Unit 1

Id 9
Question In interactivity chart Dark circle • on module link shows
A module is part of a set but that are not processed many times
B module is not a part of set that are processed many times & in a loop.
C module is part of a set that are processed many times & in a loop.
D None of these
Answer Correct Option C
Marks 2
Unit 1

Id 13
Question arrange the essential data items for IPO Chart in correct order
A 1)Output 2)Processing 3)Module Reference 4)Input
B 1)Input 2)Module 3) Processing Reference 4)Output
C 1)Input 2)Processing 3)Module Reference 4)Output
D None of these
Answer Correct Option C
Marks 4
Unit 1
Id Keep it blank

Id 10
Question If max is a function that returns the larger of the two integers, given as arguments,
then which of the following statements finds the largest of three given numbers
A max(max(a,b),max (a,c))
B max(max(a,b),max (b,c))
C max(b,max (a,c))
D All of these
Answer Correct Option D
Marks 4

Page 3
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 11
Question A function can make…………..
A One throw
B One throw of each scale type
C One throw of each programmer defined type
D As many throws of as many types as necessary
Answer Correct Option D
Marks 2
Unit 1

Id 12
Question Consider the function
find ( int x, int y)
{
return (( x < y ) ? 0 : ( x - y ));
}
Let a, b be two non-negative integers.
The call find{ a, find(a, b)} can be used to find the
A maximum of a,b
B positive difference of a,b
C sum of a,b
D minimum of a,b
Answer Correct Option D
Marks 4
Unit 1

Id 13
Question Let a, b be two non-negative integers. Which of the following calls, finds the positive
difference of a and b ?
A find(a,b) + find(b,a)
B find(a, find(a,b))
C a + find(a,b)
D b + find(a,b)
Answer Correct Option A
Marks 4
Unit 1

Id 14
Question The default parameter passing mechanism is
A call by value

Page 4
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

B call by reference
C call by value result
D none of the above
Answer Correct Option A
Marks 2
Unit 1

Id 15
Question Use of functions
A helps to avoid repeating a set of statements many times
B enhances the logical clarity of the program
C helps to avoid repeated programming across programs
D all of the above
Answer Correct Option D
Marks 2
Unit 1

Id 15
Question Pick the correct statements
A The body of a function should have only one return statement
B The body of a function may have many return statements
C A function can return only one value to the calling environment
D Both (b) and (c )
Answer Correct Option D
Marks 2
Unit 1

Id 16
Question Forward declaration is absolutely necessary
A if a function returns a non integer quantity
B lithe function call precedes its definition
C if the function call precedes its definition and the function returns a non integer
quantity
D none of the above
Answer Correct Option C
Marks 2
Unit 1

Id 17
Question void can be used…………
A as a data type of a function that returns nothing to its calling environment

Page 5
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

B inside the brackets of a function that does not need any argument
C in an expression
D Both (a) and (b)
Answer Correct Option D
Marks 2
Unit 1

Id 18
Question Any C++ program
A must contain at least one function
B need not contain any function
C needs input data
D none of these
Answer Correct Option A
Marks 1
Unit 1

Id 19
Question In a certain language, the expression 5-3+2 x 4+1, evaluates to 0. Which of the
following conclusions about the precedence and associativity of the operators +, -, *
are correct?
A + has precedence over - and - has precedence over *
B All these have equal precedence and associate to the right
C All these have equal precedence and associate to the left
D + and – have equal precedence, which is over * and all associate to the left
Answer A
Marks 2
Unit 1

Id 20
Question Which of the following comparison between static and dynamic type checking is
Incorrect?
A Dynamic type checking slows down execution
B Dynamic type checking offers more flexibility to the programmers
C Dynamic type checking is more reliable
D Dynamic type checking is done during compilation, unlike static type checking
Answer A
Marks 2
Unit 1

Id 21

Page 6
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Question The period of time between an allocation and its subsequent disposal is called
A Scope
B (dynamic) binding
C Lifetime
D Longevity
Answer C
Marks 2
Unit 1

Id 22
Question Consider the following sequence of statements
Statement 1: A := B+C
Statement 2: D := A+C
Statement 3: E := A+B
Statement 4: G := D-E
Statement 5: H := E+A
Statement 6: I := H+G
Which of the statements can be executed in parallel?

A 2 and 4
B 4 and 5
C 5 and 6
D 4, 5 and 6
Answer A
Marks 2
Unit 1

Id 23
Question If instructions are executed in parallel, whenever the required operands are
available, then the execution time of the previous problem is logically same as that of
sequential algorithm consisting of
A 3 statements
B 2 statements
C 4 statements
D 5 statements
Answer C
Marks 2
Unit 1

Id 24
Question
A recursive function f(x), is defined as follows:
if(x>100)
return(x-10)
else return(f(f(x+11)))
For which of the values of x, f(x) = 91?

Page 7
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

A 100
B 91
C 1
D 101
Answer A
Marks 2
Unit 1

Id 25
Question English language uses full stop as a sentence, while C++ uses ……….
A Separator
B Terminator
C Delimiter
D All of the above
Answer B
Marks 2
Unit 1

Id 26
Question The ASCII (American Standard Code for Information Interchange) character set
contains ------------- characters.
A 652
B 562
C 256
D 265
Answer C
Marks 2
Unit 1

Id 27
Question The character data set, sometimes called alphanumeric data set, consists of all------
A a, A
B A, Z
C #, &
D a, A, Z, 3, #, &
Answer D
Marks 2
Unit 1

Id 33
Question Character data or string data can be joined together with the + operator in an

Page 8
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

operation called-----------
A Palindrome
B Join
C Reverse String
D concatenation
Answer D
Marks 1
Unit 1

Id 34
Question When two pieces of character data are joined, the concatenation results in “4” + “4”
= ? (Replace? With suitable option)
A “44”
B 8
C “8”
D 4+4
Answer A
Marks 2
Unit 1

Id 35
Question Identify the data type for following data set : The price of an Item: 7.39, 12.98
A Numeric: real
B Character string
C Numeric: integer
D Logical
Answer A
Marks 1
Unit 1

Id 36
Question Identify the data type for following data set : An account number: “A2453,” “2987”
A Numeric: real
B Character string
C Numeric: integer
D Logical
Answer B
Marks 2
Unit 1

Id 37

Page 9
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Question Identify the data type for following data set :A quantity:12389
A Numeric: real
B Numeric: integer
C Reverse String
D Logical
Answer B
Marks 1
Unit 1

Id 38
Question Identify the data type for following data set :A credit check: True, False
A Numeric: real
B Numeric: integer
C Logical
D Character string
Answer C
Marks 1
Unit 1

Id 39
Question Choose the correct syntax for defining the function
A Function(Data);
B DefineFunction(value)
C FunctionName(Value)

D FunctionName(Value)
Answer C
Marks 1
Unit 1

Id 40
Question Absolute value, or a random number are belongs to which function type?
A Mathematical functions
B String functions.

C Conversion functions.
D Statistical functions.
Answer A
Marks 1
Unit 1

Id 41

Page 10
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Question Unrestricted use of goto is harmful because


A It makes debugging difficult
B It increase the running time of program
C It increase memory requirements of program
D It result in the compiler generating longer machine code
Answer Correct option A
Marks 1
Unit 1

Id 42
Question The recurrence relation that arises in relation with the complexity of binary search
is
A T(n)=T(n/2)+k, where k is constant
B T(n)=2T(n/2)+k, where k is constant
C T(n)=T(n/2)+log(n)
D T(n)=T(n/2)+n
Answer Correct option A
Marks 1
Unit 1

Id 43
Question Which of the following algorithm design technique is used in the quick sort
algorithm
A Dynamic programming
B Backtracking
C Divide & conquer
D Greedy method
Answer Correct option C
Marks 1
Unit 1

Id 44
Question Literal means
A a string
B a string constant
C a character
D an alphabet
Answer Correct Option B
Marks 2
Unit Unit 1

Page 11
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Id 45
Question The value of an automatic variable that is declared but not initialized will be
A 0
B -1
C unpredictable(garbage value)

D none of these
Answer Correct Option C
Marks 2
Unit Unit 1

Id 46
Question Which of the following is true of external variables?
A they provide a way for two way communication between functions
B their scope extends from the point of definition through the remainder of the
program
C if they are not initialized, they will be initilised to zero
D All of these
Answer Correct Option D
Marks 2
Unit Unit 1

Id 47
Question The declaration
int x : 4;
means
A x is a four digit integer
B x cannot be greater than a four digit integer
C x is a four-bit integer
D none of these
Answer Correct Option C
Marks 4
Unit Unit 1

Id 48
Question What is the correct way to round off x from a float, to an int value?

A y=(int) (x+0.5)
B y=int (x+0.5)
C y=(int) x+0.5
D y=(int)(int) x+0.50
Answer Correct Option A
Marks 4
Unit Unit 1

Page 12
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Id Keep it blank
Question By default, any real number in 'C' is treated as ……..
A A float
B A double
C A long double
D Depends on the memory model you are using
Answer Correct Option B
Marks 2
Unit Unit 1

Id 49
Question To print out a and b given below, which printf() statement would you use?
float a = 3.14;
double b = 3.14;
A printf("%f%f",a,b);
B printf("%Lf%f",a,b);
C printf("%f%Lf",a,b);
D printf("%Lf%Lf",a,b);
Answer Correct Option A
Marks 4
Unit Unit 1

Id 50
Question In the following 'C' code, in which order the functions would be called ?
a = ( f1(23,14 ) * f2 (12/14)) + f3 () ;
A f1,f2,f3
B f3,f2,f1
C The order may vary from compiler to compiler
D None of these
Answer Correct Option A
Marks 4

Unit Unit 1

Id 51
Question Which one of the following is not the step in ensuring best decision
A Identify the problem.
B Understand the problem.
C Discard the problem & solution
D Evaluate the solution.
Answer C
Marks 2

Page 13
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 52
Question Solutions that cannot be reached through a direct set of steps are called..........
A algorithmic solutions.
B alternative Solution
C heuristic solutions.
D straightforward Solution
Answer C
Marks 2
Unit 1

Id 53
Question A problem that can be solved with a series of actions is called............
A Heuristic solutions.
B Algorithmic solutions.
C straightforward Solution
D alternative Solution
Answer B
Marks 2
Unit 1

Id 54
Question A heuristic type of problems is called..........
A Operation Research

B Artificial intelligence
C Fuzzy Logic
D None of these
Answer B
Marks 2
Unit 1

Id 55
Question The.................... steps in problem solving lead to the best possible solution to a
problem.
A Six
B Four
C Five
D Seven
Answer A
Marks 1

Page 14
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 56
Question The..................solutions are reached in a series of steps.
A algorithmic solutions
B heuristic solutions
C Artificial intelligence
D straightforward Solution
Answer A
Marks 1
Unit 1

Id 57
Question The...................... solutions are attained through trial and error.
A straightforward Solution
B alternative Solution
C algorithmic solutions.
D heuristic solutions.
Answer D
Marks 1
Unit 1

Id 58
The programmer defines each .............and ............... in a problem solution as a
Question particular data type
A Pointer , Array
B Integer , Double
C String , Float
D constant , variable
Answer D
Marks 1
Unit 1

Id 59
Question Variable also known as .....
A Font
B Constant
C Identifier
D File
Answer C
Marks 1

Page 15
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 60
Question A constant is a value that never changes during the processing of all the instructions
in a solution
A FALSE
B None of these
C TRUE
D Both A &C
Answer D
Marks 1
Unit 1

Id 61
Question In UML Sequence diagram used to indicate----------

A to create a logical model of your solution


B how a system functions from the user‟s standpoint
C describe how a class functions
D interactivity between objects
Answer D
Marks 2
Unit 1

Id 62
Question In UML Use case diagrams Used to indicate----------
A how a system functions from the user‟s standpoint
B to create a logical model of your solution
C describe how a class functions
D interactivity between objects
Answer A
Marks 2
Unit 1

Id 63
Question In UML Class diagrams Used to indicate----------
A describe how a class functions
B how a system functions from the user‟s standpoint
C to create a logical model of your solution
D interactivity between objects
Answer A
Marks 2

Page 16
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 64
Question Two main measures for the efficiency of an algorithm are
A Processor and memory
B Complexity and Capacity
C Time and Space
D Data and Space
Answer C
Marks 2
Unit 1

Id 65
Question The time factor while determining the efficiency of algorithm is measured by
A Counting microseconds
B Counting the number of key operations
C Counting the number of statements
D Counting the kilobytes of algorithm
Answer B
Marks 2
Unit 1

Id 66
Question The worst case occur in linear search algorithm when
A Item is somewhere in the middle of the array
B Item is not in the array at all
C Item is the last element in the array
D Item is the last element in the array or is not there at all
Answer D
Marks 2
Unit 1

Id 67
Question In case of ordinary int variables
A leftmost bit is reserved for sign
B rightmost bit is reserved for sign
C no bit is reserved for sign
D none of these
Answer A
Marks 2

Page 17
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 68
Question The variables which can be accessed by all modules in a program are known as

A Local variables
B Internal variables
C External variables
D Global variables
Answer Correct Option (D)
Marks 2
Unit 1

ID 69
Question The basic unit of information is the
A Byte
B Bit
C Block
D Sector
Answer B
Marks 2
Unit 1

ID 70
Question The most widely used method for interpreting bit setting as nonnegative integer is
the
A Octal number system
B ASCII
C ANS!
D Binary number system
Answer D
Marks 2
Unit 1

ID 71
Question The method used by the computers to represent real number is
A Floating-point notation
B Mantissa
C ANSI
D Binary number system
Answer D
Marks 2

Page 18
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

ID 72
Question The variable which can be accessed by all modules in a program, are known as
A Local variable
B Internal variable
C External variable
D Global variable
Answer D
Marks 2
Unit 1

ID 73
Question In which kind of storage structure for string , one can easily insert ,delete,
concatenate ,and rearrange substring?
A Fixed length storage structure
B Variable length storage structure
C Linked list storage
D Array type storage
Answer C
Marks 2
Unit 1

ID 74
Question Which of the following sorting procedure is the slowest ?
A Quick sort
B Heap sort
C Shell sort
D Bubble sort
Answer B
Marks 2
Unit 1

ID 75
Question The smallest element of an array‟s index is called its

A Lower bound
B Upper bound
C Range
D Extraction
Answer A

Page 19
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Marks 2
Unit 1

ID 76
Question The preliminary evaluation of a top-down design before programs are written is
referred to as a (an)
A Informal design review
B Structured walk through
C formal design review
D Scheduled review
Answer A
Marks 2
Unit 1

ID 77
Question Which of the following is not an example of program documentation
A Source code
B Object code
C Specification
D Identifier names
Answer B
Marks 1
Unit 2

ID 78
Question Which of the following is non-essential to stepwise refinement?
I. Refining the subprogram
II. Decomposing the problem into subprograms
III. Declaring all variables
IV. Stating the problem simply
V. Inputing the data

A 2
B 3 and 4
C 4 and 5
D 5
Answer D
Marks 4
Unit 1

ID 79
Question A top-down approach to programming calls for
1. Working from the general to the specific

Page 20
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

2. Postponing the minor decisions


3. A systematic approach
4. Immediate coding of the problem

A 1
B 1 and 2
C 1,2 and 3
D 1,2 and 4
Answer C
Marks 4
Unit 1

ID 80
Question Repeated execution of simple computation of
A Round-off errors
B Syntax errors
C Run-time errors
D Logic errors
Answer A
Marks 2
Unit 1

ID 81
Question Which of the following boolean expression is true?
A 2*2+3=10
B (2.4)and not(4.3)
C (5.6)or(3 div 3 = 1)
D -7 * 2 + 2 * 7 = 1
Answer C
Marks 2
Unit 1

id 82
Question In C++ programming language, which of the following type of operators have the
highest precedence
A Relation operators
B Equality operators
C Logical operators
D Arithmetic operators
Answer D
Marks 2
Unit 1

Page 21
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

196 83
Question In C++ programming language, which of the following operators has the highest
precedence
A Unary +
B *
C ≥
D ==
Answer A
Marks 2
Unit 1

197 84
In C++ programming language, if the first and the second operands of operator + are
Question of types int and float,respectively,the result will be of type
A int
B float
C char
D Long int
Answer B
Marks 2
Unit 1

199 85
Question In C++ language, the bitwise operators can be applied to which of the following
operands
A char
B Short,long
C Int
D All of the above
Answer D
Marks 2
Unit 1

Id 86
Question Consider the n elements are to be sorted. what is the worst case time complexity of
20 bubble sort?
A O(1)
B O(log2 n)
C O(n)
2
D O(n )
Answer Correct Option (D)

Page 22
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Marks 4
Unit 1

Id 87
Question Consider that n elements are to be sorted. What is the worst case time complexity of
21 shell sort?
A O(n)
B O(n log2 n)

C O(n1.2)
D O(n)

Answer Correct Option (C)


Marks 4
Unit 1

Id 88
Question What is the worst case time Complexity of straight insertion sort algorithm to sort n
22 elements
A O (n)
B O (n Log2 n)

C O(n1.2)
D O(n2)
Answer Correct Option(D)
Marks 4
Unit 1

Id 89
Question What is the worst space time complexity of binary insertion sort algorithm to sort n
23 elements
A O(n)
B O(n log2 n)

C O(n1.2)
D O(n2)
Answer Correct Option (D)
Marks 4
Unit 1

Id 90
Question 25 Which of the following sorting procedure in the slowest?
A Quick sort
B Heap sort
C Shell sort

Page 23
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

D Bubble sort
Answer Correct option (D)
Marks 2
Unit 1

Id 91
Question In a 'C++' expression involving || operator, evaluation
A Will be stopped if one of its components evaluates to false
B Will be stopped if one of its components evaluates to true
C Takes place from right to left
D Will be stopped if both of its components evaluates to true
Answer Correct Option B
Marks 2
Unit 1

Id 92
Question In C programming language, which of the following type of operators have the
highest precedence
A Relational Operators
B Equality Operators
C Logical Operators
D Arithmetic Operators
Answer Correct Option D
Marks 2
Unit 1

Id 93
Question In C programming language, which of the following operators has the highest
precedence?
A Unary +
B *
C >=
D Equals (==)
Answer Correct Option A
Marks 2
Unit 1

Id 94
Question Which of the following operators takes only integer operands ?
A +
B *

Page 24
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

C /
D %
Answer Correct Option D
Marks 2
Unit 1

Id 95
Question In an operation involving || operator, evaluation
A takes palce from left to right
B Will be stopped if one of its components evaluates to true
C Takes place from right to left
D Both (a) and (b)
Answer Correct Option D
Marks 2
Unit 1

Id 96
Question Pick the operators that associate from the left
A +
B ,
C <
D All the above
Answer Correct Option D
Marks 2
Unit 1

Id 97
Question The operators . , || , < , = , if arranged in the ascending order of precedence reads
A . , || , < , =
B (=, < , ||, .)
C (=, || , < , .)

D (< , || , = , .)
Answer Correct Option C
Marks 2
Unit 1

Id 98
Question The expression 4 + 6 / 3 * 2 - 2 + 7 % 3 evaluates to
A 3
B 5

Page 25
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

C 6
D 7
Answer Correct Option D
Marks 4
Unit 1

Id 99
Question Which of the following sorting algorithm is stable
A insertion sort.
B bubble sort.
C quick sort.
D heap sort.
Answer Correct Option D
Marks 2
Unit 1

Id 100
Question The number of elements that can be sorted in Θ(logn) time using heap sort is
A Θ(1)
B Θ(√logn)
C Θ(√logn)
D Θ(logn)
Answer Correct Option A
Marks 2
Unit 1

Id 101
Question A sort which relatively passes through a list to exchange the first element with any
element less than it and then repeats with a new first element is called
A Insertion sort
B Selection sort
C Heap sort
D Quick sort
Answer Correct Option D
Marks 2
Unit 1

Id 102
Question A sorting technique which uses the binary tree concept such that label of any node is
larger than all the labels in the subtrees, is called
A Selection sort

Page 26
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

B Insertion sort
C Insertion sort
D Quick sort
Answer Correct Option C
Marks 2
Unit 1

Id 103
Question A sort which uses binary tree concept such that any number is larger than all the
numbers in the subtree below it,is called
A Selection sort
B Insertion sort
C Heap sort
D Quick sort
Answer Correct Option C
Marks 2
Unit 1

Id 104
Question Which sorting algorithm uses the median-of-3 partitioning?
A heap sort

B merge sort
C quick sort
D Shell sort
Answer Correct Option
Marks 2
Unit 1

Id 105
Question Which data type is not a primary data type?
A int
B array
C float
D char
Answer Correct Option B
Marks 1
Unit 1

Id 106
Question How much memory is required to store a value of type double
A 4bytes

Page 27
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

B 6 bytes
C 8 bytes
D 10 bytes
Answer Correct Option C
Marks 1
Unit 1

Id 107
Question The modifier which is used to declare a variable as constant
A short
B signed
C unsigned
D const
Answer Correct Option D
Marks 1
Unit 1

Id 108
Question A declaration "short int" is used for variables
A which have a short duration in a program
B which have short names
C which may require less storage than normal integer
D all of these
Answer Correct Option C
Marks 1
Unit 1

Id 109
Question 5 The number of swapping needed to sort the number 8,12,7,9,31,19,5,13 in ascending
order, using bubble sort is
A 11
B 12
C 13
D 14
Answer D
Marks 4
Unit 1

Id 110
Question 6 Given 2 sorted list of size „m‟ and „n‟ respectively. The number of comparisons needed
in the worst case by the merge sort algorithm will be

Page 28
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

A mn
B max (m,n)
C min (m,n)
D M+n-1
Answer B
Marks 4
Unit 1

Id 111

A hash table with 10 buckets with one slot per bucket is depicted. The symbols, S1 to
Question 8 S7 are initially entered using a hashing function with linear probing. The maximum
number of comparisons needed in searching an item that is not present is
A 4
B 5
C 6
D 3
Answer B
Marks 4
Unit 1

Id 112
Question 9 A binary tree in which every non-leaf node has non-empty left and right sub-trees is
called a strictly binary tree. Such a tree with 10 leaves
A Cannot have more than 19 node
B Has exactly 19 nodes
C Has exactly 17 nodes
D Cannot have more than 17 nodes
Answer A
Marks 4
Unit 1

Id 113
Question 87 The variables which can be accessed by all modules in a program, are called
A local variables
B internal variables
C external variables
D global variable
Answer D
Marks 2
Unit 1

Page 29
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Id 114
Question 90 A static variable
A cannot be initialized
B is initialized once at the commencement of execution and cannot be changed at run
time

C retains its value throughout the file of the program


D is same as an automatic variable but is placed at the head of the program
Answer C
Marks 2
Unit 1

Id 115
Question 31 To find the length or the number of characters in the string, which function type you
will use?
A String Functions
B Mathematical functions.
C Conversion functions.
D Statistical functions.
Answer A
Marks 1
Unit 1

Id 116
Question 32 Match the Definitions from given options, for the function Sqrt(N)
A Returns the absolute value of N
B Returns the square root of N.
C Returns the rounded value of N to the n1 place.
D Returns a random number between 0 and 1
Answer B
Marks 2
Unit 1

Id Keep it blank
Question 33 Match the Definitions from given options, for the function Abs(N)
A Returns the square root of N.
B Returns the absolute value of N.
C Returns the rounded value of N to the n1 place.
D Returns a random number between 0 and 1
Answer B
Marks 2
Unit 1

Page 30
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .40

Id 117
Question 34 If we use function Integer (5.7269) then what will be the result it will return.
A 5.72
B 5.7269
C 5
D 5.7
Answer C
Marks 4
Unit 1

Id 118
Question 35 If we use function Abs (-3)then what will be the result it will return.
A -3
B -3
C 3
D A3.0
Answer C
Marks 4
Unit 1

Id 119
Question Replace blank space with suitable option :- ----------- are used to calculate things
such as maximum values, minimum values, and so forth..
A Statistical functions.
B Mathematical functions.
C String functions.
D Conversion functions
Answer A
Marks 1
Unit 1

Id 120
Question Select appropriate definition from given options for the function Value(S)
A Changes a string value into a numeric value.
B Changes a numeric value into a string value.

Page 31
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .41

C Returns the average of a list of numbers.


D Returns the maximum value from a list of numbers.
Answer A
Marks 2
Unit 1

Id 121
Question Select appropriate definition from given options for the function String(N)
A Changes a string value into a numeric value.
B Changes a numeric value into a string value.
C Returns the average of a list of numbers.
D Returns the maximum value from a list of numbers..
Answer B
Marks 2
Unit 1

Id 122
Question Which of the following sorting algorithms does not have a worst case running time of
o(n2)
A Insertion sort
B Merge sort
C Quick sort
D Bubble sort
Answer Correct Option (B)
Marks 2
Unit 1

Id 123
Question Identify the operator & operand from given expression 5 + 7
A 5 and 7 are operator, + is the operand
B 5 is operator & 7 is operand
C + is the operator, 5 and 7 are the operand
D None of these
Answer C
Marks 1
Unit 1

Page 32
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Id 124
Question Calculate the resultant for the operation like 9 MOD 4
A 2
B 0.44
C 2.25

D 1
Answer D
Marks 2
Unit 1

Id 125
Question Choose the correct resultant for the logical operation like:- True AND True
A TRUE
B FALSE
C Both A&B
D None of these
Answer A
Marks 2
Unit 1

Id 126
Question Construct the expression for”a 40-hour work week and overtime pay at 1.5 times
regular pay, calculated overtime pay would subtract 40 from the hours worked and
multiply the result by the regular wage times 1.5”
A (Hours-40)*Wage*1.5
B (Wage-40)*Hours*1.5
C (Hours-1.5)*Wage*40
D (Overtime-40)*Regular Pay*1.5
Answer A
Marks 2
Unit 1

Id 127
Question --------------------refers to the rules governing the computer operating system, the
language, and the application.
A Bug.
B Syntax
C Debugging.
D Testing
Answer B
Marks 2

Page 33
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 128
Question Problem analysis chart shows -----------------
A input, the processing, and the output;
B overall layout or structure of the solution;
C a beginning analysis of the problem
D a language like solution
Answer C
Marks 1
Unit 1

Id 129
Question Which of the following case does not exist in complexity theory?
A Best case
B Worst case
C Average case
D Null case
Answer D
Marks 1
Unit 1

Id 130
Question The complexity of linear search algorithm is
A O(n)
B O(log n)
C O(n2)
D O(n log n)
Answer A
Marks 1
Unit 1

Id 131
Question The complexity of Binary search algorithm is
A O(n)
B O(log n)
C O(n2)
D O(n log n)
Answer B
Marks 1
Unit 1

Id 132
Question The complexity of merge sort algorithm is
A O(n)
B O(log n)
C O(n2)

Page 34
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

D O(n log n)
Answer D
Marks 1
Unit 1

Id 133
Question The complexity of Bubble sort algorithm is
A O(n)
B O(log n)
C O(n2)
D O(n log n)
Answer C
Marks 1
Unit 1

Id 134
Question The Worst case occur in linear search algorithm when
A Item is somewhere in the middle of the array
B Item is not in the array at all
C Item is the last element in the array
D Item is the last element in the array or is not there at all
Answer D
Marks 1
Unit 1

Id 135
Question The worst case complexity for insertion sort is
A O(n)
B O(log n)
C O(n2)
D O(n log n)
Answer C
Marks 1
Unit 1

Id 136
Question The complexity of Fibonacci series is
A O(2n)
B O(log n)
C O(n2)
D O(n log n)
Answer A
Marks 1
Unit 1

Id 137
Question If f(x) = 3x2 + x3logx, then f(x) is
A O(x2)
B O(x3)

Page 35
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

C O(x)
D O(1)
Answer B
Marks 1
Unit 1

Id 138
Question The big-O notation for f(n) = (nlogn + n2)(n3 + 2) is
A O(n2)
B O(3n)
C O(n4)
D O(n5)
Answer D
Marks 1
Unit 1

Id 139
Question The big-O notation for f(n) = 2log(n!) + (n2 + 1)logn is
A n
B n2
C nlogn
D n2logn
Answer D
Marks 1
Unit 1

Id 140
Question The big-theta notation for function f(n) = 2n3 + n – 1 is
A n
B n2
C n3
D n4
Answer C
Marks
Unit

Id 141
Question The big-theta notation for f(n) = nlog(n2 + 1) + n2logn is
A n2logn
B n2
C logn
D nlog(n2)
Answer A
Marks 1
Unit 1

Id 142
Question The big-omega notation for f(x, y) = x5y3 + x4y4 + x3y5 is
A x5y3

Page 36
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

B x5y5
C x3y3
D x4y4
Answer C
Marks 1
Unit 1

Id 143
Question If f1(x) is O(g(x)) and f2(x) is o(g(x)), then f1(x) + f2(x) is
A O(g(x))
B o(g(x))
C O(g(x)) + o(g(x))
D None of these
Answer A
Marks 1
Unit 1

Id 144
Question The big-O notation for f(x) = 5logx is
A 1
B X
C X2
D X3
Answer B
Marks 1
Unit 1

Id 145
Question Which if the following is/are the levels of implementation of data structure
A Abstract level
B Application level
C Implementation level
D All of the above
Answer D
Marks 1
Unit 1

Id 146
Question ……………….. level is where the model becomes compatible executable code
A Abstract level
B Application level
C Implementation level
D All of the above
Answer C
Marks 1
Unit 1

Id 147
Question Stack is also called as

Page 37
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

A Last in first out


B First in last out
C Last in last out
D First in first out
Answer A
Marks 1
Unit 1

Id 148
Which of the following is true about the characteristics of abstract data types?
i) It exports a type.
Question ii) It exports a set of operations
A True, False
B False, True
C True, True
D False, False
Answer C
Marks 1
Unit 1

Id 149
Question …………… is not the component of data structure.
A Operations
B Storage Structures
C Algorithms
D None of above
Answer D
Marks 1
Unit 1

Id 150
Question Which of the following is not the part of ADT description?
A Data
B Operations
C Both of the above
D None of the above
Answer D
Marks 1
Unit 1

Id 151
Inserting an item into the stack when stack is not full is called …………. Operation
and deletion of item form the stack, when stack is not empty is called
Question ………..operation.
A push, pop
B pop, push
C insert, delete
D delete, insert
Answer A
Marks 2

Page 38
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 152
……………. Is a pile in which items are added at one end and removed from the
Question other.
A Stack
B Queue
C List
D None of the above
Answer B
Marks 1
Unit 1

Id 153
………… is very useful in situation when data have to stored and then retrieved in
Question reverse order.
A Stack
B Queue
C List
D Link list
Answer A
Marks 1
Unit 1

Id 154
Question Which data structure allows deleting data elements from and inserting at rear?
A Stacks
B Queues
C Dequeues
D Binary search tree
Answer B
Marks 1
Unit 1

Id 155
Which of the following data structure can't store the non-homogeneous data
Question elements?
A Arrays
B Records
C Pointers
D Stacks
Answer A
Marks 1
Unit 1

Id 156
A ....... is a data structure that organizes data similar to a line in the supermarket,
Question where the first one in line is the first one out.
A Queue linked list
B Stacks linked list

Page 39
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

C Both of them
D Neither of them
Answer A
Marks 1
Unit 1

Id 157
Identify the data structure which allows deletions at both ends of the list but
Question insertion at only one end.
A Input-restricted deque
B Output-restricted deque
C Priority queues
D None of above
Answer A
Marks 1
Unit 1

Id 158
Question Which of the following data structure is non-linear type?
A Strings
B Lists
C Stacks
D None of above
Answer D
Marks 1
Unit 1

Id 159
Question Which of the following data structure is linear type?
A Strings
B Lists
C Queues
D All of above
Answer D
Marks 1
Unit 1

Id 160
To represent hierarchical relationship between elements, which data structure is
Question suitable?
A Deque
B Priority
C Tree
D All of above
Answer C
Marks 1
Unit 1

Id 161

Page 40
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Question An algorithm that calls itself directly or indirectly is known as


A Sub algorithm
B Recursion
C Polish notation
D Traversal algorithm
Answer B
Marks 1
Unit 1

Id 162
Question A mathematical-model with a collection of operations defined on that model is called
A Data Structure
B Abstract Data Type
C Primitive Data Type
D Algorithm
Answer B
Marks 1
Unit 1

Page 41
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

UNIT-2
Marks distribution for Unit 2

4 + 4+ 2 +2 +1 = 13 Marks (Only 2 Question will be asked for 4 marks , 2 Questions will be asked for 2
Marks, 1 Question will be asked for 1 Mark )
Syllabus for Unit-2

Sequential Organization, Linear Data Structure Using Sequential Organization, Array as an Abstract
Data Type, Memory Representation and Address Calculation, Inserting an element into an array,
Deleting an element, Multidimensional Arrays, Two-dimensional arrays, n- dimensional arrays, Concept
of Ordered List, Single Variable Polynomial, Representation using arrays, Polynomial as array of
structure, Polynomial addition, Polynomial multiplication, Sparse Matrix, Sparse matrix representation,
Sparse matrix addition, Transpose of sparse matrix, String Manipulation Using Array.
Case Study- Use of sparse matrix in Social Networks and Maps.
Reference Book:
• “Data Structures Using C++”, Varsha H. Patil, ISBN 13-9780198066231
Id 1
What will happen if in a C++ program, you assign a value to an array element whose
Question subscript exceeds the size of array?
A The element will be set to 0.
B The compiler would report an error
C The program may crash if some important data gets overwritten.
D The array size would appropriately grow.
Answer C
Marks 2

Id 2
What does the following declaration mean?
Question int (*ptr)[10];
A ptr is array of pointers to 10 integers
B ptr is a pointer to an array of 10 integers
C ptr is an array of 10 integers
D ptr is an pointer to array
Answer B
Marks 2

Id 3
Question In C++, if you pass an array as an argument to a function, what actually gets passed?
A Value of elements in array
B First element of the array
C Base address of the array
D Address of the last element of array
Answer C
Marks 2

Id 4
What is meaning of following declaration ?
Question int arr[20];

Page 1
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

A None of these
B Integer Array of size 20
C Array of Size 20
D Array of size 20 that can have integer address
Answer B
Marks 2

Id 5

int a[20];
What will be the size of above array element ?
Question
A 20
B 19
C 22
D 21
Answer A
Marks 2

Id 6
Question What is meaning of the following statement? int *ptr[20];
A None of these
B Array of Integer Pointers of size 20
C Integer Array to Integer Pointers having size 20
D Integer Array of size 20 pointing to an Integer Pointer
Answer B
Marks 2

Id 7
Question In C++ Programming, If we need to store word "INDIA" then syntax is as below -
char name[]; name = "INDIA";
A
char name[6] = {'I','N','D','I','A'}
B
char name[6] = {"I","N","D","I","A"}
C
char name[6] = {'I','N','D','I','A','\0'}
D
Answer D
Marks 2

Id 8

int RollNum[30][4];
Above is an example of:
Question
A 2-D Array
B 1-D Array
C 3-D Array
D 4-D Array

Page 2
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Answer A
Marks 2

Id 9
What is the output of this C code?
#include <stdio.h>
void main()
{
int a[2][3] = {1, 2, 3, 4, 5};
int i = 0, j = 0;
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
printf("%d", a[i][j]);
Question }
A 123450
B 1 2 3 4 5 junk
C 123455
D Run time error
Answer A
Marks 4

Id 10
What is the output of this C code?
#include <stdio.h>
void main()
{
int a[2][3] = {1, 2, 3, , 4, 5};
Question
int i = 0, j = 0;
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
printf("%d", a[i][j]);
}
A 1 2 3 junk 4 5
B Compile time error
C 123045
D 123345
Answer B
Marks 4
Unit

Id 11
What is the output of this C code?
#include <stdio.h>
void f(int a[ ][3])
{
a[0][1] = 3;
int i = 0, j = 0;
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
printf("%d", a[i][j]);
}
void main()
Question {

Page 3
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

int a[2][3] = {0};


f(a);
}
A 030000
B Junk 3 junk junk junk junk
C Compile time error
D All junk values
Answer A
Marks 4
Unit

Id 12
What is the output of this C code?
#include <stdio.h>
void f(int a[ ][ ])
{
a[0][1] = 3;
int i = 0, j = 0;
for (i = 0;i < 2; i++)
for (j = 0;j < 3; j++)
printf("%d", a[i][j]);
}
void main()
{
int a[2][3] = {0};
f(a);
Question }
A 030000
B Junk 3 junk junk junk junk
C Compile time error
D All junk values
Answer C
Marks 4
Unit

Id 13
Which of the following statements are correct about 6 used in the program?
int num[6];
Question num[6]=21;
In the first statement 6 specifies a particular element, whereas in the second
A statement it specifies a type.
In the first statement 6 specifies a array size, whereas in the second statement it
B specifies a particular element of array.
In the first statement 6 specifies a particular element, whereas in the second
C statement it specifies a array size.
D In both the statement 6 specifies array size.
Answer B
Marks 2
Unit

Id 14
Which of the following statements are correct about an array?
1: The array int num[26]; can store 26 elements.
Question 2: The expression num[1] designates the very first

Page 4
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

element in the array.


3: It is necessary to initialize the array at the time of
declaration.
4: The declaration num[SIZE] is allowed if SIZE is a
macro.

A 1
B 1,4
C 2,3
D 2,4
Answer B
Marks 2
Unit

Id 15
What will be the output of the program ?
#include<stdio.h>

int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
return 0;
Question }
A 2,1,15
B 1,2,5
C 3,2,15
D 2,3,20
Answer C
Marks 4
Unit

Id 16
Question What will be the output of the program ?
#include<stdio.h>
int main()
{
static int a[2][2] = {1, 2, 3, 4};
int i, j;
static int *p[] = {(int*)a, (int*)a+1, (int*)a+2};
for(i=0; i<2; i++)
{
for(j=0; j<2; j++)
{
printf("%d, %d, %d, %d\n", *(*(p+i)+j), *(*(j+p)+i),
*(*(i+p)+j), *(*(p+j)+i));
}
}
return 0;
}
1, 1, 1, 1
A 2, 3, 2, 3

Page 5
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

3, 2, 3, 2
4, 4, 4, 4
1, 2, 1, 2
2, 3, 2, 3
3, 4, 3, 4
B 4, 2, 4, 2
1, 1, 1, 1
2, 2, 2, 2
2, 2, 2, 2
C 3, 3, 3, 3
1, 2, 3, 4
2, 3, 4, 1
3, 4, 1, 2
D 4, 1, 2, 3
Answer C
Marks 4
Unit

Id 17
What will be the output of the program ?
#include<stdio.h>
void fun(int **p);

int main()
{
int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 8, 7, 8, 9, 0};
int *ptr;
ptr = &a[0][0];
fun(&ptr);
return 0;
}
void fun(int **p)
{
printf("%d\n", **p);
Question }
A 1
B 2
C 3
D 4
Answer A
Marks 4

Id 18
Question The extra key inserted at the end of the array is called a
A End Key
B Stop Key
C Sentinel
D Transposition
Answer C
Marks 1

Id 19
Question The size of array int a[5]={1,2} is
A 4
B 12

Page 6
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

C 10
D 6
Answer C
Marks 2

Id 20
The output of the following statements is
char ch[6]={„e‟, „n‟, „d‟, „\0‟, „p‟};
Question printf(“%s”, ch);
A endp
B end0p
C end
D error
Answer C
Marks 2

Id 21
Question To declare an array S that holds a 5-character string, you would write
A char S[5]
B String S[5]
C char S[6]
D String S[6]
Answer A
Marks 1

Id 22
Question If x is one dimensional array, then pick up the correct answer
A *(x + i) is same as &x[i]
B *&x[i] is same as x + i
C *(x + i) is same as x[i] +1
D *(x + i) is same as *x[i]
Answer A
Marks 2
Unit

Id 23
What will be the output of the following code segment?
main( ) {
char s[10];
strcpy(s, “abc”);
printf(“%d %d”, strlen(s), sizeof(s));
Question }
A 3 10
B 33
C 10 3
D 10 10
Answer A

Page 7
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Marks 2
Unit

Id 24
Question What is the output of the following C++ program?
# include <stdio.h>
main ( )
{
int a, b=0;
static int c [10]={1,2,3,4,5,6,7,8,9,0};
for (a=0; a<10;+ + a)
if ((c[a]%2)= = 0) b+ = c [a];
cout<< b;
}
A 20
B 25
C 45
D 90
Answer A
Marks 2
Unit

Id 25
Question Sparse matrices have?
A no zero
B many zero
C higher dimension
D none
Answer B
Marks 1
Unit

Id 26
Consider the polynomial p(x) = a0 + a1x + a2x^2 +a3x^3, where ai != 0, for all i. The
Question minimum number of multiplications needed to evaluate p on an input x is:
A 3
B 4
C 6
D 9
Answer A
Marks 2
Unit

Id 27

Page 8
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Question Which of the following data structure is linear data structure?


A Trees
B Graphs
C Arrays
D None of above
Answer C
Marks 1
Unit

Id 28
Question The elements of an array are stored successively in memory cells because
by this way computer can keep track only the address of the first element and the
A addresses of other elements can be calculated
the architecture of computer memory does not allow arrays to store other than
B serially
C both of above
D none of above
Answer A
Marks 1
Unit

Id 29
Question
Which of the following data structure is not linear data structure?
A Arrays
B Linked lists
C Both of above
D None of above
Answer D
Marks 1
Unit

Id 30
Question Finding the location of the element with a given value is:
A Traversal
B Search
C Sort
D None of above
Answer B
Marks 1
Unit

Id 31

Page 9
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Question Arrays are best data structures


A for relatively permanent collections of data
B for the size of the structure and the data in the structure are constantly changing
C for both of above situation
D for none of above situation
Answer A
Marks 1
Unit

Id 32
Question Each array declaration need not give, implicitly or explicitly, the information about
A the name of array
B the data type of array
C the first data from the set to be stored
D the index set of the array
Answer C
Marks 1
Unit

Id 33
Question Which of the following data structure is non-linear type?

A Strings
B Lists
C Stacks
D Tree
Answer D
Marks 1
Unit 2

Id 34
Question Which of the following data structure is linear type?
A Array
B Tree
C Graphs
D Hierarchy
Answer A
Marks 1
Unit 2

Id 35
Question The logical or mathematical model of a particular organization of data is called a

Page 10
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

.........

A Data structure
B Data arrangement
C Data configuration
D Data formation
Answer A
Marks 1
Unit 2

Id 36

Question The simplest type of data structure is ..................


A Multidimensional array
B Linear array
C Two dimensional array
D Three dimensional array
Answer A
Marks 1
Unit 2

Id 37
Question Arrays are best data structures ............
A For relatively permanent collections of data.
B For the size of the structure and the data in the structure are constantly changing
C For both of above situation
D For none of the above
Answer A
Marks 1
Unit 2

Id 38
Question Which of the following data structures are indexed structures?
A Linear arrays
B Linked lists
C Graphs
D Trees
Answer A
Marks
Unit

Id 39

Page 11
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Question Each node in a linked list has two pairs of .............. and ...................
A Link field and information field
B Link field and avail field
C Avail field and information field

D Address field and link field


Answer A
Marks 1
Unit 2

Id 40
Question A ........................ does not keep track of address of every element in the list.
A Stack
B String

C Linear array
D Queue
Answer A
Marks 1
Unit 2

Id 41
Question To implement Sparse matrix dynamically, the following data structure is used
A Trees
B Graphs
C Priority Queues
D Linked List
Answer D
Marks 1
Unit 2

Id 42
Question Sparse matrix has?
A Many zero entries
B Many non-zero entries
C Higher dimension
D None of the above
Answer A
Marks 1
Unit 2

Id 43

Page 12
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

The linked list implementation of sparse matrices is superior to the generalized dope
Question vector method because it is?
A Conceptually easier
B Completely dynamic
C Efficient in accessing an entry
D A and B
Answer D
Marks 1
Unit 2

Id 44
Question An array is a collection of:
A Different data types scattered throughout memory
B Same data types scattered throughout memory
C Same data types placed next to each other in memory
D Different data types placed next to each other in memory
Answer C
Marks 1
Unit 2

Id 45
Question Which of the declaration of array are correct?
A int a(25);
B int size = 10, b[size];
C int c = {0, 1, 2};

D None of the above


Answer D
Marks 1
Unit 2

Id 46
What is the difference between the 5‟s in these two expressions?(Select the correct
option)
int num[5];
Question num[5] = 11;
A First is particular element, second is type
B First is array size, second is particular element
C First is particular element, second is array size
D Both specify array size
Answer B
Marks 2
Unit 2

Page 13
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Id 47
Let A be a square matrix of size n x n. Consider the following program. What is the
expected output?
C = 100
for i = 1 to n do
for j = 1 to n do
{
Temp = A[i][j] + C
A[i][j] = A[j][i]
A[j][i] = Temp - C
}
for i = 1 to n do
for j = 1 to n do
Question Output(A[i][j]);
A The matrix A itself
B Transpose of matrix A
Adding 100 to the upper diagonal elements and subtracting 100 from diagonal
C elements of A
D None of the above
Answer A
Marks 4
Unit 2

Id 48
The minimum number of arithmetic operations required to evaluate the polynomial
Question P(X) = X5 + 4X3 + 6X + 5 for a given value of X using only one temporary variable.

A 6
B 7
C 8
D 9
Answer B
Marks 2
Unit 2

Id 49
Consider the following C++ function in which size is the number of elements in the
array E:
The value returned by the function MyX is the
int MyX(int *E, unsigned int size)
{
int Y = 0;
int Z;
int i, j, k;

for (i = 0; i < size; i++)


Y = Y + E[i];

for (i = 0; i < size; i++)


for (j = i; j < size; j++)
{
Question Z = 0;

Page 14
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

for (k = i; k <= j; k++)


Z = Z + E[k];
if (Z > Y)
Y = Z;
}
return Y;
}
A maximum possible sum of elements in any sub-array of array E.
B maximum element in any sub-array of array E.
C sum of the maximum elements in all possible sub-arrays of array E
D the sum of all the elements in the array E.
Answer A
Marks 4
Unit 2

Id 50
If array A is made to hold the string “abcde”, which of the following four test cases
will be successful in exposing the flaw in this procedure?
(1) oldc = "abc", newc = "dab"
(2) oldc = "cde", newc = "bcd"
(3) oldc = "bca", newc = "cda"
Question (4) oldc = "abc", newc = "bac"
A None
B 2 only
C 3 and 4 only
D 4 only
Answer C
Marks 4
Unit 2

Id 51
A program P reads in 500 integers in the range [0..100] representing the scores of
500 students. It then prints the frequency of each score above 50. What would be the
Question best way for P to store the frequencies?
A An array of 50 numbers
B An array of 100 numbers
C An array of 500 numbers
D A dynamically allocated array of 550 numbers
Answer A
Marks 4

Unit 2

Id 52
Consider the following C++ program that attempts to locate an element x in an
array Y[] using binary search. The program is erroneous.
f(int Y[10], int x) {
int i, j, k;
Question i = 0; j = 9;

Page 15
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

do {
k = (i + j) /2;
if( Y[k] < x) i = k; else j = k;
} while(Y[k] != x && i < j);
if(Y[k] == x) cout<<"x is in the array " ;
else cout<<" x is not in the array " ;
}
On which of the following contents of Y and x does the program fail?
A Y is [1 2 3 4 5 6 7 8 9 10] and x < 10
B Y is [1 3 5 7 9 11 13 15 17 19] and x < 1
C Y is [2 2 2 2 2 2 2 2 2 2] and x > 2
D Y is [2 4 6 8 10 12 14 16 18 20] and 2 < x < 20 and x is even
Answer C
Marks 4
Unit 2

Id 53
Consider the following C++ program that attempts to locate an element x in an
array Y[] using binary search. The program is erroneous.
f(int Y[10], int x) {
int i, j, k;
i = 0; j = 9;
do {
k = (i + j) /2;
if( Y[k] < x) i = k; else j = k;
} while(Y[k] != x && i < j);
if(Y[k] == x) cout<<"x is in the array " ;
else cout<<" x is not in the array " ;
}
Question What is the correction needed in the program to make it work properly?
A Change line 6 to: if (Y[k] < x) i = k + 1; else j = k-1;
B Change line 6 to: if (Y[k] < x) i = k - 1; else j = k+1;
C Change line 6 to: if (Y[k] <= x) i = k; else j = k;
D Change line 7 to: } while ((Y[k] == x) && (i < j));
Answer A
Marks 4
Unit 2

Id 54
A set X can be represented by an array x[n] as follows:

Consider the following algorithm in which x,y and z are Boolean arrays of size n:
algorithm zzz(x[] , y[], z [])
{
int i;
for (i=O; i<n; ++i)
z[i] = (x[i] ^ ~y[i]) V (~x[i] ^ y[i])
}
Question The set Z computed by the algorithm is:

Page 16
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

A (X Intersection Y)
B (X Union Y)
C (X-Y) Intersection (Y-X)
D (X-Y) Union (Y-X)
Answer D
Marks 4
Unit 2

Id 55
Question Array name indicates________
A Just the name of array

B Address of starting element


C Value of starting element
D None of the above
Answer B
Marks 1
Unit 2

Id 56
Question The array subscript always start at ________
A 1
B -1
C 0
D Any position
Answer C
Marks 1
Unit 2

Id 57
Question Array elements occupy______
A Varying length of memory locations for each element
B Subsequent memory locations
C Random memory locations
D None of these
Answer B
Marks 1
Unit 2

Id 58
Question In arrays ______ and ______ are difficult but ______ is easy operation.

Page 17
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

A Insertion, deletion, searching


B Searching, insertion, deletion
C Deletion, searching, insertion
D None of these.
Answer A
Marks 2
Unit 2

Id 59
What is the output for following program?
void main()
{
int a[5]={3,4};
cout<<a[2]<<a[3]<<a[4];
Question }
A 211
B Garbage value
C 122
D 000
Answer D
Marks 1
Unit 2

Id 60
What is the output for following program?
void main()
{
int i=0,a[3];
a[i] = i++;
cout<<a[i];
Question }
A Garbage value
B Syntax error
C 1
D 0
Answer A
Marks 1
Unit 2

Id 61
Question In Linked list, the logical order of elements ________
A Is determined by their physical arrangement
B Cannot be determined by their physical arrangement
C Is the same as their physical arrangement
D None of these.

Page 18
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Answer B
Marks 1
Unit 2

Id 62
Question In CLL, insertion of a record involves modification of……
A 1 pointer
B 2 pointers
C No pointer
D 3 pointers
Answer B
Marks 2
Unit 2

Id 63
Question For traversing a list, which pointer do you need?
A NULL
B Insertion
C Beginning
D Walking
Answer C
Marks 1
Unit 2

Id 64
Question The nth node in SLL, is accessed via ________
A Tail node
B Head node
C (n-1) nodes
D None of these
Answer B
Marks 1
Unit 2

Id 65
What is the output of this c++ code?
void main()
{
int a[2][3] = {1,2,3,4,5}
int i=0,j=0;
for(i=0 ; i<2 ; i++)
for(j=0 ; j<3 ; j++)
Question cout<<a[i][j];

Page 19
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

A 1 2 3 4 5 junk
B 123455
C 123450
D Run time error
Answer C
Marks 2
Unit 2

Id 66
Question Which of the following data structures are indexed structure?
A L
Trees
B Linked list
C Linear arrays
D All of these
Answer B
Marks 1
Unit 2

Id 67
When new data is to be inserted into a data structure, but there is no available space
Question is called ________________
A Overflow
B Saturated
C Houseful
D Underflow
Answer B
Marks 1
Unit

Id 68
Question Array name is ______
A An array variable
B A common name shared by all elements
C A keyword
D Not used in a program
Answer B
Marks 1
Unit 2

Id

Page 20
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Question To initialize a 5 element array all having value 1 is given by ……


A int num[ ] = (1);
B int num[ ] = {1,1,1,1,1};
C int num[ 5 ] = (1);
D int num[ 4 ] = (1,1,1,1,1);
Answer B
Marks 1
Unit 2

ID 69
Question Missing elements of partially initialized arrays are ………
A Set to zero
B Not defined
C Invalid
D Set to one
Answer C
Marks 1
Unit 2

ID 70
Question Two-way list may be maintained in memory by means of .............
A Queues
B Linear arrays
C Non linear arrays
D Stacks
Answer B
Marks 1
Unit 2

ID 71
Question Sparse matrices have?
A many zero entries
B many non- zero entries
C higher dimension
D none of above
Answer A
Marks 1
Unit 2

ID 72
Question Two dimensional arrays are also called ?

Page 21
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

A Matrix Array
B Table Array
C Both a and b
D None of the Above
Answer C
Marks 1
Unit 2

ID 73
Question Which of the following function sets first n characters of a string to a given character?
A strinit()
B strnset()
C strset()
D strcset()
Answer B
Marks 1
Unit 2

ID 74
Question If the two strings are identical, then strcmp() function returns
A -1
B 1
C 0
D 2
Answer C
Marks 1
Unit 2

ID 75
Question The library function used to find the last occurrence of a character in a string is
A strnstr()
B laststr()
C strrchr()
D strstr()
Answer C
Marks 1
Unit 2

ID 76
Which of the following function is used to find the first occurrence of a given string
Question in another string?
A strchr()

Page 22
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

B strrchr()
C strstr()
D strnset()
Answer C
Marks 1
Unit 2

ID 77
Which of the following function is more appropriate for reading in a multi-word
Question string?
A printf();
B scanf();
C gets();
D puts();
Answer C
Marks 1
Unit 2

ID 78
Question Which of the following function is correct that finds the length of a string?
int xstrlen(char *s)
{
int length=0;
while(*s!='\0')
{ length++; s++; }
return (length);
}
A
int xstrlen(char s)
{
int length=0;
while(*s!='\0')
length++; s++;
return (length);
}
B
int xstrlen(char *s)
{
int length=0;
while(*s!='\0')
length++;
return (length);
}
C
int xstrlen(char *s)
{
int length=0;
while(*s!='\0')
s++;
return (length);
}
D
Answer A
Marks 4
Unit 2

ID 79

Page 23
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Question An array elements are always stored in ________ memory locations.


A Sequential
B Random
C Sequential and Random
D None of the above
Answer A
Marks 1
Unit 2

ID 80
Question
A
B
C
D
Answer
Marks
Unit 2

ID 81
What will be printed after execution of the following code?
void main()
{
int arr[10] = {1,2,3,4,5};
printf("%d", arr[5]);
Question }
A Garbage Value
B 5
C 6
D 0
Answer D
Marks 1
Unit 2

ID 82
Question What is right way to Initialize array?
A int num[6] = { 21, 41, 2, 15, 4, 5 };
B int n{} = { 21, 41, 2, 15, 4, 5 };
C int n{6} = { 21, 41, 2 };
D int n(6) = { 21, 41, 2, 15, 4, 5 };
Answer A
Marks 1
Unit 2

Page 24
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

ID 83
What will be the output of the following code?\
#include"stdio.h"
void main()
{
int a[10];
printf("%d %d", a[-1], a[12]);
Question }
A 00
B Garbage value 0
C 0 Garbage Value
D Garbage value Garbage Value
Answer D
Marks 2
Unit 2

ID 84
Let x be an array. Which of the following operations are illegal?
1. ++X
2. X+1
3. X++
Question 4. X*2
A I and II
B I, II and III
C II and III
D I, III and IV
Answer D
Marks 2
Unit 2

ID 85
Question What is the maximum number of dimensions an array in C may have?
A 2
B 8
C 20
D Theoretically no limit. The only practical limits are memory size and compilers
Answer D
Marks 1
Unit 2

ID 86
What will be the output of the program?
#include"stdio.h"
int main()
Question {

Page 25
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

int arr[5] = {10};


printf("%d", 0[arr]);

return 0;
}
A 1
B 0
C 10
D 6
Answer C
Marks 2
Unit 2

ID
Question
A
B
C
D
Answer
Marks
Unit

ID
Question
A
B
C
D
Answer
Marks
Unit

ID
Question
A
B
C
D
Answer
Marks
Unit

Page 26
3/23/2021 Arrays Questions and Answers - Sanfoundry

Data Structure Questions and Answers – Array


and Array Operations
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on “Array and
Array Operations”.

1. Which of these best describes an array?


a) A data structure that shows a hierarchical behavior
b) Container of objects of similar types
c) Arrays are immutable once initialised
d) Array is not a data structure

View Answer

Answer: b
Explanation: Array contains elements only of the same type.

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-array-array-operations/ 1/8
3/23/2021 Arrays Questions and Answers - Sanfoundry

2. How do you initialize an array in C?


a) int arr[3] = (1,2,3);
b) int arr(3) = {1,2,3};
c) int arr[3] = {1,2,3};
d) int arr(3) = (1,2,3);

View Answer

Answer: c
Explanation: This is the syntax to initialize an array in C.

3. How do you instantiate an array in Java?


a) int arr[] = new int(3);
b) int arr[];
c) int arr[] = new int[3];
d) int arr() = new int(3);

View Answer

Answer: c
Explanation: Note that int arr[]; is declaration whereas int arr[] = new int[3]; is to instantiate an
array.

4. Which of the following is the correct way to declare a multidimensional array in Java?
a) int[] arr;
b) int arr[[]];
c) int[][]arr;
d) int[[]] arr;

View Answer

Answer: c
Explanation: The syntax to declare multidimensional array in java is either int[][] arr; or int arr[]
[];

5. What is the output of the following Java code?

https://www.sanfoundry.com/data-structure-questions-answers-array-array-operations/ 2/8
3/23/2021 Arrays Questions and Answers - Sanfoundry

advertisement

All 10 Antenna Locations In GTA Online - Cayo Perico Heist

public class array


{
public static void main(String args[])
{
int []arr = {1,2,3,4,5};
System.out.println(arr[2]);
System.out.println(arr[4]);
}
}

a) 3 and 5
b) 5 and 3
c) 2 and 4
d) 4 and 2

View Answer

Answer: a
Explanation: Array indexing starts from 0.

6. What is the output of the following Java code?

public class array


{
public static void main(String args[])
{
int []arr = {1,2,3,4,5};
System.out.println(arr[5]);
}
}

https://www.sanfoundry.com/data-structure-questions-answers-array-array-operations/ 3/8
3/23/2021 Arrays Questions and Answers - Sanfoundry

a) 4
b) 5
c) ArrayIndexOutOfBoundsException
d) InavlidInputException

View Answer

Answer: c
Explanation: Trying to access an element beyond the limits of an array gives
ArrayIndexOutOfBoundsException.

advertisement

7. When does the ArrayIndexOutOfBoundsException occur?


a) Compile-time
b) Run-time
c) Not an error
d) Not an exception at all

View Answer

Answer: b
Explanation: ArrayIndexOutOfBoundsException is a run-time exception and the compilation is
error-free.

8. Which of the following concepts make extensive use of arrays?


a) Binary trees
b) Scheduling of processes
c) Caching
d) Spatial locality

View Answer

https://www.sanfoundry.com/data-structure-questions-answers-array-array-operations/ 4/8
3/23/2021 Arrays Questions and Answers - Sanfoundry

Answer: d
Explanation: Whenever a particular memory location is referred to, it is likely that the locations
nearby are also referred, arrays are stored as contiguous blocks in memory, so if you want to
access array elements, spatial locality makes it to access quickly.

9. What are the advantages of arrays?


a) Objects of mixed data types can be stored
b) Elements in an array cannot be sorted
c) Index of rst element of an array is 1
d) Easier to store elements of same data type

View Answer

Answer: d
Explanation: Arrays store elements of the same data type and present in continuous memory
locations.

10. What are the disadvantages of arrays?


a) Data structure like queue or stack cannot be implemented
b) There are chances of wastage of memory space if elements inserted in an array are lesser
than the allocated size
c) Index value of an array can be negative
d) Elements are sequentially accessed

View Answer

Answer: b
Explanation: Arrays are of xed size. If we insert elements less than the allocated size,
unoccupied positions can’t be used again. Wastage will occur in memory.

11. Assuming int is of 4bytes, what is the size of int arr[15];?


a) 15
b) 19
c) 11
d) 60

View Answer

Answer: d
Explanation: Since there are 15 int elements and each int is of 4bytes, we get 15*4 = 60bytes.

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-array-array-operations/ 5/8
3/23/2021 Arrays Questions and Answers - Sanfoundry

12. In general, the index of the rst element in an array is __________


a) 0
b) -1
c) 2
d) 1

View Answer

Answer: a
Explanation: In general, Array Indexing starts from 0. Thus, the index of the rst element in an
array is 0.

13. Elements in an array are accessed _____________


a) randomly
b) sequentially
c) exponentially
d) logarithmically

View Answer

Answer: a
Explanation: Elements in an array are accessed randomly. In Linked lists, elements are
accessed sequentially.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice Questions
and Answers.

Participate in the Sanfoundry Certi cation contest to get free Certi cate of Merit. Join our social
networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest

» Next - Data Structure Questions and Answers – Stack Operations – 1

https://www.sanfoundry.com/data-structure-questions-answers-array-array-operations/ 6/8
3/23/2021 Arrays Questions and Answers - Sanfoundry

advertisement

Recommended Posts:
1. Data Science Questions and Answers
2. Java Programming Examples on Collection API
3. Java Programming Examples on Exception Handling
4. Java Programming Examples on Java.Lang
5. C# Programming Examples on Sorting
6. C Programming Examples on Searching and Sorting
7. Data Structures & Algorithms II – Questions and Answers
8. Java Programming Examples on Combinatorial Problems & Algorithms
9. Java Programming Examples
10. C# Programming Examples on Data Structures
11. Java Programming Examples on Utility Classes
12. C Programming Examples on Arrays
13. C Programming Examples on Stacks & Queues
14. C++ Programming Examples on Data-Structures
15. C Programming Examples on Data-Structures
16. C# Programming Examples on Arrays
17. Java Programming Examples on Arrays
18. Java Programming Examples on Collections
19. Java Programming Examples on Data-Structures
20. Data Structure Questions and Answers

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-array-array-operations/ 7/8
3/23/2021 Arrays Questions and Answers - Sanfoundry

Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is
Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN
Architect and is passionate about competency developments in these areas.
He lives in Bangalore and delivers focused training sessions to IT
professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux
Networking, Linux Storage, Advanced C Programming, SAN Storage
Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber
Channel. Stay connected with him @ LinkedIn

Subscribe Sanfoundry Newsletter and Posts

Name*

Email*

Subscribe

About | Certi cations | Internships | Jobs | Privacy Policy | Terms | Copyright | Contact

     

© 2011-2021 Sanfoundry. All Rights Reserved.

https://www.sanfoundry.com/data-structure-questions-answers-array-array-operations/ 8/8
3/23/2021 Stacks Questions and Answers - Sanfoundry

Data Structure Questions and Answers – Stack


Operations – 1
« Prev Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on “Stack
Operations – 1”.

1. Process of inserting an element in stack is called ____________


a) Create
b) Push
c) Evaluation
d) Pop

View Answer

Answer: b
Explanation: Push operation allows users to insert elements in the stack. If the stack is lled
completely and trying to perform push operation stack – over ow can happen.

advertisement 

https://www.sanfoundry.com/data-structure-questions-answers-stack-operations/ 1/7
3/23/2021 Stacks Questions and Answers - Sanfoundry

2. Process of removing an element from stack is called __________


a) Create
b) Push
c) Evaluation
d) Pop

View Answer

Answer: d
Explanation: Elements in the stack are removed using pop operation. Pop operation removes
the top most element in the stack i.e. last entered element.

3. In a stack, if a user tries to remove an element from an empty stack it is called _________
a) Under ow
b) Empty collection
c) Over ow
d) Garbage Collection

View Answer

Answer: a
Explanation: Under ow occurs when the user performs a pop operation on an empty stack.
Over ow occurs when the stack is full and the user performs a push operation. Garbage
Collection is used to recover the memory occupied by objects that are no longer used.

4. Pushing an element into stack already having ve elements and stack size of 5, then stack
becomes ___________
a) Over ow
b) Crash
c) Under ow
d) User ow

View Answer

Answer: a
Explanation: The stack is lled with 5 elements and pushing one more element causes a stack
https://www.sanfoundry.com/data-structure-questions-answers-stack-operations/ 2/7
3/23/2021 Stacks Questions and Answers - Sanfoundry

over ow. This results in overwriting memory, code and loss of unsaved work on the computer.

5. Entries in a stack are “ordered”. What is the meaning of this statement?


a) A collection of stacks is sortable
b) Stack entries may be compared with the ‘<‘ operation
c) The entries are stored in a linked list
d) There is a Sequential entry that is one by one

View Answer

Answer: d
Explanation: In stack data structure, elements are added one by one using push operation.
Stack follows LIFO Principle i.e. Last In First Out(LIFO).

advertisement

All 10 Antenna Locations In GTA Online - Cayo Perico Heist

6. Which of the following is not the application of stack?


a) A parentheses balancing program
b) Tracking of local variables at run time
c) Compiler Syntax Analyzer
d) Data Transfer between two asynchronous process

View Answer

Answer: d
Explanation: Data transfer between the two asynchronous process uses the queue data
structure for synchronisation. The rest are all stack applications. 

7. Consider the usual algorithm for determining whether a sequence of parentheses is balanced.
The maximum number of parentheses that appear on the stack AT ANY ONE TIME when the
algorithm analyzes: (()(())(()))?
https://www.sanfoundry.com/data-structure-questions-answers-stack-operations/ 3/7
3/23/2021 Stacks Questions and Answers - Sanfoundry

a) 1
b) 2
c) 3
d) 4 or more

View Answer

Answer: c
Explanation: In the entire parenthesis balancing method when the incoming token is a left
parenthesis it is pushed into stack. A right parenthesis makes pop operation to delete the
elements in stack till we get left parenthesis as top most element. 3 elements are there in
stack before right parentheses comes. Therefore, maximum number of elements in stack at
run time is 3.

8. Consider the usual algorithm for determining whether a sequence of parentheses is balanced.
Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right
parentheses (in some order). The maximum number of parentheses that appear on the stack AT
ANY ONE TIME during the computation?
a) 1
b) 2
c) 3
d) 4 or more

View Answer

Answer: b
Explanation: In the entire parenthesis balancing method when the incoming token is a left
parenthesis it is pushed into stack. A right parenthesis makes pop operation to delete the
elements in stack till we get left parenthesis as top most element. 2 left parenthesis are
pushed whereas one right parenthesis removes one of left parenthesis. 2 elements are there
before right parenthesis which is the maximum number of elements in stack at run time.

9. What is the value of the post x expression 6 3 2 4 + – *?


a) 1
b) 40
c) 74
d) -18

View Answer

Answer: d
Explanation: Post x Expression is (6*(3-(2+4))) which results -18 as output.


advertisement

https://www.sanfoundry.com/data-structure-questions-answers-stack-operations/ 4/7
3/23/2021 Stacks Questions and Answers - Sanfoundry

10. Here is an in x expression: 4 + 3*(6*3-12). Suppose that we are using the usual stack
algorithm to convert the expression from in x to post x notation. The maximum number of
symbols that will appear on the stack AT ONE TIME during the conversion of this expression?
a) 1
b) 2
c) 3
d) 4

View Answer

Answer: d
Explanation: When we perform the conversion from in x to post x expression +, *, (, *
symbols are placed inside the stack. A maximum of 4 symbols are identi ed during the entire
conversion.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice Questions
and Answers.

Participate in the Sanfoundry Certi cation contest to get free Certi cate of Merit. Join our social
networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest

« Prev - Data Structure Questions and Answers – Array and Array Operations
» Next - Data Structure Questions and Answers – Stack Operations – 2

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-stack-operations/ 5/7
3/23/2021 Stacks Questions and Answers - Sanfoundry

Recommended Posts:
1. Data Science Questions and Answers
2. Java Programming Examples on Graph Problems & Algorithms
3. C# Programming Examples on Conversions
4. C Programming Examples on Searching and Sorting
5. Java Programming Examples on Collections
6. C++ Programming Examples on Graph Problems & Algorithms
7. C Programming Examples on Arrays
8. C Programming Examples on Linked List
9. Python Programming Examples on Linked Lists
10. C Programming Examples on Graph Problems & Algorithms
11. C# Programming Examples on Sorting
12. C# Programming Examples on Exceptions
13. Data Structures & Algorithms II – Questions and Answers
14. Python Programming Examples on Stacks & Queues
15. C++ Programming Examples on Data-Structures
16. C Programming Examples on Data-Structures
17. Java Programming Examples on Data-Structures
18. C Programming Examples on Stacks & Queues
19. C# Programming Examples on Data Structures
20. Data Structure Questions and Answers

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-stack-operations/ 6/7
3/23/2021 Stacks Questions and Answers - Sanfoundry

Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is
Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN
Architect and is passionate about competency developments in these areas.
He lives in Bangalore and delivers focused training sessions to IT
professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux
Networking, Linux Storage, Advanced C Programming, SAN Storage
Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber
Channel. Stay connected with him @ LinkedIn

Subscribe Sanfoundry Newsletter and Posts

Name*

Email*

Subscribe

About | Certi cations | Internships | Jobs | Privacy Policy | Terms | Copyright | Contact

     

© 2011-2021 Sanfoundry. All Rights Reserved.

https://www.sanfoundry.com/data-structure-questions-answers-stack-operations/ 7/7
3/23/2021 Data Structure Questions and Answers for Freshers - Sanfoundry

Data Structure Questions and Answers – Stack


Operations – 3
« Prev Next »

This set of Data Structure Questions and Answers for Freshers focuses on “Stack Operations – 3”.

1. The result of evaluating the post x expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is?


a) 600
b) 350
c) 650
d) 588

View Answer

Answer: b
Explanation: The post x expression is evaluated using stack. We will get the in x expression as
(5*(4+6))*(4+9/3). On solving the In x Expression, we get
(5*(10))*(4+3)
= 50*7
= 350. 

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-freshers/ 1/7
3/23/2021 Data Structure Questions and Answers for Freshers - Sanfoundry

2. Convert the following in x expressions into its equivalent post x expressions.


(A + B ⋀D)/(E – F)+G
a) (A B D ⋀ + E F – / G +)
b) (A B D +⋀ E F – / G +)
c) (A B D ⋀ + E F/- G +)
d) (A B D E F + ⋀ / – G +)

View Answer

Answer: a
Explanation: The given in x expression is (A + B ⋀D)/(E – F)+G.
(A B D ^ + ) / (E – F) +G
(A B D ^ + E F – ) + G. ‘/’ is present in stack.
A B D ^ + E F – / G +. Thus Post x Expression is A B D ^ + E F – / G +.

3. Convert the following In x expression to Post x form using a stack.


x + y * z + (p * q + r) * s, Follow usual precedence rule and assume that the expression is legal.
a) xyz*+pq*r+s*+
b) xyz*+pq*r+s+*
c) xyz+*pq*r+s*+
d) xyzp+**qr+s*+

View Answer

Answer: a
Explanation: The In x Expression is x + y * z + (p * q + r) * s.
(x y z ) + (p * q + r) * s. ‘+’, ‘*’ are present in stack.
(x y z * + p q * r) * s. ‘+’ is present in stack.
x y z * + p q * r + s * +. Thus Post x Expression is x y z * + p q * r + s * +.

4. Which of the following statement(s) about stack data structure is/are NOT correct?
a) Linked List are used for implementing Stacks
b) Top of the Stack always contain the new node

https://www.sanfoundry.com/data-structure-questions-answers-freshers/ 2/7
3/23/2021 Data Structure Questions and Answers for Freshers - Sanfoundry

c) Stack is the FIFO data structure


d) Null link is present in the last node at the bottom of the stack

View Answer

Answer: c
Explanation: Stack follows LIFO.

5. Consider the following operation performed on a stack of size 5.

Push(1);
Pop();
Push(2);
Push(3);
Pop();
Push(4);
Pop();
Pop();
Push(5);

advertisement

All 10 Antenna Locations In GTA Online - Cayo Perico Heist

After the completion of all operation, the number of elements present in stack is?
a) 1
b) 2
c) 3 
d) 4

View Answer

https://www.sanfoundry.com/data-structure-questions-answers-freshers/ 3/7
3/23/2021 Data Structure Questions and Answers for Freshers - Sanfoundry

Answer: a
Explanation: Number of elements present in stack is equal to the di erence between number
of push operations and number of pop operations. Number of elements is 5-4=1.

6. Which of the following is not an inherent application of stack?


a) Reversing a string
b) Evaluation of post x expression
c) Implementation of recursion
d) Job scheduling

View Answer

Answer: d
Explanation: Job Scheduling is not performed using stacks.

7. The type of expression in which operator succeeds its operands is?


a) In x Expression
b) Pre x Expression
c) Post x Expression
d) Both Pre x and Post x Expressions

View Answer

Answer: c
Explanation: The expression in which operator succeeds its operands is called post x
expression. The expression in which operator precedes the operands is called pre x
expression. If an operator is present between two operands, then it is called in x expressions.

8. Assume that the operators +,-, X are left associative and ^ is right associative. The order of
precedence (from highest to lowest) is ^, X, +, -. The post x expression for the in x expression a
+ b X c – d ^ e ^ f is?
a) abc X+ def ^^ –
b) abc X+ de^f^ –
c) ab+c Xd – e ^f^
d) -+aXbc^ ^def

View Answer

Answer: b
Explanation: Given In x Expression is a + b X c – d ^ e ^ f.
(a b c X +) (d ^ e ^ f). ‘–‘ is present in stack.
(a b c X + d e ^ f ^ -). Thus the nal expression is (a b c X + d e ^ f ^ -).

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-freshers/ 4/7
3/23/2021 Data Structure Questions and Answers for Freshers - Sanfoundry

9. If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a time, what is
the order of removal?
a) ABCD
b) DCBA
c) DCAB
d) ABDC

View Answer

Answer: b
Explanation: Stack follows LIFO(Last In First Out). So the removal order of elements are DCBA.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure for Freshers, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certi cation contest to get free Certi cate of Merit. Join our social
networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest

« Prev - Data Structure Questions and Answers – Stack Operations – 2


» Next - Data Structure Questions and Answers – Queue Operations

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-freshers/ 5/7
3/23/2021 Data Structure Questions and Answers for Freshers - Sanfoundry

Recommended Posts:
1. Compilers Questions and Answers
2. C Programming Examples on Linked List
3. Automata Theory Questions and Answers
4. Java Programming Examples on Graph Problems & Algorithms
5. Python Programming Examples on Linked Lists
6. C++ Programming Examples on Graph Problems & Algorithms
7. Petroleum Production Operations Questions and Answers
8. C Tutorials
9. Data Structures & Algorithms II – Questions and Answers
10. C Programming Examples on Bitwise Operations
11. C Programming Examples on Graph Problems & Algorithms
12. Data Science Questions and Answers
13. C++ Programming Examples on Data-Structures
14. Python Programming Examples on Stacks & Queues
15. Java Programming Examples on Data-Structures
16. C Programming Examples on Data-Structures
17. C# Programming Examples on Conversions
18. C Programming Examples on Stacks & Queues
19. C# Programming Examples on Data Structures
20. Data Structure Questions and Answers

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-freshers/ 6/7
3/23/2021 Data Structure Questions and Answers for Freshers - Sanfoundry

Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is
Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN
Architect and is passionate about competency developments in these areas.
He lives in Bangalore and delivers focused training sessions to IT
professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux
Networking, Linux Storage, Advanced C Programming, SAN Storage
Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber
Channel. Stay connected with him @ LinkedIn

Subscribe Sanfoundry Newsletter and Posts

Name*

Email*

Subscribe

About | Certi cations | Internships | Jobs | Privacy Policy | Terms | Copyright | Contact

     

© 2011-2021 Sanfoundry. All Rights Reserved.

https://www.sanfoundry.com/data-structure-questions-answers-freshers/ 7/7
3/23/2021 Queues Questions and Answers - Sanfoundry

Data Structure Questions and Answers –


Queue Operations
« Prev Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on “Queue
Operations”.

1. A linear list of elements in which deletion can be done from one end (front) and insertion can
take place only at the other end (rear) is known as _____________
a) Queue
b) Stack
c) Tree
d) Linked list

View Answer

Answer: a
Explanation: Linear list of elements in which deletion is done at front side and insertion at rear
side is called Queue. In stack we will delete the last entered element rst.

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-queue-operations/ 1/7
3/23/2021 Queues Questions and Answers - Sanfoundry

2. The data structure required for Breadth First Traversal on a graph is?
a) Stack
b) Array
c) Queue
d) Tree

View Answer

Answer: c
Explanation: In Breadth First Search Traversal, BFS, starting vertex is rst taken and adjacent
vertices which are unvisited are also taken. Again, the rst vertex which was added as an
unvisited adjacent vertex list will be considered to add further unvisited vertices of the graph.
To get the rst unvisited vertex we need to follows First In First Out principle. Queue uses FIFO
principle.

3. A queue follows __________


a) FIFO (First In First Out) principle
b) LIFO (Last In First Out) principle
c) Ordered array
d) Linear tree

View Answer

Answer: a
Explanation: Element rst added in queue will be deleted rst which is FIFO principle.

4. Circular Queue is also known as ________


a) Ring Bu er
b) Square Bu er
c) Rectangle Bu er

d) Curve Bu er

View Answer

https://www.sanfoundry.com/data-structure-questions-answers-queue-operations/ 2/7
3/23/2021 Queues Questions and Answers - Sanfoundry

Answer: a
Explanation: Circular Queue is also called as Ring Bu er. Circular Queue is a linear data
structure in which last position is connected back to the rst position to make a circle. It forms
a ring structure.

advertisement

All 10 Antenna Locations In GTA Online - Cayo Perico Heist

5. If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time, in
what order will they be removed?
a) ABCD
b) DCBA
c) DCAB
d) ABDC

View Answer

Answer: a
Explanation: Queue follows FIFO approach. i.e. First in First Out Approach. So, the order of
removal elements are ABCD.

6. A data structure in which elements can be inserted or deleted at/from both ends but not in
the middle is?
a) Queue
b) Circular queue
c) Dequeue
d) Priority queue

View Answer

Answer: c
Explanation: In dequeuer, we can insert or delete elements from both the ends. In queue, we

https://www.sanfoundry.com/data-structure-questions-answers-queue-operations/ 3/7
3/23/2021 Queues Questions and Answers - Sanfoundry

will follow rst in rst out principle for insertion and deletion of elements. Element with least
priority will be deleted in a priority queue.

7. A normal queue, if implemented using an array of size MAX_SIZE, gets full when?
a) Rear = MAX_SIZE – 1
b) Front = (rear + 1)mod MAX_SIZE
c) Front = rear + 1
d) Rear = front

View Answer

Answer: a
Explanation: When Rear = MAX_SIZE – 1, there will be no space left for the elements to be
added in queue. Thus queue becomes full.

advertisement

8. Queues serve major role in ______________


a) Simulation of recursion
b) Simulation of arbitrary linked list
c) Simulation of limited resource allocation
d) Simulation of heap sort

View Answer

Answer: c
Explanation: Simulation of recursion uses stack data structure. Simulation of arbitrary linked
lists uses linked lists. Simulation of resource allocation uses queue as rst entered data needs

to be given rst priority during resource allocation. Simulation of heap sort uses heap data
structure.

https://www.sanfoundry.com/data-structure-questions-answers-queue-operations/ 4/7
3/23/2021 Queues Questions and Answers - Sanfoundry

9. Which of the following is not the type of queue?


a) Ordinary queue
b) Single ended queue
c) Circular queue
d) Priority queue

View Answer

Answer: b
Explanation: Queue always has two ends. So, single ended queue is not the type of queue.

Sanfoundry Global Education & Learning Series – Data Structure.

advertisement

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice Questions
and Answers.

Participate in the Sanfoundry Certi cation contest to get free Certi cate of Merit. Join our social
networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest

« Prev - Data Structure Questions and Answers – Stack Operations – 3


» Next - Data Structure Questions and Answers – Singly Linked List Operations – 1

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-queue-operations/ 5/7
3/23/2021 Queues Questions and Answers - Sanfoundry

Recommended Posts:
1. Java Programming Examples on Collections
2. C Programming Examples using Recursion
3. C++ Programming Examples on Graph Problems & Algorithms
4. C++ Algorithms, Problems & Programming Examples
5. C Programming Examples without using Recursion
6. C Algorithms, Problems & Programming Examples
7. Java Algorithms, Problems & Programming Examples
8. C Programming Examples
9. Data Science Questions and Answers
10. C++ Programming Examples on STL
11. Data Structures & Algorithms II – Questions and Answers
12. Python Programming Examples on Stacks & Queues
13. C Programming Examples on Linked List
14. C Programming Examples on Stacks & Queues
15. Python Programming Examples on Linked Lists
16. C Programming Examples on Data-Structures
17. C++ Programming Examples on Data-Structures
18. C# Programming Examples on Data Structures
19. Java Programming Examples on Data-Structures
20. Data Structure Questions and Answers

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-queue-operations/ 6/7
3/23/2021 Queues Questions and Answers - Sanfoundry

Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is
Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN
Architect and is passionate about competency developments in these areas.
He lives in Bangalore and delivers focused training sessions to IT
professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux
Networking, Linux Storage, Advanced C Programming, SAN Storage
Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber
Channel. Stay connected with him @ LinkedIn

Subscribe Sanfoundry Newsletter and Posts

Name*

Email*

Subscribe

About | Certi cations | Internships | Jobs | Privacy Policy | Terms | Copyright | Contact

     

© 2011-2021 Sanfoundry. All Rights Reserved.

https://www.sanfoundry.com/data-structure-questions-answers-queue-operations/ 7/7
3/23/2021 Singly Linked Lists Interview Questions and Answers - Sanfoundry

Data Structure Questions and Answers – Singly


Linked List Operations – 1
« Prev Next »

This set of Data Structure Interview Questions & Answers focuses on “Singly Linked List
Operations – 1”.

1. A linear collection of data elements where the linear node is given by means of pointer is
called?
a) Linked list
b) Node list
c) Primitive list
d) Unordered list

View Answer

Answer: a
Explanation: In Linked list each node has its own data and the address of next node. These
nodes are linked by using pointers. Node list is an object that consists of a list of all nodes in a
document with in a particular selected set of nodes. 

advertisement

https://www.sanfoundry.com/data-structure-interview-questions-answers-single-linked-lists/ 1/8
3/23/2021 Singly Linked Lists Interview Questions and Answers - Sanfoundry

2. Consider an implementation of unsorted singly linked list. Suppose it has its representation
with a head pointer only. Given the representation, which of the following operation can be
implemented in O(1) time?

i) Insertion at the front of the linked list


ii) Insertion at the end of the linked list
iii) Deletion of the front node of the linked list
iv) Deletion of the last node of the linked list

a) I and II
b) I and III
c) I, II and III
d) I, II and IV

View Answer

Answer: b
Explanation: We know the head node in the given linked list. Insertion and deletion of
elements at the front of the linked list completes in O (1) time whereas for insertion and
deletion at the last node requires to traverse through every node in the linked list. Suppose
there are n elements in a linked list, we need to traverse through each node. Hence time
complexity becomes O(n).

3. In linked list each node contains a minimum of two elds. One eld is data eld to store the
data second eld is?
a) Pointer to character
b) Pointer to integer
c) Pointer to node
d) Node

View Answer

Answer: c
Explanation: Each node in a linked list contains data and a pointer (reference) to the next
https://www.sanfoundry.com/data-structure-interview-questions-answers-single-linked-lists/ 2/8
3/23/2021 Singly Linked Lists Interview Questions and Answers - Sanfoundry

node. Second eld contains pointer to node.

advertisement

All 10 Antenna Locations In GTA Online - Cayo Perico Heist

4. What would be the asymptotic time complexity to add a node at the end of singly linked list, if
the pointer is initially pointing to the head of the list?
a) O(1)
b) O(n)
c) θ(n)
d) θ(1)

View Answer

Answer: c
Explanation: In case of a linked list having n elements, we need to travel through every node of
the list to add the element at the end of the list. Thus asymptotic time complexity is θ(n).

5. What would be the asymptotic time complexity to insert an element at the front of the linked
list (head is known)?
a) O(1)
b) O(n)
c) O(n2)
d) O(n3)

View Answer

Answer: a 
Explanation: To add an element at the front of the linked list, we will create a new node which
holds the data to be added to the linked list and pointer which points to head position in the
linked list. The entire thing happens within O (1) time. Thus the asymptotic time complexity is
O (1).

https://www.sanfoundry.com/data-structure-interview-questions-answers-single-linked-lists/ 3/8
3/23/2021 Singly Linked Lists Interview Questions and Answers - Sanfoundry

6. What would be the asymptotic time complexity to nd an element in the linked list?
a) O(1)
b) O(n)
c) O(n2)
d) O(n4)

View Answer

Answer: b
Explanation: If the required element is in the last position, we need to traverse the entire
linked list. This will take O (n) time to search the element.

7. What would be the asymptotic time complexity to insert an element at the second position in
the linked list?
a) O(1)
b) O(n)
c) O(n2)
d) O(n3)

View Answer

Answer: a
Explanation: A new node is created with the required element. The pointer of the new node
points the node to which the head node of the linked list is also pointing. The head node
pointer is changed and it points to the new node which we created earlier. The entire process
completes in O (1) time. Thus the asymptotic time complexity to insert an element in the
second position of the linked list is O (1).

advertisement

8. The concatenation of two lists can be performed in O(1) time. Which of the following variation
of the linked list can be used?

https://www.sanfoundry.com/data-structure-interview-questions-answers-single-linked-lists/ 4/8
3/23/2021 Singly Linked Lists Interview Questions and Answers - Sanfoundry

a) Singly linked list


b) Doubly linked list
c) Circular doubly linked list
d) Array implementation of list

View Answer

Answer: c
Explanation: We can easily concatenate two lists in O (1) time using singly or doubly linked list,
provided that we have a pointer to the last node at least one of the lists. But in case of circular
doubly linked lists, we will break the link in both the lists and hook them together. Thus
circular doubly linked list concatenates two lists in O (1) time.

9. Consider the following de nition in c programming language.

struct node
{
int data;
struct node * next;
}
typedef struct node NODE;
NODE *ptr;

Which of the following c code is used to create new node?


a) ptr = (NODE*)malloc(sizeof(NODE));
b) ptr = (NODE*)malloc(NODE);
c) ptr = (NODE*)malloc(sizeof(NODE*));
d) ptr = (NODE)malloc(sizeof(NODE));

View Answer

Answer: a
Explanation: As it represents the right way to create a node.

advertisement

https://www.sanfoundry.com/data-structure-interview-questions-answers-single-linked-lists/ 5/8
3/23/2021 Singly Linked Lists Interview Questions and Answers - Sanfoundry

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure for Interviews, here is complete set of 1000+ Multiple
Choice Questions and Answers.

Participate in the Sanfoundry Certi cation contest to get free Certi cate of Merit. Join our social
networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest

« Prev - Data Structure Questions and Answers – Queue Operations


» Next - Data Structure Questions and Answers – Singly Linked List Operations – 2

advertisement

Recommended Posts:
1. Python Programming Examples
2. Java Programming Examples on Collections
3. Home
4. C Programming Examples on Trees
5. C++ Programming Examples on Combinatorial Problems & Algorithms
6. C Programming Examples using Recursion
7. Java Programming Examples on Combinatorial Problems & Algorithms
8. C Programming Examples on Stacks & Queues
9. Data Science Questions and Answers 
10. C Tutorials
11. C Programming Examples on Combinatorial Problems & Algorithms
12. Data Structures & Algorithms II – Questions and Answers
13. C Programming Examples without using Recursion

https://www.sanfoundry.com/data-structure-interview-questions-answers-single-linked-lists/ 6/8
3/23/2021 Singly Linked Lists Interview Questions and Answers - Sanfoundry

14. C# Programming Examples on Data Structures


15. Java Programming Examples on Data-Structures
16. C Programming Examples on Data-Structures
17. C++ Programming Examples on Data-Structures
18. Data Structure Questions and Answers
19. Python Programming Examples on Linked Lists
20. C Programming Examples on Linked List

advertisement

Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is
Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN
Architect and is passionate about competency developments in these areas.
He lives in Bangalore and delivers focused training sessions to IT
professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux
Networking, Linux Storage, Advanced C Programming, SAN Storage
Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber
Channel. Stay connected with him @ LinkedIn

Subscribe Sanfoundry Newsletter and Posts

Name*

Email*

Subscribe

https://www.sanfoundry.com/data-structure-interview-questions-answers-single-linked-lists/ 7/8
3/23/2021 Singly Linked Lists Interview Questions and Answers - Sanfoundry

About | Certi cations | Internships | Jobs | Privacy Policy | Terms | Copyright | Contact

     

© 2011-2021 Sanfoundry. All Rights Reserved.

https://www.sanfoundry.com/data-structure-interview-questions-answers-single-linked-lists/ 8/8
3/23/2021 Data Structure Interview Questions and Answers for Freshers - Sanfoundry

Data Structure Questions and Answers – Singly


Linked List Operations – 2
« Prev Next »

This set of Data Structure Interview Questions and Answers for freshers focuses on “Singly
Linked Lists Operations – 2”.

1. What kind of linked list is best to answer questions like “What is the item at position n?”
a) Singly linked list
b) Doubly linked list
c) Circular linked list
d) Array implementation of linked list

View Answer

Answer: d
Explanation: Arrays provide random access to elements by providing the index value within
square brackets. In the linked list, we need to traverse through each element until we reach
the nth position. Time taken to access an element represented in arrays is less than the singly,
doubly and circular linked lists. Thus, array implementation is used to access the item at the
position n.

advertisement

https://www.sanfoundry.com/data-structure-interview-questions-answers-freshers/ 1/7
3/23/2021 Data Structure Interview Questions and Answers for Freshers - Sanfoundry

2. Linked lists are not suitable for the implementation of ___________


a) Insertion sort
b) Radix sort
c) Polynomial manipulation
d) Binary search

View Answer

Answer: d
Explanation: It cannot be implemented using linked lists.

3. Linked list is considered as an example of ___________ type of memory allocation.


a) Dynamic
b) Static
c) Compile time
d) Heap

View Answer

Answer: a
Explanation: As memory is allocated at the run time.

4. In Linked List implementation, a node carries information regarding ___________


a) Data
b) Link
c) Data and Link
d) Node

View Answer

Answer: b
Explanation: A linked list is a collection of objects linked together by references from an object
to another object. By convention these objects are names as nodes. Linked list consists of
https://www.sanfoundry.com/data-structure-interview-questions-answers-freshers/ 2/7
3/23/2021 Data Structure Interview Questions and Answers for Freshers - Sanfoundry

nodes where each node contains one or more data elds and a reference(link) to the next
node.

5. Linked list data structure o ers considerable saving in _____________


a) Computational Time
b) Space Utilization
c) Space Utilization and Computational Time
d) Speed Utilization

View Answer

Answer: c
Explanation: Linked lists saves both space and time.

advertisement

All 10 Antenna Locations In GTA Online - Cayo Perico Heist

6. Which of the following points is/are not true about Linked List data structure when it is
compared with an array?
a) Arrays have better cache locality that can make them better in terms of performance
b) It is easy to insert and delete elements in Linked List
c) Random access is not allowed in a typical implementation of Linked Lists
d) Access of elements in linked list takes less time than compared to arrays

View Answer

Answer: d
Explanation: To access an element in a linked list, we need to traverse every element until we
reach the desired element. This will take more time than arrays as arrays provide random
access to its elements.

7. What does the following function do for a given Linked List with rst node as head?
https://www.sanfoundry.com/data-structure-interview-questions-answers-freshers/ 3/7
3/23/2021 Data Structure Interview Questions and Answers for Freshers - Sanfoundry

void fun1(struct node* head)


{
if(head == NULL)
return;
fun1(head->next);
printf("%d ", head->data);
}

a) Prints all nodes of linked lists


b) Prints all nodes of linked list in reverse order
c) Prints alternate nodes of Linked List
d) Prints alternate nodes in reverse order

View Answer

Answer: b
Explanation: fun1() prints the given Linked List in reverse manner.
For Linked List 1->2->3->4->5, fun1() prints 5->4->3->2->1.

advertisement

8. Which of the following sorting algorithms can be used to sort a random linked list with
minimum time complexity?
a) Insertion Sort
b) Quick Sort
c) Heap Sort
d) Merge Sort

View Answer

Answer: d
Explanation: Both Merge sort and Insertion sort can be used for linked lists. The slow random-
access performance of a linked list makes other algorithms (such as quicksort) perform poorly,

https://www.sanfoundry.com/data-structure-interview-questions-answers-freshers/ 4/7
3/23/2021 Data Structure Interview Questions and Answers for Freshers - Sanfoundry

and others (such as heapsort) completely impossible. Since worst case time complexity of
Merge Sort is O(nLogn) and Insertion sort is O(n2), merge sort is preferred.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure for Interviews, here is complete set of 1000+ Multiple
Choice Questions and Answers.

Participate in the Sanfoundry Certi cation contest to get free Certi cate of Merit. Join our social
networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest

« Prev - Data Structure Questions and Answers – Singly Linked List Operations – 1
» Next - Data Structure Questions and Answers – Singly Linked List Operations – 3

advertisement

Recommended Posts:
1. Java Programming Examples on Collections
2. C Programming Examples on Searching and Sorting
3. Data Structures & Algorithms II – Questions and Answers
4. C Programming Examples on Arrays
5. C# Programming Examples on Sorting
6. C Programming Examples on Trees
7. C Programming Examples
8. C Programming Examples on Stacks & Queues
9. Java Programming Examples on Combinatorial Problems & Algorithms
10. C++ Programming Examples on Combinatorial Problems & Algorithms
11. C Programming Examples without using Recursion
12. C Programming Examples using Recursion

https://www.sanfoundry.com/data-structure-interview-questions-answers-freshers/ 5/7
3/23/2021 Data Structure Interview Questions and Answers for Freshers - Sanfoundry

13. C# Programming Examples on Data Structures


14. C Programming Examples on Combinatorial Problems & Algorithms
15. Java Programming Examples on Data-Structures
16. C Programming Examples on Data-Structures
17. C++ Programming Examples on Data-Structures
18. Data Structure Questions and Answers
19. Python Programming Examples on Linked Lists
20. C Programming Examples on Linked List

advertisement

Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is
Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN
Architect and is passionate about competency developments in these areas.
He lives in Bangalore and delivers focused training sessions to IT
professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux
Networking, Linux Storage, Advanced C Programming, SAN Storage
Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber
Channel. Stay connected with him @ LinkedIn

Subscribe Sanfoundry Newsletter and Posts

Name*

Email*

Subscribe

https://www.sanfoundry.com/data-structure-interview-questions-answers-freshers/ 6/7
3/23/2021 Data Structure Interview Questions and Answers for Freshers - Sanfoundry

About | Certi cations | Internships | Jobs | Privacy Policy | Terms | Copyright | Contact

     

© 2011-2021 Sanfoundry. All Rights Reserved.

https://www.sanfoundry.com/data-structure-interview-questions-answers-freshers/ 7/7
3/23/2021 Data Structure Questions and Answers for Experienced - Sanfoundry

Data Structure Questions and Answers – Singly


Linked List Operations – 3
« Prev Next »

This set of Data Structure Questions and Answers for Experienced people focuses on “Singly
Linked Lists Operations – 3”.

1. The following function reverse() is supposed to reverse a singly linked list. There is one line
missing at the end of the function.

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-experienced/ 1/9
3/23/2021 Data Structure Questions and Answers for Experienced - Sanfoundry

/* Link list node */


struct node
{
int data;
struct node* next;
};

/* head_ref is a double pointer which points to head (or start) pointer


of linked list */
static void reverse(struct node** head_ref)
{
struct node* prev = NULL;
struct node* current = *head_ref;
struct node* next;
while (current != NULL)
{
next = current->next;
current->next = prev;
prev = current;
current = next;
}
/*ADD A STATEMENT HERE*/
}

What should be added in place of “/*ADD A STATEMENT HERE*/”, so that the function correctly
reverses a linked list.
a) *head_ref = prev;
b) *head_ref = current;
c) *head_ref = next;
d) *head_ref = NULL;

View Answer

Answer: a
Explanation: *head_ref = prev; At the end of while loop, the prev pointer points to the last
node of original linked list.
We need to change *head_ref so that the head pointer now starts pointing to the last node.

2. What is the output of following function for start pointing to rst node of following linked list?

1->2->3->4->5->6
void fun(struct node* start)
{
if(start == NULL)
return;
printf("%d ", start->data);

https://www.sanfoundry.com/data-structure-questions-answers-experienced/ 2/9
3/23/2021 Data Structure Questions and Answers for Experienced - Sanfoundry

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

View Answer

Answer: d
Explanation: fun() prints alternate nodes of the given Linked List, rst from head to end, and
then from end to head.
If Linked List has even number of nodes, then skips the last node.

advertisement
Dainsleif questions and answers in Genshin Impact

3. The following C function takes a simply-linked list as an input argument. It modi es the list by
moving the last element to the front of the list and returns the modi ed list. Some part of the
code is left blank. Choose the correct alternative to replace the blank line.

typedef struct node


{
int value;
struct node *next;
}Node;

Node *move_to_front(Node *head)


{
Node *p, *q;

https://www.sanfoundry.com/data-structure-questions-answers-experienced/ 3/9
3/23/2021 Data Structure Questions and Answers for Experienced - Sanfoundry

if ((head == NULL: || (head->next == NULL))


return head;
q = NULL; p = head;
while (p-> next !=NULL)
{
q = p;
p = p->next;
}
_______________________________
return head;
}

a) q = NULL; p->next = head; head = p;


b) q->next = NULL; head = p; p->next = head;
c) head = p; p->next = q; q->next = NULL;
d) q->next = NULL; p->next = head; head = p;

View Answer

Answer: d
Explanation: When while loop completes its execution, node ‘p’ refers to the last node whereas
the ‘q’ node refers to the node before ‘p’ in the linked list. q->next=NULL makes q as the last
node. p->next=head places p as the rst node. the head must be modi ed to ‘p’ as ‘p’ is the
starting node of the list (head=p). Thus the sequence of steps are q->next=NULL, p-
>next=head, head=p.

4. The following C function takes a single-linked list of integers as a parameter and rearranges
the elements of the list. The function is called with the list containing the integers 1, 2, 3, 4, 5, 6, 7
in the given order. What will be the contents of the list after the function completes execution?

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-experienced/ 4/9
3/23/2021 Data Structure Questions and Answers for Experienced - Sanfoundry

struct node
{
int value;
struct node *next;
};
void rearrange(struct node *list)
{
struct node *p, * q;
int temp;
if ((!list) || !list->next)
return;
p = list;
q = list->next;
while(q)
{
temp = p->value;
p->value = q->value;
q->value = temp;
p = q->next;
q = p?p->next:0;
}
}

a) 1, 2, 3, 4, 5, 6, 7
b) 2, 1, 4, 3, 6, 5, 7
c) 1, 3, 2, 5, 4, 7, 6
d) 2, 3, 4, 5, 6, 7, 1

View Answer

Answer: b
Explanation: The function rearrange() exchanges data of every node with its next node. It
starts exchanging data from the rst node itself.

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

View Answer

Answer: d
Explanation: In the worst case, the element to be searched has to be compared with all
elements of the linked list.

6. Given pointer to a node X in a singly linked list. Only one pointer is given, pointer to head node
is not given, can we delete the node X from given linked list?
https://www.sanfoundry.com/data-structure-questions-answers-experienced/ 5/9
3/23/2021 Data Structure Questions and Answers for Experienced - Sanfoundry

a) Possible if X is not last node


b) Possible if size of linked list is even
c) Possible if size of linked list is odd
d) Possible if X is not rst node

View Answer

Answer: a
Explanation: Following are simple steps.

struct node *temp = X->next;


X->data = temp->data;
X->next = temp->next;
free(temp);

7. You are given pointers to rst and last nodes of a singly linked list, which of the following
operations are dependent on the length of the linked list?
a) Delete the rst element
b) Insert a new element as a rst element
c) Delete the last element of the list
d) Add a new element at the end of the list

View Answer

Answer: c
Explanation: Deletion of the rst element of the list is done in O (1) time by deleting memory
and changing the rst pointer.
Insertion of an element as a rst element can be done in O (1) time. We will create a node that
holds data and points to the head of the given linked list. The head pointer was changed to a
newly created node.
Deletion of the last element requires a pointer to the previous node of last, which can only be
obtained by traversing the list. This requires the length of the linked list.
Adding a new element at the end of the list can be done in O (1) by changing the pointer of the
last node to the newly created node and last is changed to a newly created node.

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-experienced/ 6/9
3/23/2021 Data Structure Questions and Answers for Experienced - Sanfoundry

8. In the worst case, the number of comparisons needed to search a singly linked list of length n
for a given element is?
a) log2 n
b) n⁄2
c) log2 n – 1
d) n

View Answer

Answer: d
Explanation: The worst-case happens if the required element is at last or the element is absent
in the list. For this, we need to compare every element in the linked list. If n elements are
there, n comparisons will happen in the worst case.

Sanfoundry Global Education & Learning Series – Data Structure.

TTo practice all areas of Data Structure for Experienced people, here is complete set of 1000+
Multiple Choice Questions and Answers.

Participate in the Sanfoundry Certi cation contest to get free Certi cate of Merit. Join our social
networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest

« Prev - Data Structure Questions and Answers – Singly Linked List Operations – 2
» Next - Data Structure Questions and Answers – Singly Linked List

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-experienced/ 7/9
3/23/2021 Data Structure Questions and Answers for Experienced - Sanfoundry

Recommended Posts:
1. Python Programming Examples on Trees
2. Java Programming Examples on Collections
3. Heat Transfer Operations Questions and Answers
4. C Programming Examples on Arrays
5. C Programming Examples on Bitwise Operations
6. C Programming Examples on Combinatorial Problems & Algorithms
7. C Tutorials
8. C Programming Examples on Stacks & Queues
9. Data Science Questions and Answers
10. C Programming Examples on Trees
11. C Programming Examples using Recursion
12. Data Structures & Algorithms II – Questions and Answers
13. C Programming Examples without using Recursion
14. C Programming Examples on Data-Structures
15. Java Programming Examples on Data-Structures
16. C# Programming Examples on Data Structures
17. C++ Programming Examples on Data-Structures
18. Data Structure Questions and Answers
19. Python Programming Examples on Linked Lists
20. C Programming Examples on Linked List

advertisement

Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is
Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN
Architect and is passionate about competency developments in these areas.
He lives in Bangalore and delivers focused training sessions to IT
professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux
Networking, Linux Storage, Advanced C Programming, SAN Storage

https://www.sanfoundry.com/data-structure-questions-answers-experienced/ 8/9
3/23/2021 Data Structure Questions and Answers for Experienced - Sanfoundry

Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with
him @ LinkedIn

Subscribe Sanfoundry Newsletter and Posts

Name*

Email*

Subscribe

About | Certi cations | Internships | Jobs | Privacy Policy | Terms | Copyright | Contact

     

© 2011-2021 Sanfoundry. All Rights Reserved.

https://www.sanfoundry.com/data-structure-questions-answers-experienced/ 9/9
3/23/2021 Singly Linked Lists Questions and Answers - Sanfoundry

Data Structure Questions and Answers – Singly


Linked List
« Prev Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on “Singly Linked
List”.

1. Which of the following is not a disadvantage to the usage of array?


a) Fixed size
b) There are chances of wastage of memory space if elements inserted in an array are lesser
than the allocated size
c) Insertion based on position
d) Accessing elements at speci ed positions

View Answer

Answer: d
Explanation: Array elements can be accessed in two steps. First, multiply the size of the data
type with the speci ed position, second, add this value to the base address. Both of these
operations can be done in constant time, hence accessing elements at a given index/position 
is faster.

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-single-linked-lists/ 1/14
3/23/2021 Singly Linked Lists Questions and Answers - Sanfoundry

2. What is the time complexity of inserting at the end in dynamic arrays?


a) O(1)
b) O(n)
c) O(logn)
d) Either O(1) or O(n)

View Answer

Answer: d
Explanation: Depending on whether the array is full or not, the complexity in dynamic array
varies. If you try to insert into an array that is not full, then the element is simply stored at the
end, this takes O(1) time. If you try to insert into an array which is full, rst you will have to
allocate an array with double the size of the current array and then copy all the elements into
it and nally insert the new element, this takes O(n) time.

3. What is the time complexity to count the number of elements in the linked list?
a) O(1)
b) O(n)
c) O(logn)
d) O(n2)

View Answer

Answer: b
Explanation: To count the number of elements, you have to traverse through the entire list,
hence complexity is O(n).

4. Which of the following performs deletion of the last element in the list? Given below is the

Node class.

class Node
{

https://www.sanfoundry.com/data-structure-questions-answers-single-linked-lists/ 2/14
3/23/2021 Singly Linked Lists Questions and Answers - Sanfoundry

protected Node next;


protected Object ele;
Node(Object e,Node n)
{
ele = e;
next = n;
}
public void setNext(Node n)
{
next = n;
}
public void setEle(Object e)
{
ele = e;
}
public Node getNext()
{
return next;
}
public Object getEle()
{
return ele;
}
}
class SLL
{
Node head;
int size;
SLL()
{
size = 0;
}
}

a)

public Node removeLast()


{
if(size == 0)
return null;
Node cur;
Node temp;
cur = head;
while(cur.getNext() != null)
{
temp = cur;
cur = cur.getNext(); 
}
temp.setNext(null);
size--;

https://www.sanfoundry.com/data-structure-questions-answers-single-linked-lists/ 3/14
3/23/2021 Singly Linked Lists Questions and Answers - Sanfoundry

return cur;
}

b)

advertisement
All 10 Antenna Locations In GTA Online - Cayo Perico Heist

public void removeLast()


{
if(size == 0)
return null;
Node cur;
Node temp;
cur = head;
while(cur != null)
{
temp = cur;
cur = cur.getNext();
}
temp.setNext(null);
return cur;
}

c)

public void removeLast()


{
if(size == 0)
return null; 
Node cur;
Node temp;
cur = head;
while(cur != null)

https://www.sanfoundry.com/data-structure-questions-answers-single-linked-lists/ 4/14
3/23/2021 Singly Linked Lists Questions and Answers - Sanfoundry

{
cur = cur.getNext();
temp = cur;
}
temp.setNext(null);
return cur;
}

d)

public void removeLast()


{
if(size == 0)
return null;
Node cur;
Node temp;
cur = head;
while(cur.getNext() != null)
{
cur = cur.getNext();
temp = cur;
}
temp.setNext(null);
return cur;
}

View Answer
Answer: a
Explanation: Since you have to traverse to the end of the list and delete the last node, you
need two reference pointers. ‘cur’ to traverse all the way and nd the last node, and ‘temp’ is a
trailing pointer to ‘cur’. Once you reach the end of the list, setNext of ‘temp’ to null, ‘cur’ is not
being pointed to by any node, and hence it is available for garbage collection.

 
 

5. What is the functionality of the following code?

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-single-linked-lists/ 5/14
3/23/2021 Singly Linked Lists Questions and Answers - Sanfoundry

public void function(Node node)


{
if(size == 0)
head = node;
else
{
Node temp,cur;
for(cur = head; (temp = cur.getNext())!=null; cur = temp);
cur.setNext(node);
}
size++;
}

a) Inserting a node at the beginning of the list


b) Deleting a node at the beginning of the list
c) Inserting a node at the end of the list
d) Deleting a node at the end of the list

View Answer

Answer: c
Explanation: The for loop traverses through the list and then inserts a new node as
cur.setNext(node);

6. What is the space complexity for deleting a linked list?


a) O(1)
b) O(n)
c) Either O(1) or O(n)
d) O(logn)

View Answer

Answer: a
Explanation: You need a temp variable to keep track of current node, hence the space
complexity is O(1).

7. How would you delete a node in the singly linked list? The position to be deleted is given.
a)

public void delete(int pos)


{
if(pos < 0)
https://www.sanfoundry.com/data-structure-questions-answers-single-linked-lists/ 6/14
3/23/2021 Singly Linked Lists Questions and Answers - Sanfoundry

pos = 0;
if(pos > size)
pos = size;
if( size == 0)
return;
if(pos == 0)
head = head.getNext();
else
{
Node temp = head;
for(int i=1; i<pos; i++)
{
temp = temp.getNext();
}
temp.setNext(temp.getNext().getNext());
}
size--;
}

b)

public void delete(int pos)


{
if(pos < 0)
pos = 0;
if(pos > size)
pos = size;
if( size == 0)
return;
if(pos == 0)
head = head.getNext();
else
{
Node temp = head;
for(int i=1; i<pos; i++)
{
temp = temp.getNext();
}
temp.setNext(temp.getNext());
}
size--;
}

c)

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-single-linked-lists/ 7/14
3/23/2021 Singly Linked Lists Questions and Answers - Sanfoundry

public void delete(int pos)


{
if(pos < 0)
pos = 0;
if(pos > size)
pos = size;
if( size == 0)
return;
if(pos == 0)
head = head.getNext();
else
{
Node temp = head;
for(int i=1; i<pos; i++)
{
temp = temp.getNext().getNext();
}
temp.setNext(temp.getNext().getNext());
}
size--;
}

d)

public void delete(int pos)


{
if(pos < 0)
pos = 0;
if(pos > size)
pos = size;
if( size == 0)
return;
if(pos == 0)
head = head.getNext();
else 
{
Node temp = head;
for(int i=0; i<pos; i++)
{

https://www.sanfoundry.com/data-structure-questions-answers-single-linked-lists/ 8/14
3/23/2021 Singly Linked Lists Questions and Answers - Sanfoundry

temp = temp.getNext();
}
temp.setNext(temp.getNext().getNext());
}
size--;
}

View Answer
Answer: a
Explanation: Loop through the list to get into position one behind the actual position given.
temp.setNext(temp.getNext().getNext()) will delete the speci ed node.

 
 

8. Which of these is not an application of a linked list?


a) To implement le systems
b) For separate chaining in hash-tables
c) To implement non-binary trees
d) Random Access of elements

View Answer

Answer: d
Explanation: To implement le system, for separate chaining in hash-tables and to implement
non-binary trees linked lists are used. Elements are accessed sequentially in linked list.
Random access of elements is not an applications of linked list.

9. Which of the following piece of code has the functionality of counting the number of elements
in the list?
a)

public int length(Node head)


{
int size = 0;
Node cur = head;
while(cur!=null)
{
size++;
cur = cur.getNext();
}
return size;
}

b)

public int length(Node head)


{
https://www.sanfoundry.com/data-structure-questions-answers-single-linked-lists/ 9/14
3/23/2021 Singly Linked Lists Questions and Answers - Sanfoundry

int size = 0;
Node cur = head;
while(cur!=null)
{
cur = cur.getNext();
size++;
}
return size;
}

c)

public int length(Node head)


{
int size = 0;
Node cur = head;
while(cur!=null)
{
size++;
cur = cur.getNext();
}
}

d)

public int length(Node head)


{
int size = 0;
Node cur = head;
while(cur!=null)
{
size++;
cur = cur.getNext().getNext();
}
return size;
}

View Answer
Answer: a
Explanation: ‘cur’ pointer traverses through list and increments the size variable until the end
of list is reached.

 
 

10. How do you insert an element at the beginning of the list?
a)

https://www.sanfoundry.com/data-structure-questions-answers-single-linked-lists/ 10/14
3/23/2021 Singly Linked Lists Questions and Answers - Sanfoundry

public void insertBegin(Node node)


{
node.setNext(head);
head = node;
size++;
}

b)

public void insertBegin(Node node)


{
head = node;
node.setNext(head);
size++;
}

c)

public void insertBegin(Node node)


{
Node temp = head.getNext()
node.setNext(temp);
head = node;
size++;
}

d)

public void insertBegin(Node node)


{
Node temp = head.getNext()
node.setNext(temp);
node = head;
size++;
}

View Answer
Answer: a
Explanation: Set the ‘next’ pointer point to the head of the list and then make this new node as
the head.

 
 

11. What is the functionality of the following piece of code?

public int function(int data)


{

https://www.sanfoundry.com/data-structure-questions-answers-single-linked-lists/ 11/14
3/23/2021 Singly Linked Lists Questions and Answers - Sanfoundry

Node temp = head;


int var = 0;
while(temp != null)
{
if(temp.getData() == data)
{
return var;
}
var = var+1;
temp = temp.getNext();
}
return Integer.MIN_VALUE;
}

a) Find and delete a given element in the list


b) Find and return the given element in the list
c) Find and return the position of the given element in the list
d) Find and insert a new element in the list

View Answer

Answer: c
Explanation: When temp is equal to data, the position of data is returned.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice Questions
and Answers.

Participate in the Sanfoundry Certi cation contest to get free Certi cate of Merit. Join our social
networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest

« Prev - Data Structure Questions and Answers – Singly Linked List Operations – 3
» Next - Data Structure Questions and Answers – Doubly Linked List

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-single-linked-lists/ 12/14
3/23/2021 Singly Linked Lists Questions and Answers - Sanfoundry

Recommended Posts:
1. C Programming Examples using Recursion
2. C Programming Examples on Searching and Sorting
3. C++ Programming Examples on Combinatorial Problems & Algorithms
4. Data Science Questions and Answers
5. Python Programming Examples on Trees
6. Java Programming Examples on Arrays
7. Java Programming Examples on Combinatorial Problems & Algorithms
8. Java Programming Examples on Collections
9. C Programming Examples on Trees
10. C Programming Examples on Combinatorial Problems & Algorithms
11. C Programming Examples on Arrays
12. C# Programming Examples on Arrays
13. Data Structures & Algorithms II – Questions and Answers
14. C# Programming Examples on Data Structures
15. Java Programming Examples on Data-Structures
16. C Programming Examples on Data-Structures
17. C++ Programming Examples on Data-Structures
18. Data Structure Questions and Answers
19. Python Programming Examples on Linked Lists
20. C Programming Examples on Linked List

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-single-linked-lists/ 13/14
3/23/2021 Singly Linked Lists Questions and Answers - Sanfoundry

Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at
Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate
about competency developments in these areas. He lives in Bangalore and
delivers focused training sessions to IT professionals in Linux Kernel, Linux
Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced
C Programming, SAN Storage Technologies, SCSI Internals & Storage
Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn

Subscribe Sanfoundry Newsletter and Posts

Name*

Email*

Subscribe

About | Certi cations | Internships | Jobs | Privacy Policy | Terms | Copyright | Contact

     

© 2011-2021 Sanfoundry. All Rights Reserved.

https://www.sanfoundry.com/data-structure-questions-answers-single-linked-lists/ 14/14
3/23/2021 Doubly Linked Lists Questions and Answers - Sanfoundry

Data Structure Questions and Answers –


Doubly Linked List
« Prev Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on “Doubly
Linked List”.

1. Which of the following is false about a doubly linked list?


a) We can navigate in both the directions
b) It requires more space than a singly linked list
c) The insertion and deletion of a node take a bit longer
d) Implementing a doubly linked list is easier than singly linked list

View Answer

Answer: d
Explanation: A doubly linked list has two pointers ‘left’ and ‘right’ which enable it to traverse in
either direction. Compared to singly liked list which has only a ‘next’ pointer, doubly linked list
requires extra space to store this extra pointer. Every insertion and deletion requires
manipulation of two pointers, hence it takes a bit longer time. Implementing doubly linked list 
involves setting both left and right pointers to correct nodes and takes more time than singly
linked list.

advertisement
https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 1/13
3/23/2021 Doubly Linked Lists Questions and Answers - Sanfoundry

2. Given the Node class implementation, select one of the following that correctly inserts a node
at the tail of the list.

public class Node


{
protected int data;
protected Node prev;
protected Node next;
public Node(int data)
{
this.data = data;
prev = null;
next = null;
}
public Node(int data, Node prev, Node next)
{
this.data = data;
this.prev = prev;
this.next = next;
}
public int getData()
{
return data;
}
public void setData(int data)
{
this.data = data;
}
public Node getPrev()
{

return prev;
}
public void setPrev(Node prev)
{

https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 2/13
3/23/2021 Doubly Linked Lists Questions and Answers - Sanfoundry

this.prev = prev;
}
public Node getNext
{
return next;
}
public void setNext(Node next)
{
this.next = next;
}
}
public class DLL
{
protected Node head;
protected Node tail;
int length;
public DLL()
{
head = new Node(Integer.MIN_VALUE,null,null);
tail = new Node(Integer.MIN_VALUE,null,null);
head.setNext(tail);
length = 0;
}
}

a)

public void insertRear(int data)


{
Node node = new Node(data,tail.getPrev(),tail);
node.getPrev().setNext(node);
tail.setPrev(node);
length++;
}

b)

public void insertRear(int data)


{
Node node = new Node(data,tail.getPrev(),tail);
node.getPrev().getPrev().setNext(node);
tail.setPrev(node);
length++;
}

c)

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 3/13
3/23/2021 Doubly Linked Lists Questions and Answers - Sanfoundry

All 10 Antenna Locations In GTA Online - Cayo Perico Heist

public void insertRear(int data)


{
Node node = new Node(data,tail.getPrev(),tail);
node.getPrev().setNext(tail);
tail.setPrev(node);
length++;
}

d)

public void insertRear(int data)


{
Node node = new Node(data,head,tail);
node.getPrev().setNext(node);
tail.setPrev(node);
length++;
}

View Answer
Answer: a
Explanation: First create a new node whose ‘prev’ points to the node pointed to by the ‘prev’ of
tail. The ‘next’ of the new node should point to tail. Set the ‘prev’ of tail to point to new node
and the ‘prev’ of new node to point to the new node.

 
  

3. What is a memory e cient double linked list?


a) Each node has only one pointer to traverse the list back and forth
b) The list has breakpoints for faster traversal

https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 4/13
3/23/2021 Doubly Linked Lists Questions and Answers - Sanfoundry

c) An auxiliary singly linked list acts as a helper list to traverse through the doubly linked list
d) A doubly linked list that uses bitwise AND operator for storing addresses

View Answer

Answer: a
Explanation: Memory e cient doubly linked list has only one pointer to traverse the list back
and forth. The implementation is based on pointer di erence. It uses bitwise XOR operator to
store the front and rear pointer addresses. Instead of storing actual memory address, every
node store the XOR address of previous and next nodes.

4. Which of the following piece of code removes the node from a given position?
a)

public void remove(int pos)


{
if(pos<0 || pos>=size)
{
System.out.println("Invalid position");
return;
}
else
{
if(head == null)
return;
if(pos == 0)
{
head = head.getNext();
if(head == null)
tail = null;
}
else
{
Node temp = head;
for(int i=1; i<position; i++)
temp = temp.getNext();
}
temp.getNext().setPrev(temp.getPrev());
temp.getPrev().setNext(temp.getNext());
}
size--;
}

b)


advertisement

https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 5/13
3/23/2021 Doubly Linked Lists Questions and Answers - Sanfoundry

public void remove(int pos)


{
if(pos<0 || pos>=size)
{
System.out.println("Invalid position");
return;
}
else
{
if(head == null)
return;
if(pos == 0)
{
head = head.getNext();
if(head == null)
tail = null;
}
else
{
Node temp = head;
for(int i=1; i<position; i++)
temp = temp.getNext();
}
temp.getNext().setPrev(temp.getNext());
temp.getPrev().setNext(temp.getPrev());
}
size--;
}

c)

public void remove(int pos)


{

if(pos<0 || pos>=size)
{
System.out.println("Invalid position");
return;
}

https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 6/13
3/23/2021 Doubly Linked Lists Questions and Answers - Sanfoundry

else
{
if(head == null)
return;
if(pos == 0)
{
head = head.getNext();
if(head == null)
tail = null;
}
else
{
Node temp = head;
for(int i=1; i<position; i++)
temp = temp.getNext().getNext();
}
temp.getNext().setPrev(temp.getPrev());
temp.getPrev().setNext(temp.getNext());
}
size--;
}

d)

public void remove(int pos)


{
if(pos<0 || pos>=size)
{
System.out.println("Invalid position");
return;
}
else
{
if(head == null)
return;
if(pos == 0)
{
head = head.getNext();
if(head == null)
tail = null;
}
else
{
Node temp = head;
for(int i=1; i<position; i++)
temp = temp.getNext().getNext();
} 
temp.getNext().setPrev(temp.getNext());
temp.getPrev().setNext(temp.getPrev());
}

https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 7/13
3/23/2021 Doubly Linked Lists Questions and Answers - Sanfoundry

size--;
}

View Answer
Answer: a
Explanation: If the position to be deleted is not the head, advance to the given position and
manipulate the previous and next pointers of next and previous nodes respectively.

 
 

5. How do you calculate the pointer di erence in a memory e cient double linked list?
a) head xor tail
b) pointer to previous node xor pointer to next node
c) pointer to previous node – pointer to next node
d) pointer to next node – pointer to previous node

View Answer

Answer: b
Explanation: The pointer di erence is calculated by taking XOR of pointer to previous node
and pointer to the next node.

6. What is the worst case time complexity of inserting a node in a doubly linked list?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(1)

View Answer

Answer: c
Explanation: In the worst case, the position to be inserted maybe at the end of the list, hence
you have to traverse through the entire list to get to the correct position, hence O(n).

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 8/13
3/23/2021 Doubly Linked Lists Questions and Answers - Sanfoundry

7. How do you insert a node at the beginning of the list?


a)

public class insertFront(int data)


{
Node node = new Node(data, head, head.getNext());
node.getNext().setPrev(node);
head.setNext(node);
size++;
}

b)

public class insertFront(int data)


{
Node node = new Node(data, head, head);
node.getNext().setPrev(node);
head.setNext(node);
size++;
}

c)

public class insertFront(int data)


{
Node node = new Node(data, head, head.getNext());
node.getNext().setPrev(head);
head.setNext(node);
size++;
}

d)

public class insertFront(int data)


{
Node node = new Node(data, head, head.getNext());
node.getNext().setPrev(node);
head.setNext(node.getNext());
size++;
} 

View Answer
Answer: a
Explanation: The new node’s previous pointer will point to head and next pointer will point to
https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 9/13
3/23/2021 Doubly Linked Lists Questions and Answers - Sanfoundry

the current next of head.

 
 

8. Consider the following doubly linked list: head-1-2-3-4-5-tail. What will be the list after
performing the given sequence of operations?

Node temp = new Node(6,head,head.getNext());


Node temp1 = new Node(0,tail.getPrev(),tail);
head.setNext(temp);
temp.getNext().setPrev(temp);
tail.setPrev(temp1);
temp1.getPrev().setNext(temp1);

a) head-0-1-2-3-4-5-6-tail
b) head-1-2-3-4-5-6-tail
c) head-6-1-2-3-4-5-0-tail
d) head-0-1-2-3-4-5-tail

View Answer

Answer: c
Explanation: The given sequence of operations performs addition of nodes at the head and tail
of the list.

9. What is the functionality of the following piece of code?

public int function()


{
Node temp = tail.getPrev();
tail.setPrev(temp.getPrev());
temp.getPrev().setNext(tail);
size--;
return temp.getItem();
}

a) Return the element at the tail of the list but do not remove it
b) Return the element at the tail of the list and remove it from the list
c) Return the last but one element from the list but do not remove it
d) Return the last but one element at the tail of the list and remove it from the list

View Answer

Answer: b
Explanation: The previous and next pointers of the tail and the last but one element are
manipulated, this suggests that the last node is being removed from the list.

https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 10/13
3/23/2021 Doubly Linked Lists Questions and Answers - Sanfoundry

10. Consider the following doubly linked list: head-1-2-3-4-5-tail. What will be the list after
performing the given sequence of operations?

Node temp = new Node(6,head,head.getNext());


head.setNext(temp);
temp.getNext().setPrev(temp);
Node temp1 = tail.getPrev();
tail.setPrev(temp1.getPrev());
temp1.getPrev().setNext(tail);

a) head-6-1-2-3-4-5-tail
b) head-6-1-2-3-4-tail
c) head-1-2-3-4-5-6-tail
d) head-1-2-3-4-5-tail

View Answer

Answer: b
Explanation: A new node is added to the head of the list and a node is deleted from the tail
end of the list.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice Questions
and Answers.

Participate in the Sanfoundry Certi cation contest to get free Certi cate of Merit. Join our social
networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest

« Prev - Data Structure Questions and Answers – Singly Linked List


» Next - Data Structure Questions and Answers – Circular Linked List

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 11/13
3/23/2021 Doubly Linked Lists Questions and Answers - Sanfoundry

Recommended Posts:
1. Python Programming Examples
2. Python Programming Examples on Trees
3. C Programming Examples on Combinatorial Problems & Algorithms
4. Home
5. C Programming Examples
6. Object Oriented Programming Questions and Answers
7. C Programming Examples on Trees
8. C Programming Examples on Stacks & Queues
9. C Programming Examples using Recursion
10. Data Science Questions and Answers
11. C Tutorials
12. Data Structures & Algorithms II – Questions and Answers
13. C Programming Examples without using Recursion
14. C# Programming Examples on Data Structures
15. C Programming Examples on Data-Structures
16. Java Programming Examples on Data-Structures
17. C++ Programming Examples on Data-Structures
18. Data Structure Questions and Answers
19. Python Programming Examples on Linked Lists
20. C Programming Examples on Linked List

advertisement


Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at
Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency
developments in these areas. He lives in Bangalore and delivers focused training sessions to IT

https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 12/13
3/23/2021 Doubly Linked Lists Questions and Answers - Sanfoundry

professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux


Networking, Linux Storage, Advanced C Programming, SAN Storage
Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber
Channel. Stay connected with him @ LinkedIn

Subscribe Sanfoundry Newsletter and Posts

Name*

Email*

Subscribe

About | Certi cations | Internships | Jobs | Privacy Policy | Terms | Copyright | Contact

     

© 2011-2021 Sanfoundry. All Rights Reserved.

https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 13/13
3/23/2021 Circular Linked Lists Questions and Answers - Sanfoundry

Data Structure Questions and Answers –


Circular Linked List
« Prev Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on “Circular
Linked List”.

1. What di erentiates a circular linked list from a normal linked list?


a) You cannot have the ‘next’ pointer point to null in a circular linked list
b) It is faster to traverse the circular linked list
c) You may or may not have the ‘next’ pointer point to null in a circular linked list
d) Head node is known in circular linked list

View Answer

Answer: c
Explanation: The ‘next’ pointer points to null only when the list is empty, otherwise it points to
the head of the list. Every node in a circular linked list can be a starting point(head).

advertisement 

https://www.sanfoundry.com/data-structure-questions-answers-circular-linked-lists/ 1/11
3/23/2021 Circular Linked Lists Questions and Answers - Sanfoundry

2. How do you count the number of elements in the circular linked list?
a)

public int length(Node head)


{
int length = 0;
if( head == null)
return 0;
Node temp = head.getNext();
while(temp != head)
{
temp = temp.getNext();
length++;
}
return length;
}

b)

public int length(Node head)


{
int length = 0;
if( head == null)
return 0;
Node temp = head.getNext();
while(temp != null)
{
temp = temp.getNext();
length++;
}
return length;
}

c)

public int length(Node head)


{

https://www.sanfoundry.com/data-structure-questions-answers-circular-linked-lists/ 2/11
3/23/2021 Circular Linked Lists Questions and Answers - Sanfoundry

int length = 0;
if( head == null)
return 0;
Node temp = head.getNext();
while(temp != head && temp != null)
{
temp = head.getNext();
length++;
}
return length;
}

d)

advertisement
All 10 Antenna Locations In GTA Online - Cayo Perico Heist

public int length(Node head)


{
int length = 0;
if( head == null)
return 0;
Node temp = head.getNext();
while(temp != head && temp == null)
{
temp = head.getNext();
length++;
}
return length;
}

View Answer
Answer: a
Explanation: If the head is null, it means that the list is empty. Otherwise, traverse the list until
https://www.sanfoundry.com/data-structure-questions-answers-circular-linked-lists/ 3/11
3/23/2021 Circular Linked Lists Questions and Answers - Sanfoundry

the head of the list is reached.

 
 

3. What is the functionality of the following piece of code? Select the most appropriate.

public void function(int data)


{
int flag = 0;
if( head != null)
{
Node temp = head.getNext();
while((temp != head) && (!(temp.getItem() == data)))
{
temp = temp.getNext();
flag = 1;
break;
}
}
if(flag)
System.out.println("success");
else
System.out.println("fail");
}

a) Print success if a particular element is not found


b) Print fail if a particular element is not found
c) Print success if a particular element is equal to 1
d) Print fail if the list is empty

View Answer

Answer: b
Explanation: The function prints fail if the given element is not found. Note that this option is
inclusive of option “Print fail if the list is empty”, the list being empty is one of the cases
covered.

4. What is the time complexity of searching for an element in a circular linked list?
a) O(n)
b) O(nlogn)
c) O(1)
d) O(n2)

View Answer 

Answer: a
Explanation: In the worst case, you have to traverse through the entire list of n elements.

https://www.sanfoundry.com/data-structure-questions-answers-circular-linked-lists/ 4/11
3/23/2021 Circular Linked Lists Questions and Answers - Sanfoundry

5. Which of the following application makes use of a circular linked list?


a) Undo operation in a text editor
b) Recursive function calls
c) Allocating CPU to resources
d) Implement Hash Tables

View Answer

Answer: c
Explanation: Generally, round robin fashion is employed to allocate CPU time to resources
which makes use of the circular linked list data structure. Recursive function calls use stack
data structure. Undo Operation in text editor uses doubly linked lists. Hash tables uses singly
linked lists.

advertisement

6. Choose the code snippet which inserts a node to the head of the list?
a)

public void insertHead(int data)


{
Node temp = new Node(data);
Node cur = head;
while(cur.getNext() != head)
cur = cur.getNext()
if(head == null)
{
head = temp;
head.setNext(head); 
}
else
{
temp.setNext(head);

https://www.sanfoundry.com/data-structure-questions-answers-circular-linked-lists/ 5/11
3/23/2021 Circular Linked Lists Questions and Answers - Sanfoundry

head = temp;
cur.setNext(temp);
}
size++;
}

b)

public void insertHead(int data)


{
Node temp = new Node(data);
while(cur != head)
cur = cur.getNext()
if(head == null)
{
head = temp;
head.setNext(head);
}
else
{
temp.setNext(head.getNext());
cur.setNext(temp);
}
size++;
}

c)

public void insertHead(int data)


{
Node temp = new Node(data);
if(head == null)
{
head = temp;
head.setNext(head);
}
else
{
temp.setNext(head.getNext());
head = temp;
}
size++;
}

d)


public void insertHead(int data)
{
Node temp = new Node(data);
if(head == null)
{
https://www.sanfoundry.com/data-structure-questions-answers-circular-linked-lists/ 6/11
3/23/2021 Circular Linked Lists Questions and Answers - Sanfoundry

head = temp;
head.setNext(head.getNext());
}
else
{
temp.setNext(head.getNext());
head = temp;
}
size++;
}

View Answer
Answer: a
Explanation: If the list is empty make the new node as ‘head’, otherwise traverse the list to the
end and make its ‘next’ pointer point to the new node, set the new node’s next point to the
current head and make the new node as the head.

 
 

7. What is the functionality of the following code? Choose the most appropriate answer.

advertisement

public int function()


{
if(head == null)
return Integer.MIN_VALUE; 
int var;
Node temp = head;
while(temp.getNext() != head)
temp = temp.getNext();
if(temp == head)
https://www.sanfoundry.com/data-structure-questions-answers-circular-linked-lists/ 7/11
3/23/2021 Circular Linked Lists Questions and Answers - Sanfoundry

{
var = head.getItem();
head = null;
return var;
}
temp.setNext(head.getNext());
var = head.getItem();
head = head.getNext();
return var;
}

a) Return data from the end of the list


b) Returns the data and deletes the node at the end of the list
c) Returns the data from the beginning of the list
d) Returns the data and deletes the node from the beginning of the list

View Answer

Answer: d
Explanation: First traverse through the list to nd the end node, then manipulate the ‘next’
pointer such that it points to the current head’s next node, return the data stored in head and
make this next node as the head.

8. What is the functionality of the following code? Choose the most appropriate answer.

public int function()


{
if(head == null)
return Integer.MIN_VALUE;
int var;
Node temp = head;
Node cur;
while(temp.getNext() != head)
{
cur = temp;
temp = temp.getNext();
}
if(temp == head)
{
var = head.getItem();
head = null;
return var;
}
var = temp.getItem();
cur.setNext(head);
return var; 
}

a) Return data from the end of the list


b) Returns the data and deletes the node at the end of the list

https://www.sanfoundry.com/data-structure-questions-answers-circular-linked-lists/ 8/11
3/23/2021 Circular Linked Lists Questions and Answers - Sanfoundry

c) Returns the data from the beginning of the list


d) Returns the data and deletes the node from the beginning of the list

View Answer

Answer: b
Explanation: First traverse through the list to nd the end node, also have a trailing pointer to
nd the penultimate node, make this trailing pointer’s ‘next’ point to the head and return the
data stored in the ‘temp’ node.

9. Which of the following is false about a circular linked list?


a) Every node has a successor
b) Time complexity of inserting a new node at the head of the list is O(1)
c) Time complexity for deleting the last node is O(n)
d) We can traverse the whole circular linked list by starting from any point

View Answer

Answer: b
Explanation: Time complexity of inserting a new node at the head of the list is O(n) because
you have to traverse through the list to nd the tail node.

10. Consider a small circular linked list. How to detect the presence of cycles in this list
e ectively?
a) Keep one node as head and traverse another temp node till the end to check if its ‘next points
to head
b) Have fast and slow pointers with the fast pointer advancing two nodes at a time and slow
pointer advancing by one node at a time
c) Cannot determine, you have to pre-de ne if the list contains cycles
d) Circular linked list itself represents a cycle. So no new cycles cannot be generated

View Answer

Answer: b
Explanation: Advance the pointers in such a way that the fast pointer advances two nodes at a
time and slow pointer advances one node at a time and check to see if at any given instant of
time if the fast pointer points to slow pointer or if the fast pointer’s ‘next’ points to the slow
pointer. This is applicable for smaller lists.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice Questions
and Answers. 

Participate in the Sanfoundry Certi cation contest to get free Certi cate of Merit. Join our social
networks below and stay updated with latest contests, videos, internships and jobs!

https://www.sanfoundry.com/data-structure-questions-answers-circular-linked-lists/ 9/11
3/23/2021 Circular Linked Lists Questions and Answers - Sanfoundry

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest

« Prev - Data Structure Questions and Answers – Doubly Linked List


» Next - Data Structure Questions and Answers – Stack using Array

advertisement

Recommended Posts:
1. Java Programming Examples on Collections
2. Java Algorithms, Problems & Programming Examples
3. Python Programming Examples on Trees
4. C Programming Examples on Combinatorial Problems & Algorithms
5. C Programming Examples
6. Object Oriented Programming Questions and Answers
7. C Programming Examples on Trees
8. C Tutorials
9. C Programming Examples on Stacks & Queues
10. Data Science Questions and Answers
11. C Programming Examples using Recursion
12. Data Structures & Algorithms II – Questions and Answers
13. C Programming Examples without using Recursion
14. C Programming Examples on Data-Structures
15. Java Programming Examples on Data-Structures
16. C++ Programming Examples on Data-Structures
17. C# Programming Examples on Data Structures
18. Data Structure Questions and Answers
19. Python Programming Examples on Linked Lists
20. C Programming Examples on Linked List 

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-circular-linked-lists/ 10/11
3/23/2021 Circular Linked Lists Questions and Answers - Sanfoundry

Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is
Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN
Architect and is passionate about competency developments in these areas.
He lives in Bangalore and delivers focused training sessions to IT
professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux
Networking, Linux Storage, Advanced C Programming, SAN Storage
Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber
Channel. Stay connected with him @ LinkedIn

Subscribe Sanfoundry Newsletter and Posts

Name*

Email*

Subscribe

About | Certi cations | Internships | Jobs | Privacy Policy | Terms | Copyright | Contact

     

© 2011-2021 Sanfoundry. All Rights Reserved.

https://www.sanfoundry.com/data-structure-questions-answers-circular-linked-lists/ 11/11
3/23/2021 Stack using Array Questions and Answers - Sanfoundry

Data Structure Questions and Answers – Stack


using Array
« Prev Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on “Stack using
Array”.

1. Which of the following real world scenarios would you associate with a stack data structure?
a) piling up of chairs one above the other
b) people standing in a line to be serviced at a counter
c) o er services based on the priority of the customer
d) tatkal Ticket Booking in IRCTC

View Answer

Answer: a
Explanation: Stack follows Last In First Out (LIFO) policy. Piling up of chairs one above the other
is based on LIFO, people standing in a line is a queue and if the service is based on priority,
then it can be associated with a priority queue. Tatkal Ticket Booking Follows First in First Out
Policy. People who click the book now rst will enter the booking page rst. 

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-stack-array/ 1/9
3/23/2021 Stack using Array Questions and Answers - Sanfoundry

2. What does the following function check for? (all necessary headers to be included and function
is called from main)

#define MAX 10

typedef struct stack


{
int top;
int item[MAX];
}stack;

int function(stack *s)


{
if(s->top == -1)
return 1;
else return 0;
}

a) full stack
b) invalid index
c) empty stack
d) in nite stack

View Answer

Answer: c
Explanation: An empty stack is represented with the top-of-the-stack(‘top’ in this case) to be
equal to -1.

3. What does ‘stack under ow’ refer to?


a) accessing item from an unde ned stack

b) adding items to a full stack
c) removing items from an empty stack

https://www.sanfoundry.com/data-structure-questions-answers-stack-array/ 2/9
3/23/2021 Stack using Array Questions and Answers - Sanfoundry

d) index out of bounds exception

View Answer

Answer: c
Explanation: Removing items from an empty stack is termed as stack under ow.

advertisement

Dainsleif questions and answers in Genshin Impact

4. What is the output of the following program?

public class Stack


{
protected static final int CAPACITY = 100;
protected int size,top = -1;
protected Object stk[];

public Stack()
{
stk = new Object[CAPACITY];
}

public void push(Object item)


{
if(size_of_stack==size)
{
System.out.println("Stack overflow");
return;
}

else
{
top++;
stk[top]=item;

https://www.sanfoundry.com/data-structure-questions-answers-stack-array/ 3/9
3/23/2021 Stack using Array Questions and Answers - Sanfoundry

}
}
public Object pop()
{
if(top<0)
{
return -999;
}
else
{
Object ele=stk[top];
top--;
size_of_stack--;
return ele;
}
}
}

public class StackDemo


{
public static void main(String args[])
{
Stack myStack = new Stack();
myStack.push(10);
Object element1 = myStack.pop();
Object element2 = myStack.pop();
System.out.println(element2);
}
}

a) stack is full
b) 20
c) 0
d) -999

View Answer

Answer: d
Explanation: The rst call to pop() returns 10, whereas the second call to pop() would result in
stack under ow and the program returns -999.

5. What is the time complexity of pop() operation when the stack is implemented using an array?
a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn) 
View Answer

https://www.sanfoundry.com/data-structure-questions-answers-stack-array/ 4/9
3/23/2021 Stack using Array Questions and Answers - Sanfoundry

Answer: a
Explanation: pop() accesses only one end of the structure, and hence constant time.

6. Which of the following array position will be occupied by a new element being pushed for a
stack of size N elements(capacity of stack > N)?
a) S[N-1]
b) S[N]
c) S[1]
d) S[0]

View Answer

Answer: b
Explanation: Elements are pushed at the end, hence N.

advertisement

7. What happens when you pop from an empty stack while implementing using the Stack ADT in
Java?
a) Unde ned error
b) Compiler displays a warning
c) EmptyStackException is thrown
d) NoStackException is thrown

View Answer

Answer: c
Explanation: The Stack ADT throws an EmptyStackException if the stack is empty and a pop()

operation is tried on it.

8. What is the functionality of the following piece of Java code?


Assume: ‘a’ is a non empty array of integers, the Stack class creates an array of speci ed size and
https://www.sanfoundry.com/data-structure-questions-answers-stack-array/ 5/9
3/23/2021 Stack using Array Questions and Answers - Sanfoundry

provides a top pointer indicating TOS(top of stack), push and pop have normal meaning.

public void some_function(int[] a)


{
Stack S=new Stack(a.length);
int[] b=new int[a.length];
for(int i=0;i<a.length;i++)
{
S.push(a[i]);
}
for(int i=0;i<a.length;i++)
{
b[i]=(int)(S.pop());
}
System.out.println("output :");
for(int i=0;i<b.length;i++)
{
System.out.println(b[i]);
}
}

a) print alternate elements of array


b) duplicate the given array
c) parentheses matching
d) reverse the array

View Answer

Answer: d
Explanation: Every element from the given array ‘a’ is pushed into the stack, and then the
elements are popped out into the array ‘b’. Stack is a LIFO structure, this results in reversing
the given array.

9. Array implementation of Stack is not dynamic, which of the following statements supports this
argument?
a) space allocation for array is xed and cannot be changed during run-time
b) user unable to give the input for stack operations
c) a runtime exception halts execution
d) improper program compilation

View Answer

Answer: a
Explanation: You cannot modify the size of an array once the memory has been allocated,

adding fewer elements than the array size would cause wastage of space, and adding more
elements than the array size at run time would cause Stack Over ow.

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-stack-array/ 6/9
3/23/2021 Stack using Array Questions and Answers - Sanfoundry

10. Which of the following array element will return the top-of-the-stack-element for a stack of
size N elements(capacity of stack > N)?
a) S[N-1]
b) S[N]
c) S[N-2]
d) S[N+1]

View Answer

Answer: a
Explanation: Array indexing start from 0, hence N-1 is the last index.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice Questions
and Answers.

Participate in the Sanfoundry Certi cation contest to get free Certi cate of Merit. Join our social
networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest

« Prev - Data Structure Questions and Answers – Circular Linked List


» Next - Data Structure Questions and Answers – Stack using Linked List

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-stack-array/ 7/9
3/23/2021 Stack using Array Questions and Answers - Sanfoundry

Recommended Posts:
1. C# Programming Examples on Exceptions
2. Microprocessor Questions & Answers
3. C Programming Examples using Recursion
4. Java Programming Examples on Java.Lang
5. Java Programming Examples on Multithreading
6. C# Programming Examples on Threads
7. C++ Programming Examples on STL
8. Data Structures & Algorithms II – Questions and Answers
9. Data Science Questions and Answers
10. Java Programming Examples on Inheritance
11. Python Programming Examples on Searching and Sorting
12. C Programming Examples on Searching and Sorting
13. Object Oriented Programming Questions and Answers
14. Python Programming Examples on Stacks & Queues
15. C# Programming Examples on Data Structures
16. C Programming Examples on Stacks & Queues
17. C++ Programming Examples on Data-Structures
18. C Programming Examples on Data-Structures
19. Java Programming Examples on Data-Structures
20. Data Structure Questions and Answers

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-stack-array/ 8/9
3/23/2021 Stack using Array Questions and Answers - Sanfoundry

Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is
Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN
Architect and is passionate about competency developments in these areas.
He lives in Bangalore and delivers focused training sessions to IT
professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux
Networking, Linux Storage, Advanced C Programming, SAN Storage
Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber
Channel. Stay connected with him @ LinkedIn

Subscribe Sanfoundry Newsletter and Posts

Name*

Email*

Subscribe

About | Certi cations | Internships | Jobs | Privacy Policy | Terms | Copyright | Contact

     

© 2011-2021 Sanfoundry. All Rights Reserved.

https://www.sanfoundry.com/data-structure-questions-answers-stack-array/ 9/9
3/23/2021 Stack using Linked List Questions and Answers - Sanfoundry

Data Structure Questions and Answers – Stack


using Linked List
« Prev Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on “Stack using
Linked List”.

1. What is the best case time complexity of deleting a node in a Singly Linked list?
a) O (n)
b) O (n2)
c) O (nlogn)
d) O (1)

View Answer

Answer: d
Explanation: Deletion of the head node in the linked list is taken as the best case. The
successor of the head node is changed to head and deletes the predecessor of the newly
assigned head node. This process completes in O(1) time.

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-stack-linked-list/ 1/12
3/23/2021 Stack using Linked List Questions and Answers - Sanfoundry

2. Which of the following statements are not correct with respect to Singly Linked List(SLL) and
Doubly Linked List(DLL)?
a) Complexity of Insertion and Deletion at known position is O(n) in SLL and O(1) in DLL
b) SLL uses lesser memory per node than DLL
c) DLL has more searching power than SLL
d) Number of node elds in SLL is more than DLL

View Answer

3. Given below is the Node class to perform basic list operations and a Stack class with a no arg
constructor.
Select from the options the appropriate pop() operation that can be included in the Stack class.
Also ‘ rst’ is the top-of-the-stack.

class Node
{
protected Node next;
protected Object ele;
Node()
{
this(null,null);
}
Node(Object e,Node n)
{
ele=e;
next=n;
}
public void setNext(Node n)
{
next=n;
}
public void setEle(Object e) 
{
ele=e;
}
public Node getNext()
{
https://www.sanfoundry.com/data-structure-questions-answers-stack-linked-list/ 2/12
3/23/2021 Stack using Linked List Questions and Answers - Sanfoundry

return next;
}
public Object getEle()
{
return ele;
}
}

class Stack
{
Node first;
int size=0;
Stack()
{
first=null;
}
}

a)

public Object pop()


{
if(size == 0)
System.out.println("underflow");
else
{
Object o = first.getEle();
first = first.getNext();
size--;
return o;
}
}

b)

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-stack-linked-list/ 3/12
3/23/2021 Stack using Linked List Questions and Answers - Sanfoundry

All 10 Antenna Locations In GTA Online - Cayo Perico Heist

public Object pop()


{
if(size == 0)
System.out.println("underflow");
else
{
Object o = first.getEle();
first = first.getNext().getNext();
size--;
return o;
}
}

c)

public Object pop()


{
if(size == 0)
System.out.println("underflow");
else
{
first = first.getNext();
Object o = first.getEle();
size--;
return o;
}
}

d)

public Object pop()


{

https://www.sanfoundry.com/data-structure-questions-answers-stack-linked-list/ 4/12
3/23/2021 Stack using Linked List Questions and Answers - Sanfoundry

if(size == 0)
System.out.println("underflow");
else
{
first = first.getNext().getNext();
Object o = first.getEle();
size--;
return o;
}
}

View Answer
Answer: a
Explanation: pop() should return the Object pointed to by the node ‘ rst’. The sequence of
operations is, rst, get the element stored at node ‘ rst’ using getEle(), and second, make the
node point to the next node using getNext().

 
 

4. What does the following function do?

public Object some_func()throws emptyStackException


{
if(isEmpty())
throw new emptyStackException("underflow");
return first.getEle();
}

a) pop
b) delete the top-of-the-stack element
c) retrieve the top-of-the-stack element
d) push operation

View Answer

Answer: c
Explanation: This code is only retrieving the top element, note that it is not equivalent to pop
operation as you are not setting the ‘next’ pointer point to the next node in sequence.

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-stack-linked-list/ 5/12
3/23/2021 Stack using Linked List Questions and Answers - Sanfoundry

5. What is the functionality of the following piece of code?

public void display()


{
if(size == 0)
System.out.println("underflow");
else
{
Node current = first;
while(current != null)
{
System.out.println(current.getEle());
current = current.getNext();
}
}
}

a) reverse the list


b) display the list
c) display the list excluding top-of-the-stack-element
d) reverse the list excluding top-of-the-stack-element

View Answer

Answer: b
Explanation: An alias of the node ‘ rst’ is created which traverses through the list and displays
the elements.

6. What does ‘stack over ow’ refer to?


a) accessing item from an unde ned stack
b) adding items to a full stack
c) removing items from an empty stack
d) index out of bounds exception

View Answer

Answer: b
Explanation: Adding items to a full stack is termed as stack under ow.

https://www.sanfoundry.com/data-structure-questions-answers-stack-linked-list/ 6/12
3/23/2021 Stack using Linked List Questions and Answers - Sanfoundry

7. Given below is the Node class to perform basic list operations and a Stack class with a no arg
constructor. Select from the options the appropriate push() operation that can be included in the
Stack class. Also ‘ rst’ is the top-of-the-stack.

class Node
{
protected Node next;
protected Object ele;
Node()
{
this(null,null);
}
Node(Object e,Node n)
{
ele=e;
next=n;
}
public void setNext(Node n)
{
next=n;
}
public void setEle(Object e)
{
ele=e;
}
public Node getNext()
{
return next;
}
public Object getEle()
{
return ele;
}
}

class Stack
{
Node first;
int size=0;
Stack()
{
first=null;
}
}

a)

advertisement

https://www.sanfoundry.com/data-structure-questions-answers-stack-linked-list/ 7/12
3/23/2021 Stack using Linked List Questions and Answers - Sanfoundry

public void push(Object item)


{
Node temp = new Node(item,first);
first = temp;
size++;
}

b)

public void push(Object item)


{
Node temp = new Node(item,first);
first = temp.getNext();
size++;
}

c)

public void push(Object item)


{
Node temp = new Node();
first = temp.getNext();
first.setItem(item);
size++;
}

d)

public void push(Object item)


{
Node temp = new Node();
first = temp.getNext.getNext();

first.setItem(item);
size++;
}

https://www.sanfoundry.com/data-structure-questions-answers-stack-linked-list/ 8/12
3/23/2021 Stack using Linked List Questions and Answers - Sanfoundry

View Answer
Answer: a
Explanation: To push an element into the stack, rst create a new node with the next pointer
point to the current top-of-the-stack node, then make this node as top-of-the-stack by
assigning it to ‘ rst’.

 
 

8. Consider these functions:


push() : push an element into the stack
pop() : pop the top-of-the-stack element
top() : returns the item stored in top-of-the-stack-node
What will be the output after performing these sequence of operations

push(20);
push(4);
top();
pop();
pop();
pop();
push(5);
top();

a) 20
b) 4
c) stack under ow
d) 5

View Answer

Answer: d
Explanation: 20 and 4 which were pushed are popped by the two pop() statements, the recent
push() is 5, hence top() returns 5.

9. Which of the following data structures can be used for parentheses matching?
a) n-ary tree
b) queue
c) priority queue
d) stack

View Answer

Answer: d
Explanation: For every opening brace, push it into the stack, and for every closing brace, pop it
o the stack. Do not take action for any other character. In the end, if the stack is empty, then
the input has balanced parentheses.
https://www.sanfoundry.com/data-structure-questions-answers-stack-linked-list/ 9/12
3/23/2021 Stack using Linked List Questions and Answers - Sanfoundry

10. Minimum number of queues to implement stack is ___________


a) 3
b) 4
c) 1
d) 2

View Answer

Answer: c
Explanation: Use one queue and one counter to count the number of elements in the queue.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice Questions
and Answers.

Participate in the Sanfoundry Certi cation contest to get free Certi cate of Merit. Join our social
networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest

« Prev - Data Structure Questions and Answers – Stack using Array


» Next - Data Structure Questions and Answers – Queue using Array

advertisement

Recommended Posts:
1. C Programming Examples on Searching and Sorting 
2. Home
3. C# Programming Examples on Exceptions
4. Python Programming Examples on Searching and Sorting
5. Data Science Questions and Answers
https://www.sanfoundry.com/data-structure-questions-answers-stack-linked-list/ 10/12
3/23/2021 Stack using Linked List Questions and Answers - Sanfoundry

6. Object Oriented Programming Questions and Answers


7. Data Structures & Algorithms II – Questions and Answers
8. C Programming Examples using Recursion
9. Java Programming Examples on Event Handling
10. C Programming Examples without using Recursion
11. Java Programming Examples on Collections
12. Python Programming Examples on Stacks & Queues
13. C Programming Examples on Stacks & Queues
14. Java Programming Examples on Data-Structures
15. C++ Programming Examples on Data-Structures
16. C Programming Examples on Data-Structures
17. Data Structure Questions and Answers
18. Python Programming Examples on Linked Lists
19. C# Programming Examples on Data Structures
20. C Programming Examples on Linked List

advertisement

Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is
Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN
Architect and is passionate about competency developments in these areas.
He lives in Bangalore and delivers focused training sessions to IT
professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux
Networking, Linux Storage, Advanced C Programming, SAN Storage
Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber
Channel. Stay connected with him @ LinkedIn

Subscribe Sanfoundry Newsletter and Posts

https://www.sanfoundry.com/data-structure-questions-answers-stack-linked-list/ 11/12
3/23/2021 Stack using Linked List Questions and Answers - Sanfoundry

Name*

Email*

Subscribe

About | Certi cations | Internships | Jobs | Privacy Policy | Terms | Copyright | Contact

     

© 2011-2021 Sanfoundry. All Rights Reserved.

https://www.sanfoundry.com/data-structure-questions-answers-stack-linked-list/ 12/12
1)Which of the following type of operators have higher precedence_____
a)Relational operators b)equality operators
c)Logical operators d)Arithmatic operators
ans-Arithmatic operators

2)Which of the following operators takes only integer operands?


a)+ b)/ c)% d)*
ans-%

3)Which of the operators associate from left?


a)+ b)> c)% d)all of these
ans-all of these

4)If a,b,c are integer variables with values 1,2,3 respectively, then what is the value
of the expression
!((a+5)<(b+c))
a)0 b)6 c)5 d)1
ans-1

5) Give the value of x after execution of given code.


x=5
x=x++ +++x-x;
a)5 b)7 c)6 d)0
ans-7

6)Construct a logical expression to check whether x is largest among three


numbers x,y,z
a)x>y&&x>z b)!(x<=y||x<=z) c)x>y,z d)both a and b
ans-d

Q.7 In a circular linked list……….


(A) components are all linked together in some sequential manner.
(B) there is no beginning and no end.
(C) components are arranged hierarchically.
(D) forward and backward traversal within the list is permitted.
Ans:B
Q.8 In a linked list with n nodes, the time taken to insert an element after an
element pointed by some pointer is……..
(A) 0 (1) (B) 0 (log n) (C) 0 (n) (D) 0 (n 1og n)
Ans:A
Q.9 The data structure required to evaluate a postfix expression is …….
(A) queue (B) stack (C) array (D) linked-list
Ans:B
Q.10 Which of the following sorting methods would be most suitable for sorting a
list which is almost sorted …………
(A) Bubble Sort (B) Insertion Sort
(C) Selection Sort (D) Quick Sort
Ans:A
Q.11 Representation of data structure in memory is known as………….
(A) recursive (B) abstract data type
(C) storage structure (D) file structure
Ans:B
Q.12 The largest element of an array index is called its………..
(A) lower bound. (B) range.
(C) upper bound. (D) All of these.
Ans. (C)
Q.13 Which data structure is used for implementing recursion?
(A) Queue. (B) Stack.
(C) Arrays. (D) List.
Ans. (B)
Q.14 Null character needs a space of……………
A. zero bytes B. one byte
C. three bytes D. four bytes
Ans. (B)
Q.15 …………gives the step-by-step procedure for solving the problem which
gives correct solution.
A.Algorithm B.Array
C.Link List D.None of the above
Ans.(A)
Q.16 Which of the followings are derived data types?
A.Array B.String
C.Float D.Both ‘a’ &’b’
Ans.(D)
Q.17 Which of the followings are application of data structure?
A.Facebook B.Searching
C.Sorting D.All of the above
Ans.(D)
Q.18 Which of the following data structure is not linear data structure?
A.Array B.Linked List
C.Both of above D.None of above
Ans.(A)
Q.19 Which of the following steps are correct for solving the problem?
A.Identify the problem B.Explore information & create ideas
C.Select the best ideas D.All of these
Ans.(D)
Q20) In how many blocks Problem Analysis Chartis divided?
A) 2 B)3 C)4 D)5
Ans.(C)
Q21) Interactivity Chart is divided into subtasks called _____.
A) Function
B) Module
C) Sub program
D) None
Ans. (B)
Q 22) what is full form of IPO?
A) Input-Program-Output B) Input-Parallel-Output
C)Input-Processing-Output D) Inbuilt- Processing-Output
Ans.(C)
Q23) Algorithms are similar to____
A) Flowchart
B) Pseudo code
C) Interactivity chart
D) Problem Analysis Chart
Ans. (B)

Q24) Flowcharts can show errors in ____ which is not readily visible in the other
charts.
A) Arithmetic operations
B) Logic
C) Code
D) All of these
Ans. (B)
Q25) Which equation is to be satisfied to find the BIG-O?
A) F(n)=c*g(n)
B) F(n)>=c*g(n)
C) F(n)<=c*g(n)
D) None
ANS:C

Q26) Time Complexity is


A) Time required for the machine to compile the program.
B) Time required for the machine to execute the program.
C) Time required for the machine to debug the program.
D) None
ANS:B

Q27) Step count for the following loop is


For(int i=5; i>0; i++)
A) 5 times
B) N+1 times
C) Infinite
D) No execution
ANS:C

Q28) which of the following is not an asymptotic notation?


A) BIG-O
B) Omega
C) Phi
D) Theta
ANS:C
Q29) What is the step count of 5th line?
1. For(int i=0, i<4, i++)
2. {
3. For(int j=5; j>0; j--)
4. {
5. Cout<<A[i][j];
6. }
7. }
A) 16
B) 25
C) 20
D) 5
ANS:C
Q.30 Which of the following character used for null….?

a) /0 b)\0 c)/n d)\n

Q.31 which of the following is not datatype…?

a)float b)long int c)long float d)long string

Q.32 Variable is…………..

a) used to store a data value

b) used to store address

c) it has fixed value

d) none of these

Q.33 In c++ float datatype allocate……..memory.

a) 4byte b) 8byte c)16byte d)1byte

Q.34 In c float datatype allocate……..memory.

a) 8byte b) 4byte c)16byte d)1byte

Q.35 For function which is sequence of syntax…?

a) define-calling-declaration

b) declaration-define-calling

c) calling-define-declaration

d) none of these
Q.36. The function written by the user according to requirement
known As…………..

a) mathematical function b) string function

c) user define function d) none of above

Q.37. Which of the following is syntax for declaration of array…?

a) datatype array_name[size]

b) datatype string name[size]

c) datatype [size] array_name

d) none of these

Q38. Which of the following is type of function…?

a) mathematical function b) statistical function

c) utility function d) all of above

Q39. Array is……….datatype

a) homogenous datatype b) heterogenous datatype

c) both a & b d) none of above

Q40. The smallest element of an array index called……

a) lower bound b) upper bound c) range d) none of above


JSPM's
Jayawantrao sawant College of EngineeringHadpsar, Pune-33
Department of Information Technology
Multiple Choice Questions

Unit-1

1. Which of the following is not a valid variable name declaration?


a) int _a3;
b) int a_3;
c) int 3_a;
d) int _3a
Answer:c

2. Variable names beginning with underscore is not encouraged. Why?


a) It is not standardized
b) To avoid conflicts since assemblers and loaders use such names
c) To avoid conflicts since library routines use such names
d) To avoid conflicts with environment variables of an operating system
Answer:c

3. All keywords in C are in


a) LowerCase letters
b) UpperCase letters
c) CamelCase letters
d) None
Answer:a

4. Variable name resolving (number of significant characters for uniqueness of variable) depends
on
a) Compiler and linker implementations
b) Assemblers and loaders implementations
c) C language
d) None
Answer:a

5. Which of the following is not a valid C variable name?


a) int number;
b) float rate;
c) int variable_count;
d) int $main;
Answer:d

6. Which of the following is true for variable names in C?


a) They can contain alphanumeric characters as well as special characters
b) It is not an error to declare a variable to be one of the keywords(like goto, static)
c) Variable names cannot start with a digit
d) Variable can be of any length
Answer:c

7. What is the output of this C code?


#include <stdio.h>
int main()
{
int c = 2 ^ 3;
printf("%d\n", c);
}

a) 1
b) 8
c) 9
d) 0
Answer: a

8. What is the output of this C code?

#include <stdio.h>
int main()
{
unsigned int a = 10;
a = ~a;
printf("%d\n", a);
}

a) -9
b) -10
c) -11
d) 10
Answer:c

9. What is the output of this C code?

#include <stdio.h>
int main()
{
if (7 & 8)
printf("Honesty");
if ((~7 & 0x000f) == 8)
printf("is the best policy\n");
}

a) Honesty is the best policy


b) Honesty
c) is the best policy
d) No output
Answer:c

10. What is the output of this C code?

#include <stdio.h>
int main()
{
int a = 2;
if (a >> 1)
printf("%d\n", a);
}

a) 0
b) 1
c) 2
d) No Output.
Answer:c

11. Comment on the output of this C code?

#include <stdio.h>
int main()
{
int i, n, a = 4;
scanf("%d", &n);
for (i = 0; i < n; i++)
a = a * 2;
}

a) Logical Shift left


b) No output
c) Arithmetic Shift right
d) bitwise exclusive OR
Answer:b

12. What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 97;
int y = sizeof(x++);
printf("x is %d", x);
}

a) x is 97
b) x is 98
c) x is 99
d) Run time error
Answer:a

13. What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 4, y, z;
y = --x;
z = x--;
printf("%d%d%d", x, y, z);
}

a) 3 2 3
b) 2 2 3
c) 3 2 2
d) 2 3 3
Answer:d

14. What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 4;
int *p = &x;
int *k = p++;
int r = p - k;
printf("%d", r);
}

a) 4
b) 8
c) 1
d) Run time error
Answer:c

15. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 2, y = 0;
int z = (y++) ? y == 1 && x : 0;
printf("%d\n", z);
return 0;
}
a) 0
b) 1
c) Undefined behaviour
d) Compile time error
Answer:a

16. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 1;
int y = x == 1 ? getchar(): 2;
printf("%d\n", y);
}

a) Compile time error


b) Whatever character getchar function returns
c) Ascii value of character getchar function returns
d) 2
Answer:c

17. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 1;
short int i = 2;
float f = 3;
if (sizeof((x == 2) ? f : i) == sizeof(float))
printf("float\n");
else if (sizeof((x == 2) ? f : i) == sizeof(short int))
printf("short int\n");
}

a) float
b) short int
c) Undefined behaviour
d) Compile time error
Answer:a

18. What is the output of this C code?

#include <stdio.h>
int main()
{
int a = 2;
int b = 0;
int y = (b == 0) ? a :(a > b) ? (b = 1): a;
printf("%d\n", y);
}

a) Compile time error


b) 1
c) 2
d) Undefined behaviour
Answer:c

19. What is the output of this C code?

#include <stdio.h>
int main()
{
int y = 1, x = 0;
int l = (y++, x++) ? y : x;
printf("%d\n", l);
}

a) 1
b) 2
c) Compile time error
d) Undefined behaviour
Answer:a

19. Comment on the output of this C code?

#include <stdio.h>
void main()
{
int k = 8;
int m = 7;
int z = k < m ? k = m : m++;
printf("%d", z);
}

a) Run time error


b) 7
c) 8

d) Depends on compiler
Answer:b

20. The code snippet below produces

#include <stdio.h>
void main()
{
1 < 2 ? return 1 : return 2;
}
a) returns 1
b) returns 2
c) Varies
d) Compile time error
Answer:d

21. What is the difference between the following 2 codes?

#include <stdio.h> //Program 1


int main()
{
int d, a = 1, b = 2;
d = a++ + ++b;
printf("%d %d %d", d, a, b);
}
#include <stdio.h> //Program 2
int main()
{
int d, a = 1, b = 2;
d = a++ + ++b;
printf("%d %d %d", d, a, b);
}

a) No difference as space doesn’t make any difference, values of a, b, d are same in both the
case
b) No difference as space doesn’t make any difference, values of a, b, d are different
c) Program 1 has syntax error, program 2 is not
d) Program 2 has syntax error, program 1 is not
b) Answer:a

22. What is the output of this C code?

#include <stdio.h>
int main()
{
int a = 1, b = 1, c;
c = a++ + b;
printf("%d, %d", a, b);
}

a) a = 1, b = 1
b) a = 2, b = 1
c) a = 1, b = 2
d) a = 2, b = 2
Answer:b

23. What is the output of this C code?

#include <stdio.h>
int main()
{
int a = 1, b = 1, d = 1;
printf("%d, %d, %d", ++a + ++a+a++, a++ + ++b, ++d + d++ + a++);
}

a) 15, 4, 5
b) 9, 6, 9
c) 9, 3, 5
d) 6, 4, 6
Answer:a

24. For which of the following, “PI++;” code will fail?


a) #define PI 3.14
b) char *PI = “A”;
c) float PI = 3.14;
d) Both (A) and (B)
Answer:a

25. What is the output of this C code?

#include <stdio.h>
int main()
{
int a = 10, b = 10;
if (a = 5)
b--;
printf("%d, %d", a, b--);
}

a) a = 10, b = 9
b) a = 10, b = 8
c) a = 5, b = 9
d) a = 5, b = 8
Answer:c

26. What is the output of this C code?

#include <stdio.h>
int main()
{
int i = 0;
int j = i++ + i;
printf("%d\n", j);
}

a) 0
b) 1
c) 2
d) Compile time error
Answer:a
27. What is the output of this C code?

#include <stdio.h>
int main()
{
int i = 2;
int j = ++i + i;
printf("%d\n", j);
}

a) 6
b) 5
c) 4
d) Compile time error
Answer:a

28. Comment on the output of this C code?

#include <stdio.h>
int main()
{
int i = 2;
int i = i++ + i;
printf("%d\n", i);
}

a) = operator is not a sequence point


b) ++ operator may return value with or without side effects
c) it can be evaluated as (i++)+i or i+(++i)
d) Both a and b
Answer:a

29. #include is called


a) Preprocessor directive
b) Inclusion directive
c) File inclusion directive
d) None of the mentioned
Answer:a

30. C preprocessors can have compiler specific features.


a) true
b) false
c) Depends on the standard
d) Depends on the platform
Answer:a
31. C preprocessor is conceptually the first step during compilation
a) true
b) false
c) Depends on the compiler
d) Depends on the standard
Answer:a

32. Preprocessor feature that supply line numbers and filenames to compiler is called?
a) Selective inclusion
b) macro substitution
c) Concatenation
d) Line control
Answer:d

33. #include are _______ files and #include “somefile.h” ________ files.
a) Library, Library
b) Library, user-created header
c) User-created header, library
d) They can include all types of file
Answer:d

34. A preprocessor is a program


a) That processes its input data to produce output that is used as input to another program
b) That is nothing but a loader
c) That links various source files
d) All of the mentioned
Answer:a

35.The sequence of allocation and deletion of variables for the following code is.

#include <stdio.h>
int main()
{
int a;
{
int b;
}
}

a) a->b, a->b
b) a->b, b->a
c) b->a, a->b
d) b->a, b->a
Answer:b
42. Array sizes are optional during array declaration by using ______ keyword.
a) auto
b) static
c) extern
d) register

43. What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 3;
{
x = 4;
printf("%d", x);
}
}

a) 4
b) 3
c) 0
d) Undefined
Answer:a

44. What is the output of this C code?

#include <stdio.h>
int x = 5;
void main()
{
int x = 3;
m();
printf("%d", x);
}
void m()
{
x = 8;
n();
}
void n()
{
printf("%d", x);
}

a) 8 3
b) 3 8
c) 8 5
d) 5 3
Answer:a
45. What is the output of this C code?

#include <stdio.h>
int x;
void main()
{
m();
printf("%d", x);
}
void m()
{
x = 4;
}

a) 0
b) 4
c) Compile time error
d) Undefined
Answer:b

46. What is the output of this C code?

#include <stdio.h>
static int x = 5;
void main()
{
int x = 9;
{
x = 4;
}
printf("%d", x);
}

a) 9
b) 5
c) 4
d) 0
Answer:c

47. What is the output of this C code?

#include <stdio.h>
void main()
{
{
int x = 8;
}
printf("%d", x);
}

a) 8
b) 0
c) Undefined
d) Compile time error
Answer:d

48.What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 1, y = 0, z = 5;
int a = x && y || z++;
printf("%d", z);
}

a) 6
b) 5
c) 0
d) Varies
Answer:a

49. What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 1, y = 0, z = 5;
int a = x && y && z++;
printf("%d", z);
}

a) 6
b) 5
c) 0
d) Varies
50. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 1, y = 0, z = 3;
x > y ? printf("%d", z) : return z;
}

a) 3
b) 1
c) Compile time error
d) Run time error
51. What is the output of this C code(when 1 is entered)?

#include <stdio.h>
void main()
{
double ch;
printf("enter a value btw 1 to 2:");
scanf("%lf", &ch);
switch (ch)
{
case 1:
printf("1");
break;
case 2:
printf("2");
break;
}
}

a) Compile time error


b) 1
c) 2
d) Varies
Answer:a

52. What is the output of this C code(When 1 is entered)?

#include <stdio.h>
void main()
{
char *ch;
printf("enter a value btw 1 to 3:");
scanf("%s", ch);
switch (ch)
{
case "1":
printf("1");
break;
case "2":
printf("2");
break;
}
}

a) 1
b) Compile time error
c) 2
d) Run time error
Answer:b

53. What is the output of this C code(When 1 is entered)?

#include <stdio.h>
void main()
{
int ch;
printf("enter a value btw 1 to 2:");
scanf("%d", &ch);
switch (ch)
{
case 1:
printf("1\n");
default:
printf("2\n");
}
}

a) 1
b) 2
c) 1 2
d) Run time error
Answer:c

54. What is the output of this C code(When 2 is entered)?

#include <stdio.h>
void main()
{
int ch;
printf("enter a value btw 1 to 2:");
scanf("%d", &ch);
switch (ch)
{
case 1:
printf("1\n");
break;
printf("hi");
default:
printf("2\n");
}
}

a) 1
b) hi 2
c) Run time error
d) 2
Answer:d

55. What is the output of this C code(When 1 is entered)?

#include <stdio.h>
void main()
{
int ch;
printf("enter a value btw 1 to 2:");
scanf("%d", &ch);
switch (ch, ch + 1)
{
case 1:
printf("1\n");
break;
case 2:
printf("2");
break;
}
}

a) 1
b) 2
c) 3
d) Run time error
Answer:b

56. What is the output of this C code?

#include <stdio.h>
int main()
{
int a = 1, b = 1;
switch (a)
{
case a*b:
printf("yes ");
case a-b:
printf("no\n");
break;
}
}

a) yes
b) no
c) Compile time error
d) yes no
Answer:c

57. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 97;
switch (x)
{
case 'a':
printf("yes ");
break;
case 97:
printf("no\n");
break;
}
}
a) yes
b) yes no
c) Duplicate case value error
d) Character case value error
Answer:c

58. What is the output of this C code?

#include <stdio.h>
int main()
{
float f = 1;
switch (f)
{
case 1.0:
printf("yes\n");
break;
default:
printf("default\n");
}
}

a) yes
b) yes default
c) Undefined behaviour
d) Compile time error
Answer:d

59. What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 1, z = 3;
int y = x << 3;
printf(" %d\n", y);
}

a) -2147483648
b) -1
c) Run time error
d) 8
Answer:d

60.What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 0, y = 2, z = 3;
int a = x & y | z;
printf("%d", a);
}

a) 3
b) 0
c) 2
d) Run time error
Answer:a

61. What is the output of this C code?

#include <stdio.h>
int main()
{
reverse(1);
}
void reverse(int i)
{
if (i > 5)
exit(0);
printf("%d\n", i);
return reverse(i++);
}

a) 1 2 3 4 5
b) 1 2 3 4
c) Compile time error
d) Stack overflow
Answer:d

62. What is the output of this C code?

#include <stdio.h>
void reverse(int i);
int main()
{
reverse(1);
}
void reverse(int i)
{
if (i > 5)
return ;
printf("%d ", i);
return reverse((i++, i));
}

a) 1 2 3 4 5
b) Segmentation fault
c) Compilation error
d) Undefined behaviour
Answer:a
63. In expression i = g() + f(), first function called depends on
a) Compiler
b) Associativiy of () operator
c) Precedence of () and + operator
d) Left to write of the expression
Answer:a

64. What is the value of i and j in the below code?

#include <stdio.h>
int x = 0;
int main()
{
int i = (f() + g()) || g();
int j = g() || (f() + g());
}
int f()
{
if (x == 0)
return x + 1;
else
return x - 1;
}
int g()
{
return x++;
}

a)i value is 1 and j value is 1


b)i value is 0 and j value is 0
c)i value is 1 and j value is undefined
d)i and j value are undefined
Answer:d

65. What is the value of i and j in the below code?

#include <stdio.h>
int x = 0;
int main()
{
int i = (f() + g()) | g(); //bitwise or
int j = g() | (f() + g()); //bitwise or
}
int f()
{
if (x == 0)
return x + 1;
else
return x - 1;
}
int g()
{
return x++;
}

a) i value is 1 and j value is 1


b) i value is 0 and j value is 0
c) i value is 1 and j value is undefined
d) i and j value are undefined
Answer:c

66. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 2, y = 0;
int z = y && (y |= 10);
printf("%d\n", z);
return 0;
}

a) 1
b) 0
c) Undefined behaviour due to order of evaluation
d) 2
Answer:a

67. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 2, y = 0;
int z = (y++) ? 2 : y == 1 && x;
printf("%d\n", z);
return 0;
}

a) 0
b) 1
c) 2
d)Undefined behaviour
Answer:b

68. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 2, y = 0;
int z;
z = (y++, y);
printf("%d\n", z);
return 0;
}

a) 0
b) 1
c) Undefined behaviour
d) Compilation error

Answer:b

69. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 2, y = 0, l;
int z;
z = y = 1, l = x && y;
printf("%d\n", l);
return 0;
}

a) 0
b) 1
c) Undefined behaviour due to order of evaluation can be different
d) Compilation error
Answer:b

70. What is the output of this C code?

#include <stdio.h>
int main()
{
int y = 2;
int z = y +(y = 10);
printf("%d\n", z);
}

a) 12
b) 20
c) 4
d) Either 12 or 20
Answer:b

71.What is the final value of j in the below code?

#include <stdio.h>
int main()
{
int i = 0, j = 0;
if (i && (j = i + 10))
//do something
;
}

a) 0
b) 10
c) Depends on the compiler
d) Depends on language standard
Answer:a

72. What is the final value of j in the below code?

#include <stdio.h>
int main()
{
int i = 10, j = 0;
if (i || (j = i + 10))
//do something
;
}

a) 0
b) 20
c) Compile time error
d) Depends on language standard
Answer:a

73. What is the output of this C code?

#include <stdio.h>
int main()
{
int i = 1;
if (i++ && (i == 1))
printf("Yes\n");
else
printf("No\n");
}

a) Yes
b) No
c) Depends on the compiler
d) Depends on the standard
Answer:b

74. function tolower(c) defined in library works for


a) Ascii character set
b) Unicode character set
c) Ascii and utf-8 but not EBSIDIC character set
d) Any character set
Answer:d

75. What is the output of the below code considering size of short int is 2, char is 1 and int is 4
bytes?

#include <stdio.h>
int main()
{
short int i = 20;
char c = 97;
printf("%d, %d, %d\n", sizeof(i), sizeof(c), sizeof(c + i));
return 0;
}

a) 2, 1, 2
b) 2, 1, 1
c) 2, 1, 4
d) 2, 2, 8
Answer:c

76. Which type conversion is NOT accepted?


a) From char to int
b) From float to char pointer
c) From negative int to char
d) From double to char
View AnswerAnswer:b

77. What will be the data type of the result of the following operation?
(float)a * (int)b / (long)c * (double)d
a) int
b) long
c) float
d) double
Answer:d

78. Which of the following type-casting have chances for wrap around?
a) From int to float
b) From int to char
c) From char to short
d) From char to int
Answer:b

79. Which of the following typecasting is accepted by C?


a) Widening conversions
b) Narrowing conversions
c) Both
d) None of the mentioned
Answer:c

80. When do you need to use type-conversions?


a) The value to be stored is beyond the max limit
b) The value to be stored is in a form not supported by that data type
c) To reduce the memory in use, relevant to the value
d) All of the mentioned
Answer: d

81.Comment on the output of this C code?

#include <stdio.h>
int main()
{
float f1 = 0.1;
if (f1 == 0.1)
printf("equal\n");
else
printf("not equal\n");
}

a) equal
b) not equal
c) Output depends on compiler
d) None of the mentionedAnswer:b

82. Comment on the output of this C code?

#include <stdio.h>
int main()
{
float f1 = 0.1;
if (f1 == 0.1f)
printf("equal\n");
else
printf("not equal\n");
}

a) equal
b) not equal
c) Output depends on compiler
d) None of the mentionedAnswer:a
83. What is the output of this C code (on a 32-bit machine)?

#include <stdio.h>
int main()
{
int x = 10000;
double y = 56;
int *p = &x;
double *q = &y;
printf("p and q are %d and %d", sizeof(p), sizeof(q));
return 0;
}

a) p and q are 4 and 4


b) p and q are 4 and 8
c) Compiler error
d) p and q are 2 and 8Answer:a

84. Which is correct with respect to size of the datatypes?


a) char > int > float
b) int > char > float
c) char < int < double
d) double > char > intAnswer:c

85. What is the output of the following C code(on a 64 bit machine)?

#include <stdio.h>
union Sti
{
int nu;
char m;
};
int main()
{
union Sti s;
printf("%d", sizeof(s));
return 0;
}

a) 8
b) 5
c) 9
d) 4Answer:d

86. What is the output of this C code?

#include <stdio.h>
int main()
{
float x = 'a';
printf("%f", x);
return 0;
}
a) a
b) run time error
c) a.0000000
d) 97.000000

Answer:d

87. Which of the datatypes have size that is variable?


a) int
b) struct
c) float
d) double

Answer:b

88.What is the output of this C code?

#include <stdio.h>
void main()
{
int a = 3;
int b = ++a + a++ + --a;
printf("Value of b is %d", b);
}

a) Value of x is 12
b) Value of x is 13
c) Value of x is 10
d) Undefined behaviour

Answer:d

89.. The precedence of arithmetic operators is (from highest to lowest)


a) %, *, /, +, -
b) %, +, /, *, -
c) +, -, %, *, /
d) %, +, -, *, /

Answer:a

90. Which of the following is not an arithmetic operation?


a) a *= 10;
b) a /= 10;
c) a != 10;
d) a %= 10;

Answer:c

91. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 2, y = 2;
float f = y + x /= x / y;
printf("%d %f\n", x, f);
return 0;
}

a) 2 4.000000
b) Compile time error
c) 2 3.500000
d) Undefined behaviour

Answer:b

92. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 1, y = 2;
if (x && y == 1)
printf("true\n");
else
printf("false\n");
}

a) true
b) false
c) Compile time error
d) Undefined behaviour

Answer:b

93. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 1, y = 2;
int z = x & y == 2;
printf("%d\n", z);
}

a) 0
b) 1
c) Compile time error
d) Undefined behaviour

Answer:b

94. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 3, y = 2;
int z = x /= y %= 2;
printf("%d\n", z);
}

a) 1
b) Compile time error
c) Floating point exception
d) Segmentation fault

Answer:c

95. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 3, y = 2;
int z = x << 1 > 5;
printf("%d\n", z);
}

a) 1
b) 0
c) 3
d) Compile time error

Answer:a

96. What is the output of this C code?


#include <stdio.h>
int main()
{
int x = 3; //, y = 2;
const int *p = &x;
*p++;
printf("%d\n", *p);
}

a) Increment of read-only location compile error


b) 4
c) Some garbage value
d) Undefined behaviour

Answer:c

97. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 2, y = 2;
int z = x ^ y & 1;
printf("%d\n", z);
}

a) 1
b) 2
c) 0
d) 1 or 2

Answer:b

98. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 2, y = 0;
int z = x && y = 1;
printf("%d\n", z);
}

a) 0
b) 1
c) Compile time error
d) 2
Answer:c

99. What is the output of the code given below

#include <stdio.h>
int main()
{
int x = 0, y = 2;
if (!x && y)
printf("true\n");
else
printf("false\n");
}

a) true
b) false
c) Compile time error
d) Undefined behaviour

Answer:a

100. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 0, y = 2;
int z = ~x & y;
printf("%d\n", z);
}

a) -1
b) 2
c) 0
d) Compile time error

Answer:b
JSPM's
Jayawantrao sawant College of EngineeringHadpsar, Pune-33
Department of Information Technology
Multiple Choice Questions

Unit-3

1. Two main measures for the efficiency of an algorithm are


a. Processor and memory
b. Complexity and capacity
c. Time and space
d. Data and space

2. The time factor when determining the efficiency of algorithm is measured by


a. Counting microseconds
b. Counting the number of key operations
c. Counting the number of statements
d. Counting the kilobytes of algorithm

3. The space factor when determining the efficiency of algorithm is measured by


a. Counting the maximum memory needed by the algorithm
b. Counting the minimum memory needed by the algorithm
c. Counting the average memory needed by the algorithm
d. Counting the maximum disk space needed by the algorithm

4. Which of the following case does not exist in complexity theory


a. Best case
b. Worst case
c. Average case
d. Null case

5. The Worst case occur in linear search algorithm when


a. Item is somewhere in the middle of the array
b. Item is not in the array at all
c. Item is the last element in the array
d. Item is the last element in the array or is not there at all
6. The Average case occur in linear search algorithm
a. When Item is somewhere in the middle of the array
b. When Item is not in the array at all
c. When Item is the last element in the array
d. When Item is the last element in the array or is not there at all

7. The complexity of the average case of an algorithm is


a. Much more complicated to analyze than that of worst case
b. Much more simpler to analyze than that of worst case
c. Sometimes more complicated and some other times simpler than that of worst case
d. None or above

8. The complexity of linear search algorithm is


a. O(n)
b. O(log n)
c. O(n2)
d. O(n log n)

9. The complexity of Binary search algorithm is


a. O(n)
b. O(log )
c. O(n2)
d. O(n log n)

11. The complexity of merge sort algorithm is


a. O(n)
b. O(log n)
c. O(n2)
d. O(n log n)

12. The indirect change of the values of a variable in one module by another module is called
a. internal change
b. inter-module change
c. side effect
d. side-module update
13. Which of the following data structure is not linear data structure?
a. Arrays
b. Linked lists
c. Both of above
d. None of above

14. Which of the following data structure is linear data structure?


a. Trees
b. Graphs
c. Arrays
d. None of above

15. The operation of processing each element in the list is known as


a. Sorting
b. Merging
c. Inserting
d. Traversal

16. Finding the location of the element with a given value is:
a. Traversal
b. Search
c. Sort
d. None of above

17. Arrays are best data structures


a. for relatively permanent collections of data
b. for the size of the structure and the data in the structure are constantly changing
c. for both of above situation
d. for none of above situation

18. Linked lists are best suited


a. for relatively permanent collections of data
b. for the size of the structure and the data in the structure are constantly changing
c. for both of above situation
d. for none of above situation

19. Each array declaration need not give, implicitly or explicitly, the information about
a. the name of array
b. the data type of array
c. the first data from the set to be stored
d. the index set of the array

20. The elements of an array are stored successively in memory cells because
a. by this way computer can keep track only the address of the first element and the
addresses of other elements can be calculated
b. the architecture of computer memory does not allow arrays to store other than serially
c. both of above
d. none of above

21. When determining the efficiency of algorithm, the space factor is measured by
a. Counting the maximum memory needed by the algorithm
b. Counting the minimum memory needed by the algorithm
c. Counting the average memory needed by the algorithm
d. Counting the maximum disk space needed by the algorithm

22. The complexity of Bubble sort algorithm is


a. O(n)
b. O(log n)
c. O(n2)
d. O(n log n)

23. Linked lists are best suited


a. for relatively permanent collections of data
b. for the size of the structure and the data in the structure are constantly changing
c. for both of above situation
d. for none of above situation

24. If the values of a variable in one module is indirectly changed by another module, this
situation is called
a. internal change
b. inter-module change
c. side effect
d. side-module update
25. In linear search algorithm the Worst case occurs when
a. The item is somewhere in the middle of the array
b. The item is not in the array at all
c. The item is the last element in the array
d. The item is the last element in the array or is not there at all

26. For an algorithm the complexity of the average case is


a. Much more complicated to analyze than that of worst case
b. Much more simpler to analyze than that of worst case
c. Sometimes more complicated and some other times simpler than that of worst case
d. None or above

27. The complexity of merge sort algorithm is


a. O(n)
b. O(log n)
c. O(n2)
d. O(n log n)

28. The complexity of linear search algorithm is


a. O(n)
b. O(log n)
c. O(n2)
d. O(n log n)

29. When determining the efficiency of algorithm the time factor is measured by
a. Counting microseconds
b. Counting the number of key operations
c. Counting the number of statements
d. Counting the kilobytes of algorithm

30. Which of the following data structure is linear data structure?


a. Trees
b. Graphs
c. Arrays
d. None of above

31. The elements of an array are stored successively in memory cells because
a. by this way computer can keep track only the address of the first element and the
addresses of other elements can be calculated
b. the architecture of computer memory does not allow arrays to store other than serially
c. both of above
d. none of above

32. Which of the following data structure is not linear data structure?
a. Arrays
b. Linked lists
c. Both of above
d. None of above

33. The Average case occur in linear search algorithm


a. When Item is somewhere in the middle of the array
b. When Item is not in the array at all
c. When Item is the last element in the array
d. When Item is the last element in the array or is not there at all

34. Two main measures for the efficiency of an algorithm are


a. Processor and memory
b. Complexity and capacity
c. Time and space
d. Data and space

35. Finding the location of the element with a given value is:
a. Traversal
b. Search
c. Sort
d. None of above

36. Which of the following case does not exist in complexity theory
a. Best case
b. Worst case
c. Average case
d. Null case

37. The operation of processing each element in the list is known as


a. Sorting
b. Merging
c. Inserting
d. Traversal

38. Arrays are best data structures


a. for relatively permanent collections of data
b. for the size of the structure and the data in the structure are constantly changing
c. for both of above situation
d. for none of above situation

39. Each array declaration need not give, implicitly or explicitly, the information about
a. the name of array
b. the data type of array
c. the first data from the set to be stored
d. the index set of the array
40. The complexity of Binary search algorithm is
a. O(n)
b. O(log )
c. O(n2)
d. O(n log n)

41.Which of the following data structure is non-linear type?


A) Strings
B) Lists
C) Stacks
D) Tree

42. Which of the following data structure is linear type?


A) Array
B) Tree
C) Graphs
D) Hierarchy

43. The logical or mathematical model of a particular organization of data is called a .........
A) Data structure
B) Data arrangement
C) Data configuration
D) Data formation

44. The simplest type of data structure is ..................


A) Multidimensional array
B) Linear array
C) Two dimensional array
D) Three dimensional array

45. Linear arrays are also called ...................


A) Straight line array
B) One-dimensional array
C) Vertical array
D) Horizontal array

46. Arrays are best data structures ............


A) For relatively permanent collections of data.
B) For the size of the structure and the data in the structure are constantly changing
C) For both of above situation
D) For none of the above

47. Which of the following data structures are indexed structures?


A) Linear arrays
B) Linked lists
C) Graphs
D) Trees

48. Each node in a linked list has two pairs of .............. and ...................
A) Link field and information field
B) Link field and avail field
C) Avail field and information field
D) Address field and link field

49. A ........................ does not keep track of address of every element in the list.
A) Stack
B) String
C) Linear array
D) Queue

50. When does top value of the stack changes?


A) Before deletion
B) While checking underflow
C) At the time of deletion
D) After deletion
JSPM's
Jayawantrao sawant College of EngineeringHadpsar, Pune-33
Department of Information Technology
Multiple Choice Questions

Unit-4

1.Which of the following best describes sorting ?


A.Accessing and processing each record exactly once
B.Finding the location of the record with a given key
C.Arranging the data (record) in some given order
D.Adding a new record to the data structure
ANSWER: C

2.The time complexity of linear search algorithm over an array of n elements is


A.O (log2 n)
B.O(n)
C.O(n log2 n)
D.0 (n2)
ANSWER: B

3.A characteristic of the data that binary search uses but the linear search ignores is
the___________
A.Order of the elements of the list
B.Length of the list
C.Maximum value in list
D.Type of elements of the list
ANSWER: A

4.The data for which you are searching is called


A.search argument
B.sorting argument
C.detection argument
D.binary argument
ANSWER: A

5.For a linear search in an array of n elements the time complexity for best, worst and average
case are ......., ....... and ........ respectively
A.O(n), O(1), and O(n/2)
B.O(1), O(n) and O(n/2)
C.O(1),O(n) and O(n)
D.O(1), O(n) and (n-1/2)
ANSWER: C
6.Which of the following is false ?
A.A serial search begins with the first array element
B.A serial search continues searching, element by element, either until a match is found or until
the end of the array is encountered
C.A serial search is useful when the amount of data that must be search is small
D.For a serial search to work, the data in the array must be arranged in either alphabetical or
numerical order
ANSWER: D

7.The average successful search time for sequential search on 'n' items is
A.n/2
B.(n-1)/2
C.(n+1)/2
D.log (n)+1
ANSWER: C

8.A search begins the search with the element that is located in the middle of the array
A.serial
B.random
C.parallel
D.binary
ANSWER: D

9.Suppose DATA array contains 1000000 elements. Using the binary search algorithm, one
requires only about n comparisons to find the location of an item in the DATA array, then n is
A.60
B.45
C.20
D.None of these
ANSWER: C

10.Which of the following is false ?


A.A binary search begins with the middle element in the array
B.A binary search continues having the array either until a match is found or until there are no
more elements to search
C.If the search argument is greater than the value located in the middle of the binary, the binary
search continues in the upper half of the array
D.For a binary search to work, the data in the array must be arranged in either alphabetical or
numerical order
ANSWER: C

11.The order of the binary search algorithm is


A.n
B.n2
C.nlog(n)
D.log(n)
ANSWER: Option D

12.Sorting is useful for


A.report generation
B.respondingtoe queries easily
C.making searching easier and efficient
D.All of these
ANSWER: D

13.Choose the correct statements


A.Internal sorting is used if the number of items to be sorted is very large.
B.External sorting is used if the number of items to be sorted is very large
C.External sorting needs auxilary storage
D.Both (b) & (c)
ANSWER: D

14.A sort which compares adjacent elements in a list and switches where necessary is
A.insertion sort
B.heap sort
C.quick sort
D.bubble sort
ANSWER: D

15.Which of the following sorting methods would be most suitable for sorting a list which is
almost sorted
A.Bubble Sort
B.Insertion Sort
C.Selection Sort
C.Quick Sort
ANSWER: A

16.Which of the following sorting procedure is the slowest ?


A.Quick sort
B.Heap sort
C.Shell sort
D.Bubble sort
ANSWER: D

17.The number of swappings needed to sort the numbers 8, 22, 7, 9, 31, 19, 5, 13 in ascending
order, using bubble sort is
A.11
B.12
C.13
D.14
ANSWER: D

18.A machine took 200 sec to sort 200 names, using bubble sort. In 800 sec, it can approximately
sort
A.400 names
B.800 names
C.750 names
D.800 names
ANSWER: A

19.Given a file of size n the number of times a given file is passed through in bubble sort is
A.n2
B.n - 1
C.n log n
ANSWER: B

20.In bubble sort, for a file of size n, after p iterations number of records in proper positions is
A.n - p
B.n - p + 1
C.p
ANSWER: A

21.A sort which iteratively passes through a list to exchange the first element with any element
less than it and then repeats with a new first element is called
A.insertion sort
B.selection sort
C.heap sort
D.quick sort
ANSWER: B

22.Which of the following sorting methods will be the best if number of swappings done, is the
only measure of efficienty?
A.Bubble sort
B.Selection sort
C.Insertion sort
D.Quick sort
ANSWER: B
23.What is the number of swaps required to sort n elements using selection sort, in the worst
case?
A.T(n)
B.T(n log n)
C.T(n2)
D.T(n2 log n)
ANSWER: A

24.Staright selection sort is basically a method of repeated


A.interchange
B.searching
C.position adjustment
ANSWER: C

25.Number of selections required to sort a file of size N by straight selection requires


a.N - 1
b.log N
c.O(N2)
ANSWER: A

26.For sorting a file of size n by straight selection sort, the number of comparisons made in the
first pass is
a.n
b.n - 1
c.n(n - 1)/2
ANSWER: B

27.Which of the following sorting method is stable ?


A.insertion sort
B.Quick sort
C.Shell sort
D.Heap sort
ANSWER: A

28.You have to sort a list L consisting of a sorted list followed by a few “random”
elements.Which of the following sorting methods would be especially suitable for such a task?
A.Bubble sort
B.Selection sort
C.Quick sort
D.Insertion sort
Ans:D
29.Which of the following sorting methods would be most suitable for sorting a list which is
already sorted
A.Bubble Sort
B.Insertion Sort
C.Selection Sort
C.Quick Sort
ANSWER: B

30.The way a card game player arranges his cards as he picks them up one by one, is an example
of
A.bubble sort
B.Selection sort
C.insertion sort
D.merge sort
ANSWER: C

31.You want to check whether a given set of items is sorted. Which of the following sorting
methods will be most efficient if it is already in sorted order?
A.Bubble sort
B.Selection sort
C.Insertion sort
D.Merge Sort
ANSWER: C

32.Which of the following sorting algorithms does not have a worst case running time of O(n2)?
A.Insertion sort
B.Merge sort
C.Quick sort
D.Bubble sort
ANSWER: B

33.Merge sort uses


A.divide and conquer strategy
B.backtracking approach
C.heuristic search
D.greedy approach
ANSWER: A

34.Assume 5 buffer pages are available to sort a file of 105 pages. The cost of sorting using m-
way merge sort is
A.206
B.618
C.840
D.926
ANSWER: C

35.A desirable choice for the partitioning element in quick sort is


A.First element of the list
B.Last element of the list
C.Randomly chosen element of the list
D.Median of the list
Answer: A

36.Quick sort is also known as


A.Merge sort
B.Heap sort
C.Bubble sort
C.None of these
ANSWER: D

37.A sort which relatively passes through a list to exchange the first element with any element
less than it and then repeats with a new first element is called
A.Insertion sort
B.Selection sort
C.Heap sort
D.Quick sort
ANSWER: D

39.The best average behaviour is shown by


38.A.Quick Sort
B.Merge Sort
C.Insertion Sort
C.Heap Sort
ANSWER: A

40.Which of the following sorting methods sorts a given set of items that is already in sorted
order or in reverse sorted order with equal speed?
A.Heap sort
B.Quick sort
C.Insertion sort
D.Selection sort
ANSWER: B

41.A machine needs a minimum of 100 sec to sort 1000 names by quick sort. The minimum time
needed to sort 100 names will be approximately
A.50.2 sec
B.6.7 sec
C.72.7 sec
D.11.2 sec
ANSWER: B

42.Which of the following is useful in implementing quick sort?


A.Stack
B.Set
C.List
D.Queue
ANSWER: A

43.In quick sort, for sorting n elements, the (n/4)th smallest element is selected as pivot using an
T(n) time algorithm. What is the worst case time complexity of the quick sort?
A.T(n)
B.T(n log n)
C.T(n2)
D.T(n2 log n)
ANSWER: B

44.The running time of the following sorting algorithm depends on whether the partitioning is
balanced or unbalanced
A.Insertion sort
B.Selection sort
C.Quick sort
D.Merge sort
ANSWER: C

45.In worst case Quick Sort has order


A.O (n log n)
B.O (n^2/2)
C.O (log n)
D.O (n2/4)
ANSWER: B

46.In quick sort, the number of partitions into which the file of size n is divided by a selected
record is
A.n
B.n - 1
C.2
ANSWER: C

47.The total number of comparisons made in quick sort for sorting a file of size n, is
a.O(n log n)
b.O(n2)
c.n(log n)
ANSWER: A

48.Quick sort efficiency can be improved by adopting


a.non-recursive method
b.insertion method
c.tree search method
ANSWER: A

49.For the improvement of efficiency of quick sort the pivot can be


a.the first element
b.the mean element
c.the last element
ANSWER: B

50.Quick sort is the fastest available method of sorting because of


a.low over head
b.O(n log n) comparisons
c.lowover head and also O(n log n) comparisons
ANSWER: C

51.A sorting technique that guarantees that records with the same primary key occurs in the same
order in the sorted list as in the original unsorted list is said to be
A.stable
B.consistent
C.External
D.linear
ANSWER: A
JSPM's
Jayawantrao Sawant College Of Engineering, Hadapsar,Pune-28
Department of Information Technology

Multiple Choice Questions


UNIT-II

Class: SE IT Subject: FDS

1) The value of eof is


a) -1
b) 1
c) 0
d) 10
ans:a

2) What is FILE in following declaration?


a) Keyword
b) File
c) Structure
d) Array

2) Which is file opening mode?


a) r
b) w
c) wb
d) all of the above

3) choose correct declaration


a) int main(intargc,char *argv)

{}

b) int main(intargc,char *argv[])


{}
c) int main(int *argc,char *argv)
{}
d) int main()
{int *argc,char *argv}

Ans D

4) what is output of the following program?


Void main()
{
File *fp;
Fp=fopen(“d:\\input,dat”,”w”);
Printf(“%d\n”,ferror(fp));0
}
a) 0
b) -1
c) 1
d) None of these

5) Which of the following file type can’t be opened using fopen()?


a) .txt
b) .dat
c) .bin
d) None of these

6) How to call a function without using the function name to send parameters?
a) typedefs
b) Function pointer
c) Both (a) and (b)
d) None of the mentioned
Answer:b

7) Correct syntax to pass a Function Pointer as an argument


a) void pass(int (*fptr)(int, float, char)){}
b) void pass(*fptr(int, float, char)){}
c) void pass(int (*fptr)){}
d) void pass(*fptr){}
Answer:a
8. Which of the following is not possible in C?
a) Array of function pointer
b) Returning a function pointer
c) Comparison of function pointer
d) None of the mentioned

Answer:d

9. What is the output of this C code?

#include <stdio.h>
void first()
{
printf("Hello World");
}
void main()
{
void *ptr() = first;
ptr++
ptr();
}

a) Illegal application of ++ to void data type


b) pointer function initialized like a variable
c) Both (a) and (b)
d) None of the mentioned

Answer:c

10) What will be output of the following?

void main()
{
Inta[]={1,2,3,4,5},j;
For(j=0;j<5;j++)
{
Printf(“%d”,*a);
a++;
}
}
a) Syntax error
b) Run time error
c) 12345
d) Garbage 1234

11) what will be output of following?

#include<stdio.h>
Void main()
{
Int a=10;
Int*b=&a;
Int**c=&b;
**c=20;
Printf(“%d”,a);
}
a) 10
b) 20
c) Garbage value
d) Syntax error

12) what will be o/p of following code?

Void main()
{
Intarr[]={10,20,30};
Int *p=arr;
Int *q=&p;
Printf(“%d”,(**q));
}

a) 10
b) 20
c) Sytax error
d) Runtime error

13) Output of following code?

Intmain()
{
Char *str;
Str=”%d\n”;
Str++;
Str++;
Printf(str-2,500);
Return 0;
}
a) 5
b) 50
c) 500
d) No o/p

14) how many no. Of pointer to pointer can be declared in C?

a) 7
b)127
c)255
d)no limit Ans:d

15) what is o/p of code?

Intmain()
{
Int i=10,*a;
Void *b;
a=b=&i;
printf(“%u%u”,a++,b++);
return 0;
}
a) 10 garbage value
b) Add will be display twice
c) Syntax error
d) None of these

16) Pointers are supported in

a. C
b. Fortron
c. Pascal
d. Both b&c ans:d
17)Identify invalid expression

a)&274

b)&(a+b)

c)&(a*b)

d)all of the above ans:d

18)main()

Int a=5;

Ptr=&a;

Printf(“%d”,++*ptr);

Output will be:

a)6

b)5

c)0

d)none

ans:a

19)Number of argument use in malloc is

a) 0
b) 1
c) 2
d) 3
ans:1
20) The no. Of argument use in realloc is
a) 0
b) 1
c) 2
d) 3
ans:c
21) the function is use in dynamic deallocation is
a) Destroy()
b) Delet()
c) Free
d) Remove()
ans:c

22) the function call realloc(ptr,0)is


a) Same as free (ptr)

b) Used to set the value of ptr to be 0

c) the value of in the address represented by ptr

d) Invalid

ans:a

23) pointers can be used to achive


a) Call by function
b) Call by refrance
c) Call by name
d) Call y procedure
ans:b

24) the declaration of float *a[5] is

a) An ordinary array
b) A pointer to an array
c) Ann array to an pointer
d) Pointer to an array
ans:c

25) The declaration int (*p)[8];


a) An array of pointer
b) A pointer to an array
c) Pointer to function
d) Function returing pointer
ans:b

26) Given int a[5][5];identify the correct expression ,yielding the starting element.
a) *a[0]
b) **a
c) a[0][0]
d) all of these
ans:d

27) Given int x[5][5][5];find value of the element x[2][3][4]


a) *(x[2][3]+4)
b) *(*(x[2]+3)+4)
c) *(*(*(x+2)+3)+4)
d) All of the above

28)The oprators used in pointr is


a) *and/
b) &and*
c) &and|
d) –and>

ans:b

29) main()
{
Inta[5]={-2,-1,3,4,5}
Int*b;
b=&a[2];
}
Then value of b[-1] is:
a) 4
b) 3
c) -1
d) -2
ans:c
30)identify invalid pointer oprator
a) &
b) >>
c) *
d) None of these
ans:b

31)Identify the wrong declaration statement.

a)int *p,a=10;

b)int a=10,*p=&a;

c)int *p=&a,a=10

d)options a and b

32) Identify the invalid expression given

intnum=15,*p=&num;

a)*num

b)*(&num)

c)*&*&num

d)**&p

33) Identify the invalid expression given float x=2.14,*y=&x;

a)&y

b)*&x

c)**&y

d)(*&)x

34)The operand of the address of operator is

a)a constant

b)an expression

c)a named region of storage

d)a register variable


35)How does compiler differentiate address of operator from bitwise AND operator?

a)by using the number of operands and the position of operands

b)by seeing the declarations

c)both options a and b

d)by using the value of the operand

36)How does compiler differentiate indirection operator from multiplication operator?

a) by using the number of operands

b) by seeing the position of operands

c) both options a and b

d)by using the value of the operand

37)The address of operator returns

a)the address of its operand

b)lvalue

c) both options a and b

d)rvalue

38)The indirection operator returns

a)the data object stored in the address represented by its operand

b)lvalue

c)both options a and b

d)rvalue
39)The operand of indirection operator is

a)pointer variable

b)pointer expression

c)both options a and b

d)ordinary variable

40)The operand of address of operator may be

a)an ordinary variable

b)an array variable

c)a pointer variable

d)Any one of above

41)Identify the invalid lvalue given int x,*p=&x;

a)*(p+1)

b)*(p-3)

c)both options a and b

d)&x

42)After the execution of statement int x; the value of x is

a)0

b)undefined

c)1

d)-1

43)Pointer variable may be initialized using


a)static memory allocation

b)dynamic memory allocation

c)both options a and b

d)a positive integer

44)Given the declaration double prec[5]; the address of element prec[2]is obtained

a)&prec[2]

b)prec+2

c)both options a and b

d)*(prec+2)

45)Identify the correct statement for given expression

floatfnum[10];

a)fnum is pointer variable

b)fnum is fixed address and not a variable.

c)fnum is an array variable

d)fnum is an address that can be modified.

46)Which is the correct function header for function main()?

a)main(intargc, char *argv[])

b)main(intargc, char **argv)

c)main(intargc, char *av[])

d)all the above

47)The invalid address arithmetic is


a)adding two pointers

b)multiplying two pointers

c)dividing two pointers

d)all the above

48)Identify the invalid assignment,for given int *p,x;

a)p=0;

b)p=255864u

c)p=&x

d)*p=10

49)Identify the invalid expression for given syntax:

float fnum[10],*fptr=fnum;

a)fnum+4

b)fnum[4]

c)fnum=++fptr

d)&fnum[4]

50)The operators &,*,++ and – have

a)same procedure level and same associativity

b)same associativity and different precedence level

c)different precedence level and different associativity

d)different precedence level and same associativity


51.What is the output of this C code?

#include <stdio.h>
int mul(int a, int b, int c)
{
return a * b * c;
}
void main()
{
int (*function_pointer)(int, int, int);
function_pointer = mul;
printf("The product of three numbers is:%d",
function_pointer(2, 3, 4));
}

a) The product of three numbers is:24


b) Run time error
c) Nothing
d) Varies

Answer:a

52. What is the output of this C code?

#include <stdio.h>
int mul(int a, int b, int c)
{
return a * b * c;
}
void main()
{
int (function_pointer)(int, int, int);
function_pointer = mul;
printf("The product of three numbers is:%d",
function_pointer(2, 3, 4));
}

a) The product of three numbers is:24


b) Compile time error
c) Nothing
d) Varies

Answer:b
53. What is the output of this C code?

#include <stdio.h>
void f(int (*x)(int));
int myfoo(int);
int (*fooptr)(int);
int ((*foo(int)))(int);
int main()
{
fooptr = foo(0);
fooptr(10);
}
int ((*foo(int i)))(int)
{
return myfoo;
}
int myfoo(int i)
{
printf("%d\n", i + 1);
}

a) 10
b) 11
c) Compile time error
d) Undefined behaviour

Answer:b

54. Which is an indirection operator among the following?


a) &
b) *
c) ->
d) .

Answer:b

55. Which of the following does not initialize ptr to null (assuming variable declaration of a as
int a=0;?
a) int *ptr = &a;
b) int *ptr = &a – &a;
c) int *ptr = a – a;
d) All of the mentioned

Answer:a

56. What is the output of this C code?

#include <stdio.h>
int x = 0;
void main()
{
int *ptr = &x;
printf("%p\n", ptr);
x++;
printf("%p\n ", ptr);
}

a) Same address
b) Different address
c) Compile time error
d) Varies

Answer:a

57. What is the output of this C code?

#include <stdio.h>
int x = 0;
void main()
{
int *const ptr = &x;
printf("%p\n", ptr);
ptr++;
printf("%p\n ", ptr);
}

a) 0 1
b) Compile time error
c) 0xbfd605e8 0xbfd605ec
d) 0xbfd605e8 0xbfd605e8

Answer:b
58. What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 0;
int *ptr = &x;
printf("%p\n", ptr);
ptr++;
printf("%p\n ", ptr);
}

a) 0xbfd605e8 0xbfd605ec
b) 0xbfd605e8 0cbfd60520
c) 0xbfd605e8 0xbfd605e9
d) Run time error

Answer:a

59. What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 0;
int *ptr = &5;
printf("%p\n", ptr);
}

a) 5
b) Address of 5
c) Nothing
d) Compile time error

Answer:d

60. What is the output of this C code?

#include <stdio.h>
void main()
{
int k = 5;
int *p = &k;
int **m = &p;
**m = 6;
printf("%d\n", k);
}

a) 5
b) Compile time error
c) 6
d) Junk

Answer:c

61. What is the output of this C code?

#include <stdio.h>
void main()
{
int a[3] = {1, 2, 3};
int *p = a;
int *r = &p;
printf("%d", (**r));
}

a) 1
b) Compile time error
c) Address of a
d) Junk value

Answer:b

62. What is the output of this C code?

#include <stdio.h>
void main()
{
int a[3] = {1, 2, 3};
int *p = a;
int **r = &p;
printf("%p %p", *r, a);
}

a) Different address is printed


b) 1 2
c) Same address is printed.
d) 1 1

Answer:c

63. How many number of pointer (*) does C have against a pointer variable declaration?
a) 7
b) 127
c) 255
d) No limits.

Answer:d

64. What is the output of this C code?

#include <stdio.h>
int main()
{
int a = 1, b = 2, c = 3;
int *ptr1 = &a, *ptr2 = &b, *ptr3 = &c;
int **sptr = &ptr1; //-Ref
*sptr = ptr2;
}

a) ptr1 points to a
b) ptr1 points to b
c) sptr points to ptr2
d) None of the mentioned

Answer:b

65. What is the output of this C code?

#include <stdio.h>
void main()
{
int a[3] = {1, 2, 3};
int *p = a;
int **r = &p;
printf("%p %p", *r, a);
}
a) Different address is printed
b) 1 2
c) Same address is printed.
d) 1 1

Answer:c

66. What substitution should be made to //-Ref such that ptr1 points to variable C?

#include <stdio.h>
int main()
{
int a = 1, b = 2, c = 3;
int *ptr1 = &a;
int **sptr = &ptr1;
//-Ref
}

a) *sptr = &c;
b) **sptr = &c;
c) *ptr1 = &c;
d) None of the mentioned.

Answer:a

67. Which of the following declaration throw run-time error?


a) int **c = &c;
b) int **c = &*c;
c) int **c = **c;
d) None of the mentioned

Answer:d

68. Comment on the output of this C code?

#include <stdio.h>
int main()
{
int a = 10;
int **c -= &&a;
}

a) You cannot apply any arithmetic operand to a pointer.


b) We don’t have address of an address operator
c) Both (a) and (b)
d) None of the mentioned.

Answer:b

69. What is the output of this C code?

#include <stdio.h>
void main()
{
int a[3] = {1, 2, 3};
int *p = a;
int *r = &p;
printf("%d", (**r));
}

a) 1
b) Compile time error
c) Address of a
d) Junk value

Answer:b

70. Comment on the output of this C code?

#include <stdio.h>
int main()
{
char *str = "This" //Line 1
char *ptr = "Program\n"; //Line 2
str = ptr; //Line 3
printf("%s, %s\n", str, ptr); //Line 4
}

a) Memory holding “this” is cleared at line 3


b) Memory holding “this” loses its reference at line 3
c) You cannot assign pointer like in Line 3
d) Output will be This, Program

Answer:b

71. What type initialization is needed for the segment “ptr[3] = ’3′;” to work?
a) char *ptr = “Hello!”;
b) char ptr[] = “Hello!”;
c) Both (a) and (b)
d) None of the mentioned

Answer:b

73. The syntax for constant pointer to address (i.e., fixed pointer address) is:

a) const <type> * <name>


b) <type> * const <name>
c) <type> const * <name>
d) Both (a) and (c)
Answer:b

74. Comment on the output of this C code?

#include <stdio.h>
int add(int a, int b)
{
return a + b;
}
int main()
{
int (*fn_ptr)(int, int);
fn_ptr = add;
printf("The sum of two numbers is: %d", (int)fn_ptr(2, 3));
}

a) Compile time error, declaration of a function inside main.


b) Compile time error, no definition of function fn_ptr.
c) Compile time error, illegal application of statement fn_ptr = add.
d) No Run time error, output is 5.

Answer:d
75. The correct way to declare and assign a function pointer is done by:
(Assuming the function to be assigned is “int multi(int, int);”)
a) int (*fn_ptr)(int, int) = multi;
b) int *fn_ptr(int, int) = multi;
c) int *fn_ptr(int, int) = &multi;
d) Both (b) & (c)

Answer:a

76. Calling a function f with a an array variable a[3] where a is an array, is equivalent to
a) f(a[3])
b) f(*(a + 3))
c) f(3[a])
d) All of the mentioned

Answer:d

77. What is the output of this C code?

#include <stdio.h>
void f(char *k)
{
k++;
k[2] = 'm';
}
void main()
{
char s[] = "hello";
f(s);
printf("%c\n", *s);
}

a) h
b) e
c) m
d) o;

Answer:a

78.What is the output of this C code?


#include <stdio.h>
void main()
{
char s[] = "hello";
s++;
printf("%c\n", *s);
}

a) Compile time error


b) h
c) e
d) o

Answer:a

81. What is the output of this C code?

#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student m;
struct student *s = &m;
s->c = "hello";
printf("%s", s->c);
}

a) hello
b) Run time error
c) Nothing
d) Depends on compiler

Answer:a

82. What is the output of this C code?

#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student *s;
s->c = "hello";
printf("%s", s->c);
}

a) hello
b) Segmentation fault
c) Run time error
d) Nothing

Answer:b

83. What is the output of this C code?

#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student m;
struct student *s = &m;
s->c = "hello";
printf("%s", m.c);
}

a) Run time error


b) Nothing
c) hello
d) Varies

Answer:c

84. What is the output of this C code?

#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student m;
struct student *s = &m;
(*s).c = "hello";
printf("%s", m.c);
}

a) Run time error


b) Nothing
c) Varies
d) hello

Answer:d

85. What is the output of this C code?

#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student n;
struct student *s = &n;
(*s).c = "hello";
printf("%p\n%p\n", s, &n);
}

a) Different address
b) Run time error
c) Nothing
d) Same address

Answer:d

86. What is the output of this C code?

#include <stdio.h>
struct p
{
int x[2];
};
struct q
{
int *x;
};
int main()
{
struct p p1 = {1, 2};
struct q *ptr1;
ptr1->x = (struct q*)&p1.x;
printf("%d\n", ptr1->x[1]);
}

a) Compile time error


b) Segmentation fault/code crash
c) 2
d) 1

Answer:b

87. What is the output of this C code?

#include <stdio.h>
struct p
{
int x[2];
};
struct q
{
int *x;
};
int main()
{
struct p p1 = {1, 2};
struct q *ptr1 = (struct q*)&p1;
ptr1->x = (struct q*)&p1.x;
printf("%d\n", ptr1->x[0]);
}

a) Compile time error


b) Undefined behaviour
c) Segmentation fault/code crash
d) 1

Answer:b
88. What is the output of this C code?

#include <stdio.h>
struct p
{
int x;
int y;
};
int main()
{
struct p p1[] = {1, 2, 3, 4, 5, 6};
struct p *ptr1 = p1;
printf("%d %d\n", ptr1->x, (ptr1 + 2)->x);
}

a) 1 5
b) 1 3
c) Compile time error
d) 1 4

Answer:a

89. What is the output of this C code?

#include <stdio.h>
struct p
{
int x;
char y;
};
int main(){
struct p p1[] = {1, 92, 3, 94, 5, 96};
struct p *ptr1 = p1;
int x = (sizeof(p1) / sizeof(struct p));
printf("%d %d\n", ptr1->x, (ptr1 + x - 1)->x);
}

a) Compile time error


b) Undefined behaviour
c) 1 3
d) 1 5

Answer:d
91. What is the output of this C code (considering sizeof char is 1 and pointer is 4)?

#include <stdio.h>
int main()
{
char *a[2] = {"hello", "hi"};
printf("%d", sizeof(a));
return 0;
}

a) 9
b) 4
c) 8
d) 10

Answer:c

92. What is the output of this C code?

#include <stdio.h>
int main()
{
char a[2][6] = {"hello", "hi"};
printf("%d", sizeof(a));
return 0;
}

a) 9
b) 12
c) 8
d) 10

Answer:b

93. What is the output of this C code?

#include <stdio.h>
int main()
{
char a[2][6] = {"hello", "hi"};
printf("%s", *a + 1);
return 0;
}
a) hello
b) hi
c) ello
d) ello hi

Answer:c

94. What is the output of this C code?

#include <stdio.h>
int main()
{
char *a[2] = {"hello", "hi"};
printf("%s", *(a + 1));
return 0;
}

a) hello
b) ello
c) hi
d) ello hi

Answer:c

95. Advantage of a multi-dimension array over pointer array.


a) Pre-defined size.
b) Input can be taken from user.
c) Faster Access.
d) All of the mentioned

Answer:d

96. Which of the following operation is possible using a pointer char?


(Assuming declaration char *a;)
a) Input via %s
b) Generation of multidimensional array
c) Changing address to point at another location
d) All of the mentioned
Answer:c

97. Comment on the following two operations?


int *a[] = {{1, 2, 3}, {1, 2, 3, 4}}; //- 1
int b[4][4] = {{1, 2, 3}, {1, 2, 3, 4}};//- 2
a) 1 will work, 2 will not
b) 1 and 2, both will work
c) 1 won’t work, 2 will work
d) Neither of them will work

Answer:c

98. Comment on the following two operations?


int *a[] = {{1, 2, 3}, {1, 2, 3, 4}}; //- 1
int b[][] = {{1, 2, 3}, {1, 2, 3, 4}}; //- 2
a) 1 works, 2 doesn’t
b) 2 works, 1 doesn’t
c) Both of them work
d) Neither of them work

Answer:d

99. What does argv and argc indicate in command-line arguments?


(Assuming: int main(int argc, char *argv[]) )
a) argument count, argument variable
b) argument count, argument vector
c) argument control, argument variable
d) argument control, argument vector

Answer:b

100. Which of the following syntax is correct for command-line arguments?


a) int main(int var, char *varg[])
b) int main(char *argv[], int argc)
c) int main()
{
int argv, char *argc[];
}
d) Both (a) and (b)

Answer:a

101. In linux, argv[0] by command-line argument can be occupied by


a) ./a.out
b) ./test
c) ./fun.out.out
d) All of the mentioned

Answer:d

102. What type of array is generally generated in Command-line argument?


a) Single dimension array
b) 2-Dimensional Square Array
c) Jagged Array
d) 2-Dimensional Rectangular Array

Answer:c

103. What would be the output if we try to execute following segment of code (assuming the
following input “cool brother in city”)?
printf(“%s\n”, argv[argc]);
a) (null)
b) City
c) In
D. Segmentation Fault

Answer:a

104. The first argument in command line arguments is


a) The number of command-line arguments the program was invoked with;
b) A pointer to an array of character strings that contain the arguments
c) Nothing
d) Both a & b
105. The second (argument vector) in command line arguments is
a) The number of command-line arguments the program was invoked with;
b) A pointer to an array of character strings that contain the arguments,one per string.
c) Nothing
d) Both a & b

Answer:b

106. argv[0] in command line arguments, is


a) The name by which the program was invoked
b) The name of the files which are passed to the program
c) Count of the arguments in argv[] vector
d) Both a & b

Answer:a
Question: 1
A data structure in which linear sequence is maintained by pointers is known as
(A) Array
(B) Stack
(C) Linked list
(D) Pointer-based data structure
Ans: C
Linked list
Question: 2
Which of the following data structure works on the principle of First Come First
Serve?
(A) Priority queue
(B) Heap
(C) Stack
(D) Queue
Ans: D
Queue
Question: 3
A ____ is a linear collection of self-referential structures, called nodes, connected by
pointer links.
(A) Queue
(B) Linked list
(C) Tree
(D) Stack
Ans: B
Linked list
Question: 4
A queue where all elements have equal priority is a
(A) ILFO data structure
(B) LILO data structure
(C) FIFO data structure
(D) LIFO data structure
Ans: C
FIFO data structure
Question: 5
A file that is only read by a program is known as ____
(A) Input file
(B) Temporary file
(C) Work file
(D) Input/output file
Ans: A
Input file

Question: 6
Which of the following sorting algorithm is the slowest?
(A) Bubble sort
(B) Heap sort
(C) Shell sort
(D) Quick sort
Ans: A
Bubble sort
Question: 7
Which of the following data structure can be used to represent many-to-many
relation?
(A) B-tree
(B) Binary tree
(C) Graph
(D) All of above
Ans: C
Graph
Question: 8
Which of the following statement is not true about linked lists?
(A) Element in a linked list, if it is sorted, can be quickly searched by applying binary
search technique
(B) Elements are not necessarily stored in contiguous locations
(C) Insertions and deletions can be performed efficiently as compared to arrays
(D) Linked list is a dynamic structure
Ans: A
Element in a linked list, if it is sorted, can be quickly searched by applying binary
search technique
Question: 9
Which of the following is not a linear data structure?
(A) Stack
(B) Queue
(C) Linked list
(D) Binary tree
Ans: D
Binary tree
Question: 10
Which of the following data structure permits insertion and deletion operations only
on one end of the structure?
(A) Linked list
(B) Array
(C) Stack
(D) Queue
Ans: C
Stack

Question: 1
Which of the following data structure is more appropriate to represent a heap?
(A) Two-dimensional array
(B) Doubly linked list
(C) Linear Array
(D) Linked list
Ans: C
Linear Array
Question: 2
Minimum number of fields in each node of a doubly linked list is ____
(A) 2
(B) 3
(C) 4
(D) None of the above
Ans: B
3
Question: 3
A graph in which all vertices have equal degree is known as ____
(A) Complete graph
(B) Regular graph
(C) Multi graph
(D) Simple graph
Ans: A
Complete graph
Question: 4
A vertex of in-degree zero in a directed graph is called a/an
(A) Root vertex
(B) Isolated vertex
(C) Sink
(D) Articulation point
Ans: C
Sink
Question: 5
A graph is a tree if and only if graph is
(A) Directed graph
(B) Contains no cycles
(C) Planar
(D) Completely connected
Ans: B
Contains no cycles

Question: 6
Which of the following piece of information does the data type to the compiler
provide?
(A) The way the data is to be interpreted
(B) Range of values
(C) Amount of memory a data element uses
(D) All of above
Ans: D
All of above
Question: 7
The elements of a linked list are stored
(A) In a structure
(B) In an array
(C) Anywhere the computer has space for them
(D) In contiguous memory locations
Ans: C
Anywhere the computer has space for them
Question: 8
A parentheses checker program would be best implemented using
(A) List
(B) Queue
(C) Stack
(D) Any of the above
Ans: C
Stack
Question: 9
To perform level-order traversal on a binary tree, which of the following data
structure will be required?
(A) Hash table
(B) Queue
(C) Binary search tree
(D) Stack
Ans: B
Queue
Question: 10
Which of the following data structure is required to convert arithmetic expression in
infix to its equivalent postfix notation?
(A) Queue
(B) Linked list
(C) Binary search tree
(D) None of above
Ans: D
None of above

Question: 11
A binary tree in which all its levels except the last, have maximum numbers of nodes,
and all the nodes in the last level have only one child it will be its left child. Name the
tree.
(A) Threaded tree
(B) Complete binary tree
(C) M-way search tree
(D) Full binary tree
Ans: B
Complete binary tree
Question: 12
Which of following data structure is more appropriate for implementing quick sort
iteratively?
(A) Deque
(B) Queue
(C) Stack
(D) Priority queue
Ans: C
Stack
Question: 13
The number of edges in a complete graph of n vertices is
(A) n(n+1)/2
(B) n(n-1)/2
(C) n2/2
(D) n
Ans: B
n(n-1)/2
Question: 14
If two trees have same structure and but different node content, then they are called
___
(A) Synonyms trees
(B) Joint trees
(C) Equivalent trees
(D) Similar trees
Ans: D
Similar trees
Question: 15
If two trees have same structure and node content, then they are called ____
(A) Synonyms trees
(B) Joint trees
(C) Equivalent trees
(D) Similar trees
Ans: C
Equivalent trees

Question: 1
What is the worst-case time for serial search finding a single item in an array?
(A) Quadratic time
(B) Linear time
(C) Logarithmic time
(D) Constant time
Ans: B
Linear time
Question: 2
A non-circular doubly linked list can best and most generally be defined as a ___
(A) Set of elements, each with two pointers
(B) Set of elements chained together with pointers
(C) Linear sequence of elements in sequential memory locations
(D) Linear sequence of elements chained together with pointers
Ans: D
Linear sequence of elements chained together with pointers
Question: 3
Which of the following operations is a dictionary operation?
(A) Search
(B) Delete
(C) Insert
(D) All of above
Ans: D
All of above
Question: 4
To create a linked structure, each node must have one member, which is ____
(A) A pointer to the head of the list
(B) A pointer to NULL
(C) A pointer to the node type
(D) A reference to the element type
Ans: C
A pointer to the node type
Question: 5
Each attribute of an entity has a defined set of values. This set of values is called a
(A) Mapping
(B) Entity set
(C) Domain
(D) Range
Ans: C
Domain

Question: 6
Which of the following is not an open addressing technique to resolve collisions?
(A) Linear probing
(B) Cubic probing
(C) Double hashing
(D) Quadratic probing
Ans: B
Cubic probing
Question: 7
Which of the following file organizations is not suitable for an interactive application?
(A) Indexed sequential file organization
(B) Inverted file organization
(C) Sequential file organization
(D) Relative file organization
Ans: C
Sequential file organization
Question: 8
Which of following is not a type of a I/O channel?
(A) Block multiplexer
(B) Multiplexer
(C) Selector
(D) Demultiplexer
Ans: D
Demultiplexer

Question: 1
The average case complexity of quick sort for sorting n numbers is
(A) O(n2)
(B) O(nlog2n)
(C) O(n)
(D) O(log2n)
Ans: B
O(nlog2n)
Question: 2
A dequeue operation removes an element
(A) From the front of the queue
(B) From any place in the queue
(C) From the rear of the queue
(D) None of above
Ans: A
From the front of the queue
Question: 3
What is the minimum number of nodes in a complete binary tree with depth 3?
(A) 4
(B) 5
(C) 6
(D) 7
Question: 4
What is the number of nodes in a full binary tree with depth 3?
(A) 5
(B) 6
(C) 7
(D) 8
Ans: C
7
Question: 5
Which of the following operation is not supported by a queue?
(A) Inserting element at rear
(B) Removing element from front
(C) Removing element from middle
(D) None of above
Ans: C
Removing element from middle

Question: 6
An enqueue operation adds an element
(A) At any position in the queue
(B) To the front of the queue
(C) To the rear of the queue
(D) None of above
Ans: C
To the rear of the queue
Question: 7
Which of the following is not an entity?
(A) Book
(B) Student
(C) Employee
(D) Roll number
Ans: D
Roll number
Question: 8
What kind of list is best to answer many questions such as “what is the item at
position n?”
(A) Singly-linked lists
(B) Doubly-linked lists
(C) Lists implemented with an array
(D) Circular- linked lists
Ans: C
Lists implemented with an array
Question: 9
Which of following operations are generally not performed on report files?
(A) Updation
(B) Maintenance
(C) Retrieval
(D) All of above
Ans: D
All of above
Question: 10
When is insertion sort a good choice for sorting an array?
(A) The array has only a few elements out of place
(B) Each element of array requires a small amount of memory
(C) The processor speed is fast
(D) Each element of array requires a large amount of memory
Ans: A
The array has only a few elements out of place

Question: 1
Name the tree in which, for every node, the height of left sub tree and height of right
sub tree can differ by at most one
(A) AVL tree
(B) B-tree
(C) Threaded tree
(D) Complete tree
Ans: A
AVL tree
Question: 2
Which of the following statements about a binary tree is correct?
(A) No binary tree is both complete and full
(B) Every full binary tree is also a complete binary tree
(C) Every complete binary tree is also a full binary tree
(D) Every binary tree is either complete or full
Ans: B
Every full binary tree is also a complete binary tree
Question: 3
What is the worst-case time for binary search finding a single item in an array?
(A) Quadratic time
(B) Linear time
(C) Logarithmic time
(D) Constant time
Ans: C
Logarithmic time
Question: 4
If a binary tree satisfies shape and order property, it is known as
(A) Rooted tree
(B) Heap
(C) Sequential search tree
(D) Binary search tree
Ans: B
Heap
Question: 5
With an array-based stack, the algorithm for push is
(A) Increment top and add item to the new top location
(B) Add item to the top location and then increment top
(C) Return the top item and increment top
(D) Return the top item and decrement top
Ans: A
Increment top and add item to the new top location

Question: 1
What is the worst case time for quick sort to sort an array of n elements?
(A) 0(n)
(B) 0(nlog2n)
(C) 0(log2n)
(D) 0(log2n)
Ans: D
0(log2n)
Question: 2
The best way to find an item in an unsorted implemented using an array list is with
(A) Binary search
(B) Linear search
(C) Direct search
(D) Random search
Ans: B
Linear search
Question: 3
Which of the following data structure is used to represent a relationship between
pairs, where relationship is not hierarchical?
(A) Priority queue
(B) Heap
(C) Tree
(D) Graph
Ans: D
Graph
Question: 4
A data item that cannot be divided into sub items is known as
(A) Elementary data item
(B) Group data item
(C) Primary key
(D) Primary data item
Ans: B
Group data item
Question: 5
The best way to find an item in a sorted list implemented using an array is with ___
(A) Direct search
(B) Random search
(C) Binary search
(D) Linear search
Ans: C
Binary search

Question: 1
An index is a pair of elements comprising key and a file pointer or record number. A
file in which indices are is known as ____
(A) Index file
(B) Sort file
(C) Key file
(D) None of above
Ans: A
Index file
Question: 2
A data item that can be used to distinguish between two entities (records) is known
as
(A) Alternate key
(B) Primary key
(C) Primary data item
(D) Unique data item
Ans: B
Primary key
Question: 3
A data structure whose elements form a sequence is known as
(A) Heterogeneous data structure
(B) Homogeneous data structure
(C) Linear data structures
(D) Non- linear data structure
Ans: C
Linear data structures
Question: 4
Which of the following data structure is used to represent hierarchical relationship
among its elements?
(A) Queue
(B) Hash table
(C) Tree
(D) Graph
Ans: C
Tree
Question: 5
Which of the following statements about a binary tree is not correct?
(A) Every binary tree has at least one node
(B) Every non-empty tree has exactly one root node
(C) Every node has at most two children
(D) Every non-root node has exactly one parent
Ans: A
Every binary tree has at least one node
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Fi
rstst
epi
npr
ocessofpr
obl
em sol
vi
ngi
sto_
___
___
_.
N))
((
OPTI
ON_ Desi
gnasol
uti
on
A))
((
OPTI
ON_ Def
ineapr
obl
em
B))
((
OPTI
ON_ Under
standi
ngofpr
obl
em
C))
((
OPTI
ON_ Sol
vi
ngt
hepr
obl
em
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA Problem Sol
vi
ngsteps:1)Identi
fy/
Defineaproblem
TION)
) 2)Understandtheproblem 3)I
ndenti
fyalt
ernat
eway s
(OPTI
ONAL tosolveprobl
em 4)Selectthebestway5)Listoutthe
) i
nstructi
onsforbestway6)Ev al
uatethebestsolut
ion

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whendet ermini
ngtheeffi
ciencyofal
gor
it
hm,
the
N)) spacefactorismeasuredby
____
___
_ _
_ __
____
_____
____.
((
OPTI
ON_ Count
ingthemaxi
mum memor
yneededbyt
he
A)) al
gori
thm
((
OPTI
ON_ Count
ingthemi
nimum memor
yneededbyt
he
B)) al
gori
thm
((
OPTI
ON_ Count
ingtheav
eragememor
yneededbyt
he
C)) al
gori
thm
((
OPTI
ON_ Count
ingthemaxi
mum di
skspaceneededbyt
he
D)) al
gori
thm
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Thecomplexi
tyofBi
nar
ysear
chal
gor
it
hm
N)) i
s___
____
___.
((
OPTI
ON_ O(
n)
A))
((
OPTI
ON_ O(
logn)
B))
((
OPTI
ON_ O(
n.l
ogn)
C))
((
OPTI n2)
ON_ O(
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whichofthefol
l
owi
ngi
snott
hepar
tofADT
N)) descr
ipt
ion?
((
OPTI
ON_ Dat
a
A))
((
OPTI
ON_ Oper
ati
ons
B))
((
OPTI
ON_ Bot
hDat
aandOper
ati
ons
C))
((
OPTI
ON_ Noneoft
heabov
e
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA AnADTconsistsof
TION)
) Decl
arat
ionofdata,
(OPTI
ONAL
) Decl
arat
ionofoperat
ions

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Analgor
it
hm t
hatcal
l
sit
sel
fdi
rect
lyori
ndi
rect
lyi
s
N)) knownas
((
OPTI
ON_ Recur
sion
A))
((
OPTI
ON_ Tr
aver
sal
B))
((
OPTI
ON_ Sear
chi
ng
C))
((
OPTI
ON_ Pol
i
shNot
ati
on
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whichofthefoll
owi
ngdat
ast
ructur
ecan'
tst
oret
he
N)) non-homogeneousdat
ael
ements?
((
OPTI
ON_ Recor
ds
A))
((
OPTI
ON_ Ar
ray
B))
((
OPTI
ON_ Poi
nter
s
C))
((
OPTI
ON_ Al
loft
hese
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA Arrayi
scol
l
ect
ionofsi
mil
ar(
homogeneous)dat
a
TION)
) ty
pes
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Anal
gor
it
hm i
s__
___
___
___
___
___
___
_.
N))
((
OPTI
ON_ api
eceofcodet
obeexecut
ed.
A))
((
OPTI
ON_ ast
epbyst
eppr
ocedur
etosol
vepr
obl
em.
B))
((
OPTI
ON_ al
oosel
ywr
it
tencodet
omakef
inal
code.
C))
((
OPTI
ON_ Al
loft
hese
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whi
chofthef
oll
owi
ngasy
mpt
oti
cnot
ati
oni
sthe
N)) wor
stamongall
?
((
OPTI
ON_ Ο(
n+9378)
A))
((
OPTI
ON_ n3)
Ο(
B))
((
OPTI
ON_ O(
logn)
C))
((
OPTI
ON_ O(
nlogn)
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whi
choneofthefol
l
owingal
gori
thmicappr
oacht
ri
es
N)) t
oachi
evel
ocali
zedopt
imum sol
uti
on?
((
OPTI
ON_ Gr
eedyAppr
oach
A))
((
OPTI
ON_ Di
vi
deandConquerAppr
oach
B))
((
OPTI
ON_ Dy
nami
cAppr
oach
C))
((
OPTI
ON_ Tr
ial
andEr
rorAppr
oach
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA Greedyappr
oachf
ocusesonl
yonl
ocal
i
zedopt
imum
TION)
) solut
ion.
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Twomai
nmeasur
esfort
heef
fi
ciencyofanal
gor
it
hm
N)) ar
e__
___
___
___
___
_.
((
OPTI
ON_ Pr
ocessorandMemor
y
A))
((
OPTI
ON_ Compl
exi
tyandCapaci
ty
B))
((
OPTI
ON_ Dat
aandSpace
C))
((
OPTI
ON_ Ti
meandSpace
D))
(
(CORRECT D
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Thet
imefact
orwhendet
ermini
ngtheeff
ici
encyof
N)) al
gor
it
hm i
smeasuredby
____
_ _
___
____
.
((
OPTI
ON_ Count
ingmi
croseconds
A))
(
(OPTI
ON_ Count
ingspacei
nKBofanal
gor
it
hm
B)
)
((
OPTI
ON_ Count
ingt
henumberofst
atement
C))
((
OPTI
ON_ Count
ingnumberofkeyoper
ati
ons
D))
(
(CORRECT D
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whichofthefol
l
owingcasedoesnotexi
sti
n
N)) complexi
tyt
heory?
((
OPTI
ON_ BestCase
A))
((
OPTI
ON_ Av
erageCase
B))
((
OPTI
ON_ Bel
owAv
erageCase
C))
((
OPTI
ON_ Wor
stCase
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(
OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Ti
mecompl
exi
tyofanal
gor
it
hm dependsupon_
___
_
N)) .
((
OPTI
ON_ Si
zeofi
nput
A))
((
OPTI
ON_ SpeedofComput
er
B))
((
OPTI
ON_ Fr
equencyCount
C))
((
OPTI
ON_ Bot
hAandB
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Bi
g-Ohi
s__
___
___
___
___
___
__.
N))
((
OPTI
ON_ Asy
mpt
oti
cLowerBound
A))
((
OPTI
ON_ Fr
equencyCount
B))
((
OPTI
ON_ Asy
mpt
oti
cUpperBound
C))
((
OPTI
ON_ Rat
eofgr
owt
hofaf
unct
ion
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Bi
g-Omegai
s__
___
___
___
___
___
__.
N))
((
OPTI
ON_ Asy
mpt
oti
cLowerBound
A))
((
OPTI
ON_ Fr
equencyCount
B))
((
OPTI
ON_ Asy
mpt
oti
cUpperBound
C))
((
OPTI
ON_ Rat
eofgr
owt
hofaf
unct
ion
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whichoneoft hef
oll
owi
ngi
snotanal
gor
it
hm’
s
N)) charact
eri
sti
c?
((
OPTI
ON_ I
nput
A))
((
OPTI
ON_ Out
put
B))
((
OPTI
ON_ I
nfi
nit
eness
C))
((
OPTI
ON_ Unambi
guous
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whi
chst
atementi
sfal
se?
N))
((
OPTI
ON_ Pseudocodei
sver
ysi
mil
art
oal
gor
it
hms.
A))
((
OPTI
ON_ Pseudocodeusual
l
yincl
udessomesy
ntaxoft
he
B)) l
anguage.
((
OPTI
ON_ Pseudocodescanbecompi
l
ed.
C))
((
OPTI
ON_ Pseudocodei
sthecombi
nati
onofEngl
ish
D)) st
atementswit
hprogr
ammingmethodology
.
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA Pseudocodescannotbecompiled.As,pseudocode
TION)
) general
l
ydoesnotactual
lyobeythesyntaxrul
esof
(OPTI
ONAL anyparti
cul
arl
anguage.
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Aflowchar
tisadiagr
ammat
icr
epr
esent
ati
onofan
N)) __
__ _
___
____
___.
((
OPTI
ON_ Dat
aty
pes
A))
((
OPTI
ON_ Al
gor
it
hms
B))
((
OPTI
ON_ Dat
aSt
ruct
ures
C))
((
OPTI
ON_ Al
loft
hese
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O I
nfl
owchart‘
Rect
angl
e’i
susedt
orepr
esent
N)) _
___
___
___
_____
.
((
OPTI
ON_ Deci
sion
A))
((
OPTI
ON_ Pr
ocessi
ng
B))
((
OPTI
ON_ I
nput
C))
((
OPTI
ON_ St
art
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O I
nfl
owchart‘
Diamond’
isusedt
orepr
esent
N)) _
___
___
___
_____
.
((
OPTI
ON_ Deci
sion
A))
((
OPTI
ON_ Pr
ocessi
ng
B))
((
OPTI
ON_ I
nput
C))
(
(OPTI
ON_ St
art
D)
)
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O I
nfl
owchart‘
Hexagon’
isusedt
orepr
esent
N)) _
___
___
___
_____
.
((
OPTI
ON_ Deci
sion
A))
((
OPTI
ON_ Pr
ocessi
ng
B))
((
OPTI
ON_ I
nputandOut
put
C))
((
OPTI
ON_ I
nit
ial
i
zat
in/
Prepar
ati
on
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O I
nfl
owchart‘
paral
l
elogr
am’
isusedt
orepr
esent
N)) _
___
___
___
_____
.
((
OPTI
ON_ Deci
sion
A))
((
OPTI
ON_ Pr
ocessi
ng
B))
((
OPTI
ON_ I
nputandOut
put
C))
((
OPTI
ON_ St
art
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O ____
_____
____
______
_ _
_ofanal
gor
it
hm i
sdef
inedas
N)) thetot
alti
mer equi
redbyt
heal
gor
it
hm t
orunto
completi
on.
((
OPTI
ON_ SpaceCompl
exi
ty
A))
((
OPTI
ON_ Ti
meCompl
exi
ty
B))
((
OPTI
ON_ Anal
ysi
s
C))
((
OPTI
ON_ Asy
mpt
oti
cAnal
ysi
s
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O _____
____
___
_ _
___
___
_ofanalgor
it
hm istotal
space
N)) requi
redbytheal
gori
thm wi
thr
especttotheinput
size.
((
OPTI
ON_ SpaceCompl
exi
ty
A))
((
OPTI
ON_ Ti
meCompl
exi
ty
B))
((
OPTI
ON_ Memor
yAl
l
ocat
ion
C))
((
OPTI
ON_ Asy
mpt
oti
cAnal
ysi
s
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Thefuncti
onf(n)is___
_ _
___
___ofg(n)if
fther
eexist
s
N)) apositi
verealconst
antcandaposi ti
veint
egern0
suchthatf(
n)≤c.g(n)foral
ln>n0.Thisisdenot
edas
f(
n)=O( g(
n)).
((
OPTI
ON_ Bi
gO
A))
((
OPTI
ON_ Bi
gOmega
B))
((
OPTI
ON_ Bi
gThet
a
C))
((
OPTI
ON_ Noneoft
hese
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Thefuncti
onf(n)is_____
____
__ofg(n)if
fther
eexist
s
N)) apositi
verealconstantcandapositi
veint
egern0
suchthatf(
n)≥c. g(
n)foral
ln>n0.Thisisdenot
edas
f(
n)=O( g(
n)).
((
OPTI
ON_ Bi
gO
A))
((
OPTI
ON_ Bi
gOmega
B))
((
OPTI
ON_ Bi
gThet
a
C))
((
OPTI
ON_ Noneoft
hese
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O I
nworstcaseanaly
sisofanalgor
it
hm,
___
___
___
___
__
N)) ofanal
gori
thm i
scalcul
ated.
((
OPTI
ON_ Bi
gO
A))
((
OPTI
ON_ Bi
gOmega
B))
((
OPTI
ON_ Bi
gThet
a
C))
((
OPTI
ON_ Noneoft
hese
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O I
nbestcaseanal
ysi
sofanalgor
it
hm,
___
___
___
___
__
N)) ofanal
gori
thm i
scal
cul
ated.
((
OPTI
ON_ Bi
gO
A))
((
OPTI
ON_ Bi
gOmega
B))
((
OPTI
ON_ Bi
gThet
a
C))
((
OPTI
ON_ Noneoft
hese
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whi
choneoft
hef
oll
owi
ngi
snotabui
l
t-i
ndat
aty
pe?
N))
((
OPTI
ON_ I
nteger
A))
((
OPTI
ON_ Bool
ean
B))
((
OPTI
ON_ St
ruct
ure
C))
((
OPTI
ON_ Char
act
er
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whi
choneoft
hef
oll
owi
ngi
snotader
iveddat
aty
pe?
N))
((
OPTI
ON_ I
nteger
A))
((
OPTI
ON_ St
ruct
ure
B))
((
OPTI
ON_ Char
act
er
C))
((
OPTI
ON_ Bot
hAandC
D))
(
(CORRECT D
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)
) 1
(
1/2/
3..
.)
(
(QUESTI
O Whi
choneoft
hef
oll
owi
ngi
sder
iveddat
aty
pe?
N))
((
OPTI
ON_ I
nteger
A))
((
OPTI
ON_ Uni
on
B))
((
OPTI
ON_ Char
act
er
C))
((
OPTI
ON_ Bool
ean
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O __
___
_ _
___
_____i
sawaytoorganizeddat
ainsucha
N)) waythati
tcanbeusedef
fi
cient
ly.
((
OPTI
ON_ Dat
aSt
ruct
ure
A))
((
OPTI
ON_ Dat
aTy
pe
B))
((
OPTI
ON_ Dat
aSet
C))
((
OPTI
ON_ Al
loft
heabov
e
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O ___
______
_ _
____isdef
inedasadatadecl
arat
ion
N)) packagedtogetherwi
ththeoper
ati
onsthatare
meaningfulfort
hedatatype.
((
OPTI
ON_ Pseudocode
A))
((
OPTI
ON_ Dat
ast
ruct
ure
B))
((
OPTI
ON_ Dat
aSet
C))
((
OPTI
ON_ Abst
ractdat
aty
pe
D))
(
(CORRECT D
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whichoneoft
hef
oll
owi
ngi
snott
heLi
nearDat
a
N)) St
ructur
e?
((
OPTI
ON_ St
ack
A))
((
OPTI
ON_ Tr
ee
B))
((
OPTI
ON_ Queue
C))
((
OPTI
ON_ Li
nkedLi
st
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whichoneoft
hef
oll
owi
ngi
stheSt
ati
cDat
a
N)) St
ructur
e?
((
OPTI
ON_ St
ack
A))
((
OPTI
ON_ Li
nkedLi
st
B))
((
OPTI
ON_ Queue
C))
(
(OPTI
ON_ Ar
ray
D)
)
(
(CORRECT D
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whichoneoft
hef
oll
owi
ngi
snott
heDy
nami
cDat
a
N)) St
ructur
e?
((
OPTI
ON_ St
ack
A))
((
OPTI
ON_ Li
nkedLi
st
B))
((
OPTI
ON_ Ar
ray
C))
((
OPTI
ON_ Queue
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Dy
nami
cdat
ast
ruct
ure_
___
___
___
___
___
__.
N))
((
OPTI
ON_ i
seasyt
opr
ogr
am.
A))
((
OPTI
ON_ hasr
andom access.
B))
((
OPTI
ON_ doesef
fi
cientuseofmemor
y.
C))
((
OPTI
ON_ Noneoft
heabov
e.
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Dat
astruct
urest
hatcanchangesi
zewhi
l
eapr
ogr
am
N)) i
srunni
ngisknownas___
______
___
__
((
OPTI
ON_ St
ati
cDat
aSt
ruct
ure.
A))
((
OPTI
ON_ Dy
nami
cDat
aSt
ruct
ure.
B))
((
OPTI
ON_ Li
nearDat
aSt
ruct
ure.
C))
((
OPTI
ON_ Non-
LinearDat
aSt
ruct
ure
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Gr
aphi
s__
___
___
___dat
ast
ruct
ure.
N))
((
OPTI
ON_ l
i
near
A))
((
OPTI
ON_ non-
li
near
B))
((
OPTI
ON_ per
sist
ent
C))
((
OPTI
ON_ ephemer
al
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Li
sti
s__
___
___
___dat
ast
ruct
ure.
N)
)
((
OPTI
ON_ st
ati
c
A))
((
OPTI
ON_ dy
nami
c
B))
((
OPTI
ON_ per
sist
ent
C))
((
OPTI
ON_ ephemer
al
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whichoneoft
hef
oll
owi
ngi
snotaal
gor
it
hm desi
gn
N)) st
rategy
?
((
OPTI
ON_ Recur
siv
e
A))
((
OPTI
ON_ Non-
li
near
B))
((
OPTI
ON_ Backt
racki
ng
C))
((
OPTI
ON_ Dy
nami
cPr
ogr
ammi
ng
D))
(
(CORRECT B
_
CHOICE))
(
A/B/
C/D)
((
EXPLANA Non-
li
neari
sat
ypeofdat
ast
ruct
ures
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whi
choneoft
hef
oll
owi
ngi
snotanal
gor
it
hm desi
gn
N)) t
ool
?
((
OPTI
ON_ Pseudocode
A))
((
OPTI
ON_ Fl
owchar
t
B))
((
OPTI
ON_ Di
vi
deandConquer
C))
((
OPTI
ON_ Onl
yAandB
D))
(
(CORRECT D
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA Di
vi
deandConqueri
sal
gor
it
hm desi
gnt
ool
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Bi
gOnot
ati
oni
sdef
inedf
or_
___
___
___
___.
N))
((
OPTI
ON_ Ti
meandSpaceCompl
exi
ty
A))
((
OPTI
ON_ Opt
imal
i
ty
B))
((
OPTI
ON_ Sear
chi
ng
C))
((
OPTI
ON_ Noneoft
heabov
e
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whati
sti
mecompl exi
tyofbinar
ysear
chwhi
chuses
N)) di
vi
deandconquerstr
ategy
?
((
OPTI
ON_ O(
n.l
og(
n))
A))
((
OPTI
ON_ O(
log(
n))
B))
((
OPTI
ON_ O(
n)
C))
((
OPTI n2)
ON_ O(
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whati
sti
mecompl exi
tyofmer
gesor
twhi
chuses
N)) di
vi
deandconquerstr
ategy
?
((
OPTI
ON_ O(
n.l
og(
n))
A))
((
OPTI
ON_ O(
log(
n))
B))
((
OPTI
ON_ O(
n)
C))
((
OPTI n2)
ON_ O(
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whatisti
mecompl
exi
tyoff
un(
)?
N)) i
ntfun(
intn)
{
i
ntcount=0;
f
or( i
nti=n;i>0;
i/=2)
for(i
ntj=0;j<i
;j++)
count+=1;
r
eturncount;
}
((
OPTI
ON_ O(
n.l
og(
n))
A))
((
OPTI
ON_ O(
log(
n))
B))
((
OPTI
ON_ O(
n.n)
C))
((
OPTI
ON_ O(
log(
n).
log(
n))
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA Thetimecompl exit
ycanbecal culatedbycounti
ng
TION)
) numberoft i
mestheexpressi
on" count=count+1;"i
s
(OPTI
ONAL executed.Theexpressi
onisexecut ed0+1+2+3+4
) +...
.+( n-
1)times.Ti
mecompl exity=Thet a(0+1+2
+3+. .+n- 1)=Theta(n*
(n-1)
/2)=Thet a(n^2)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whatdoesitmeanwhenwesaythatanal
gor
it
hm Xi
s
N)) asy
mptoti
call
ymoreeff
ici
entt
hanY?
(( ON_ Xwi
OPTI l
lbeabet
terchoi
cef
oral
li
nput
s
A))
(( ON_ Ywi
OPTI l
lbeabet
terchoi
cef
orsmal
li
nput
s
B))

(( ON_ Xwi
OPTI l
lbeabet
terchoi
cef
oral
li
nput
sexceptl
arge
C)) i
nput
s

((
OPTI
ON_ Xwillbeabet
terchoi
cef
oral
li
nput
sexceptsmal
l
D)) i
nput
s
(
(CORRECT D
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON Newdataaretobeinser
tedint
oadatastr
uct
ure,
but
)
) ther
eisnoavai
labl
espace;t
hissi
tuat
ioni
susual
l
y
call
ed__
___
_____.
(
(OPTI A Sat
ON_ urat
ion
)
)
(
(OPTI
ON_
B Ov
erf
low
)
)
(
(OPTI C Under
ON_ fl
ow
)
)
(
(OPTI D Housef
ON_ ull
)
)
(
(CORRECT_ B
CHOICE))
(A/
B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON Whichofthef
oll
owingsor
ti
ngal
gor
it
hm i
sofdi
vi
de-
)
) and-
conquert
ype?
(
(OPTI A I
ON_ nser
ti
onSor
t
)
)
(
(OPTI
ON_
B Bubbl
eSor
t
)
)
(
(OPTI C Qui
ON_ ckSor
t
)
)
(
(OPTI D Pr
ON_ im’
sAl
gor
it
hm
)
)
((CORRECT_ C
CHOICE))
(A/B/C/
D)
((
EXPLANA
TION)
)
(OPTI
ONAL)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON ExpandADT_
___
___
___
___
_
)
)
(
(OPTI A Abst
ON_ ractDat
aTy
pe
)
)
(
(OPTI
ON_
B Aut
omat
icDat
aTr
ansact
ion
)
)
(
(OPTI C AccessDat
ON_ aTy
pe
)
)
(
(OPTI D Abst
ON_ ractDat
aTr
ansmi
ssi
on
)
)
((CORRECT_ A
CHOICE))
(A/B/C/
D)
((
EXPLANA
TION)
)
(OPTI
ONAL)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON Whi
choft
hef
oll
owi
ngdoesnotbel
ongt
orecur
sion?
)
)
(
(OPTI A Fi
ON_ bonacci
Sequence
)
)
(
(OPTI
ON_
B Queue
)
)
(
(OPTI C TowerofHanoi
ON_
)
)
(
(OPTI D Fact
ON_ ori
alFunct
ion
)
)
((CORRECT_ C
CHOICE))
(A/B/C/
D)
(
(EXPLANA
TION)
)
(OPTI
ONAL)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON Thequicksor
tal
gor
it
hm expl
oit_
___
___
__desi
gn
)
) techni
que.
(
(OPTI A Gr
ON_ eedy
)
)
(
(OPTI
ON_
B Dy
nami
cPr
ogr
ammi
ng
)
)
(
(OPTI C Backt
ON_ racki
ng
)
)
(
(OPTI D Di
ON_ vi
deandConquer
)
)
((CORRECT_ D
CHOICE))
(A/B/C/
D)
((
EXPLANA
TION)
)
(OPTI
ONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whichoft
hegiv
enopti
onsprovi
desthei
ncreasi
ng
N)) or
derofasympt
oti
ccomplexi
tyoff
uncti
onsf1,f
2,f
3
andf 4?
f1(n)=2^n
f2(n)=n^(
3/2)
f3(n)=nLogn
f4(n)=n^(
Logn)

((
OPTI
ON_ f
1,f
2,f
3,f
4
A))
((
OPTI
ON_ f
3,f
2,f
4,f
1
B))
((
OPTI
ON_ f
2,f
3,f
1,f
4
C))
((
OPTI
ON_ f
4,f
1,f
2,f
3
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Whi
ON) ch 
stat
ement
 i
str
ue?

(
(OPTI
ON_
A)) Ifadynamic-
progr
ammi ng 
problem sat
isfi
estheopti
mal-
substr
uctur
epropert
y,t
henal ocal
lyoptimal 
sol
uti
on 
isgl
obal
l
y
opti
mal.
(
(OPTI
ON_
B)) I
fagreedychoi
ceproper
tysat
isf
iestheopt
imal-
subst
ruct
ure
pr
opert
y,t
henalocal
lyopti
mal
 solut
ion 
i
sglobal
lyopt
imal
.

(
(OPTI
ON_
C)) Bot
hof 
abov
e

(
(OPTI
ON_
D)) Noneofabov
e
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Whatal
ON) gor
it
hm t
echni
quei
susedi
nthei
mpl
ement
ati
onofKr
uskal
sol
uti
onfortheMST?

(
(OPTI
ON_
A)) Gr
eedyTechni
que 

(
(OPTI
ON_
B)) Di
vi
de-
and-
ConquerTechni
que

(
(OPTI
ON_
C)) Dy
nami
cPr
ogr
ammi
ngTechni
que 

(
(OPTI
ON_
D)) Theal
gor
it
hm combi
nesmor
ethanoneoft
heabov
etechni
ques

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Di
ON) j
kst
ra’
sal
gor
it
hm :

(
(OPTI
ON_
A)) Hasgr
eedyappr
oacht
ofi
ndal
lshor
testpat
hs

(
(OPTI
ON_
B)) Hasbot
hgr
eedyandDy
nami
cappr
oacht
ofi
ndal
lshor
testpat
hs

(
(OPTI
ON_
C)) Hasgreedyapproacht
ocomput
esi
ngl
esour
ceshor
testpat
hst
o
al
lot
herv er
ti
ces 
(
(OPTI
ON_
D)) Hasbothgreedyanddynamicappr
oacht
ocomput
esi
ngl
esour
ce
shor
testpat
hstoallot
herver
ti
ces
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Whi
ON) choft
hef
oll
owi
ngst
andar
dal
gor
it
hmsi
snotaGr
eedy
al
gori
thm?
(
(OPTI
ON_
A)) Qui
ckSor
t

(
(OPTI
ON_
B)) Mi
nimum Spanni
ngTr
ee

(
(OPTI
ON_
C)) Pr
imsAl
gor
it
hm

(
(OPTI
ON_
D)) Huf
fmanCodi
ng

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Qui
ON) ckSor
tal
gor
it
hm i
suseswhi
cht
echni
que

(
(OPTI
ON_
A)) Dy
nami
cPr
ogr
ammi
ng

(
(OPTI
ON_
B)) Di
vi
deandConquer

(
(OPTI
ON_
C)) Backt
racki
ng

(
(OPTI
ON_
D)) Gr
eedyMet
hod

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Mer
ON) geSor
tal
gor
it
hm i
suseswhi
cht
echni
que

(
(OPTI
ON_
A)) Dy
nami
cPr
ogr
ammi
ng

(
(OPTI
ON_
B)) Di
vi
deandConquer

(
(OPTI
ON_
C)) Backt
racki
ng

(
(OPTI
ON_
D)) Gr
eedyMet
hod

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Bi
ON) nar
ySear
chal
gor
it
hm i
suseswhi
cht
echni
que

(
(OPTI
ON_
A)) Dy
nami
cPr
ogr
ammi
ng

(
(OPTI
ON_
B)) Di
vi
deandConquer

(
(OPTI
ON_
C)) Backt
racki
ng

(
(OPTI
ON_
D)) Gr
eedyMet
hod

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)
) 1
(
1/2/
3..
.)

(
(QUESTI ) Qui
ON) ckSor
tal
gor
it
hm i
suseswhi
cht
echni
que

(
(OPTI
ON_
A)) Dy
nami
cPr
ogr
ammi
ng

(
(OPTI
ON_
B)) Di
vi
deandConquer

(
(OPTI
ON_
C)) Backt
racki
ng

(
(OPTI
ON_
D)) Gr
eedyMet
hod

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Mi
ON) nimum Spanni
ngTr
eei
suseswhi
cht
echni
que

(
(OPTI
ON_
A)) Dy
nami
cPr
ogr
ammi
ng

(
(OPTI
ON_
B)) Di
vi
deandConquer

(
(OPTI
ON_
C)) Backt
racki
ng

(
(OPTI
ON_
D)) Gr
eedyMet
hod

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Huf
ON) fmanCodi
ngi
suseswhi
cht
echni
que

(
(OPTI
ON_
A)) Dy
nami
cPr
ogr
ammi
ng

(
(OPTI
ON_
B)) Di
vi
deandConquer

(
(OPTI
ON_
C)) Backt
racki
ng

(
(OPTI
ON_
D)) Gr
eedyMet
hod

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Pr
ON) imsAl
gor
it
hm i
suseswhi
cht
echni
que

(
(OPTI
ON_
A)) Dy
nami
cPr
ogr
ammi
ng

(
(OPTI
ON_
B)) Di
vi
deandConquer

(
(OPTI
ON_
C)) Backt
racki
ng

(
(OPTI
ON_
D)) Gr
eedyMet
hod

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Di
ON) j
kst
ra’
sAl
gor
it
hmi
suseswhi
cht
echni
que

(
(OPTI
ON_
A)) Dy
nami
cPr
ogr
ammi
ng

(
(OPTI
ON_
B)) Di
vi
deandConquer

(
(OPTI
ON_
C)) Backt
racki
ng

(
(OPTI
ON_
D)) Gr
eedyMet
hod

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Anopt
ON) imi
zat
ionpr
obl
em i
sonei
nwhi
chy
ouwantt
ofi
nd,

(
(OPTI
ON_
A)) Notasol
uti
on

(
(OPTI
ON_
B)) Anal
gor
it
hm

(
(OPTI
ON_
C)) Goodsol
uti
on

(
(OPTI
ON_
D)) Thebestsol
uti
on

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) TheHuf
ON) fmanal
gor
it
hm f
indsa(
n)_
___
___
___
___sol
uti
on.
(
(OPTI
ON_
A)) Opt
imal

(
(OPTI
ON_
B)) Non-
opt
imal

(
(OPTI
ON_
C)) Exponent
ial

(
(OPTI
ON_
D)) Pol
ynomi
al

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Recur
ON) rencesar
eusef
ulf
oranal
ysi
ng

(
(OPTI
ON_
A)) Par
all
elAl
gor
it
hms&Recur
siv
eAl
gor
it
hms

(
(OPTI
ON_
B)) Recur
siv
eAl
gor
it
hms

(
(OPTI
ON_
C)) Si
mpl
eAl
gor
it
hms

(
(OPTI
ON_
D)) Par
all
elAl
gor
it
hms

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) TheHuf
ON) fmanencodi
ngal
gor
it
hm i
sa

(
(OPTI
ON_
A)) Bot
hDy
nami
candgr
eedyal
gor
it
hm

(
(OPTI
ON_
B)) Bot
hdi
vi
deandconquerandgr
eedyal
gor
it
hm

(
(OPTI
ON_
C)) Gr
eedyal
gor
it
hm.

(
(OPTI
ON_
D)) Dy
nami
cpr
ogr
ammi
ngal
gor
it
hm

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) TheHuf
ON) fmanal
gor
it
hm f
inds

(
(OPTI
ON_
A)) somet
imeopt
imal
somet
imenonopt
imal
sol
uti
on

(
(OPTI
ON_
B)) spacewi
seopt
imal
andt
imewi
senonopt
imal
sol
uti
on

(
(OPTI
ON_
C)) anon-
opt
imal
sol
uti
on

(
(OPTI
ON_
D)) anopt
imal
sol
uti
on

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Recur
ON) siv
eal
gor
it
hmsar
ebasedon
(
(OPTI
ON_
A)) Di
vi
deandconquerappr
oach

(
(OPTI
ON_
B)) Top-
downappr
oach

(
(OPTI
ON_
C)) Bot
tom-
upappr
oach

(
(OPTI
ON_
D)) Hi
erar
chi
cal
appr
oach

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ther
ON) ecur
rencer
elat
ionf
orFi
bonacci
ser
iesi
s

(
(OPTI
ON_
A)) T(
n)=2T(
n–2)+2

(
(OPTI
ON_
B)) T(
n)=T(
n–1)+T(
n-2)

(
(OPTI
ON_
C)) T(
n)=2T(
n/2)+1

(
(OPTI
ON_
D))
T(
n)=2T(
n–1)+1

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ther
ON) ecurr
encerel
ati
oncapt
uri
ngt
heopt
imal
timeoft
heTowerof
Hanoiprobl
em wit
hndiscsi
s
(
(OPTI
ON_
A)) T(
n)=2T(
n–2)+2

(
(OPTI
ON_
B)) T(
n)=2T(
n–1)+n

(
(OPTI
ON_
C)) T(
n)=2T(
n/2)+1

(
(OPTI
ON_
D))
T(
n)=2T(
n–1)+1

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Thedi
ON) videandconquermer
gesor
tal
gor
it
hm’
sti
mecompl
exi
tycan
bedef
inedas
(
(OPTI
ON_
A)) θ(
longn)

(
(OPTI
ON_
B)) θ(
n)

(
(OPTI
ON_
C)) Ω(
nlogn)

(
(OPTI
ON_
D)) θ(
nlogn)

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Kr
ON) uskal
algor
it
hm i
sbasedon_
___
___
___
_met
hod

(
(OPTI
ON_
A)) Di
vi
deandconquermet
hod
(
(OPTI
ON_
B)) Gr
eedymet
hod

(
(OPTI
ON_
C)) Dy
nami
cpr
ogr
ammi
ng

(
(OPTI
ON_
D)) Br
anchandbound

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Themet
ON) hodwhichret
urndi
ff
erentsol
uti
onsf
rom asi
ngl
epoi
nt
,whichis____
____
_
(
(OPTI
ON_A)
) greedyme t
hod

(
(OPTI
ON_
B)) br
anchandbound

(
(OPTI
ON_
C)) dy
nami
cpr
ogr
ammi
ng

(
(OPTI
ON_
D)) di
vi
deandconquer

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) j
ON) obsequenci
ngwi
thdeadl
i
nei
sbasedon_
___
___
___
__met
hod

(
(OPTI
ON_
A)) gr
eedymet
hod

(
(OPTI
ON_
B)) br
anchandbound

(
(OPTI
ON_
C)) dy
nami
cpr
ogr
ammi
ng

(
(OPTI
ON_
D)) di
vi
deandconquer

(
(CORRECT_
C A
HOI
CE))
(
A/B/
C/D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Theopt
ON) imal
mer
gepat
ter
nisbasedon_
___
___
__met
hod

(
(OPTI
ON_
A)) Gr
eedymet
hod

(
(OPTI
ON_
B)) Dy
nami
cpr
ogr
ammi
ng

(
(OPTI
ON_
C)) Knapsackmet
hod

(
(OPTI
ON_
D)) Br
anchandbound

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Anal
ON) gor
it
hm t
hatcal
l
sit
sel
fdi
rect
lyori
ndi
rect
lyi
sknownas

(
(OPTI
ON_
A)) Subal
gor
it
hm

(
(OPTI
ON_
B)) Pol
i
shnot
ati
on

(
(OPTI
ON_
C)) Recur
sion

(
(OPTI
ON_
D)) Tr
aver
sal
algor
it
hm

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Whatal
ON) gori
thm t
echni
quei
susedi
nthei
mpl
ement
ati
onof
Kr
uskal

ssoluti
onfort
heMST?
(
(OPTI
ON_ ) Gr
A) eedyTechni
que

(
(OPTI
ON_
B)) Di
vi
de-
and-
Conquer
Techni
que

(
(OPTI
ON_
C)) Dy
nami
cPr
ogr
ammi
ngTechni
que

(
(OPTI
ON_
D)) Theal
gor
it
hm combi
nesmor
ethanoneoft
heabov
etechni
ques

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Whi
ON) chal
gor
it
hm doesnotusegr
eedyst
rat
egy
?

(
(OPTI
ON_
A)) Mer
geSor
t

(
(OPTI
ON_
B)) Bi
nar
ySear
ch

(
(OPTI
ON_
C)) Qui
cksor
t

(
(OPTI
ON_
D)) Al
loft
heabov
e

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Whi
ON) chal
gor
it
hm doesnotusedi
vi
deandconquerst
rat
egy
?

(
(OPTI
ON_
A)) Mer
geSor
t

(
(OPTI
ON_
B)) Huf
fmancodi
ng
(
(OPTI
ON_
C)) Qui
cksor
t

(
(OPTI
ON_
D)) Al
loft
heabov
e

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Runni
ngt
imef
orf
oll
owi
ngr
ecur
rencer
elat
ion
T(
n)=T(
n/4)
+T(
n/ +n2
2)
(
(OPTI
ON_
A)) θ(
nlog(
n))
2
(
(OPTI
ON_
B)) θ(
(n))

(
(OPTI
ON_
C)) θ(
log(
n))

(
(OPTI
ON_
D)) θ(
n)

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Gi
venafuncti
ontocomput
eonni
nput
s,t
hedi
vi
de-
and-
conquer
st
rat
egyconsi
stsof
:
(
(OPTI
ON_
A)) Divi
dethepr
oblem i
ntotwoormor esmallersubpr
oblems.Thati
s
spli
tt
ingt
heinput
sintokdist
inctsubset
s,1kn, y
iel
dingksub-
probl
ems.

(
(OPTI
ON_
B)) Conquert
hesubpr
obl
emsbysol
vi
ngt
hem r
ecur
siv
ely
.

(
(OPTI
ON_
C)) Combi
net
hesol
uti
onst
othesubpr
obl
emsi
ntot
hesol
uti
onsf
or
t
heor
igi
nal
probl
em.
(
(OPTI
ON_
D)) Al
loft
heabov
e

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whi
chonei
str
ueaboutdi
vi
de-
and-
conquerst
rat
egy
:

(
(OPTI
ON_
A)) Combinethesol
uti
onst
othesubpr
obl
emsi
ntot
hesol
uti
onsf
or
theor
igi
nalpr
obl
em.
(
(OPTI
ON_
B)) Sel
ectsetofi
nputf
rom gi
veni
nputset

(
(OPTI
ON_
C)) Tosol
vet
hepr
obl
em t
akesasequenceofdeci
sion

(
(OPTI
ON_
D)) None

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whi
chonei
snott
rueaboutdi
vi
de-
and-
conquerst
rat
egy
:

(
(OPTI
ON_
A)) Combinethesol
uti
onst
othesubpr
obl
emsi
ntot
hesol
uti
onsf
or
theor
igi
nalpr
obl
em.
(
(OPTI
ON_
B)) Sel
ectsetofi
nputf
rom gi
veni
nputset

(
(OPTI
ON_
C)) Tosol
vet
hepr
obl
em di
vi
desi
nputi
ntot
wopar
ts

(
(OPTI
ON_
D)) None

(
(CORRECT_
C B
HOI
CE))
(
A/B/
C/D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whichofthefol
lowingi
snotmet
hodbywhi
chwecansol
vet
he
r
ecurrencer
elat
ion
(
(OPTI
ON_
A)) Subst
it
uti
onMet
hod

(
(OPTI
ON_
B)) ChangeofVar
iabl
e

(
(OPTI
ON_
C)) Char
act
eri
sti
cEquat
ion

(
(OPTI
ON_
D)) None

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Subst
it
uti
onmet
hodi
susedf
or

(
(OPTI
ON_
A)) Forsol
vi
ngr
ecur
rencer
elat
ion

(
(OPTI
ON_
B)) Al
gor
it
hmi
cDesi
gnSt
rat
egy

(
(OPTI
ON_
C)) Bot
hA&B

(
(OPTI
ON_
D)) Nei
therAorB

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Char
act
eri
sti
cequat
ioni
susedf
or

(
(OPTI
ON_
A)) Al
gor
it
hmi
cDesi
gnSt
rat
egy

(
(OPTI
ON_
B)) Forsol
vi
ngr
ecur
rencer
elat
ion

(
(OPTI
ON_
C)) Bot
hA&B

(
(OPTI
ON_
D)) Nei
therAorB

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Changeofv
ari
abl
emet
hodi
susedf
or

(
(OPTI
ON_
A)) Al
gor
it
hmi
cDesi
gnSt
rat
egy

(
(OPTI
ON_
B)) Forsol
vi
ngr
ecur
rencer
elat
ion

(
(OPTI
ON_
C)) Bot
hA&B

(
(OPTI
ON_
D)) Nei
therAorB

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
) Di
vi
deandConquermet
hodi
s

(
(OPTI
ON_
A)) Al
gor
it
hmi
cDesi
gnSt
rat
egy

(
(OPTI
ON_
B)) Usedf
orsol
vi
ngr
ecur
rencer
elat
ion

(
(OPTI
ON_
C)) Bot
hA&B

(
(OPTI
ON_
D)) Nei
therAorB

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Di
vi
deandConquermet
hodi
s

(
(OPTI
ON_
A)) Al
gor
it
hmi
cDesi
gnSt
rat
egy

(
(OPTI
ON_
B)) Usedf
orsol
vi
ngr
ecur
rencer
elat
ion

(
(OPTI
ON_
C)) Usedt
ofi
ndoutopt
imal
sol
uti
ont
ogi
venpr
obl
em

(
(OPTI
ON_
D)) Takessequenceofdeci
siont
ofi
ndoutt
hesol
uti
on.

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Di
vi
deandConquermet
hodi
snot

(
(OPTI
ON_
A)) Al
gor
it
hmi
cDesi
gnSt
rat
egy

(
(OPTI
ON_
B)) Usedf
orsol
vi
ngr
ecur
rencer
elat
ion

(
(OPTI
ON_
C)) Usedtofi
ndoutsolut
iontogivenprobl
em bydi
vi
dinggi
ven
pr
oblem i
ntosub-
problem orsubt
ask
(
(OPTI
ON_
D)) Di
vi
dest
hepr
obl
em andcombi
net
hesol
uti
ons.

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Di
vi
deandConquermet
hodi
snot

(
(OPTI
ON_
A)) Usedf
orsol
vi
ngr
ecur
rencer
elat
ion

(
(OPTI
ON_
B)) Usedtofi
ndoutsolut
iontogivenprobl
em bydi
vi
dinggi
ven
pr
oblem i
ntosub-
problem orsubt
ask
(
(OPTI
ON_
C)) Bot
hA&B

(
(OPTI
ON_
D)) Nei
therAnorB

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Gr
eedymet
hodi
s

(
(OPTI
ON_
A)) Al
gor
it
hmi
cDesi
gnSt
rat
egy

(
(OPTI
ON_
B)) Usedf
orsol
vi
ngr
ecur
rencer
elat
ion

(
(OPTI
ON_
C)) Bot
hA&B

(
(OPTI
ON_
D)) Nei
therAorB

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Gr
eedymet
hodi
snot

(
(OPTI
ON_
A)) Al
gor
it
hmi
cDesi
gnSt
rat
egy

(
(OPTI
ON_
B)) Usedf
orsol
vi
ngr
ecur
rencer
elat
ion

(
(OPTI
ON_
C)) Usedt
ofi
ndoutopt
imal
sol
uti
ont
ogi
venpr
obl
em

(
(OPTI
ON_
D)) Takessequenceofdeci
siont
ofi
ndoutt
hesol
uti
on.

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Gr
eedymet
hodi
s

(
(OPTI
ON_
A)) Al
gor
it
hmi
cDesi
gnSt
rat
egy

(
(OPTI
ON_
B)) Usedf
orsol
vi
ngr
ecur
rencer
elat
ion

(
(OPTI
ON_
C)) Usedtofi
ndoutsolut
iontogivenprobl
em bydi
vi
dinggi
ven
pr
oblem i
ntosub-
problem orsubt
ask
(
(OPTI
ON_
D)) Di
vi
dest
hepr
obl
em andcombi
net
hesol
uti
ons.

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
) Gr
eedymet
hodi
snot

(
(OPTI
ON_
A)) Usedf
orsol
vi
ngr
ecur
rencer
elat
ion

(
(OPTI
ON_
B)) Usedt
ofi
ndoutopt
imal
sol
uti
ont
ogi
venpr
obl
em

(
(OPTI
ON_
C)) Bot
hA&B

(
(OPTI
ON_
D)) Nei
therAnorB

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whati
sti
mecompl exi
tyofmer
gesor
twhi
chuses
N)) di
vi
deandconquerstr
ategy
?
((
OPTI
ON_ O(
n.l
og(
n))
A))
((
OPTI
ON_ O(
log(
n))
B))
((
OPTI
ON_ O(
n)
C))
((
OPTI n2)
ON_ O(
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Adat
astr
ucturewhosesizei
sdeter
minedatcompil
e
N)) t
imeandcannotbechangedatr
untimeis_
_____
___
.
((
OPTI
ON_ ADT
A))
((
OPTI
ON_ st
ati
c
B))
((
OPTI
ON_ ephemer
al
C))
((
OPTI
ON_ per
manent
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Datastr
uctur
ewhichiscapableofexpr
essingmor e
N)) complexrel
ati
onshipt
hanthatofphysi
caladjacency
i
scall
ed_____
_____
____
.
((
OPTI
ON_ l
i
nkedl
i
st
A))
((
OPTI
ON_ nonl
i
neardat
ast
ruct
ure
B))
((
OPTI
ON_ dat
ast
ruct
ure
C))
((
OPTI
ON_ l
i
neardat
ast
ruct
ure
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Thecorr
ect
nessofadi
vi
deandconqueral
gor
it
hm i
s
N)) usual
l
yprovedby_
___
____
_.
((
OPTI
ON_ mat
hemat
ical
theor
em
A))
((
OPTI
ON_ mat
hemat
ical
induct
ion
B))
((
OPTI
ON_ de-
Mor
gan’
slaw
C))
((
OPTI
ON_ none
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Whichdat
astruct
ureinacompil
eri
susedf
or
N)) managi
nginf
ormationaboutv
ari
abl
esandt
hei
r
at
tri
but
es?
((
OPTI
ON_ Abst
ractDat
aTy
pe
A))
((
OPTI
ON_ Semant
icSt
ack
B))
((
OPTI
ON_ Sy
mbol
Tabl
e
C))
((
OPTI
ON_ Par
seTabl
e
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Theminimum numberofcompari
sonsrequi
redto
N)) det
erminei
fanintegerappear
smorethann/2ti
mes
i
nasortedarr
ayofni nt
egersi
s
((
OPTI
ON_ θ(
n)
A))
((
OPTI
ON_ θ(
logn)
B))
(
(OPTI
ON_ θ(
n.l
ogn)
C)
)
((
OPTI
ON_ θ(
1)
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Theti
mecompl exi
tyofanal
gori
thm T(
n),
wher
eni
s
N)) t
heinputsize,i
sgivenby
T(n)=T(n-1)+1/ nifn>1
Theorderofthi
salgori
thm i
s__
____
____
___.
((
OPTI
ON_ n
A))
((
OPTI
ON_ l
og(
n)
B))
((
OPTI
ON_ n.
n
C))
((
OPTI
ON_ n.
log(
n)
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Analgori
thm ismadeupoft woi
ndependentti
me
N)) complexi
tiesf(n)andg(n)
.Thenthecomplexi
ti
esof
theal
gori
thm isintheor
derof__
_____
____.
((
OPTI
ON_ f
(n).
g(n)
A))
((
OPTI
ON_ Mi
n(f
(n).
g(n))
B))
((
OPTI
ON_ Max(f
(n).
g(n))
C))
((
OPTI
ON_ f
(n)+g(
n)
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Timecomplexi
ti
esoft
hreeal
gori
thmsaregiv
en
N)) bel
ow.Whichshoul
dexecut
etheslowestf
orlar
ge
val
uesofN?
((
OPTI
ON_ O(
logN)
A))
((
OPTI
ON_ O(
N)
B))
((
OPTI N1/2)
ON_ O(
C))
((
OPTI
ON_ Noneoft
heabov
e
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON Considerthef
oll
owingpseudocode.Whati
sthet
otal
)
) numberofmul t
ipl
icat
ionst
obeperfor
med?
D=2
fori=1t ondo
f
orj =itondo
fork=j +1tondo
D=D*3
(
(OPTI A Hal
ON_ foft
hepr
oductoft
he3consecut
ivei
nteger
s
)
)
(
(OPTI
ON_
B One-
thi
rdoft
hepr
oductoft
he3consecut
ivei
nteger
s
)
)
(
(OPTI C One-
ON_ sixt
hoft
hepr
oductoft
he3consecut
ivei
nteger
)
)
(
(OPTI D Noneoft
ON_ heabov
e
)
)
((CORRECT_ C
CHOICE))
(A/B/C/
D)
((
EXPLANA
TION)
)
(OPTI
ONAL)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Whi choft
hegivenopti
onsprovi
desthei
ncreasi
ng
N)) orderofasymptot
iccomplexi
tyoff
uncti
onsf1,f
2,f
3
andf 4?
f1(n)=2^n
f2(n)=n^(
3/2)
f3(n)=nLogn
f4(n)=n^(
Logn)

((
OPTI
ON_ f
1,f
2,f
3,f
4
A))
((
OPTI
ON_ f
3,f
2,f
4,f
1
B))
((
OPTI
ON_ f
2,f
3,f
1,f
4
C))
((
OPTI
ON_ f
4,f
1,f
2,f
3
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Whatist i
mecomplexit
yoff
un(
)?
N)) i
ntfun(intn)
{
i
ntcount=0;
f
or( i
nti=n;i>0;
i/=2)
for(i
ntj =0;
j<i
;j++)
count+=1;
r
eturncount;
}
((
OPTI
ON_ O(
n.l
og(
n))
A))
((
OPTI
ON_ O(
log(
n))
B))
((
OPTI
ON_ O(
n.n)
C))
((
OPTI
ON_ O(
log(
n).
log(
n))
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA Thetimecompl exit
ycanbecal culatedbycounti
ng
TION)
) numberoft i
mestheexpressi
on" count=count+1;"i
s
(OPTI
ONAL executed.Theexpressi
onisexecut ed0+1+2+3+4
) +...
.+( n-
1)times.Ti
mecompl exity=Thet a(0+1+2
+3+. .+n- 1)=Theta(n*
(n-1)
/2)=Thet a(n^2)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O I
nanal y
sisofalgor
it
hm, appr
oxi
mat er
elati
onship
N)) betweenthesizeofthejobandtheamountofwor k
requi
redtodoisexpressedbyusing__
__ _
____.
((
OPTI
ON_ Cent
ral
tendency
A))
((
OPTI
ON_ Di
ff
erent
ial
equat
ion
B))
((
OPTI
ON_ Or
derofexecut
ion
C))
((
OPTI
ON_ Or
derofmagni
tude
D))
(
(CORRECT D
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Ifalgori
thm Ahasrunni
ngtime7n^
2+2n+3and
N)) algori
thm Bhasrunningti
me2n^2,t
hen_
___
___
___
_
((
OPTI
ON_ Bot
hhav
esameasy
mpt
oti
cti
mecompl
exi
ty
A))
((
OPTI
ON_ Bi
sasy
mpt
oti
cal
l
ygr
eat
er
B))
((
OPTI
ON_ Ai
sasy
mpt
oti
cal
l
ygr
eat
er
C))
((
OPTI
ON_ Noneoft
heabov
e
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Whati
sthesol
uti
ont
other
ecur
renceT(
n)=T(
n/2)+
N)) n
((
OPTI
ON_ O(
n)
A))
((
OPTI
ON_ O(
logn)
B))
((
OPTI
ON_ O(
n.l
ogn)
C))
((
OPTI
ON_ O(
n^2)
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Considert hefollowi
ngalgorit
hm:
N)) fact
orial(n){return1 if(n=1)el se ret
urn(
n*
fact
orial(n-1))}
Recurrencer elati
onforgivenalgori
thm i
s:
((
OPTI
ON_ T(
n)=n.
T(n-
1)+1
A))
((
OPTI
ON_ T(
n)=T(
n-1)+1
B))
((
OPTI
ON_ T(
n)=T(
n(n-
1))+1
C))
((
OPTI
ON_ T(
n)=T(
n-1)+n
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Gi
venacoll
ecti
onofalgor
ithmsthatr
unsonO( 1)
,
N)) O(
nlogn),
O(n),O(n^
2),O(l
ogn),O(n!
),or
dert
he
al
gor
it
hmsf r
om fast
esttoslowest
((
OPTI
ON_ O(
1),
O(nl
ogn)
,O(
n),
O(n^
2),
O(l
ogn)
,O(
n!)
A))
((
OPTI
ON_ O(
1),
O(l
ogn)
,O(
n),
O(nl
ogn)
,O(
n^2),
O(n!
)
B))
((
OPTI
ON_ O(
n),
O(l
ogn)
,O(
nlogn)
,O(
n^2),
O(n!
),O(
1),
C))
((
OPTI
ON_ O(
n!)
,O(
n),
O(l
ogn)
,O(
nlogn)
,O(
n^2),
O(1)
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Gi
venacoll
ecti
onofalgor
ithmsthatr
unsonO( 1)
,
N)) O(
nlogn),
O(n),O(n^
2),O(l
ogn),O(n!
),or
dert
he
al
gor
it
hmsf r
om fast
esttoslowest
((
OPTI
ON_ O(
1),
O(nl
ogn)
,O(
n),
O(n^
2),
O(l
ogn)
,O(
n!)
A))
((
OPTI
ON_ O(
1),
O(l
ogn)
,O(
n),
O(nl
ogn)
,O(
n^2),
O(n!
)
B))
((
OPTI
ON_ O(
n),
O(l
ogn)
,O(
nlogn)
,O(
n^2),
O(n!
),O(
1),
C))
((
OPTI
ON_ O(
n!)
,O(
n),
O(l
ogn)
,O(
nlogn)
,O(
n^2),
O(1)
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Recur
sivefunct
ioni
mpl
ement
swhi
chmechani
sm?
N)) 1)Queue
2)LI
FO
3)FIFO
4)FILO
((
OPTI
ON_ Onl
y1
A))
((
OPTI
ON_ 2and3
B))
((
OPTI
ON_ 1and4
C))
((
OPTI
ON_ Al
l
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Considerthef
oll
owingcharact
erist
icsconnect
edwith
N)) aprogram.
(i
)Theinputtotheprogram
(i
i)Thetimecomplexit
yofthealgori
thm under
lyi
ng
theprogram
(i
ii
)Thequali
tyoft
heCompil
er
(i
v)Thenatur
eandspeedofthemachi
ne
Theknowledgeofwhichoft
heabovei
sneededt
o
cal
culat
etheexactr
unni
ngti
meofaprogram?

((
OPTI
ON_ (
i)and(
ii
)onl
y
A))

((
OPTI
ON_ (
i)
,(i
i
)and(
ii
i)onl
y
B))

((
OPTI
ON_ (
i)
,(i
i
)and(
iv)onl
y
C))

((
OPTI
ON_ (
i)
,(i
i
i)and(
iv)onl
y
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O
N))
((
OPTI
ON_
A))
((
OPTI
ON_
B))
((
OPTI
ON_
C))
((
OPTI
ON_
D))
(
(CORRECT
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Whatist
hev al
ueoffol
lowi
ngrecur
rence.
N)) T(
n)=T(n/4)+T(n/2)+cn^2
T(
1)=c
T(
0)=0
Wherecisaposit
iveconst
ant
((
OPTI
ON_
O(
n^3)
A))
((
OPTI
ON_
O(
n^2)
B))
((
OPTI
ON_
O(
n^2Logn)
C))
((
OPTI
ON_ O(
nLogn)
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Whatisthesol
uti
onoft
her
ecur
rencer
elat
ion
N)) an=an-1+2an-
2
wit
ha0=2anda1=7?
((
OPTI
ON_
an=5.2n-( n
-1)
A))
ON_ an=2n-( n
((
OPTI -1)
B))
ON_ an=3.2n-( n
((
OPTI -1)
C))
((
OPTI
ON_ None
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O
Sol
vet
her
ecur
rencer
elat
ionFn=2Fn−1−2Fn−2
N))
wher
eF0=1andF1=3

((
OPTI
ON_ Fn=(
√2)
n(cos(
n.π/4))
A))
((
OPTI
ON_
Fn=(
√2)
n
B))
((
OPTI
ON_
Fn=(
√2)
n(cos(
n.π/4)+2si
n(n.π/4)
)
C))
((
OPTI
ON_ None
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O
Sol
vet
her
ecur
rencer
elat
ionFn=10Fn−1−25Fn−2
N))
wher
eF0=3andF1=17

((
OPTI
ON_
Fn=3n+2n.
2n
A))
((
OPTI
ON_
5n+(
Fn=3. 2/5).
n.2n
B))
((
OPTI
ON_
Fn=(
2/5).
n.2n
C))
((
OPTI
ON_ None
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
(
(EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O n
Sol
vetherecur
rencer
elat
ionFn=3Fn−1+10Fn−2+7.
5
N))
whereF0=4andF1=3

((
OPTI
ON_
Fn=n5n+1+6. n
(−2) 5n
−2.
A))
((
OPTI
ON_
Fn=n5n+1+( n
−2) 5n
−2.
B))
((
OPTI
ON_
Fn=n5n+1+6. n
(−2)
C))
((
OPTI
ON_ None
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Asequenceisdef
inedbyther
ecur
rencerel
ati
onun+1=
N)) pun+q.Whichofthefol
l
owingwouldbean
expr
essi
onforu2?
((
OPTI
ON_
u2=3p2+pq+q
A))
((
OPTI
ON_
u2=3p+q
B))
((
OPTI
ON_
u2=6p+2q
C))
((
OPTI
ON_
u2=9p2+6pq+q2
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Whati
stheval
ueoff
oll
owi
ngr
ecur
rence.
N)) T(
n)=2T(n/
2)+n

((
OPTI
ON_
O(
n^3)
A))
((
OPTI
ON_
O(
n^2)
B))
((
OPTI
ON_
O(
n^2Logn)
C))
((
OPTI
ON_ O(
nLogn)
D))
(
(CORRECT D
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Whati
sthevalueoff
oll
owi
ngr
ecur
rence.
N)) g(
n+1)=n^2+g(n)

((
OPTI
ON_
g(
n)=n(
2n-
1)
A))
((
OPTI
ON_
g(
n)=(
n-1)
n(2n-
1)
B))
((
OPTI
ON_
g(
n)=c1+1/
6(n-
1)n(
2n-
1)
C))
((
OPTI
ON_ None
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Findt
hesol ut
ionfort
her
ecur
rencer
elat
ion
N)) xn=6xn-1-9xn-2
Wherex1=3andx0=2
((
OPTI
ON_
3n–n.3n
xn=2.
A))
((
OPTI
ON_
xn=3n–n.3n
B))
((
OPTI
ON_
3n–3n
xn=2.
C))
((
OPTI
ON_
3n
xn=2.
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Findthesol utionf
ort
her
ecur
rencer
elat
ion
N)) xn=2xn-1-5xn-2
Wherex1=5andx0=1

((
OPTI
ON_ n+1 n+1
xn=5/
2(1+2i
) +5/
2(1-
2i)
A))
((
OPTI
ON_ n+1 n+1
xn=2/
5(1+2i
) +5/
2(1-
2i)
B))
((
OPTI
ON_ n+1 n+1
xn=2/
5(1+2i
) +2/
5(1-
2i)
C))
((
OPTI
ON_
None
D))
(
(CORRECT B
_
CHOICE)
)
(
A/B/
C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Findthesoluti
onf orther
ecur
rencer
elat
ion
n
N)) xn=3xn-1+10xn-2+7.5
Wherex1=3andx0=4
((
OPTI
ON_
5n+1 -2.
5n+6( n
xn=n. -2)
A))
((
OPTI
ON_ n
xn=6(
-2)
B))
((
OPTI
ON_
5n+6( n+1
xn=n.
5-2. -2)
C))
((
OPTI
ON_
None
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Findt
hesol uti
onf ort
herecur
rencer
elat
ion
n
N)) xn=10xn-1+25xn-2+8.
5
Wherex1=10andx0=6
((
OPTI
ON_ n
xn=(8n+6)
(5)
A))
((
OPTI
ON_
4n2+8n+6) n
xn=( (5)
B))
((
OPTI
ON_
4n2+8) n
xn=( (5)
C))
((
OPTI
ON_
None
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Findt
hesol ut
ionf
ort
her
ecur
rencer
elat
ion
N)) xn=10xn/2+1
Wherex1=1
((
OPTI
ON_
xn=l
og2n+1
A))
((
OPTI
ON_
xn=l
ogn
B))
((
OPTI
ON_
xn=nl
ogn
C))
((
OPTI
ON_
None
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Consi
derthepolynomialp(
x)=a0+a1x+a2x^ 2
N)) +a3x^
3,whereai!=0,foral
li.Themini
mum number
ofmulti
pli
cat
ionsneededtoev al
uat
eponaninputx
i
s:
((
OPTI
ON_
3
A))
((
OPTI
ON_
4
B))
((
OPTI
ON_
6
C))
((
OPTI
ON_
9
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)
) 2
(
1/2/
3..
.)
(
(QUESTI
O Whati
sthev
alueoff
oll
owi
ngr
ecur
rence.
N))
T(
n)=3T(
n/4)+n
((
OPTI
ON_
O(
n^3)
A))
((
OPTI
ON_
O(
n^2)
B))
((
OPTI
ON_
O(
n^2Logn)
C))
((
OPTI
ON_ O(
n)
D))
(
(CORRECT D
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Whati
sthev
alueoff
oll
owi
ngr
ecur
rence.
N))
T(
n)=2T(
n/4)+n2
((
OPTI
ON_
O(
n^3)
A))
((
OPTI
ON_
O(
n^2)
B))
((
OPTI
ON_
O(
n^2Logn)
C))
((
OPTI
ON_ O(
n)
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Whati
sthev
alueoff
oll
owi
ngr
ecur
rence.
N))
T(
n)=4T(
n/2)+n3
((
OPTI
ON_
O(
n^3)
A))
((
OPTI
ON_
O(
n^2)
B))
((
OPTI
ON_
O(
n^2Logn)
C))
((
OPTI
ON_ O(
n)
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Ther
unni
ngt
imeofanal
gor
it
hm i
srepr
esent
edbyt
he
N)
) foll
owingr ecur
rencerel
ati
on:
i
fn<=3t hen T(n)=n
elseT(n)=4T( n/3)+cn2
Whi choneoft hefol
lowingrepr
esent
sthet
ime
compl exi
tyofthealgori
thm?
((
OPTI
ON_
Θ(
n)
A))
((
OPTI
ON_
Θ(
nlogn)
B))
((
OPTI
ON_
n2)
Θ(
C))
((
OPTI
ON_
n2l
Θ( ogn)
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Ther unni
ngt imeofanal gorit
hm isrepr
esent
edbyt
he
N)) foll
owingr ecurrencerel
ation:
i
fn<=3t hen T( n)=n
elseT(n)=3T( n/ 3)+cn2
Whi choneoft hef ol
lowingr epresent
stheti
me
compl exi
tyoft healgori
thm?
((
OPTI
ON_
Θ(
n)
A))
((
OPTI
ON_
Θ(
nlogn)
B))
((
OPTI
ON_
n2)
Θ(
C))
((
OPTI
ON_
n2l
Θ( ogn)
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O
Whichoneofthefol
lowingcor
rect
lydet
erminest
he
N))
sol
uti
onoftherecur
rencerel
ati
onwithT(1)=1?

T(
n)=2T(
n/2)+Logn
((
OPTI
ON_ Θ(
n)
A))
((
OPTI
ON_ Θ(
nLogn)
B))
((
OPTI
ON_ Θ(
n*n)
C))
((
OPTI
ON_ Θ(
logn)
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Whati
sthev
alueoff
oll
owi
ngr
ecur
rence.
N))
T(
n)=4T(
n/2)+C

((
OPTI
ON_ Θ(
n)
A))
((
OPTI
ON_ Θ(
nLogn)
B))
((
OPTI n2)
ON_ Θ(
C))
((
OPTI
ON_
Θ(
logn)
D))

(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Whati
sthev
alueoff
oll
owi
ngr
ecur
rence.
N))
T(
n)=T(
n/2)+Θ(
n)

((
OPTI
ON_ Θ(
n)
A))
((
OPTI
ON_ Θ(
nLogn)
B))
((
OPTI n2)
ON_ Θ(
C))
((
OPTI
ON_
Θ(
logn)
D))

(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Whati
sthev
alueoff
oll
owi
ngr
ecur
rence.
N))
T(
n)=6T(
n/3)+n2l
ogn

((
OPTI
ON_ Θ(
n)
A))
((
OPTI
ON_ Θ(
nLogn)
B))
((
OPTI
ON_
C)) n2l
Θ( ogn)
((
OPTI
ON_ Θ(
logn)
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Whati
stheval
ueoff
oll
owi
ngrecur
rence.
N)) T(
n)=5T(n/
5)+n,T(
1)=1,T(
0)=0

((
OPTI
ON_ Ө(
n)
A))
((
OPTI
ON_ Ө(
n^2)
B))
((
OPTI
ON_ Ө(
sqr
t(n)
)
C))
((
OPTI
ON_ Ө(
nLogn)
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Whati st hewor stcaset imecompl exit
yoffol
lowi
ng
N)) i
mpl ement at i
onofsubsetsum pr oblem.
//Ret urnst rueift herei sasubsetofset [
]wit
hsunequaltogi
ven
sum
boolisSubset Sum( intset[]
,intn,i
nt sum)
{
 
  /
/BaseCases
 
  i
f(
sum ==0)
 
   
 r
et urnt rue;
 
  i
f(
n==0&&sum ! =0)
 
   
 r
et urnf alse;
 
 
 
  /
/Ifl astel ementi sgr eat erthansum, theni
gnor
eit
 
  i
f(
set [
n-1]>sum)
 
   
 r
et urnisSubset Sum( set,n-1,sum) ;
 
 
 
  /
*el se, checki fsum canbeobt ainedbyanyofthefoll
owing
 
   
  
(a)i ncl udingt hel astelement
 
   
  
(b)excl udi ngthel astel ement   */
 
  r
etur nisSubset Sum( set,n-1,sum)| |
 
   
  
  
  isSubset Sum( set,n-
1, sum- set[n-
1]);
}

((
OPTI
ON_ O(
n*2^
n)
A))
(( ON_ O(
OPTI n^2)
B))
((
OPTI
ON_ O(
n^2*2^
n)
C))
((
OPTI
ON_ O(
2^n)
D))
(
(CORRECT D
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O SupposeT(n)=2T(
n/2)+n,
T(0)=T(
1)=1Whi
chone
N)) ofthefol
l
owingisf
alse.

((
OPTI
ON_ T(
n)=O(
n^2)
A))
((
OPTI
ON_ T(
n)= (
nLogn)
B))
((
OPTI
ON_ T(
n)= (
n^2)
C))
((
OPTI
ON_ T(
n)=O(
nLogn)
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Former
gingt
wosor
tedl
ist
sofsizesm andnintoa
N)) sort
edl
i
stofsi
zem +n,
wer equi
recompari
sonsof

((
OPTI
ON_
 
O(m)
A))
((
OPTI
ON_  
O(n)
B))
((
OPTI
ON_ O(
m+n)
C))
((
OPTI
ON_
O(
log(
m)+l
og(
n))
D))

(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Consi
dert
hef
oll
owi
n-
gr
ecur
rence:
N)) T (n) = 2T ff.Jnl) + 1, T (1) = 1
Whi
choneoft
hef
oll
owi
ngi
str
ue?
((
OPTI
ON_ T(
n)= (
logl
ogn)
A))
((
OPTI
ON_ T(
n)= (
logn)
B))
((
OPTI
ON_ T(
n)= (
sqr
t(n)
)
C))
((
OPTI
ON_ T(
n)= (
n)
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Ther unni
ngt imeofanal gorit
hm isrepr
esent
edbyt
he
N)) foll
owingr ecurrencerel
ation:
i
fn<=3t hen T( n)=n
elseT(n)=T( n/3)+cn
Whi choneoft hef ol
lowingr epresent
stheti
me
compl exi
tyoft healgori
thm?
((
OPTI
ON_ (
n)
A))
((
OPTI
ON_ (
nlogn)
B))
((
OPTI
ON_ (
n^2)
C))
((
OPTI
ON_ (
n^2l
ogn)
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Ther unningti
meoft hefol
l
owi
ngal
gori
thm
N)) Pr ocedureA(n)
{
Ifn>1
return(A(n/2)
+A(n/
2));
}
i
sbestdescr i
bedbywhichoft
hef
oll
owingrecur
rence
relati
on

((
OPTI
ON_ T(
n)=2T(
n–2)+2
A))
(( ON_ T(
OPTI n)=2T(
n–1)+n
B))
((
OPTI
ON_ T(
n)=2T(
n/2)+1
C))
((
OPTI
ON_
T(
n)=T(
n–1)+1
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Ther unningti
meofthefol
l
owi
ngal
gori
thm
N)) Pr ocedureA(n)
{
Ifn<=2
returnA(n-1)
;
}
i
sbestdescr i
bedbywhi
choft
hef
oll
owingrecur
rence
relati
on

((
OPTI
ON_ T(
n)=2T(
n–2)+2
A))
(( ON_ T(
OPTI n)=2T(
n–1)+n
B))
((
OPTI
ON_ T(
n)=2T(
n/2)+1
C))
((
OPTI
ON_
T(
n)=T(
n–1)+1
D))
(
(CORRECT D
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)
) 2
(
1/2/
3..
.)
(
(QUESTI
O Therunni
ngti
meofthef
ollowi
ngalgori
thm
N)) Pr
ocedureA(n)
I
fn<=2r et
urn(
1)el
ser
eturnA([
√n])
;
i
sbestdescri
bedby

(( ON_ O(
OPTI n)
A))
(( ON_ O(
OPTI logn)
B))
((
OPTI
ON_ O(
1ogl
ogn)
C))
((
OPTI
ON_ O(
1)
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Whatist
heti
mecomplexi
tyoft
hef
oll
owi
ngr
ecur
siv
e
N)) f
uncti
on:
i
ntDoSomet
hing(
int
n)
{
 
 i
f(
n<=2)
 
  
 r
etur
n1;
 
 el
se 
 
  
 r
etur
n(DoSomet
hing(
fl
oor
(sqr
t(n)
))+
n);
}

((
OPTI
ON_ O(
n)
A))
((
OPTI
ON_ O(
nlogn)
B))
((
OPTI
ON_ O(
logn)
C))
((
OPTI
ON_ O(
logl
ogn)
D))
(
(CORRECT D
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Thet i
mecompl exit
yofthefol
lowingCfunct
ioni
s
N)) (assumen>0
i
nt r
ecursi
ve(mtn)
{
 
  i
f(n==1)
 
   
 r
eturn(
1);
 
  el
se
 
   
 r
eturn(
recur
sive(n-
1)+recursi
ve(n-
1))
;
}

((
OPTI
ON_
0(
n)
A))
((
OPTI
ON_
0(
nlogn)
B))
((
OPTI
ON_
0(
n^2)
C))
((
OPTI
ON_
0(
2^n)
D))
(
(CORRECT D
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
((QUESTIO Consi
dert
hef
oll
owi
ngr
ecur
renceT(
n)=3T(
n/5)+l
gn
hati
sthev
aNl
u)
e)ofT(
n)?
((
OPTI nlog53)
ON_ Ө(
A))

((
OPTI nlog35)
ON_ Ө(
B))
((
OPTI
ON_ Ө(
nlogn)
C))
((
OPTI
ON_ Ө(
logn)
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Considert
hefol
l
owingrecur
rence.
N)) T(n)=T(√n)+Ө(l
ogl
ogn)

Whati
sthev
alueofr
ecur
rence?

2
((
OPTI
ON_ Ө(
(l
ogl
ogn))
A))
((
OPTI
ON_ Ө(
logl
ogn
B))
((
OPTI
ON_ Ө(
n)
C))
((
OPTI
ON_ Ө(
logl
ogl
ogn)
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Whi choneofthefol
lowingcor
rect
lydet
erminest
he
N)) soluti
onoftherecur
rencerel
ati
onwithT(1)=1?
T(n)=2T(n/2)+Logn
((
OPTI
ON_ Θ(
n)
A))
((
OPTI
ON_ Θ(
nLogn)
B))
((
OPTI
ON_
C)) Θ(
n*n)
((
OPTI
ON_ Θ(
logn)
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Letf(
n)=nandg(n)=n(1+sinn),
wher
enisaposit
ive
N)) i
nteger.Whi
choft
hefollowi ngstat
ement
sis/
are
corr
ect?
I.f(
n)=O(g(n)
)
II
.f(
n)=Ω(g(n)
)
((
OPTI
ON_
Onl
yI
A))
((
OPTI
ON_
Onl
yII
B))
(
( ON_ Bot
OPTI hIandI
I
C)
)
((
OPTI
ON_
Nei
therInorI
I
D))
(
(CORRECT D
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Consideral istofr ecursi
veal gor i
thmsandal i
stof
N)) recurr
encerelationsasshownbel ow.Eachr ecurr
ence
rel
ati
oncor respondst oexact l
yoneal gor
ithm andis
usedtoder i
vet het i
mecompl exit
yoft healgori
thm.
RecursiveAl
gor it
hm Recur renceRel ati
on
P.BinarysearchI .T(n)=T(n-k)+T( k)+cn
Q.Mer gesortII
.T( n)=2T(n-1)+1
R.QuicksortIII
.T(n)=2T( n/2)+cn
S.TowerofHanoi IV.T(n)=T( n/2)+1
((
OPTI
ON_ P-
II
,Q-
II
I,
R-I
V,S-
I
A))
((
OPTI
ON_ P-
II
,Q-
II
I,
R-I
V,S-
I
B))
((
OPTI
ON_ P-
II
I,
Q-I
I,
R-I
V,S-
I
C))
(( ON_ P-
OPTI IV,
Q-I
I,
R-I
,S-
II
I
D))
(
(CORRECT B
_
CHOICE))
(
A/B/
C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Consi derther
ecur
rencerel
ati an=6n2+2n+
ona1=8,
N)) an-1.Leta99=kx104.Theval
ueofKis_
___

((
OPTI
ON_
190
A))
((
OPTI
ON_
296
B))
((
OPTI
ON_
198
C))
((
OPTI
ON_
200
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Whenn=22kforsomek≥0,ther
ecur
rencer
elat
ion
N)) T(
n)=√(2)T(
n/2)+√n,
T(1)=1
ev
aluat
esto:
((
OPTI
ON_
√(
n)(
logn+1)
A))
((
OPTI
ON_
√(
n)(
logn)
B))
((
OPTI
ON_
√(
n)l
og√(
n)
C))
((
OPTI
ON_
nl
og√(
n)
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Consi derthef ollowi ngr ecur r
encer
elat
ion
T( 1) = 1
N))
T(n + 1) = T(n)+ L.Jn + 1 J for all n~1

Thev
al m2)f
ueofT( orm ≥1i
s
((
OPTI
ON_
(
m/6)(
21m -39)+4
A))
((
OPTI
ON_
(
m/ 4m2-3m +5)
6)(
B))
((
OPTI
ON_
(
m/ m2.5-11m +20)–5
2)(
C))
((
OPTI
ON_
(
m/ 5m3-34m2+137m -104)+(
6)( 5/6)
D))
(
(CORRECT B
_
CHOICE)
)
(
A/B/
C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Thesol
uti
ont
other
ecur
renceequat
i 2k)=3T(
onT( 2k-
,
T(1)=1,
is:N))
((
OPTI
ON_ k
2
A))
((
OPTI
ON_
3k+1-1)
( /2
B))
((
OPTI
ON_ log
3 2k
C))
((
OPTI
ON_ log
2 3k
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
O Selectthecorr
ectasympt
oti
ccomplexi
tyofan
N)) al
gor i
thm wit
hrunti
meT(n,n)wher
e
T(x,c)=Θ(x)forc<=2,
T(
c,y
)=Θ(
y)f
orc<=2,and
T(
x,y
)=Θ(
x+y
)+T(x/
2,y/2)
((
OPTI
ON_
Θ(
nLogn)
A))
((
OPTI
ON_
n2)
Θ(
B))
((
OPTI
ON_
Θ(
n)
C))
((
OPTI
ON_
n2Logn)
Θ(
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Ar
ray
sinC++ar
e
N))
((
OPTI
ON_ RowMaj
or
A))
((
OPTI
ON_ Col
umnMaj
or
B))
((
OPTI
ON_ Di
agonal
Maj
or
C))
((
OPTI
ON_ Noneoft
heabov
e
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whichamongt hef
oll
owi ngpai
rsofoper
ati
onsi
s
N)) Suppor
tedbyanarrayADT?
i) St oreandr
etrieve
ii
) I nser
tanddelete
ii
i
) Copyanddel et e
iv
) Appendandcopy
((
OPTI
ON_ (
i)
A))
((
OPTI
ON_ (
ii
)
B))
((
OPTI
ON_ (
ii
i)
C))
((
OPTI
ON_ (
iv)
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Thenumberofel
ementsi
nanarr
ay
N)) ARRAY[
b1:u1,
b2:
u2]i
sgiv
enby
((
OPTI
ON_ (
u1-
b1-
1)(
u2-
b2-
1)
A))
((
OPTI
ON_ (
u1.
u2)
B))
((
OPTI
ON_ (
u1-
b1)
(u2-
b2)
C))
((
OPTI
ON_ (
u1-
b1+1)
(u2-
b2+1)
D))
(
(CORRECT D
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Amultidi
mensionalar
rayOPEN[
0:2,
10:
20,
3:4,
-
10:
2]
N)) cont
ains___
___elements
((
OPTI
ON_ 240
A))
((
OPTI
ON_ 858
B))
((
OPTI
ON_ 390
C))
((
OPTI
ON_ 160
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Fort
hearrayA[
1:u1,
1:u2,
1:u3]wher
eaisthebase
N)) addr
ess,
theaddressofA[i,
j,
1]i
sgivenby
((
OPTI
ON_ a+(
i-
1)u2u3+(
j-
1)u3
A))
((
OPTI
ON_ a+i
.u2u3+j
.u3
B))
((
OPTI
ON_ a+(
i-
1)u1u2+(
j-
1)u2
C))
((
OPTI
ON_ a+i
.u1u2+j
.u2
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O ____i
sastruct
ureusedtorepresentt
hel
i
near
N)) rel
ati
onshi
pbetweenelementsbymeansof
sequent
ial
memor ylocat
ions
((
OPTI
ON_ Li
nkedLi
st
A))
((
OPTI
ON_ Ar
ray
B))
((
OPTI
ON_ Poi
nter
C))
((
OPTI
ON_ St
ack
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O A___
_isali
stoff
ini
tenumberofhomogeneousdat
a
N)) el
ements
((
OPTI
ON_ Li
nearar
ray
A))
((
OPTI
ON_ Poi
nter
B))
((
OPTI
ON_ Li
nkedLi
st
C))
((
OPTI
ON_ Tr
ee
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Thenumberofel
ement
sni
scal
l
edt
hel
engt
hor_
__
N)) oft
hearr
ay
((
OPTI
ON_ UpperBound
A))
((
OPTI
ON_ LowerBound
B))
((
OPTI
ON_ Si
ze
C))
((
OPTI
ON_ Var
iabl
e
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O ThenumberKi
nA[
K]i
scal
l
edt
hesubscr
iptort
he
N)) ___
__
((
OPTI
ON_ Si
ze
A))
((
OPTI
ON_ I
ndex
B))
((
OPTI
ON_ Var
iabl
e
C))
((
OPTI
ON_ Const
ant
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Whichofthef
oll
owi
ngar
enotpar
toft
hear
ray
N)) decl
arat
ion?
((
OPTI
ON_ Nameoft
hear
ray
A))
((
OPTI
ON_ Dat
aty
peoft
hear
ray
B))
((
OPTI
ON_ I
ndexsetoft
hear
ray
C))
((
OPTI
ON_ Lengt
hoft
hear
ray
D))
(
(CORRECT D
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Thepr
ocessofaccessi
ngandpr
ocessi
ngeach
N)) el
ementofanarr
ayAexactl
yoncei
scall
ed___
___
_
((
OPTI
ON_ Del
eti
ng
A))
((
OPTI
ON_ I
nser
ti
ng
B))
((
OPTI
ON_ Tr
aver
sing
C))
((
OPTI
ON_ Sear
chi
ng
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Twodimensi
onal
arr
aysar
esomet
imescal
l
ed_
___
__
N)) ar
ray
s.
((
OPTI
ON_ I
nteger
A))
((
OPTI
ON_ Bool
ean
B))
((
OPTI
ON_ Mat
ri
x
C))
((
OPTI
ON_ Real
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Representat
ionofatwodimensi
onal
arrayasone
N)) si
nglecolumnofr owsandmappingi
tsequent
ial
l
yis
cal
led____represent
ati
on
((
OPTI
ON_ Row-
Maj
or
A))
((
OPTI
ON_ Row
B))
((
OPTI
ON_ Col
umn-
Maj
or
C))
((
OPTI
ON_ Col
umn
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Matr
iceswit
hrel
ati
velyhi
ghpr
opor
ti
onofzer
oent
ri
es
N)) ar
ecalled_
____matr
ices
((
OPTI
ON_ Tr
iangul
ar
A))
((
OPTI
ON_ Di
agonal
B))
((
OPTI
ON_ Spar
se
C))
((
OPTI
ON_ Adj
acency
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O _____
array
sarewher
etheelementsint
hedif
fer
ent
N)) array
swi t
hthesamesubscr
iptbel
ongtot
hesame
record.
((
OPTI
ON_ Onedi
mensi
onal
A))
((
OPTI
ON_ Par
all
el
B))
((
OPTI
ON_ Two-
dimensi
onal
C))
((
OPTI
ON_ St
ati
c
D))
(
(CORRECT B
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Amat ri
xinwhichnonzer
oentr
iescanonlyoccur
eon
N)) thediagonaloronel
ementsi
mmedi at
elyaboveor
belowthediagonali
scal
led_
_____matri
x.
((
OPTI
ON_ Tr
iangul
ar
A))
((
OPTI
ON_ Tr
idi
agonal
B))
((
OPTI
ON_ Spar
se
C))
((
OPTI
ON_ Si
mpl
e
D))
(
(CORRECT C
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
O Recor
dscanbest
oredi
nanar
eaofmemor
ycal
l
ed
N)) ___
_memory
((
OPTI
ON_ Dy
nami
c
A))
((
OPTI
ON_ St
ati
c
B))
((
OPTI
ON_ Si
mpl
e
C))
((
OPTI
ON_ Par
all
el
D))
(
(CORRECT A
_
CHOI CE)
)
(
A/B/C/D)
((
EXPLANA
TION)
)
(OPTI
ONAL
)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
) Thememoryaddr
essoft
hef
ir
stel
ementofan
arr
ayi
scal
l
ed
(
(OPTI
ON_
A)) f
looraddr
ess
(
(OPTI
ON_
B)) f
oundat
ionaddr
ess
(
(OPTI
ON_
C)) f
ir
staddr
ess
(
(OPTI
ON_
D)) baseaddr
ess

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) Eachar
ON) raydecl
arati
onneednotgi
ve,
impl
i
cit
lyor
expl
ici
tl
y,thei
nformati
onabout
(
(OPTI
ON_
A)) t
henameofar
ray
(
(OPTI
ON_
B)) t
hedat
aty
peofar
ray
(
(OPTI
ON_
C)) t
hef
ir
stdat
afr
om t
hesett
obest
ored
(
(OPTI
ON_
D)) t
hei
ndexsetoft
hear
ray
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) Theel
ON) ementsofanar rayar
estoredsuccessiv
elyi
n
memor ycel
lsbecause
(
(OPTI
ON_ ) byt
A) hiswaycomput ercankeeptr
ackonlythe
addressoft
hefirstelementandtheaddressesof
otherel
ementscanbecal cul
ated
(
(OPTI
ON_
B)) ar
chi
tectur
eofcomputermemorydoesnotal
l
ow
ar
ray
st ostor
eothert
hanser
ial
l
y
(
(OPTI
ON_
C)) bot
hofabov
e

(
(OPTI
ON_
D)) noneofabov
e

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)
Thememoryaddressoff
if
thel
ementofanar
ray
canbecal
cul
atedbythef
ormul
a

(
(OPTI
ON_
A)) LOC(Ar
ray[
5]=Base(
Arr
ay)
+w(
5-l
owerbound),
wherewisthenumberofwor
dspermemor ycel
l
fort
hearr
ay
(
(OPTI
ON_
B)) LOC(Ar
ray[
5])
=Base(
Arr
ay[
5])
+(5-
lowerbound),
wherewisthenumberofwordspermemor ycel
l
fort
hearr
ay
(
(OPTI
ON_
C)) LOC(Ar
ray[
5])
=Base(
Arr
ay[
4])
+(5-
Upperbound)
,
wherewisthenumberofwordspermemorycell
fort
hearr
ay
(
(OPTI
ON_
D)) Noneofabov
e

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)
Whichofthef
oll
owi
ngdat
ast
ruct
uresar
eindexed
st
ruct
ures?

(
(OPTI
ON_
A)) l
i
nearar
ray
s
(
(OPTI
ON_
B)) l
i
nkedl
i
sts
(
(OPTI
ON_
C)) bot
hofabov
e
(
(OPTI
ON_
D)) noneofabov
e
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)
Twodi
mensi
onal
arr
aysar
eal
socal
l
ed

(
(OPTI
ON_
A)) t
abl
esar
ray
s
(
(OPTI
ON_
B)) mat
ri
xar
ray
s
(
(OPTI
ON_
C)) bot
hofabov
e
(
(OPTI
ON_
D)) noneofabov
e

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)
Av
ari
abl
ePi
scal
l
edpoi
nteri
f

(
(OPTI
ON_
A)) Pcont
ainst
headdr
essofanel
ementi
nDATA.
(
(OPTI
ON_
B)) Ppoi
ntst
otheaddr
essoff
ir
stel
ementi
nDATA
(
(OPTI
ON_
C)) Pcanst
oreonl
ymemor
yaddr
esses
(
(OPTI
ON_
D)) Pcont
aint
heDATAandt
headdr
essofDATA
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)
Whi
chofthef
oll
owingdat
ast
ruct
urecan'
tst
ore
t
henon-
homogeneousdat
ael
ements?

(
(OPTI
ON_
A)) Ar
ray
s
(
(OPTI
ON_
B)) Recor
ds
(
(OPTI
ON_
C)) Poi
nter
s

(
(OPTI
ON_
D)) None
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)
Whichofthef
oll
owingdat
astruct
urest
oret
he
homogeneousdatael
ements?

(
(OPTI
ON_
A)) Ar
ray
s
(
(OPTI
ON_
B)) Recor
ds
(
(OPTI
ON_
C)) Poi
nter
s
(
(OPTI
ON_
D)) None

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)
Eachdat
ait
em inarecor
dmaybeagr oupit
em
composedofsub-
it
ems;thosei
temswhichare
i
ndecomposabl
earecall
ed

(
(OPTI
ON_
A)) el
ement
aryi
tems
(
(OPTI
ON_
B)) at
oms
(
(OPTI
ON_
C)) scal
ars
(
(OPTI
ON_
D)) al
lofabov
e

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)
Thedi
ff
erencebet
weenl
i
nearar
rayandar
ecor
dis

(
(OPTI
ON_
A)) Anarr
ayi
ssui
tabl
eforhomogeneousdatabutt
he
dat
ait
emsinarecor
dmayhav edi
ffer
entdat
atype
(
(OPTI
ON_
B)) I
nar ecor
d,t
heremaynotbeanat
ural
order
ingi
n
opposedtol
inearar
ray
.
(
(OPTI
ON_
C)) Arecor
dform ahi
erar
chi
cal
str
uct
urebutal
i
near
ar
raydoesnot
(
(OPTI
ON_
D)) Al
lofabov
e
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
) Eacharraydecl
arati
onneednotgi
ve,
impl
i
cit
lyor
expl
ici
tl
y,thei
nformati
onabout
(
(OPTI
ON_
A))  
Thenameofar
ray
(
(OPTI
ON_
B)) Thedat
aty
peofar
ray
(
(OPTI
ON_
C)) Thef
ir
stdat
afr
om t
hesett
obest
ored
(
(OPTI
ON_
D)) Thei
ndexsetoft
hear
ray
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
) Theel
ementsofanar
rayar
est
oredsuccessi
vel
yin
memorycel
l
sbecause
(
(OPTI
ON_
A)) bythiswaycomputercankeeptr
ackonlythe
addressofst
hefir
stel
ementandt headdr
essesof
otherel
ementscanbecalcul
ated
(
(OPTI
ON_
B)) thear
chi
tect
ureofcomputermemor ydoesnot
all
owarr
aystostor
eotherthanser
ial
ly
(
(OPTI
ON_
C)) bot
hofabov
e
(
(OPTI
ON_
D)) noneofabov
e
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) C
ON) onsi
#i
ncl
derf
ol
ude<i
l
owi
ostr
ngcode:
eam.h>
i
ntmai n(
)
{
i
nta[10];
A[0]
=10;A[1]
=4;
A[3]
=15;
cout
<<A[2+1];
}
Whatwi l
lbetheout
putoff
oll
owi
ngcode?
(
(OPTI
ON_
A)) NULL
(
(OPTI
ON_
B)) 10
(
(OPTI
ON_
C)) 4
(
(OPTI
ON_
D)) 15
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
) Whi
char
ethecor
rectar
rayi
nit
ial
i
zat
ionst
atement
s?

(
(OPTI
ON_
A)) i
ntA[
3]={
1,2,
3};

(
(OPTI
ON_
B)) i
ntA[
3]={
123}
;

(
(OPTI
ON_
C)) i
ntA[
3]=”
123”
;

(
(OPTI
ON_
D)) Al
l

(
(CORRECT_
C
HOI
CE)) A
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) Whi
ON) choft
hef
oll
owi
ngst
atement
sar
ewr
ongst
atement
s?

(
(OPTI
ON_
A)) Ar
rayi
spr
imi
ti
vedat
ast
ruct
ure.

(
(OPTI
ON_
B)) Ever
yel
ementofar
raymustbesame.

(
(OPTI
ON_
C)) I
nar
ray
,Inser
tel
ementi
scal
l
edpushoper
ati
on.

(
(OPTI
ON_
D)) Al
l

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
) Whi
char
etheappl
i
cat
ionsofar
ray
?
(
(OPTI
ON_
A)) Spar
semat
ri
x
(
(OPTI
ON_
B)) Or
der
edl
i
st
(
(OPTI
ON_
C)) Bot
ha&b
(
(OPTI
ON_
D)) none
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) Whi
ON) chamongthefoll
owingpai
rsofoper
ati
onsi
s
suppor
tedbyanarrayADT?
(
(OPTI
ON_ ) St
A) or
eandRetri
eve

(
(OPTI
ON_
B)) I
nser
tandDel
ete

(
(OPTI
ON_
C)) CopyandDel
ete

(
(OPTI
ON_
D)) AppendandCop
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) Thenumberofel
ON) ement
sinar
rayAr
ray
[1:
u]i
sgi
ven
by
(
(OPTI
ON_
A)) (
1-u)
(
(OPTI
ON_
B)) (
u)
(
(OPTI
ON_
C)) (
u–1+1)
(
(OPTI
ON_
D)) (
u–1-
1)
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
) Thenumberofel
ement
sinar
rayAr
ray
[l
1:u1,
l2:
u2]i
sgi
venby

(
(OPTI
ON_
A)) (
u1-
l1–1)
(u2–l
2-1)

(
(OPTI
ON_
B)) (
u1*
u2)

(
(OPTI
ON_
C)) (
u1–l
1)(
u2–l
2)

(
(OPTI
ON_
D)) (
u1-
l1+1)
(u2–l
2+1)

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) T
ON) henumberofel
givenby
ementsinar
rayAr
ray
[l1:
u1,
l2:
u2,
l3:
u3]i
s

(
(OPTI
ON_A)
) (u1-l
1–1)
(u2–l
2-1)(
u3–l3-
1)

(
(OPTI
ON_
B)) (
u1*
u2*
u3)

(
(OPTI
ON_
C)) (
u1–l
1)(
u2–l
2)(
u3-
l3)

(
(OPTI
ON_
D)) (
u1-
l1+1)
(u2–l
2+1)
(u3–l
3+1)

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) A
ON) none-
el
di
ement
s.
mensi
onal
arr
ayar
ray[
1:5]cont
ains_
___
___
__

(
(OPTI
ON_A)
) 5
(
(OPTI
ON_
B)) 4
(
(OPTI
ON_
C)) 1
(
(OPTI
ON_
D)) 6
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) At
ON) el
wo-
di
ement
mensi
s.
onal
arr
ayar
ray
[1:
3,1:
3]cont
ains_
___
___
__

(
(OPTI
ON_A)
) 3
(
(OPTI
ON_
B)) 6
(
(OPTI
ON_
C)) 9
(
(OPTI
ON_
D)) 7
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) I
ON) fthear
r
ofanar
r
ayi
sA[
ayhav
i
1:
10],whatwi
ngbaseaddr
l
lbetheaddr
ess100.
essofA[
5]el
ement

(
(OPTI
ON_A)
) 105
(
(OPTI
ON_
B)) 106
(
(OPTI
ON_
C)) 107
(
(OPTI
ON_
D)) 104
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) I
ON) ft
A[
hear
5,
r
ayi
2]el
sA[1:
10,
1:
ementofanar
5]
r
,__
__
ayhav
_
_
i
__
____wi
ll
bet
ngbaseaddr
headdr
ess100.
essof

(
(OPTI
ON_A)
) 120
(
(OPTI
ON_
B)) 121
(
(OPTI
ON_
C)) 122
(
(OPTI
ON_
D)) 123
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) I
ON) fthear
ofA[
1,
r
ayi
2,
sA[
3]el
1:5,
1:2,
1:3]
ementofanar
,
r
__
___
_
ayhav
_
i
__
___
wil
lbet
ngbaseaddr
headdr
ess
ess100.
(
(OPTI
ON_A)
) 102
(
(OPTI
ON_
B)) 104
(
(OPTI
ON_
C)) 105
(
(OPTI
ON_
D)) None
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) Spar
ON) semat
ri
xhav
e? 

(
(OPTI
ON_
A)) manyzer
oent
ri
es

(
(OPTI
ON_
B)) manynon-
zer
oent
ri
es

(
(OPTI
ON_
C)) hi
gherdi
mensi
on

(
(OPTI
ON_
D)) noneofabov
e

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) At
ON) wodimensionalarr
ayTABLE[6][
8]isst
oredi
n
r
owmaj ororderwit
hbaseaddress351.
Whati
st headdressofTABLE[
3][4]
?
(
(OPTI
ON_
A)) 407
(
(OPTI
ON_
B)) 410
(
(OPTI
ON_
C)) 417
(
(OPTI
ON_
D)) None
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) Theext
ON) r
akeyi
nser
tedatt
heendoft
hear
rayi
s
cal
leda,
(
(OPTI
ON_
A)) Endkey
(
(OPTI
ON_
B)) St
opkey
.

(
(OPTI
ON_
C)) Sent
inel
.

(
(OPTI
ON_
D)) Tr
ansposi
ti
on
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
) Thel
argestel
ementofanar
rayi
ndexi
scal
l
edi
ts
(
(OPTI
ON_
A)) l
owerbound.
(
(OPTI
ON_
B)) r
ange
(
(OPTI
ON_
C)) upperbound.
(
(OPTI
ON_
D)) Al
loft
hese.
(
(CORRECT_
C
HOI
CE)) C
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI ) Whati
ON) stheout
putoft
hisCcode?

#incl
ude<st di
o.h>
voidmai n()
{
i
nta[2][3]={ 1,2,3,
4,5}
;
i
nti =0, j=0;
for(i=0; i<2; i
++)
for(j=0; j<3; j
++)
print
f("
%d" ,a[i
][
j]
);
}
(
(OPTI
ON_
A)) 123450
(
(OPTI
ON_
B)) 12345j
unk
(
(OPTI
ON_
C)) 123455
(
(OPTI
ON_
D)) Runt
imeer
ror

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI ) Whati
ON) stheout putoft
hisCcode?
#incl
ude<st di
o.h>
voidmai n()
{
i
nta[2][3]={ 1,2,3,
,4,
5};
i
nti =0, j=0;
for(i=0; i<2; i
++)
for(j=0; j<3; j
++)
print
f("
%d" ,a[i
][
j]
);
}
(
(OPTI
ON_ ) 123j
A) unk45

(
(OPTI
ON_
B)) Compi
l
eti
meer
ror

(
(OPTI
ON_
C)) 123045
(
(OPTI
ON_
D)) 123345
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI ) Whati
ON) st heoutputoft
hisCcode?
#include<st di
o.h>
voidf (
inta[]
[3]
)
{
a[0][
1]=3;
i
nti =0, j=0;
for(i=0; i<2; i
++)
for(j=0; j<3; j
++)
print
f("%d",a[i
][
j]
);
}
voidmai n()
{
i
nta[ 2][
3]={ 0};
f(a);
}
(
(OPTI
ON_ ) 030000
A)
(
(OPTI
ON_
B)) Junk3j
unkj
unkj
unkj
unk

(
(OPTI
ON_
C)) Compi
l
eti
meer
ror
(
(OPTI
ON_
D)) Al
lj
unkv
alues
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI ) Whati
ON) stheout putoft
hisCcode?
#include<st di
o.h>
voidf (
inta[]
[])
{
a[0][
1]=3;
i
nti =0, j=0;
for(i=0; i
<2; i++)
for(j=0; j
<3; j++)
print
f("%d",a[i
][
j]
);
}
voidmai n()
{
i
nta[ 2][
3]={ 0};
f(a);
}
(
(OPTI
ON_
A)) 030000
(
(OPTI
ON_
B)) Junk3j
unkj
unkj
unkj
unk
(
(OPTI
ON_
C)) Compi
l
eti
meer
ror

(
(OPTI
ON_
D)) Al
lj
unkv
alues

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) Commentont
ON) hef
oll
owi
ngst
atement
:
i
nt(*
a)[
7];
(
(OPTI
ON_
A)) Anar
ray“
a”ofpoi
nter
s.
(
(OPTI
ON_
B)) Apoi
nter“
a”t
oanar
ray
.

(
(OPTI
ON_
C)) Ar
aggedar
ray
.

(
(OPTI
ON_
D)) None
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) Commentont
ON) he2ar
ray
sregar
dingPandQ:
i
nt*a1[8];
i
nt*(a3[8]
);
P.Arrayofpoi
nter
s
Q.Pointert
oanarray
(
(OPTI
ON_ ) a1i
A) sP, a2isQ

(
(OPTI
ON_
B)) a1i
sP,
a2i
sP

(
(OPTI
ON_
C)) a1i
sQ,
a2i
sP
(
(OPTI
ON_
D)) a1i
sQ,
a2i
sQ

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) Whi
ON) choft
hefol
l
owi
ngi
snotpossi
blest
ati
cal
l
yin
C?
(
(OPTI
ON_ ) JaggedAr
A) ray

(
(OPTI
ON_
B)) Rect
angul
arAr
ray

(
(OPTI
ON_
C)) Cuboi
dal
Arr
ay
(
(OPTI
ON_
D)) Mul
ti
dimensi
onal
Arr
ay

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) Whatwi
ON) l
lhappenifi
naCprogram y
ouassigna
val
uetoanarrayel
ementwhosesubscr
iptexceeds
t
hesizeofarr
ay?
(
(OPTI
ON_
A)) Theel
ementwi
l
lbesett
o0.
(
(OPTI
ON_
B)) Thecompi
l
erwoul
drepor
taner
ror
(
(OPTI
ON_
C)) Thepr
ogram maycr
ashi
fsomei
mpor
tantdat
a
get
sover
writ
ten.
(
(OPTI
ON_
D)) Thear
raysi
zewoul
dappr
opr
iat
elygr
ow.
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) Whatdoest
ON) hef
oll
owi
ngdecl
arat
ionmean?
i
nt(*
ptr
)[10]
;
(
(OPTI
ON_
A)) pt
risar
rayofpoi
nter
sto10i
nteger
s
(
(OPTI
ON_
B)) pt
risapoi
ntert
oanar
rayof10i
nteger
s
(
(OPTI
ON_
C)) pt
risanar
rayof10i
nteger
s
(
(OPTI
ON_
D)) pt
risanpoi
ntert
oar
ray
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) I
ON) nCifyoupassanar
rayasanargumentt
oa
f
unct
ionwhatact
ual
l
ygetspassed?
(
(OPTI
ON_
A)) Val
ueofel
ement
sinar
ray
(
(OPTI
ON_
B)) Fi
rstel
ementoft
hear
ray
(
(OPTI
ON_
C)) Baseaddr
essoft
hear
ray
(
(OPTI
ON_
D)) Addr
essoft
hel
astel
ementofar
ray
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI ) Whatwi
ON) l
lbet
heout
putoft
hef
oll
owi
ngcode?
#i
ncl
ude<st
dio.
h>

i
ntmai n()
{
i
nta[5]={ 5,1,
15,20,25}
;
i
nti,j
,m;
i=++a[ 1]
;
j=a[1]++;
m =a[i++];
pri
ntf(
"%d, %d,%d"
,i,
j,m);
ret
urn0;
}

(
(OPTI
ON_
A)) 2,
1,15
(
(OPTI
ON_
B)) 1,
2,5
(
(OPTI
ON_
C)) 3,
2,15
(
(OPTI
ON_
D)) 2,
3,20
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)
Whatwi
l
lbet
heout
putoft
hepr
ogr
am?

#i
ncl ude<stdio.h>
i
ntmai n(
)
{
stati
cinta[ 2][2]={1,2,3,4};
i
nti ,j
;
stati
cint* p[]={ (i
nt*
)a,(i
nt*
)a+1,(i
nt*)
a+2}
;
for(i
=0;i<2;i++)
{
for(j
=0;j<2; j++)
{pr i
ntf(
"%d, %d,%d,%d\n",*(
*(p+i
)+j
),
*(
*(j+p)+i)
,*(*(i+p)+j)
,*(*
(p+j)
+i)
);
}
}
return0;
}

(
(OPTI
ON_
A)) 1,
1,1,
1
2,
3,2,
3
3,
2,3,
2
4,
4,4,
4
(
(OPTI
ON_
B)) 1,
2,1,
2
2,
3,2,
3
3,
4,3,
4
4,
2,4,
2
(
(OPTI
ON_
C)) 1,
1,1,
1
2,
2,2,
2
2,
2,2,
2
3,
3,3,
3
(
(OPTI
ON_
D)) 1,
2,3,
4
2,
3,4,
1
3,
4,1,
2
4,
1,2,
3
(
(CORRECT_
CH C
OI
CE))
(
A/B/C/
D)
(
(EXPLANATION
)
)(OPTIONAL)
(
MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)
Whatwi
l
lbet
heout
putoft
hepr
ogr
am ?

#include<st dio.h>
i
ntmai n( )
{
voidf un(int,i
nt [
])
;
intar r[]={ 1,2,3,4};
inti;
fun( 4, arr)
;
for(i=0; i
<4;i++)
pr intf("%d,",arr
[i
])
;
retur n0;
}
voidf un( intn, i
ntarr[
])
{
int* p=0;
inti=0;
whi le(i++<n)
p=&ar r[
i]
;
*p=0;
}

(
(OPTI
ON_
A)) 2,
3,4,
5
(
(OPTI
ON_
B)) 1,
2,3,
4
(
(OPTI
ON_
C)) 0,
1,2,
3
(
(OPTI
ON_
D)) 3,
2,10
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi l
lbetheoutputoft
hef
oll
owi
ngcode
#incl
ude<stdi
o.h>
voidfun(
int**
p);

i
ntmai n()
{
i
nta[ 3]
[4]={ 1,
2,3,4,
4,3,
2,8,
7,8,
9,0}
;
i
nt* ptr
;
ptr=&a[ 0][
0];
fun(&ptr);
return0;
}
v
oi dfun(i
nt* *p)
{
pri
ntf("
%d\ n",*
*p);
}

(
(OPTI
ON_
A)) 1
(
(OPTI
ON_
B)) 2
(
(OPTI
ON_
C)) 3
(
(OPTI
ON_
D)) 4
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi l
lbetheoutput
#i
nclude<stdi
o.h>
i
ntmai n()
{ stati
cintarr[
]={0,1,2,3,4}
;
i
nt*p[]={arr
,arr
+1,arr+2,ar
r+3,ar
r+4};
i
nt**ptr=p;
ptr
++;
pri
ntf(
"%d,%d,%d\n",
pt r
-p,*
ptr-
arr
,**pt
r);
*ptr
++;
pri
ntf(
"%d,%d,%d\n",
pt r
-p,*
ptr-
arr
,**pt
r);
*++ptr
;
pri
ntf(
"%d,%d,%d\n",
pt r
-p,*
ptr-
arr
,**pt
r);
++*ptr
;
pri
ntf(
"%d,%d,%d\n",
pt r
-p,*
ptr-
arr
,**pt
r);
ret
urn0;
}

(
(OPTI
ON_
A)) 0,
0,0
1,
1,1
2,
2,2
3,
3,3
(
(OPTI
ON_
B)) 1,
1,2
2,
2,3
3,
3,4
4,
4,1
(
(OPTI
ON_
C)) 1,
1,1
2,
2,2
3,
3,3
3,
4,4
(
(OPTI
ON_
D)) 0,
1,2
1,
2,3
2,
3,4
3,
4,5
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whi
chofthefoll
owingi
scor
rectwayt
odef
inet
he
f
unct
ionf
un()inthebel
owprogr
am?

#i
nclude<st
dio.
h>
i
ntmai n(
)
{
i
nta[3]
[4]
;
f
un(a);
r
eturn0;
}

(
(OPTI
ON_
A)) v
oidf
un(
intp[
][
4])

(
(OPTI
ON_
B)) v
oidf
un(
int*
p[4]
)

(
(OPTI
ON_
C)) v
oidf
un(
int*
p[]
[4]
)

(
(OPTI
ON_
D)) v
oidf
un(
int*
p[3]
[4]
)

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whichoft
hefoll
owingstat
ement
sar
ecor
rect
aboutt
heprogr
am below?

#i
ncl
ude<st
dio.
h>

i
ntmai n( )
{
i
ntsi ze,i
;
scanf (
"%d",&size);
i
ntar r[
size]
;
for(
i=1;i<=si
ze; i
++)
{
scanf (
"%d",arr[
i]
);
printf
("%d",arr
[i
]);
}
ret
urn0;
}

(
(OPTI
ON_
A)) Thecodei
serr
oneoussi
ncethesubscri
ptf
orar
ray
nf
usedi orl
oopisi
ntherange1tosize.
(
(OPTI
ON_
B)) Thecodei
serroneoussincet
heval
uesofar
rayar
e
get
ti
ngscannedthroughthel
oop.
(
(OPTI
ON_
C)) Thecodei
serroneoussincet
hest
atement
decl
ari
ngar
rayisinval
i
d
(
(OPTI
ON_
D)) Thecodei
scor
rectandr
unssuccessf
ull
y
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)
Whichofthef
oll
owi
ngstatement
sar
ecor
rect
about6usedi
ntheprogr
am?
i
ntnum[6];
num[6]
=21;

(
(OPTI
ON_
A)) Inthefir
ststatement6specif
iesapart
icul
ar
element,whereasinthesecondstat
ementit
specif
iesatype
(
(OPTI
ON_
B)) I
nthef i
rststat
ement6specif
iesaarraysi
ze,
whereasinthesecondstat
ementitspecif
iesa
par
ti
cularelementofar
ray.
(
(OPTI
ON_
C)) Inthefir
ststatement6specif
iesapart
icul
ar
element,whereasinthesecondstat
ementit
specif
iesaar r
aysize.
(
(OPTI
ON_
D)) I
nbot
hthest
atement6speci
fi
esar
raysi
ze
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whichofthefol
l
owi
ngst
atement
sar
ecor
rect
aboutanarr
ay?

1Thear rayintnum[26]
;canstor
e26el ement s.
2Theexpr essionnum[1]desi
gnatesthev er
yf i
rst
elementi nthearr
ay.
3Itisnecessarytoini
ti
ali
zethearrayatthetimeof
declarati
on.
4Thedecl aratonnum[
i SIZE]i
sall
owedi fSIZEisa
macr o.

(
(OPTI
ON_
A)) 1
(
(OPTI
ON_
B)) 1,
4
(
(OPTI
ON_
C)) 2,
3
(
(OPTI
ON_
D)) 2,
4
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Ifxi
sonedimensi
onalar
ray
,thenpi
ckupt
he
corr
ectanswer
(
(OPTI
ON_
A)) *(x+i)i
ssameas&x[i
]

(
(OPTI
ON_
B)) *
&x[
i]i
ssameasx+i

(
(OPTI
ON_
C)) *
(x+i
)issameasx[
i]+1

(
(OPTI
ON_
D)) *
(x+i
)issameas*
x[i
]

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Considerthefoll
owi
ngcodesegment:
i
nta[10],*
p1, *
p2;
p1=&a[ 4]
;
p2=&a[ 6]
;
Whichofthef ol
lowi
ngstat
ementsi
sincor
rect
w.r
.t.poi
nters?
(
(OPTI
ON_
A)) p1+2
(
(OPTI
ON_
B)) p2–2
(
(OPTI
ON_
C)) p2+p1
(
(OPTI
ON_
D)) p2–p1
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi l
lbetheoutputofthef
oll
owingcode
segment?
main(){
chars[
10];
str
cpy(s,“
abc”)
;
pri
ntf
(“%d%d” ,
str
len(
s),si
zeof
(s)
);
}
(
(OPTI
ON_
A)) 310
(
(OPTI
ON_
B)) 33
(
(OPTI
ON_
C)) 103
(
(OPTI
ON_
D)) 1010
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi l
lbet heout putofthef
oll
owi
ngcodeseg
ment,i
fany ?
myfunc(st ructtestt){
st
rcpy(t
.s,“world”);
}
main(){
st
ructtest{chars[ 10];}t
;
st
rcpy(t
.s,“Hell
o” )
;
pr
intf
(“%s”,t.s)
;
myfunc(t)
;
pr
intf
(“%s”,t.s)
;
}
(
(OPTI
ON_
A)) Hell
oHel l
o

(
(OPTI
ON_
B)) wor
ldwor
ld

(
(OPTI
ON_
C)) Hel
l
owor
ld

(
(OPTI
ON_
D)) t
hepr
ogr
am wi
l
lnotcompi
l
e
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whati stheoutputofthef oll


owingCpr
ogr
am?
#incl ude<stdio.
h>
mai n()
{
i
nta, b=0;
staticintc[10]={
1,2,
3,
4,5,6,7,
8,9,
0};
for( a=0;a<10;
++a)
i
f( (c[a]
%2) ==0)b+=c[ a];
printf(“%d”,b)
;
}
(
(OPTI
ON_
A)) 20
(
(OPTI
ON_
B)) 25
(
(OPTI
ON_
C)) 45
(
(OPTI
ON_
D)) 90
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Themaxi
mum numberofdi
mensi
onsanar
raycan
havei
nCis
(
(OPTI
ON_
A)) 3
(
(OPTI
ON_
B)) 4
(
(OPTI
ON_
C)) 5
(
(OPTI
ON_
D)) compi
l
erdependent

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Thesi
zeofar
rayi
nta[
5]={
1,2}i
s
(
(OPTI
ON_
A)) 4
(
(OPTI
ON_
B)) 12
(
(OPTI
ON_
C)) 10
(
(OPTI
ON_
D)) 6
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Theoutputoft hefol
lowingstat
ement
sis
charch[6]
={‘e’
,‘
n’,
‘d’
,‘\
0’,‘
p’
};
pri
ntf
(“%s”,ch);
(
(OPTI
ON_
A)) endp
(
(OPTI
ON_
B)) end0p
(
(OPTI
ON_
C)) end
(
(OPTI
ON_
D)) er
ror
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Todeclareanar
raySthathol
dsa5-
char
act
erst
ri
ng,youwouldwri
te
(
(OPTI
ON_
A)) charS[5]

(
(OPTI
ON_
B)) St
ri
ngS[
5]

(
(OPTI
ON_
C)) charS[
6]

(
(OPTI
ON_
D)) St
ri
ngS[
6]
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) Whi
ON) chofthef
oll
owi
ngexpressi
onsaccessesthe
(
i,
j)
thentr
yofan(m xn)matri
xstor
edincolumn
majorf
orm?
(
(OPTI
ON_
A)) nx(
i-
1)+j
(
(OPTI
ON_
B)) m x(
n-j
)+j
(
(OPTI
ON_
C)) m x(
j-
1)+i
(
(OPTI
ON_
D)) nx(
m-i
)+j
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) Amat
ON) hemati
cal-
model
wit
hacoll
ect
ionof
oper
ati
onsdef
inedont
hatmodel
iscal
led
(
(OPTI
ON_
A)) Dat
aSt
ruct
ure
(
(OPTI
ON_
B)) Abst
ractDat
aTy
pe
(
(OPTI
ON_
C)) Pr
imi
ti
veDat
aTy
pe
(
(OPTI
ON_
D)) Al
gor
it
hm
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) AnADTi
ON) sdefi
nedtobeamat hemat
ical
modelofa
user-
defi
nedtypealongwit
hthecoll
ecti
onofal
l
____
____
____operat
ionsonthatmodel
(
(OPTI
ON_
A)) Car
dinal
i
ty
(
(OPTI
ON_
B)) Assi
gnment
(
(OPTI
ON_
C)) Pr
imi
ti
ve
(
(OPTI
ON_
D)) St
ruct
ured
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) Repr
ON) esent
ati
onofdat
ast
ruct
urei
nmemor
yis
knownas
(
(OPTI
ON_
A)) Recur
siv
e
(
(OPTI
ON_
B)) Abst
ractdat
aty
pe
(
(OPTI
ON_
C)) St
oragest
ruct
ure
(
(OPTI
ON_
D)) Fi
l
est
ruct
ure
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whati
sri
ghtwayt
oini
ti
ali
zear
ray
?
(
(OPTI
ON_
A))
i
ntnum[
6]={2,
4,12,
5,45,
5};

(
(OPTI
ON_
B)) i
ntn{
}={2,
4,12,
5,45,
5};
(
(OPTI
ON_
C)) i
ntn{
6}={2,
4,12}
;
(
(OPTI
ON_
D))
i
ntn(
6)={2,
4,12,
5,45,
5};

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi l
lbetheoutputoft
hepr
ogr
am ?
#include<stdi
o.h>
voidmai n()
{
inta[5]={5,1,15,
20,25}
;
inti,j
,m;
i=++a[ 1];
j=a[ 1]
++;
m =a[ i
++];
printf
("%d,%d,%d",i
,j
,m);
}
(
(OPTI
ON_
A)) 3,
2,15
(
(OPTI
ON_
B)) 2,
3,20
(
(OPTI
ON_
C))
2,
1,15

(
(OPTI
ON_
D))
1,
2,5

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi ll
bet heout putoffol
l
owingprogr
am code?
#i
nclude<st dio.h>
i
ntmai n(void)
{
charp;
charbuf[10]={ 1,2,3,4,
5,6,9,
8};
p=( buf+1) [5];
pri
ntf(
"%d" ,
p) ;
ret
urn0;
}
(
(OPTI
ON_
A)) 5
(
(OPTI
ON_
B)) 6
(
(OPTI
ON_
C)) 9
(
(OPTI
ON_
D)) er
ror
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Letxbeanarr
ay.Whi
choft
hef
oll
owi
ngoper
ati
ons
areill
egal
?
I.
  
 ++x
II

 x+1
II
I.
 x++
IV.
  x*
2
(
(OPTI
ON_
A)) IandI
I
(
(OPTI
ON_
B))
I
,I
IandI
II 
  

(
(OPTI
ON_
C)) I
IandI
II
(
(OPTI
ON_
D)) I
,I
IIandI
V
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Anar
rayel
ementsareal
way
sst
oredi
n__
___
___
memoryl
ocat
ions.
(
(OPTI
ON_
A))
Sequent
ial

(
(OPTI
ON_
B)) Random
(
(OPTI
ON_
C))
Sequent
ial
andRandom

(
(OPTI
ON_
D)) Noneoft
heabov
e
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Si
zeoft
hear
rayneednotbespeci
fi
ed,
when
(
(OPTI
ON_
A)) I
nit
ial
i
zat
ioni
sapar
tofdef
ini
ti
on
(
(OPTI
ON_
B)) I
tisadecl
arat
ri
on
(
(OPTI
ON_
C)) I
tisaf
ormal
par
amet
er
(
(OPTI
ON_
D)) Al
loft
hese
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Considert hefoll
owingty
pedef
ini
ti
on.
typedefcharx[ 10];
xmy Array[5];
Whatwi llsizeof(
my Ar
ray
)be?(Assumeone
characteroccupi es1byt
e)
(
(OPTI
ON_
A)) 15
(
(OPTI
ON_
B)) 10
(
(OPTI
ON_
C)) 50
(
(OPTI
ON_
D)) 30
(
(CORRECT_
C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwillbepri
ntedaft
erexecut
ionoft
hef
oll
owi
ng
code?
voi
dmai n()
{
i
ntarr[
10]={1,
2,3,
4,
5};
pr
int
f("
%d",arr
[5]
);
}
(
(OPTI
ON_
A)) Gar
bageVal
ue
(
(OPTI
ON_
B)) 5
(
(OPTI
ON_
C)) 6
(
(OPTI
ON_
D)) 0
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwillbetheout putoft
hef
oll
owi
ngpr
ogr
am?
voi
dmain( )
{
charstr1[]="abcd";
charstr2[]="abcd";
if(
str
1==st r2)
pri
ntf("Equal
");
else
pri
ntf("Unequal"
);
}
(
(OPTI
ON_
A))
Equal

(
(OPTI
ON_
B)) Unequal
(
(OPTI
ON_
C))
Er
ror

(
(OPTI
ON_
D)) Noneoft
hese
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwillbetheoutputofthefol
l
owi
ngcode?
voi
dmai n()
{
inta[
10];
print
f("
%d%d" ,a[
-1]
,a[12]
);
}
(
(OPTI
ON_
A)) 00
(
(OPTI
ON_
B))
Gar
bagev
alue0

(
(OPTI
ON_
C)) 0Gar
bageVal
ue
(
(OPTI
ON_
D))
Gar
bagev
alueGar
bageVal
ue

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatdoesthef
oll
owi
ngdecl
arat
ionmean?
i
nt(*
ptr
)[10]
;
(
(OPTI
ON_
A)) pt
risar
rayofpoi
nter
sto10i
nteger
s
(
(OPTI
ON_
B))
pt
risapoi
ntert
oanar
rayof10i
nteger
s

(
(OPTI
ON_
C))
pt
risanar
rayof10i
nteger
s

(
(OPTI
ON_
D)) pt
risanpoi
ntert
oar
ray
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Ar
raypassedasanar
gumentt
oaf
unct
ioni
s
i
nter
pret
edas
(
(OPTI
ON_
A))
Addr
essoft
hear
ray
.

(
(OPTI
ON_
B)) Val
uesoft
hef
ir
stel
ement
soft
hear
ray
(
(OPTI
ON_
C))
Addr
essoft
hef
ir
stel
ementoft
hear
ray
.

(
(OPTI
ON_
D))
Numberofel
ementoft
hear
ray
.

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi l
lbetheoutputoftheprogr
am ifthear
ray
beginsat65472andeachi nt
egeroccupies2
bytes?
#include
voidmai n()
{
inta[3]
[4]={1,
2,3,4,4,3,2,1,7,
8,9,0};
printf
("%u,%u"
,a+1,&a+1);
}
(
(OPTI
ON_
A)) 65474,
65488
(
(OPTI
ON_
B))
65480,
65488

(
(OPTI
ON_
C))
65480,
65496

(
(OPTI
ON_
D))
65474,
65476

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi l
lbetheoutputoft
hepr
ogr
am ?
#i
nclude
i
ntmai n()
{
i
ntarr[
1]={10};
pri
ntf(
"%d"
,0[ar
r]
);
ret
urn0;
}
(
(OPTI
ON_
A)) 1
(
(OPTI
ON_
B)) 0
(
(OPTI
ON_
C)) 10
(
(OPTI
ON_
D)) 6
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi l
lbetheoutputoftheprogr
am i
fthear
ray
beginsataddr ess65486?
#include
voidmai n()
{
intarr[
]={12,14,15,23,45}
;
printf
("%u,%u",ar
r,&ar
r);
}
(
(OPTI
ON_
A))
65486,
65488

(
(OPTI
ON_
B)) 65486,
65490
(
(OPTI
ON_
C))
65486,
65487

(
(OPTI
ON_
D))
65486,
65486

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi l
lbetheoutputoft heprogram?
#incl
ude
voidmain()
{
fl
oatarr[
]={12.4,
2.3,4.5,6.7}
;
pri
ntf
("%d",
sizeof
(arr
)/sizeof(
arr
[0]
))
;
}
(
(OPTI
ON_
A)) 5
(
(OPTI
ON_
B)) 4
(
(OPTI
ON_
C)) 6
(
(OPTI
ON_
D)) 7
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whi chofthef oll


owingi
scor
rectwayt
odef
inet
he
functionfun()inthebel
owprogr
am?
#include<stdi
o.h>
voidmai n()
{
inta[3]
[4];
fun(a);
}
(
(OPTI
ON_
A))
v
oidf
un(
intp[
][
4])
{}

(
(OPTI
ON_
B))
v
oidf
un(
int*
p[4]
){
}

(
(OPTI
ON_
C))
v
oidf
un(
int*
p[]
[4]
){
}

(
(OPTI
ON_
D))
v
oidf
un(
int*
p[3]
[4]
){
}

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whichoft hef ol
lowingstatementsarecorrect
aboutanar ray?
1.Thearrayi ntnum[ 26]
;canstor
e26el ement s.
2.Theexpr essionnum[ 1]desi
gnatesthev er
yf i
rst
el
ementint hearray.
3.I
tisnecessar yt oini
ti
ali
zethearrayatthetimeof
decl
arat
ion.
4.Thedecl arati
onnum[ SIZE]i
sall
owedi fSIZEisa
macro.
(
(OPTI
ON_
A)) 1
(
(OPTI
ON_
B)) 1,
4
(
(OPTI
ON_
C)) 2,
3
(
(OPTI
ON_
D)) 2,
4
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whi choft hefollowingstat


ement
sar
ecor
rect
aboutt hepr ogram below?
#include<st dio.h>
voidmai n()
{
intsi ze,i;
scanf (
"%d" ,
&si ze);
intar r[
size];
for (
i=1;i<=size; i
++)
{
scanf ("
%d" ,arr[
i]
);
printf
("%d", arr
[i
]);
}
}
(
(OPTI
ON_
A)) Thecodei
serroneoussincet
hest
atement
decl
ari
ngar
rayisinval
i
d.
(
(OPTI
ON_
B)) Thecodei
serr
oneoussi
ncethesubscri
ptf
orar
ray
usedi
nforl
oopisi
ntherange1tosize
(
(OPTI
ON_
C)) Thecodei
scor
rectandr
unssuccessf
ull
y
(
(OPTI
ON_
D))
Thecodei
serroneoussincet
heval
uesofar
rayar
e
get
ti
ngscannedthroughthel
oop.

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whichoft
hef
oll
owingcor
rect
lyaccessesthe
sevent
hel
ementst
oredi
narr,
anar r
aywith100
el
ements?
(
(OPTI
ON_
A))
ar
r[
6]

(
(OPTI
ON_
B)) ar
r[
7]
(
(OPTI
ON_
C))
ar
r{6}

(
(OPTI
ON_
D))
ar
r{7}

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

i
nta[
5]={1,
2,
3}
Whati
stheval
ueofa[
4]?
(
(OPTI
ON_
A)) 3
(
(OPTI
ON_
B)) 1
(
(OPTI
ON_
C)) 2
(
(OPTI
ON_
D)) 0
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwil
lbeout
putwheny
ouwi
l
lexecut
efol
l
owi
ng
ccode?
#incl
ude<stdio.h>
voidmain(){
 
  chararr[
7]="Networ
k";
 
  pri
ntf
("%s",ar
r);
}
Chooseal l
thatapply:
(
(OPTI
ON_
A)) Net
wor
k
(
(OPTI
ON_
B)) N
(
(OPTI
ON_
C)) Gar
bagev
alue
(
(OPTI
ON_
D)) Compi
l
ati
oner
ror
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

#incl
ude<stdi
o.h>
voidmain(){
 
  chararr[
11]="
TheAf
ri
canQueen"
;
 
  pri
ntf
("%s",
arr
);
}
(
(OPTI
ON_
A)) TheAf
ri
canQueen
(
(OPTI
ON_
B)) The
(
(OPTI
ON_
C)) TheAf
ri
can
(
(OPTI
ON_
D)) Compi
l
ati
oner
ror
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi l
lbeout putwheny ouwill
execut
efoll
owi
ng
ccode?
#include<stdio.
h>
voidmai n()
{
 
  intconstSI ZE=5;
 
  intexpr;
 
  doublev alue[SIZE]={
2.0,
4.0,
6.0,
8.0,
10.
0};
 
  expr=1|2|3|4;
 
  printf
("%f",
value[expr
]);
}
(
(OPTI
ON_
A)) 2.
000000
(
(OPTI
ON_
B)) 4.
000000
(
(OPTI
ON_
C)) 8.
000000
(
(OPTI
ON_
D)) Compi
l
ati
oner
ror
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi ll
beout putwheny ouwillexecutefol
lowi
ng
ccode?
#include<stdi
o.h>
enum power {
 
  Dalai,
 
  Vladimi r
=3,
 
  Bar ack,
 
  Hill
ar y
};
voidmai n(){
 
  fl
oatl eader[
Dalai+Hil
lary
]={1.
f,2.
f,
3.f,
4.f
,5.
f}
;
 
  enum powerp=Bar ack;
 
  pri
nt f(
"%0.f
",
leader[p>>1+1]);
}
(
(OPTI
ON_
A)) 1
(
(OPTI
ON_
B)) 2
(
(OPTI
ON_
C)) 3
(
(OPTI
ON_
D)) Compi
l
ati
oner
ror
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi l
lbeout putwheny ouwil
lexecutefol
l
owi
ng
ccode?
#incl
ude<stdi
o.h>
voidmain(){
 
  chardata[
2][
3][2]={
0,1,
2,3,
4,
5,
6,
7,8,
9,10,
11};
 
  pri
ntf
("%o",
data[0][
2][
1])
;
}
(
(OPTI
ON_
A)) 5
(
(OPTI
ON_
B)) 6
(
(OPTI
ON_
C)) 7
(
(OPTI
ON_
D)) Compi
l
ati
oner
ror
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi llbeout putwhenyouwi ll


executef
oll
owi
ng
ccode?
#incl
ude<st di
o.h>
voidmai n()
{
 
  shortnum[ 3]
[2]={3,
6,
9,
12,15,18}

 
print
f("
%d %d" ,
*(num+1)[
1],
**(num+2));
}
(
(OPTI
ON_
A)) 1218
(
(OPTI
ON_
B)) 1818
(
(OPTI
ON_
C)) 1515
(
(OPTI
ON_
D)) 1215
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi l
lbeout putwheny ouwil
lexecut
efol
l
owi
ng
ccode?
#include<stdi
o.h>
voidmai n()
{
 
  intarray[
2][
3]={5,10,15,
20,25,
30}
;
 
  int(*ptr
)[
2][
3]=&ar ray;
 
  printf
("%d\t
",
** *
pt r
);
 
  printf
("%d\t
",
** *
(ptr+1))
;
 
  printf
("%d\t
",
** (
*ptr+1))
;
 
  printf
("%d\t
",
*(*(*ptr+1)
+2) )
;
}
(
(OPTI
ON_
A)) 5Gar
bage2030
(
(OPTI
ON_
B)) 10153020
(
(OPTI
ON_
C)) 5152030
(
(OPTI
ON_
D)) Compi
l
ati
oner
ror
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi l
lbeout putwheny ouwil
lexecutefol
l
owing
ccode?
#include<stdio.h>
voidmai n(){
 
  intarr[
][3]
={{1,2},
{3,
4,
5},
{5}}
;
 
  printf
("%d%d%d" ,
si
zeof(ar
r),
arr
[0]
[2]
,
arr[
1][
2])
;
}
(
(OPTI
ON_
A)) 1235
(
(OPTI
ON_
B)) 1805
(
(OPTI
ON_
C)) 1205
(
(OPTI
ON_
D)) 1835
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whati
stheout
putoft
hisCcode?

1. #include<stdio.h>
2. voidmai n()
3. {
4. inta[2]
[3]={ 1,2,3,
4,5}
;
5. inti=0, j=0;
6. for(i=0; i<2; i
++)
7. for(j=0; j<3; j
++)
8. printf
("%d",a[i
][
j]
);
9. }
(
(OPTI
ON_
A)) 123450
(
(OPTI
ON_
B)) 12345j
unk
(
(OPTI
ON_
C)) 123455
(
(OPTI
ON_
D))
Runt
imeer
ror

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whati
stheout
putoft
hisCcode?

1. #include<stdio.h>
2. voidmai n()
3. {
4. inta[2]
[3]={ 1,2,3,
,4,
5};
5. inti=0, j=0;
6. for(i=0; i<2; i
++)
7. for(j=0; j<3; j
++)
8. printf
("%d",a[i
][
j]
);
9. }
(
(OPTI
ON_
A)) 123j
unk45
(
(OPTI
ON_
B)) Compi
l
eti
meer
ror
(
(OPTI
ON_
C)) 123045
(
(OPTI
ON_
D))
123345

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whati
stheout
putoft
hisCcode?

1. #include<stdio.h>
2. voidf (
inta[]
[3]
)
3. {
4. a[0][
1]=3;
5. inti=0, j=0;
6. for(i =0;i<2; i
++)
7. for(j =0;j<3; j
++)
8. printf(
"%d",a[
i][
j]
);
9. }
10. voidmai n()
11. {
12. i
nta[2][
3]={0};
13. f(
a);
14. }
(
(OPTI
ON_
A)) 030000
(
(OPTI
ON_
B)) Junk3j
unkj
unkj
unkj
unk
(
(OPTI
ON_
C)) Compi
l
eti
meer
ror
(
(OPTI
ON_
D)) Al
lj
unkv
alues

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Commentonthef
oll
owi
ngst
atement
:
 
  
 i
nt(
*a)
[7]
;
(
(OPTI
ON_
A)) Anar
ray“
a”ofpoi
nter
s.
(
(OPTI
ON_
B)) Apoi
nter“
a”t
oanar
ray
.
(
(OPTI
ON_
C)) Ar
aggedar
ray
(
(OPTI
ON_
D)) Noneoft
hement
ioned
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi
l
lbet
heout
putoft
hispr
ogr
am?

1. #include<st dio.h>
2. usingnamespacest d;
3. intarray1[]={ 1200, 200,2300,1230,
1543}
;
4. intarray2[]={ 12, 14,16,18,20}
;
5. inttemp, r
esult=0;
6. intmai n()
7. {
8. for(temp=0; temp<5; temp++){
9. r
esul t+=ar ray1[temp];
10. }
11. for(temp=0; temp<4; t
emp++){
12. result+=ar ray2[
temp];
13. }
14. cout<<r esul t
;
15. retur
n0;
16. }
(
(OPTI
ON_
A)) 6553

(
(OPTI
ON_
B)) 6533
(
(OPTI
ON_
C)) 6522

(
(OPTI
ON_
D)) 12200

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi
l
lbet
heout
putoft
hispr
ogr
am?

1. #include<stdio.h>
2. usingnamespacest d;
3. intmai n()
4. {
5. intarray[
]={ 0,2,4,6,7,
5,3}
;
6. intn,resul
t=0;
7. for(n=0; n<8; n++){
8. result+=ar ray[
n];
9. }
10. cout<<r esult;
11. retur
n0;
12. }
(
(OPTI
ON_
A)) 25
(
(OPTI
ON_
B)) 26
(
(OPTI
ON_
C)) 27
(
(OPTI
ON_
D)) None
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whati
stheout
putoft
hispr
ogr
am?

1. #include<stdi
o.h>
2. usingnamespacest d;
3. i
ntmai n(
)
4. {
5. inta=5, b=10, c=15;
6. intarr[
3]={&a,&b,&c}
;
7. cout<<* arr
[*ar
r[
1]-8]
;
8. return0;
9. }
(
(OPTI
ON_
A)) 15
(
(OPTI
ON_
B)) 18
(
(OPTI
ON_
C)) gar
bagev
alue
(
(OPTI
ON_
D)) compi
l
eti
meer
ror
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whati
stheout
putoft
hispr
ogr
am?

1. #incl
ude<stdio.
h>
2. usingnamespacestd;
3. i
ntmai n(
)
4. {
5. charst
r[5]="ABC"
;
6. cout<<str[
3];
7. cout<<str;
8. ret
urn0;
9. }
(
(OPTI
ON_
A)) ABC
(
(OPTI
ON_
B)) ABCD
(
(OPTI
ON_
C)) AB
(
(OPTI
ON_
D)) Noneoft
hement
ioned
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whati
stheout
putoft
hispr
ogr
am?

1. #include<stdio.h>
2. usingnamespacest d;
3. i
ntmai n()
4. {
5. intarray[
]={ 10,20,30}
;
6. cout<<- 2[ar
r ay
];
7. return0;
8. }
(
(OPTI
ON_
A)) 15
(
(OPTI
ON_
B)) 20
(
(OPTI
ON_
C)) compi
l
eti
meer
ror
(
(OPTI
ON_
D)) gar
bagev
alue
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whati
stheout
putoft
hispr
ogr
am?

1. #include<iost
ream>
2. usingnamespacest d;
3. i
ntmai n(
)
4. {
5. i nta[2]
[4]={3,6,
9,12,
15,18,
21,
24};
6. cout<<* (a[
1]+2)<<*(*
(a+1)+2)<<
2[
1[a]]
;
7. r eturn0;
8. }
(
(OPTI
ON_
A)) 151821
(
(OPTI
ON_
B)) 212121
(
(OPTI
ON_
C)) 242424
(
(OPTI
ON_
D)) Compi
l
eti
meer
ror
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whati
stheout
putoft
hispr
ogr
am?

1. #include<iostream>
2. usingnamespacest d;
3. intmai n()
4. {
5. i nti;
6. char* arr
[]={"C"
,"C++"
,"Jav
a",
"VBA"
};
7. char* (*
ptr)
[4]=&arr;
8. cout<<++( *ptr)
[2]
;
9. r eturn0;
10. }
(
(OPTI
ON_
A)) av
a
(
(OPTI
ON_
B)) j
ava
(
(OPTI
ON_
C)) C++
(
(OPTI
ON_
D)) compi
l
eti
meer
ror
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whati
stheout
putoft
hispr
ogr
am?

1. #include<iost
ream>
2. usingnamespacest d;
3. i
ntmai n(
)
4. {
5. intarr[
]={4,5,6,7};
6. int*p=( ar
r+1) ;
7. cout<<* p;
8. return0;
9. }
(
(OPTI
ON_
A)) 4
(
(OPTI
ON_
B)) 5
(
(OPTI
ON_
C)) 6
(
(OPTI
ON_
D)) 7
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whati
stheout
putoft
hispr
ogr
am?

1. #include<iostr
eam>
2. usingnamespacest d;
3. i
ntmai n(
)
4. {
5. intarr[
]={4,5,6,7};
6. int*p=( ar
r+1) ;
7. cout<<ar r;
8. return0;
9. }
(
(OPTI
ON_
A)) 4
(
(OPTI
ON_
B)) 5
(
(OPTI
ON_
C)) Addr
essofar
r
(
(OPTI
ON_
D)) 7
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whati
stheout
putoft
hispr
ogr
am?

1. #include<iostr
eam>
2. usingnamespacest d;
3. intmai n()
4. {
5. i ntnumber s[
5];
6. i nt*p;
7. p=number s;*p=10;
8. p++;* p=20;
9. p=&number s[2]
;* p=30;
10. p=number s+3;* p=40;
11. p=number s;*(p+4)=50;
12. for(i
ntn=0; n<5;n++)
13. cout<<number s[
n]<<",
";
14. ret
urn0;
15. }
(
(OPTI
ON_
A)) 10,
20,
30,
40,
50,
(
(OPTI
ON_
B)) 1020304050
(
(OPTI
ON_
C)) compi
l
eer
ror
(
(OPTI
ON_
D)) r
unt
imeer
ror
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whati
stheout
putoft
hispr
ogr
am?

1. #include<iostream>
2. usingnamespacest d;
3. i
ntmai n()
4. {
5. i
ntar r[
]={4,5,6,7}
;
6. i
nt* p=( ar
r+1) ;
7. cout<<* arr+9;
8. return0;
9. }
(
(OPTI
ON_
A)) 12
(
(OPTI
ON_
B)) 5
(
(OPTI
ON_
C)) 13
(
(OPTI
ON_
D)) Er
ror
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Tot
rav
erseanar
raymeans
(
(OPTI
ON_
A)) Topr
ocesseachel
ementi
nar
ray
(
(OPTI
ON_
B)) Todel
eteel
ementf
rom ar
ray
(
(OPTI
ON_
C)) Toi
nser
tel
ementi
ntoanar
ray
(
(OPTI
ON_
D)) Tocombi
net
woar
ray
sint
osi
ngl
ear
ray
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Mer
gingr
efer
sto
(
(OPTI
ON_
A)) I
nser
ti
ngel
ement
sint
oanar
ray
(
(OPTI
ON_
B)) Pr
ocessi
ngel
ement
sofanar
ray
(
(OPTI
ON_
C)) Combi
ningt
woar
ray
sint
oasi
ngl
ear
ray
(
(OPTI
ON_
D)) Del
eti
ngel
ement
sfr
om anar
ray
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Sor
ti
ngofanar
rayr
efer
sto
(
(OPTI
ON_
A)) Pr
ocessi
ngel
ement
sofanar
ray
(
(OPTI
ON_
B)) Del
eti
ngel
ement
sfr
om anar
ray
(
(OPTI
ON_
C)) Bot
hAandB
(
(OPTI
ON_
D)) Or
gani
zi
ngel
ement
sinanar
rayi
nsomeor
der
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Patt
ernmatchi
ngistheprocessto
(
(OPTI
ON_
A)) Checkifonest
ri
ngispresentint
heanot
herst
ri
ng

(
(OPTI
ON_
B)) Checki
ftwost
ri
ngsar
eofsamel
engt
h

(
(OPTI
ON_
C)) Tochecki
ftwost
ri
ngsar
eident
ical

(
(OPTI
ON_
D)) Tocomparetwostr
ingst
oknowt
hecountof
si
mil
archar
acter
s
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Thelengt
hofast
ri
ngi
sthet
otal
numberof
char
acter
s
(
(OPTI
ON_
A)) oft
hest
ri
ngexcl
udi
ngbl
ankspace
(
(OPTI
ON_
B)) i
nthest
ri
ng
(
(OPTI
ON_
C)) Whi
char
erepeat
edi
nthest
ri
ng
(
(OPTI
ON_
D)) Noneoft
heabov
e
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Tocopyonest
ringi
ntoanot
hermeans
(
(OPTI
ON_
A)) Toaddonestr
ingatt
heendofanotherst
ri
ng

(
(OPTI
ON_
B)) Tocr
eat
enewst
ri
ng

(
(OPTI
ON_
C)) Tocopyt
het
argetst
ri
ngt
othesour
cest
ri
ng

(
(OPTI
ON_
D)) Tocopyt
hesour
cest
ri
ngt
otar
getst
ri
ng

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Toconcat
enat
east
ri
ngmeans
(
(OPTI
ON_
A)) Tocopyonest
ri
ngt
oanot
her
(
(OPTI
ON_
B)) Toaddonest
ri
ngatt
heendoft
heot
her
(
(OPTI
ON_
C)) Toaddonest
ri
ngatt
hebegi
nni
ngofot
her
(
(OPTI
ON_
D)) Toform anewstri
ngcont
aini
nguni
quechar
act
ers
fr
om boththest
ri
ngs.
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

The‘
\0’
char
act
ersi
ndi
cat
es
(
(OPTI
ON_
A)) Wher
ethest
ri
ngbegi
ns
(
(OPTI
ON_
B)) Wher
ethest
ri
ngends
(
(OPTI
ON_
C)) Thest
ri
ngi
sempt
y
(
(OPTI
ON_
D)) Thel
engt
hofast
ri
ng
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Amat
ri
xiscal
l
edwhen
(
(OPTI
ON_
A)) Mostofi
tsel
ement
sar
ezer
o
(
(OPTI
ON_
B)) Mostofi
tsel
ement
sar
enonzer
o
(
(OPTI
ON_
C)) Al
lofi
tsel
ement
sar
enonzer
o
(
(OPTI
ON_
D)) Noneofabov
e
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Aspar
semat
ri
xcanbel
owert
ri
angul
armat
ri
x
(
(OPTI
ON_
A)) Whenal
lthenonzer
oel
ement
sli
eonl
yont
he
l
eadi
ngdi
agonal
(
(OPTI
ON_
B)) Whenall
thenonzer
oel
ement
sli
eabov
eleadi
ng
di
agonal
(
(OPTI
ON_
C)) Whenall
thenonzer
oel
ement
sli
ebel
owl
eadi
ng
di
agonal
(
(OPTI
ON_
D)) Noneoft
heabov
e
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

I
nal i
nkedr
epresentat
ionofasparsemat
ri
xthe
headnodeforacolumnlist
sstor
es
(
(OPTI
ON_
A)) Apoi
ntert
othenextcol
umnheadnode
(
(OPTI
ON_
B)) Apoi
ntert
othef
ir
stnodei
nthecol
umnl
i
st
(
(OPTI
ON_
C)) Col
umnnumber
(
(OPTI
ON_
D)) Al
loft
heabov
e
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Progr
amminglanguagesl
i
kePASCALand
FORTRANall
ocatememoryspacef
orar
rays_
___
(
(OPTI
ON_
A)) Dy
nami
cal
l
y
(
(OPTI
ON_
B)) St
ati
cal
l
y
(
(OPTI
ON_
C)) Successi
vel
y
(
(OPTI
ON_
D)) al
ter
nat
ivel
y
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

___
__r efer
stotheoper
ati
onofrear
rangi
ngt
he
el
ement sofanar
rayAsothatt
heyarein
i
ncreasingorder
(
(OPTI
ON_
A)) Searching

(
(OPTI
ON_
B)) Sor
ti
ng

(
(OPTI
ON_
C)) Tr
aver
sing

(
(OPTI
ON_
D)) I
nser
ti
ng

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

__
_isali
stinwhichtheor
deroft
heitemsis
si
gni
fi
cantandtheit
emsarenotnecessar
il
ysor
ted
(
(OPTI
ON_
A)) Or
der
edl
i
st
(
(OPTI
ON_
B)) I
ndexedl
i
st
(
(OPTI
ON_
C)) Sequent
ial
li
st
(
(OPTI
ON_
D)) Unor
der
edl
i
st
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Fini
tesequenceSofzer
oormor
echar
act
ersar
e
call
ed
(
(OPTI
ON_
A)) Ar
ray
(
(OPTI
ON_
B)) St
ri
ng
(
(OPTI
ON_
C)) Li
st
(
(OPTI
ON_
D)) Bl
ock
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

St
ri
ngwi
thzer
ochar
act
ersi
scal
l
ed_
___st
ri
ng
(
(OPTI
ON_
A)) Nul
l
(
(OPTI
ON_
B)) Bi
nar
y
(
(OPTI
ON_
C)) Tot
all
ed
(
(OPTI
ON_
D)) Li
st
(
(CORRECT_
C
HOI
CE)) A
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Thenumberofchar
act
ersi
nst
ri
ngi
scal
l
edi
ts
(
(OPTI
ON_
A)) Lengt
h

(
(OPTI
ON_
B)) Br
eadt
h

(
(OPTI
ON_
C)) Wi
dth

(
(OPTI
ON_
D)) Noneoft
heabov
e

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

_
___operat
ionofwor
dprocessingi
nvolves
r
epl
acingonestri
ngi
nthetextbyanother
(
(OPTI
ON_
A)) I
nser
ti
on
(
(OPTI
ON_
B)) Del
eti
on
(
(OPTI
ON_
C)) Sear
chi
ng
(
(OPTI
ON_
D)) Repl
acement
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

__
__ist
hepr
obl
em ofdeci
dingwhetherornota
gi
venst
ri
ngpat
ter
nPappear si
natextT
(
(OPTI
ON_
A)) Pat
ter
nMat
chi
ng
(
(OPTI
ON_
B)) Sear
chi
ng
(
(OPTI
ON_
C)) Sor
ti
ng
(
(OPTI
ON_
D)) Del
eti
on
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

I
fst
ri
ng1=Johnandst
ri
ng2=Ri
ver
sar
emer
ged
t
heprocessi
scal
l
ed

(
(OPTI
ON_
A)) I
nser
ti
on
(
(OPTI
ON_
B)) Del
eti
on
(
(OPTI
ON_
C)) Concat
enat
ion
(
(OPTI
ON_
D)) Repl
acement
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatthef
oll
owingf
unct
ioncal
lmean?
St
rcpy
(s1,s2);
(
(OPTI
ON_
A)) copi
ess1st
ri
ngi
ntos2
(
(OPTI
ON_
B)) copi
ess2st
ri
ngi
ntos1

(
(OPTI
ON_
C)) copi
esbot
hs1ands2
(
(OPTI
ON_
D)) Noneoft
hese
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi l
lbetheoutput?
Voidmain(){
Chara[]=“I
NFO”;
a++;
pr
intf(
“\n%s” ,
a);}
(
(OPTI
ON_
A)) Er
ror
(
(OPTI
ON_
B)) I
NFO
(
(OPTI
ON_
C)) NFO
(
(OPTI
ON_
D)) Noneoft
hese
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Ar
raysubscr
ipt
sinCal
way
sst
artat
(
(OPTI
ON_
A)) -
1
(
(OPTI
ON_
B)) 1
(
(OPTI
ON_
C)) 0
(
(OPTI
ON_
D)) Val
uepr
ovi
dedbyuser

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Maximum numberofelement
sint
hear
ray
decl
arat
ioni
nta[
5][
8]is
(
(OPTI
ON_
A)) 28
(
(OPTI
ON_
B)) 32
(
(OPTI
ON_
C)) 35
(
(OPTI
ON_
D)) 40
(
(CORRECT_
C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Amul t
idi
mensional
arr
aycanbeexpressedi
n
ter
msof
(
(OPTI
ON_
A)) arr
ayofpoint
ersrat
herthanaspoi
nter
stoagroup
of
conti
guousarr
ay
(
(OPTI
ON_
B)) ar
raywi
thoutt
hegr
oupofcont
iguousar
ray
(
(OPTI
ON_
C)) dat
aty
pear
ray
s
(
(OPTI
ON_
D)) Noneoft
hese
(
(CORRECT_
C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Thesi
zeofaSt
ri
ngv
ari
abl
eis
(
(OPTI
ON_
A)) 1by
te
(
(OPTI
ON_
B)) 8by
tes
(
(OPTI
ON_
C)) 16by
tes
(
(OPTI
ON_
D)) None

(
(CORRECT_
C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whichofthefol
l
owingisusedasast
ri
ng
t
erminat
ioncharact
er?
(
(OPTI
ON_
A)) 0
(
(OPTI
ON_
B)) \
0
(
(OPTI
ON_
C)) /
0
(
(OPTI
ON_
D)) Noneoft
hese
(
(CORRECT_
C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
)

Whatwi llbetheout
putofthefoll
owingprogram
code?
voi
dmai n(){
chara[]
=“ Hell
oWorld”;
char*p;
p=a;
pri
ntf(
“\n%d%d%d%d” ,
si
zeof(
a),si
zeof(p)
,str
en(a)
,
str
len(
p)) ;}
(
(OPTI
ON_
A)) 11111010
(
(OPTI
ON_
B)) 10101010
(
(OPTI
ON_
C)) 12121111
(
(OPTI
ON_
D)) 1221111

(
(CORRECT_
C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
ON))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) naci
rcul
arl
i
nkedl
i
st

(
(OPTI
ON_
A)) Component
sar
eal
ll
inkedt
oget
heri
nsomesequent
ial
manner
.
(
(OPTI
ON_
B)) Ther
eisnobegi
nni
ngandnoend.
(
(OPTI
ON_
C)) Component
sar
ear
rangedhi
erar
chi
cal
l
y.
(
(OPTI
ON_
D)) For
war
dandbackwar
dtr
aver
sal
wit
hint
hel
i
sti
s
per
mit
ted.
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Al
ON) i
nearcol
l
ect
ionofdat
ael
ement
swher
ethel
i
nearnode
nbymeansofpoi
nteri
scal
l
ed?
(
(OPTI
ON_
A)) Li
nkedl
i
st

(
(OPTI
ON_
B)) Nodel
i
st
(
(OPTI
ON_
C)) Pr
imi
ti
vel
i
st

(
(OPTI
ON_
D)) None
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whichofthefol
lowi
ngoper
ati
onsisper
for
medmore
ef
fi
cient
lybydoubl
yli
nkedl
i
stthanbysi
ngl
yli
nkedl
i
st

(
(OPTI
ON_
A)) Del
eti
nganodewhosel
ocat
ioni
ngi
ven
(
(OPTI
ON_
B)) Sear
chi
ngofanunsor
tedl
i
stf
oragi
veni
tem
(
(OPTI
ON_
C)) I
nver
ti
nganodeaf
tert
henodewi
thgi
venl
ocat
ion
(
(OPTI
ON_
D)) Tr
aver
singal
i
stt
opr
ocesseachnode
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Co
ON) nsi
derani
mpl
ement
ati
onofunsor
tedsi
ngl
yli
nkedl
i
st.
Supposeithasi t
srepr esentat
ionwithaheadandtai
l
poi
nter.Giv
enther epresentation,whichoft
hefol
l
owing
operat
ioncanbei mpl ement edinO(1)time?
i
)Inserti
onatthef r
ontoft helinkedlist
i
i)I
nserti
onattheendoft heli
nkedlist
i
ii
)Deleti
onoft hefrontnodeoft heli
nkedli
st
i
v)Deleti
onoft helastnodeoft heli
nkedli
st

(
(OPTI
ON_
A)) IandI
I

(
(OPTI
ON_
B)) IandI
II
(
(OPTI
ON_
C)) I
,
IIandI
II
(
(OPTI
ON_
D)) I
,
IIandI
V
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Consi
derani
mpl
ement
ati
onofunsor
tedsi
ngl
yli
nkedl
i
st.
Supposeithasi
tsrepresentat
ionwithaheadpoint
er
onl
y.Giventher
epresentati
on,whichofthef
oll
owing
operat
ioncanbeimplement edinO(1)t
ime?
i
)Inser
ti
onatt
hef
rontoft
hel
i
nkedl
i
st
i
i
)Inser
ti
onatt
heendoft
hel
i
nkedl
i
st
i
i
i)Del
eti
onoft
hef
rontnodeoft
hel
i
nkedl
i
st
i
v)Del
eti
onoft
hel
astnodeoft
hel
i
nkedl
i
st

(
(OPTI
ON_
A)) IandI
I

(
(OPTI
ON_
B)) IandI
II
(
(OPTI
ON_
C)) I
,
IIandI
II
(
(OPTI
ON_
D)) I
,
IIandI
V
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Consi
derani
mpl
ement
ati
onofunsor
teddoubl
yli
nked
l
ist
.Supposeithasit
srepr
esentat
ionwithaheadpoint
er
andtai
lpoi
nter.Gi
venther
epresentat
ion,whi
chofthe
fol
l
owingoperati
oncanbeimplementedinO(1)ti
me?
i
)I
nser
ti
onatt
hef
rontoft
hel
i
nkedl
i
st
i
i
)Insert
ionatt
heendofthel
inkedl
ist
i
i
i)Delet
ionoft
hefr
ontnodeoftheli
nkedli
st
i
v)Delet
ionoft
heendnodeoftheli
nkedli
st

(
(OPTI
ON_
A)) IandI
I
(
(OPTI
ON_
B)) IandI
II
(
(OPTI
ON_
C)) I
,
IIandI
II
(
(OPTI
ON_
D)) I
,
II,
I
IIandI
V
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Consi
derani
mpl
ement
ati
onofunsor
teddoubl
yli
nked
l
ist
.Supposeithasi t
srepresentat
ionwithaheadpoi
nter
onl
y.Giventherepresent
ation,whi
choft hef
oll
owi
ng
operat
ioncanbei mplement edi
nO( 1)t
ime?
i
)I
nser
ti
onatt
hef
rontoft
hel
i
nkedl
i
st
i
i
)Insert
ionatt
heendofthel
inkedl
ist
i
i
i)Delet
ionoft
hefr
ontnodeoftheli
nkedli
st
i
v)Delet
ionoft
heendnodeoftheli
nkedli
st
(
(OPTI
ON_
A)) IandI
I
(
(OPTI
ON_
B)) IandI
II
(
(OPTI
ON_
C)) I
,
IIandI
II
(
(OPTI
ON_
D)) I
,
II,
I
IIandI
V
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Consi
derani
mpl
ement
ati
onofunsor
tedci
rcul
arl
i
nked
l
ist
.Supposeithasi t
srepresentat
ionwithaheadpoi
nter
onl
y.Giventherepresent
ation,whi
choft hef
oll
owi
ng
operat
ioncanbei mplement edi
nO( 1)t
ime?
i
)I
nser
ti
onatt
hef
rontoft
hel
i
nkedl
i
st
i
i
)Insert
ionatt
heendofthel
inkedl
ist
i
i
i)Delet
ionoft
hefr
ontnodeoftheli
nkedli
st
i
v)Delet
ionoft
heendnodeoftheli
nkedli
st

(
(OPTI
ON_
A)) IandI
I
(
(OPTI
ON_
B)) IandI
II
(
(OPTI
ON_
C)) I
,I
I,
II
IandI
V
(
(OPTI
ON_
D)) None
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
)
Consi derani mpl ement ati
onofunsor tedci r
culardoubl
y
l
inkedl ist.Supposei thasitsrepresent at
ionwi thahead
pointeronl y.Givent herepresentation, whichoft he
followingoper ationcanbei mplement edinO( 1)time?
i
)I nsertionatthef rontoft heli
nkedl ist
i
i)inser t
ionatt heendoft heli
nkedl i
st
i
ii)Deletionoft hefrontnodeoft hel i
nkedl i
st
i
v )Deletionoft heendnodeoft hel i
nkedl ist
(
(OPTI
ON_
A)) IandI
I.

(
(OPTI
ON_
B)) IandI
II
(
(OPTI
ON_
C)) I
,I
IandI
II
(
(OPTI
ON_
D)) I
,
II,
I
IIandI
V
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) I
nli
nkedl
i
steachnodecont
ainmi
nimum oft
wof
iel
ds.
Onef
iel
disdat
afi
eldt
ost
oret
hedat
asecondf
iel
dis?

(
(OPTI
ON_
A)) Poi
ntert
ochar
act
er
(
(OPTI
ON_
B)) Poi
ntert
oint
eger
(
(OPTI
ON_
C)) Poi
ntert
onode
(
(OPTI
ON_
D)) Node

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whatwoul
dbet
heasy
mpt
oti
cti
mecompl
exi
tyt
oadda
nodeatt
heendofsingl
yli
nkedli
st,
ift
hepoi
nteri
s
i
nit
ial
l
ypoint
ingt
otheheadoftheli
st?

(
(OPTI
ON_
A)) O(
1)
(
(OPTI
ON_
B)) O(
n)
(
(OPTI
ON_
C)) θ(
n)
(
(OPTI
ON_
D)) θ(
1)
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whatwoul
dbetheasy
mpt ot
ict
imecompl
exi
tyt
oaddan
el
ementi
nthel
i
nkedli
st?

(
(OPTI
ON_
A)) O(
1)
(
(OPTI
ON_
B)) O(
n)

(
(OPTI
ON_
C)) n2)
O(
(
(OPTI
ON_
D)) None
(
(CORRECT_
CH B
OI
CE))
(
A/B/
C/D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

1
(
(MARKS))
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whatwoul
dbet
heasy
mpt
oti
cti
mecompl
exi
tyt
ofi
ndan
el
ementi
nthel
i
nkedl
i
st?

(
(OPTI
ON_
A)) O(
1)

(
(OPTI
ON_
B)) O(
n)

(
(OPTI
ON_
C) n2)
) O(

(
(OPTI
ON_
D)) None
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whatwoul
dbet
heasy
mpt
oti
cti
mecompl
exi
tyt
oinser
t
anel
ementatt
hesecondposi
ti
oni
nthel
i
nkedl
i
st?

(
(OPTI
ON_
A)) O(
1)

(
(OPTI
ON_
B)) O(
n)
(
(OPTI
ON_
C) n2)
) O(
(
(OPTI
ON_
D)) None
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Theconcat
enat
ionoft
wol
i
stcanper
for
medi
nO(
1)t
ime.
Whichoft
hef
oll
owi
ngv
ari
ati
onofl
i
nkedl
i
stcanbe
used?

(
(OPTI
ON_
A)) Si
ngl
yli
nkedl
i
st

(
(OPTI
ON_
B)) Doubl
yli
nkedl
i
st

(
(OPTI
ON_
C)) Ci
rcul
ardoubl
yli
nkedl
i
st

(
(OPTI
ON_
D)) Ar
rayi
mpl
ement
ati
onofl
i
st
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) Consi
dert
hef
oll
owi
ngdef
ini
ti
oni
ncpr
ogr
ammi
ng
l
anguage
str
uctnode
{
i
ntdata;
str
uctnode*next;
}
ty
pedefstr
uctnodeNODE;
NODE* ptr
;

Whichoft
hef
oll
owi
ngccodei
susedt
ocr
eat
enew
node?

(
(OPTI
ON_
A)) pt
r=(
NODE*
)mal
l
oc(
sizeof
(NODE)
);
(
(OPTI
ON_
B)) pt
r=(
NODE*
)mal
l
oc(
NODE)
;

(
(OPTI
ON_
C)) pt
r=(
NODE*
)mal
l
oc(
sizeof
(NODE*
));

(
(OPTI
ON_
D)) pt
r=(
NODE)
mal
l
oc(
sizeof
(NODE)
);

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Av
ari
antofl
i
nkedl
i
sti
nwhi
chl
astnodeoft
hel
i
stpoi
nts
t
othef
ir
stnodeoft
hel
i
sti
s?

(
(OPTI
ON_
A)) Si
ngl
yli
nkedl
i
st

(
(OPTI
ON_
B)) Doubl
yli
nkedl
i
st

(
(OPTI
ON_
C)) Ci
rcul
arl
i
nkedl
i
st

(
(OPTI
ON_
D)) Mul
ti
plyl
i
nkedl
i
st
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) I
ON) ndoubl
yli
nkedl
i
sts,
trav
ersal
canbeper
for
med?
(
(OPTI
ON_
A)) Onl
yinf
orwar
ddi
rect
ion
(
(OPTI
ON_
B)) Onl
yinr
ever
sedi
rect
ion
(
(OPTI
ON_
C)) I
nbot
hdi
rect
ions
(
(OPTI
ON_
D)) None
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whatki
ndofl
i
nkedl
i
sti
sbestt
oanswerquest
ionl
i
ke

Whati
sthei
tem atposi
ti
onn?

(
(OPTI
ON_
A)) Si
ngl
yli
nkedl
i
st

(
(OPTI
ON_
B)) Doubl
yli
nkedl
i
st

(
(OPTI
ON_
C)) Ci
rcul
arl
i
nkedl
i
st

(
(OPTI
ON_
D)) Ar
rayi
mpl
ement
ati
onofl
i
nkedl
i
st
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Av
ari
ati
onofl
i
nkedl
i
sti
sci
rcul
arl
i
nkedl
i
st,
inwhi
cht
he
l
astnodeint heli
stpointstofir
stnodeoft hel
ist
.One
probl
em withthistypeofli
stis?
Itwastememor yspacesincethepointerheadalr
eady
point
stothef i
rstnodeandt hustheli
stnodedoesnot
needtopointtothef i
rstnode.

(
(OPTI
ON_
A)) I
tisnotpossi
blet
oaddanodeatt
heendoft
hel
i
st.

(
(OPTI
ON_
B)) I
tisdi
ff
icul
ttot
rav
erset
hel
i
stast
hepoi
nteroft
hel
ast
nodei
snownotNULL
(
(OPTI
ON_
C)) Al
lofabov
e
(
(OPTI
ON_
D)) None

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Av
ari
antoft
hel
i
nkedl
i
sti
nwhi
chnoneoft
henode
cont
ainsNULLpoi
nteri
s?

(
(OPTI
ON_
A)) Si
ngl
yli
nkedl
i
st

(
(OPTI
ON_
B)) Doubl
yli
nkedl
i
st
(
(OPTI
ON_
C)) Ci
rcul
arl
i
nkedl
i
st
(
(OPTI
ON_
D)) None
(
(CORRECT_
C C
HOI
CE))
(
A/B/
C/D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) nci
rcul
arl
i
nkedl
i
st,
inser
ti
onofnoder
equi
res
i
cat
ionof
?
(
(OPTI
ON_
A)) Onepoi
nter

(
(OPTI
ON_
B)) Twopoi
nter

(
(OPTI
ON_
C)) Thr
eepoi
nter

(
(OPTI
ON_
D)) None
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whi
choft
hef
oll
owi
ngst
atement
saboutl
i
nkedl
i
stdat
a
struct
ureis/
areTRUE?
Addi t
ionanddeleti
onofani
tem to/f
rom t
hel
i
nkedl
i
st
requir
emodi f
icat
ionoft
heexist
ingpoi
nter
s

(
(OPTI
ON_
A)) Thel
i
nkedl
i
stpoi
nter
sdonotpr
ovi
deanef
fi
ci
entwayt
o
sear
chani
tem i
nthel
i
nkedl
i
st
(
(OPTI
ON_
B)) Li
nkedl
i
stpoi
nter
sal
way
smai
ntai
nthel
i
sti
nascendi
ng
or
der

(
(OPTI
ON_
C)) Thel
i
nkedl
i
stdat
ast
ruct
urepr
ovi
desanef
fi
ci
entwayt
o
f
indkt
hel
ementi
nthel
i
st

(
(OPTI
ON_
D)) None

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Li
nkedl
i
stsar
enotsui
tabl
etof
ort
hei
mpl
ement
ati
onof
?

(
(OPTI
ON_
A)) I
nser
ti
onsor
t

(
(OPTI
ON_
B)) Radi
xsor
t

(
(OPTI
ON_
C)) Pol
ynomi
almani
pul
ati
on

(
(OPTI
ON_
D)) Bi
nar
ysear
ch

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) I
nwor
stcase,
thenumberofcompar
isonneedt
osear
ch
asi
ngl
yli
nkedl
i
stofl
engt
hnf
oragi
venel
ementi
s

(
(OPTI
ON_
A)) l
ogn

(
(OPTI
ON_
B)) n/
2

(
(OPTI
ON_
C)) l
og2n-
1
(
(OPTI
ON_
D)) n

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) consi
dert
hef
unct
ionfdef
inedher
e:
structit
em
{
i
ntdat a;
structit
em *next
;
};
i
ntf( str
uctit
em *p)
{
return(
(p==NULL)||
((
p->next
==NULL)
||
(p-
>dat
a<=p-
>next
->dat&&( p-
>next
)))
;
}
Foragi
venl
i
nkedl
i
stp,
thef
unct
ionfr
etur
ns1i
fand
onl
yif

(
(OPTI
ON_
A)) t
hel
i
sti
sempt
yorhasexact
lyoneel
ement

(
(OPTI
ON_
B)) t
heel
ementi
nthel
i
star
esor
tedi
nnon-
decr
easi
ngor
der
ofdat
aval
ue

(
(OPTI
ON_
C)) t
heel
ementi
nthel
i
star
esor
tedi
nnon-
incr
easi
ngor
der
ofdat
aval
ue

(
(OPTI
ON_
D)) notal
lel
ementi
nthel
i
sthav
ethesamedat
aval
ue

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) Thef
oll
owi
ngCf
unct
iont
akesasi
ngl
yli
nkedl
i
stasi
nput
argument .Itmodifi
esthel
istbymovi
ngt
helastel
ement
tot hefrontoftheli
standr
eturnst
hemodi
fi
edlist
.Some
partoft hecodeleftbl
ank.
typedefstructnode
{
i
ntv al
ue;
structnode*next ;
}Node;
Node*mov e_t
o_f
ront(
Node*hea
{
Node*p, *q;
i
f((
head==NULL)| |(
head-
>next
==NULL)
)
ret
urnhead;
q=NULL;
p=head;
whil
e(p->next!
=NULL)
{
q=p;
p=p->next;
}
ret
urnhead;
}

Chooset
hecor
rectal
ter
nat
ivet
orepl
acet
hebl
ankl
i
ne

(
(OPTI
ON_
A)) q=NULL;
p->next
=head;
head=p;

(
(OPTI
ON_
B)) q-
>next
=NULL;
head=p;
p->next=head;

(
(OPTI
ON_
C)) head=p;
p->next
=q;
q->next
=NULL;

(
(OPTI
ON_
D)) q-
>next
=NULL;
p->next
=head;
head=p;
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
)
Thefoll
owingCFunctiont akesasi ngl
y-li
nkedl
istof
i
ntegersasaparameterandr earr
anges
theelementsofthel
i
st s.Thef uncti
oniscall
edwiththe
l
istcontai
ningt
heint
eger s1,2,3,
4,5,6,
7inthegi
venorder.
Whatwil
lbet
hecontent
soft
hel
i
staf
tert
hef
unct
ion
compl
etesex
ecut
ion?
structnode{ i
ntv al
ue;
structnode*next ;
};
voidr earr
ange( structnode*l
i
st)
structnode* p,q;
i
ntt emp;
(!List||!l
ist
->next)return;
t;q=li
st->next;
whi l
e(q)
{
t
emp=p-
>val
ue;
p->v
alue=q-
>val
ue;
q-
>val
ue=t
emp;
p=q-
>next
;
q=p?
p->next
:0;
}
}

(
(OPTI
ON_
A)) 1,2,
3,4,
5,6,
7

(
(OPTI
ON_
B)) 2,1,
4,3,
6,5,
7

(
(OPTI
ON_
C)) 1,3,
2,5,
4,7,
6

(
(OPTI
ON_
D)) 2,3,
4,5,
6,7,
1

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) ndoubl
yli
nkedl
i
stt
rav
ersi
ngconet
ohal
tat
(
(OPTI
ON_
A)) Nul
l

(
(OPTI
ON_
B)) Fr
ont

(
(OPTI
ON_
C)) Rear

(
(OPTI
ON_
D)) r
ear
-1;

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) L
ON) i
nkedl
i
stsar
ebestsui
ted.
..
..

(
(OPTI
ON_
A)) f
orr
elat
ivel
yper
manentcol
l
ect
ionsofdat

(
(OPTI
ON_
B)) f
ort
hesi
zeoft
hest
ruct
ureandt
hedat
aint
hest
ruct
ure
ar
econst
ant
lychangi
ng.

(
(OPTI
ON_
C)) dat
ast
ruct
ure

(
(OPTI
ON_
D)) f
ornoneofabov
esi
tuat
ion

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) eoper
ati
onofpr
ocessi
ngeachel
ementi
nthel
i
sti
s
knownas.
..
..
.
(
(OPTI
ON_
A)) sort
ing

(
(OPTI
ON_
B)) mer
ging

(
(OPTI
ON_
C)) i
nser
ti
ng

(
(OPTI
ON_
D)) t
rav
ersal

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) esi
tuat
ionwheni
nal
i
nkedl
i
stSTART=NULLi
s..
..

(
(OPTI
ON_
A)) Under
fl
ow

(
(OPTI
ON_
B)) Ov
erf
low

(
(OPTI
ON_
C)) Housef
ul

(
(OPTI
ON_
D)) Sat
urat
ed

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) E
ON) achnodei
nsi
ngl
yli
nkedl
i
sthas.
..
..
..
.f
iel
ds.

(
(OPTI
ON_
A)) 2

(
(OPTI
ON_
B)) 3

(
(OPTI
ON_
C)) 1

(
(OPTI
ON_
D)) 4

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)
) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
choft
hef
oll
owi
ngi
stwowayl
i
sts?

(
(OPTI
ON_
A)) Gr
oundedheaderl
i
st

(
(OPTI
ON_
B)) Ci
rcul
arheaderl
i
st

(
(OPTI
ON_
C)) Li
nkedl
i
stwi
thheaderandt
rai
l
ernodes

(
(OPTI
ON_
D)) Li
stt
rav
ersedi
ntwodi
rect
ions
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

1
(
(MARKS))
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
chi
sthepoi
nterassoci
atedwi
tht
heav
ail
abi
l
ityl
i
st?

(
(OPTI
ON_
A)) FI
RST

(
(OPTI
ON_
B)) AVAI
L

(
(OPTI
ON_
C)) TOP

(
(OPTI
ON_
D)) REAR

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Va
ON) l
ueoff
ir
stl
i
nkedl
i
sti
ndexi
s..
..

(
(OPTI
ON_
A)) 0

(
(OPTI
ON_
B)) 1

(
(OPTI
ON_
C)) -
1

(
(OPTI
ON_
D)) 2

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) nli
nkedl
i
stst
her
ear
enoNULLl
i
nksi
n

(
(OPTI
ON_
A)) si
ngl
eli
nkedl
i
st

(
(OPTI
ON_
B)) l
i
neardoubl
yli
nkedl
i
st

(
(OPTI
ON_
C)) ci
rcul
arl
i
nkedl
i
st

(
(OPTI
ON_
D)) l
i
nkedl
i
st

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) E
ON) achnodei
nal
i
nkedl
i
stmustcont
ainatl
east.
..
..

(
(OPTI
ON_
A)) Thr
eef
iel
ds

(
(OPTI
ON_
B)) Twof
iel
ds

(
(OPTI
ON_
C)) Fourf
iel
ds

(
(OPTI
ON_
D)) Fi
vef
iel
ds

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) edummyheaderi
nli
nkedl
i
stcont
ain.
..
..

(
(OPTI
ON_
A)) f
ir
str
ecor
doft
heact
ual
dat
a

(
(OPTI
ON_
B)) l
astr
ecor
doft
heact
ual
dat
a

(
(OPTI
ON_
C)) poi
ntert
othel
astr
ecor
doft
heact
ual
dat
a

(
(OPTI
ON_
D)) mi
ddl
erecor
doft
heact
ual
dat
a

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) nal
i
nkedl
i
stt
he.
..
..
..
..
.fi
eldcont
ainst
headdr
essofnext
el
ementi
nthel
i
st.

(
(OPTI
ON_
A)) Li
nkf
iel
d

(
(OPTI
ON_
B)) Nextel
ementf
iel
d

(
(OPTI
ON_
C)) St
artf
iel
d

(
(OPTI
ON_
D)) I
nfof
iel
d

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) L
ON) LI
NKi
sthepoi
nterpoi
nti
ngt
othe.
..

(
(OPTI
ON_
A)) successornode

(
(OPTI
ON_
B)) pr
edecessornode

(
(OPTI
ON_
C)) headnode

(
(OPTI
ON_
D)) l
astnode
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) .
ON) ..
..
..
..
.ref
erst
oal
i
nearcol
l
ect
ionofdat
ait
ems.

(
(OPTI
ON_
A)) Li
st

(
(OPTI
ON_
B)) Tr
ee

(
(OPTI
ON_
C)) Gr
aph

(
(OPTI
ON_
D)) Edge

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ar
ON) unl
i
sti
s..
..
..

(
(OPTI
ON_
A)) smal
lbat
chesofr
ecor
dsf
rom af
il
e

(
(OPTI
ON_
B)) numberofel
ement
shav
ingsamev
alue

(
(OPTI
ON_
C)) numberofr
ecor
ds

(
(OPTI
ON_
D)) numberoff
il
esi
next
ernal
stor
age

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) A.
ON) ..
..
.indi
cat
est
heendoft
hel
i
st.

(
(OPTI
ON_
A)) Guar
d

(
(OPTI
ON_
B)) Sent
inel

(
(OPTI
ON_
C)) Endpoi
nter

(
(OPTI
ON_
D)) Lastpoi
nter

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) A.
ON) ..
..
..
.i
sal
i
nearl
i
sti
nwhi
chi
nser
ti
onsanddel
eti
onsar
e
madet
ofr
om ei
therendoft
hest
ruct
ure.

(
(OPTI
ON_
A)) ci
rcul
arqueue

(
(OPTI
ON_
B)) r
andom ofqueue

(
(OPTI
ON_
C)) pr
ior
it
y

(
(OPTI
ON_
D)) dequeue
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) ndex
ingt
he.
..
..
..
.el
ementi
nthel
i
sti
snotpossi
blei
n
l
i
nkedl
i
sts.

(
(OPTI
ON_
A)) mi
ddl
e

(
(OPTI
ON_
B)) f
ir
st

(
(OPTI
ON_
C)) l
ast

(
(OPTI
ON_
D)) anywher
einbet
ween

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Al
ON) i
nearl
i
sti
nwhi
cht
hepoi
nterpoi
ntsonl
ytot
he
successi
venodei
s..
..
..

(
(OPTI
ON_
A)) si
ngl
yli
nkedl
i
st
(
(OPTI
ON_
B)) ci
rcul
arl
i
nkedl
i
st

(
(OPTI
ON_
C)) doubl
yli
nkedl
i
st

(
(OPTI
ON_
D)) noneoft
heabov
e

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) .
ON) ..
..
..
.mayt
akepl
aceonl
ywhent
her
eissomemi
nimum
amount
(or
)nospacel
efti
nfr
eest
oragel
i
st.

(
(OPTI
ON_
A)) Memor
ymanagement

(
(OPTI
ON_
B)) Gar
bagecol
l
ect
ion

(
(OPTI
ON_
C)) Recy
clebi
n

(
(OPTI
ON_
D)) None

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) Al
ON) i
nearl
i
sti
nwhi
cht
hel
astnodepoi
ntst
othef
ir
stnode
i
s..
..
.

(
(OPTI
ON_
A)) si
ngl
yli
nkedl
i
st

(
(OPTI
ON_
B)) ci
rcul
arl
i
nkedl
i
st

(
(OPTI
ON_
C)) doubl
yli
nkedl
i
st

(
(OPTI
ON_
D)) noneoft
heabov
e

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Al
ON) i
nkedl
i
sti
swhi
cht
ypeofdat
ast
ruct
ure.

(
(OPTI
ON_
A)) Li
near

(
(OPTI
ON_
B)) NonLi
near
.

(
(OPTI
ON_
C)) Hi
erar
chi
cal

(
(OPTI
ON_
D)) .
None

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ty
ON) peofst
oragei
susedt
orepr
esentLi
sts

(
(OPTI
ON_
A)) Random

(
(OPTI
ON_
B)) Sequent
ial

(
(OPTI
ON_
C)) Dy
nami
c

(
(OPTI
ON_
D)) Logi
cal

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) L
ON) i
nkedl
i
star
ebestsui
ted

(
(OPTI
ON_
A)) Forr
elat
ivel
yper
manentcol
l
ect
ionsofdat
a

(
(OPTI
ON_
B)) Fort
hesi
zeofst
ruct
urei
sconst
ant
lychanged

(
(OPTI
ON_
C)) Bot
ha&b

(
(OPTI
ON_
D)) None

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) L
ON) i
nearor
derl
i
nkedl
i
sti
spr
ovi
dedt
hrough_
___
___
__

(
(OPTI
ON_
A)) v
ari
abl
es

(
(OPTI
ON_
B)) ar
ray
s

(
(OPTI
ON_
C)) Poi
nter

(
(OPTI
ON_
D)) St
ri
ngs
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) naSi
ngl
eLi
nkLi
st_
___
___
__nodecont
ainsnol
i
nks.

(
(OPTI
ON_
A)) Fi
rst

(
(OPTI
ON_
B)) Last

(
(OPTI
ON_
C)) l
astbutone

(
(OPTI
ON_
D)) mi
ddl
e
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) nSi
ngl
eLi
nkedLi
stanodecont
ainmi
nimum howmany
f
iel
ds(
assumi
ngonef
ordat
a).

(
(OPTI
ON_
A)) 2

(
(OPTI
ON_
B)) 3

(
(OPTI
ON_
C)) 1

(
(OPTI
ON_
D)) None

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Si
ON) ngl
eli
nkl
i
stper
for
mswhi
choft
hef
oll
owi
ngmet
hods
1)I
nser
ti
on
2)Modi
fi
cat
ion
3)Sear
chi
ng

(
(OPTI
ON_
A)) 1and2

(
(OPTI
ON_
B)) 2and3

(
(OPTI
ON_
C)) 1and3

(
(OPTI
ON_
D)) Al
l

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) nli
nkedl
i
stst
her
ear
enoNULLl
i
nksi
n:

(
(OPTI
ON_
A)) Si
ngl
yli
nkedl
i
st

(
(OPTI
ON_
B)) Doubl
yli
nkedl
i
st

(
(OPTI
ON_
C)) Ci
rcul
arl
i
nkedl
i
st

(
(OPTI
ON_
D)) None
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) el
i
stwi
thnonodei
scal
l
edas

(
(OPTI
ON_
A)) Empt
yli
st

(
(OPTI
ON_
B)) Nul
ll
ist

(
(OPTI
ON_
C)) Zer
oli
st

(
(OPTI
ON_
D)) None

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
choft
hef
oll
owi
ngi
stheappl
i
cat
ionoft
hesi
ngl
y
l
i
nkedl
i
st?

(
(OPTI
ON_
A)) Spar
semat
ri
x

(
(OPTI
ON_
B)) Pol
icenot
ati
on

(
(OPTI
ON_
C)) CTowerofHanoi

(
(OPTI
ON_
D)) Al
l

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
choft
hef
oll
owi
ngwi
l
lcont
ainmor
ememor
yspace?

(
(OPTI
ON_
A)) Si
ngl
yli
nkedl
i
st

(
(OPTI
ON_
B)) Doubl
yli
nkedl
i
st

(
(OPTI
ON_
C)) Ar
ray

(
(OPTI
ON_
D)) Ci
rcul
arl
i
nkedl
i
st

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
1
(
(MARKS))
(
1/2/
3..
.)

(
(QUESTI ) I
ON) npol
ynomi
almani
pul
ati
on,
nodesconsi
stsoft
hreef
iel
d
r
epr
esent
ing

(
(OPTI
ON_
A)) Coef
fi
cient
,exponent
ial
andl
i
nk

(
(OPTI
ON_
B)) Pr
evi
ousi
tem l
i
nk,
dat
ait
em,
nexti
tem l
i
nk

(
(OPTI
ON_
C)) Coef
fi
cient
,dat
ait
em andl
i
nk

(
(OPTI
ON_
D)) None
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Al
ON) i
nkedl
i
sti
nwhi
chl
astnodecont
aint
hel
i
nkoft
hef
ir
st
nodei
scal
l
ed

(
(OPTI
ON_
A)) Si
ngl
yli
nkedl
i
st

(
(OPTI
ON_
B)) Doubl
yli
nkedl
i
st

(
(OPTI
ON_
C)) Ci
rcul
arl
i
nkedl
i
st

(
(OPTI
ON_
D)) Al
l
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) As
ON) i
ngl
yli
nkedl
i
stf
aci
l
itat
esl
i
stt
rav
ersal
in

(
(OPTI
ON_
A)) Si
ngl
edi
rect
ion

(
(OPTI
ON_
B)) Anydi
rect
ion

(
(OPTI
ON_
C)) Ci
rcul
ardi
rect
ion

(
(OPTI
ON_
D)) Al
l
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ad
ON) oubl
yli
nkedl
i
stf
aci
l
itat
esl
i
stt
rav
ersal
in

(
(OPTI
ON_
A)) Si
ngl
edi
rect
ion

(
(OPTI
ON_
B)) Anydi
rect
ion

(
(OPTI
ON_
C)) Ci
rcul
ardi
rect
ion

(
(OPTI
ON_
D)) Al
l

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) L
ON) i
nkedl
i
stSTART=NULLi
s__
___
___
___
_

(
(OPTI
ON_
A)) Under
fl
ow
(
(OPTI
ON_
B)) Ov
erf
low

(
(OPTI
ON_
C)) None

(
(OPTI
ON_
D))

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) nal
i
nkedl
i
st,
thepoi
nteroft
hel
astnodecont
ainst
he
speci
alv
aluecal
l
ed_
___
___
___
___
__l
i
nke

(
(OPTI
ON_
A)) Li
nkedt
othef
ir
stnode

(
(OPTI
ON_
B)) Nul
l

(
(OPTI
ON_
C)) Li
nk

(
(OPTI
ON_
D)) Poi
ntert
othet
ail
node

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
choft
hef
oll
owi
ngi
sli
neardat
ast
ruct
ure?

(
(OPTI
ON_
A)) Tr
ee
(
(OPTI
ON_
B)) Gr
aph

(
(OPTI
ON_
C)) Li
nkedLi
st

(
(OPTI
ON_
D)) Al
l
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) nwhi
chl
i
nkedl
i
st,
nodesi
nfor
m ofr
ing?

(
(OPTI
ON_
A)) Si
ngl
yli
nkedl
i
st

(
(OPTI
ON_
B)) Doubl
yli
nkedl
i
st

(
(OPTI
ON_
C)) Ci
rcul
arl
i
nkedl
i
st

(
(OPTI
ON_
D)) Al
l

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ba
ON) l
anci
ngsy
mbol
isaappl
i
cat
ionof_
___
___
___
___
__.

(
(OPTI
ON_
A)) Si
ngl
yli
nkedl
i
st

(
(OPTI
ON_
B)) Doubl
yli
nkedl
i
st

(
(OPTI
ON_
C)) Ci
rcul
arl
i
nkedl
i
st
(
(OPTI
ON_
D)) Li
nkedst
ack

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) atki
ndofl
i
sti
sbestt
oanswerquest
ionssuchas
"
Whati
sthei
tem atposi
ti
onn?
"

(
(OPTI
ON_
A)) Li
stsi
mpl
ement
edwi
thanar
ray

(
(OPTI
ON_
B)) Doubl
yli
nkedl
i
sts

(
(OPTI
ON_
C)) Si
ngl
yli
nkedl
i
sts.

(
(OPTI
ON_
D)) Doubl
yli
nkedorsi
ngl
yli
nkedl
i
stsar
eequal
l
ybe
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) L
ON) i
nkedl
i
stsar
ebestsui
ted.
..
..

(
(OPTI
ON_
A)) f
orr
elat
ivel
yper
manentcol
l
ect
ionsofdat
a

(
(OPTI
ON_
B)) f
ort
hesi
zeoft
hest
ruct
ureandt
hedat
aint
hest
ruct
ure
ar
econst
ant
lychangi
ng.

(
(OPTI
ON_
C)) dat
ast
ruct
ure

(
(OPTI
ON_
D)) f
ornoneofabov
esi
tuat
ion
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) eoper
ati
onofpr
ocessi
ngeachel
ementi
nthel
i
sti
s
knownas.
..
..
.

(
(OPTI
ON_
A)) sor
ti
ng

(
(OPTI
ON_
B)) mer
ging

(
(OPTI
ON_
C)) i
nser
ti
ng

(
(OPTI
ON_
D)) t
rav
ersal

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) E
ON) achnodei
nsi
ngl
yli
nkedl
i
sthas.
..
..
..
.f
iel
ds.

(
(OPTI
ON_
A)) 2

(
(OPTI
ON_
B)) 3

(
(OPTI
ON_
C)) 1

(
(OPTI
ON_
D)) 4

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
choft
hef
oll
owi
ngi
stwowayl
i
sts?

(
(OPTI
ON_
A)) Gr
oundedheaderl
i
st

(
(OPTI
ON_
B)) Ci
rcul
arheaderl
i
st

(
(OPTI
ON_
C)) Li
nkedl
i
stwi
thheaderandt
rai
l
ernodes

(
(OPTI
ON_
D)) Li
stt
rav
ersedi
ntwodi
rect
ions

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
chi
sthepoi
nterassoci
atedwi
tht
heav
ail
abi
l
ityl
i
st?

(
(OPTI
ON_
A)) FI
RST

(
(OPTI
ON_
B)) AVAI
L

(
(OPTI
ON_
C)) TOP

(
(OPTI
ON_
D)) REAR

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Va
ON) l
ueoff
ir
stl
i
nkedl
i
sti
ndexi
s..
..

(
(OPTI
ON_
A)) 0

(
(OPTI
ON_
B)) 1

(
(OPTI
ON_
C)) -
1

(
(OPTI
ON_
D)) 2

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) nli
nkedl
i
stst
her
ear
enoNULLl
i
nksi
n

(
(OPTI
ON_
A)) si
ngl
eli
nkedl
i
st

(
(OPTI
ON_
B)) l
i
neardoubl
yli
nkedl
i
st

(
(OPTI
ON_
C)) ci
rcul
arl
i
nkedl
i
st

(
(OPTI
ON_
D)) l
i
nkedl
i
st
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) edummyheaderi
nli
nkedl
i
stcont
ain.
..
..

(
(OPTI
ON_
A)) f
ir
str
ecor
doft
heact
ual
dat
a

(
(OPTI
ON_
B)) l
astr
ecor
doft
heact
ual
dat
a

(
(OPTI
ON_
C)) poi
ntert
othel
astr
ecor
doft
heact
ual
dat
a

(
(OPTI
ON_
D)) mi
ddl
erecor
doft
heact
ual
dat
a

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) nal
i
nkedl
i
stt
he.
..
..
..
..
.fi
eldcont
ainst
headdr
essofnext
el
ementi
nthel
i
st.

(
(OPTI
ON_
A)) Li
nkf
iel
d

(
(OPTI
ON_
B)) Nextel
ementf
iel
d

(
(OPTI
ON_
C)) St
artf
iel
d

(
(OPTI
ON_
D)) I
nfof
iel
d
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) L
ON) LI
NKi
sthepoi
nterpoi
nti
ngt
othe.
..

(
(OPTI
ON_
A)) successornode

(
(OPTI
ON_
B)) pr
edecessornode

(
(OPTI
ON_
C)) headnode

(
(OPTI
ON_
D)) l
astnode
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) .
ON) ..
..
..
..
.ref
erst
oal
i
nearcol
l
ect
ionofdat
ait
ems.

(
(OPTI
ON_
A)) Li
st

(
(OPTI
ON_
B)) Tr
ee

(
(OPTI
ON_
C)) Gr
aph

(
(OPTI
ON_
D)) Edge

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) el
i
nkedl
i
stwoul
dbeabl
etomakeuseofa-
--
--
--
--
--
--
whosev
aluei
stheaddr
essoft
hel
ocat
ionwhi
chst
ores
t
henode.

(
(OPTI
ON_
A)) f
loat

(
(OPTI
ON_
B)) char

(
(OPTI
ON_
C)) poi
nter

(
(OPTI
ON_
D)) v
oid

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Toi
ON) nser
tanewnodei
nli
nkedl
i
stf
reenodewi
l
lbe
av
ail
abl
ein.
..
..
..
.

(
(OPTI
ON_
A)) Av
ail
abl
eli
st

(
(OPTI
ON_
B)) Av
ail
li
st

(
(OPTI
ON_
C)) Fr
eenodel
i
st

(
(OPTI
ON_
D)) Memor
yspacel
i
st

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) As
ON) i
ngl
yli
nkedl
i
sti
sal
socal
l
edas.
..
..
..
.

(
(OPTI
ON_
A)) l
i
nkedl
i
st

(
(OPTI
ON_
B)) onewaychai
n

(
(OPTI
ON_
C)) t
wowaychai
n

(
(OPTI
ON_
D)) r
ightl
i
nk

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) A.
ON) ..
..
li
sti
saheaderl
i
stwher
ethenodepoi
ntsbackt
othe
headernode.

(
(OPTI
ON_
A)) Ci
rcul
arheader

(
(OPTI
ON_
B)) Gr
oundedheader

(
(OPTI
ON_
C)) Twowayheader

(
(OPTI
ON_
D)) Onewayheader

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ad
ON) oubl
yli
nkedl
i
sthas.
..
..
..
..
.poi
nter
swi
theachnode.

(
(OPTI
ON_
A)) 0

(
(OPTI
ON_
B)) 1

(
(OPTI
ON_
C)) 2

(
(OPTI
ON_
D)) 3

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) He
ON) aderl
i
nkedl
i
stsar
efr
equent
lyusedf
ormai
ntai
ning
.
..
..
..
.i
nmemor
y.

(
(OPTI
ON_
A)) Pol
ynomi
als

(
(OPTI
ON_
B)) Bi
nomi
al

(
(OPTI
ON_
C)) Tr
inomi
al

(
(OPTI
ON_
D)) Quadr
ati
cequat
ion

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) epoi
ntert
hatpoi
ntst
othef
ir
stnodei
nthel
i
sti
s..
..
..
..

(
(OPTI
ON_
A)) FI
RST

(
(OPTI
ON_
B)) AVAI
L

(
(OPTI
ON_
C)) TOP

(
(OPTI
ON_
D)) REAR

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Two
ON) -
wayl
i
stmaybemai
ntai
nedi
nmemor
ybymeansof
.
..
..
..
..
..
..

(
(OPTI
ON_
A)) Queues

(
(OPTI
ON_
B)) Li
nearar
ray
s

(
(OPTI
ON_
C)) Nonl
i
nearar
ray
s

(
(OPTI
ON_
D)) St
acks

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ad
ON) oubl
yli
nkedl
i
sti
sal
socal
l
edas.
..
..
..
..l
i
nkedl
i
st

(
(OPTI
ON_
A)) onewaychai
n

(
(OPTI
ON_
B)) t
wowaychai
n

(
(OPTI
ON_
C)) r
ightl
i
nk

(
(OPTI
ON_
D)) None

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) el
i
stt
hatr
equi
rest
wopoi
nterv
ari
abl
esFI
RSTand
LASTiscall
ed.
..
..
..
.
(
(OPTI
ON_
A)) Cir
cul
arli
st

(
(OPTI
ON_
B)) Headerl
i
st

(
(OPTI
ON_
C)) Onewayl
i
st

(
(OPTI
ON_
D)) Twowayl
i
st

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) ftheav
ail
abi
l
ityl
i
sti
snul
l
,thent
hecondi
ti
oni
ssai
dtobe
..
.
(
(OPTI
ON_
A)) ni
lbl
ock

(
(OPTI
ON_
B)) avai
l
abi
l
ityl
i
stunder
fl
ow

(
(OPTI
ON_
C)) avai
l
abi
l
ityl
i
stov
erf
low

(
(OPTI
ON_
D)) memor
yloss

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) el
i
stwhi
chhasi
tsownpoi
nteri
scal
l
ed.
..
..
..
.

(
(OPTI
ON_
A)) poi
nterl
i
st

(
(OPTI
ON_
B)) sel
fpoi
nter

(
(OPTI
ON_
C)) f
reepool

(
(OPTI
ON_
D)) ownpoi
nter

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
choft
hef
oll
owi
ngi
stwowayl
i
sts?

(
(OPTI
ON_
A)) Gr
oundedheaderl
i
st

(
(OPTI
ON_
B)) Ci
rcul
arheaderl
i
st

(
(OPTI
ON_
C)) Li
nkedl
i
stwi
thheaderandt
rai
l
ernodes

(
(OPTI
ON_
D)) Noneoft
heabov
e

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) A.
ON) ..
..
..
..
.isaheaderl
i
stwher
ethel
astnodecont
ainst
he
nullpoi
nter
.
(
(OPTI
ON_
A)) groundedheaderl
i
st

(
(OPTI
ON_
B)) bot
tom headerl
i
st

(
(OPTI
ON_
C)) downheaderl
i
st

(
(OPTI
ON_
D)) dr
oppedheaderl
i
st

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) RL
ON) I
NKi
sthepoi
nterpoi
nti
ngt
othe.
..

(
(OPTI
ON_
A)) successornode

(
(OPTI
ON_
B)) pr
edecessornode

(
(OPTI
ON_
C)) headnode

(
(OPTI
ON_
D)) l
astnode

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) Th
ON) edi
sadv
ant
agei
nusi
ngaci
rcul
arl
i
nkedl
i
sti
s..
..
..
.

(
(OPTI
ON_
A)) i
tispossi
blet
ogeti
ntoi
nfi
nit
eloop

(
(OPTI
ON_
B)) l
astnodepoi
ntst
ofi
stnode.

(
(OPTI
ON_
C)) t
imeconsumi
ng

(
(OPTI
ON_
D)) r
equi
resmor
ememor
yspace
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
choft
hef
oll
owi
ngcondi
ti
onschecksav
ail
abl
efr
ee
spaceinavai
ll
ist
?
(
(OPTI
ON_
A)) Avail
=Nul
l

(
(OPTI
ON_
B)) Nul
l=Av
ail

(
(OPTI
ON_
C)) Av
ail
=Maxst
ack

(
(OPTI
ON_
D)) Av
ail
=Top
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Al
ON) i
nearl
i
sti
nwhi
cheachnodehaspoi
ntt
othe
pr
edecessorandsuccessor
snodesi
scal
l
ed.
..
..
..
.
(
(OPTI
ON_
A)) si
ngl
ylinkedl
ist

(
(OPTI
ON_
B)) ci
rcul
arl
i
nkedl
i
st

(
(OPTI
ON_
C)) doubl
yli
nkedl
i
st

(
(OPTI
ON_
D)) l
i
nearl
i
nkedl
i
st

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Su
ON) pposecur
sorpoi
ntst
oanodei
nal
i
nkedl
i
st.What
stat
ementchangescur
sorsot
hati
tpoi
ntst
othenext
node?
(
(OPTI
ON_
A))
cur
sor
++;

(
(OPTI
ON_
B))
cur
sor=l
i
nk;

(
(OPTI
ON_
C))
cur
sor+=l
i
nk;

(
(OPTI
ON_
D)) cur
sor=cur
sor
->l
i
nk
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
)
Supposecursorpointstoanodei
nalinkedli
st.What
Booleanexpressi
onwi l
lbet
ruewhencursorpoint
stothe
tai
lnodeofthel i
st?

(
(OPTI
ON_
A))
(
cur
sor==NULL)

(
(OPTI
ON_
B))
(
cur
sor
->l
i
nk==NULL)

(
(OPTI
ON_
C))
(
cur
sor
->dat
a==NULL)

(
(OPTI
ON_
D))
(
cur
sor
->dat
a==0.
0)

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
)
Supposethatpi
sapointervar
iabl
ethatcont
ainsthe
NULLpointer
.Whathappensifyourpr
ogram t
riestor
ead
orwri
te*p?

(
(OPTI
ON_
A))
Asy
ntaxer
roral
way
soccur
satcompi
l
ati
ont
ime.

(
(OPTI
ON_
B))
Ar
un-
ti
meer
roral
way
soccur
swhen*
pisev
aluat
e
(
(OPTI
ON_
C))
Arun-
ti
meer
roral
way
soccur
swhent
hepr
ogr
am
f
ini
shes.

(
(OPTI
ON_
D))
Ther
esul
tsar
eunpr
edi
ctabl
e.

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
)
Supposet
hatfi
saf
unct
ionwi
thapr
otot
ypel
i
ket
his:

 voidf(
_ _
______head_ptr
);
 
   
  
//Precondit
ion:head_ptri
saheadpoi nterforali
nked
l
ist
.
  
 //Postconditi
on:Thefuncti
onfhasdonesome
comput ati
onwi t
h
  
 //theli
nkedl i
stbutt
, heli
stit
selfisunchange
Whatisthebestdat atypeforhead_ptri
nthisfuncti
on?

(
(OPTI
ON_
A))
node

(
(OPTI
ON_
B))
constnode

(
(OPTI
ON_
C))
node*

(
(OPTI
ON_
D))
constnode*

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) atki
ndofl
i
sti
sbestt
oanswerquest
ionssuchas
i
sthei
tem atposi
ti
onn?
(
(OPTI
ON_
A))
Li
stsi
mpl
ement
edwi
thanar
ray
.
(
(OPTI
ON_
B))
Doubl
y-
li
nkedl
i
sts.

(
(OPTI
ON_
C))
Si
ngl
y-
li
nkedl
i
sts.

(
(OPTI
ON_
D))
Doubl
y-
li
nkedorsi
ngl
y-
li
nkedl
i
stsar
eequal
l
ybest

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) L
ON) i
nearor
derl
i
nkedl
i
sti
spr
ovi
dedt
hrough_
___
___
__

(
(OPTI
ON_
A))
v
ari
abl
es

(
(OPTI
ON_
B))
ar
ray
s

(
(OPTI
ON_
C))
Poi
nter

(
(OPTI
ON_
D))
st
ri
ngs

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) naSi
ngl
eLi
nkLi
st_
___
___
__nodecont
ainsnol
i
nks.

(
(OPTI
ON_
A))
Fi
rst

(
(OPTI
ON_
B))
Last

(
(OPTI
ON_
C))
l
astbutone

(
(OPTI
ON_
D))
mi
ddl
e

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Al
ON) i
nkedl
i
sti
swhi
cht
ypeofdat
ast
ruct
ure

(
(OPTI
ON_
A))
Li
near

(
(OPTI
ON_
B))
NonLi
near

(
(OPTI
ON_
C))
Hi
erar
chi
cal

(
(OPTI
ON_
D))
None

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) nSi
ngl
eLi
nkedLi
stanodecont
ainmi
nimum howmany
f
iel
ds(
assumi
ngonef
ordat
.
(
(OPTI
ON_
A)) 2

(
(OPTI
ON_
B)) 3

(
(OPTI
ON_
C)) 1

(
(OPTI
ON_
D)) 0

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) mpl
ement
ati
onofpr
ior
it
yqueue
1)Tr
ee
2)Li
nkedli
st
3)Doubl
yli
nkedl
i
st

(
(OPTI
ON_
A)) 1and2

(
(OPTI
ON_
B)) 2and3

(
(OPTI
ON_
C)) 1and3

(
(OPTI
ON_
D)) Al
l

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Nu
ON) l
lpoi
nteri
susedt
otel
l
1)Endoftheli
nkedlist
2)Emptypoint
erfiel
dofastr
uct
ure
3)Thel
inkedli
stisempt y

(
(OPTI
ON_
A)) 1

(
(OPTI
ON_
B)) 2and3

(
(OPTI
ON_
C)) 1and3

(
(OPTI
ON_
D)) Al
l

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
)
 Si
ngleli
nklistper
for
mswhi
choft
hef
oll
owi
ngmet
hods
1)I
nserti
on
2)Modificat
ion
3)Searching

(
(OPTI
ON_
A)) 1and2

(
(OPTI
ON_
B)) 1and3

(
(OPTI
ON_
C)) 2and3
(
(OPTI
ON_
D)) Al
l

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) el
i
stwi
thnonodei
scal
l
edas
1)Emptyli
st
2)Nul
lli
st
3)Zer
olist

(
(OPTI
ON_
A)) 1and2

(
(OPTI
ON_
B)) 1and3

(
(OPTI
ON_
C)) 2and3

(
(OPTI
ON_
D)) Al
l

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ana
ON) ppl
i
cat
iont
hatmakeuseofMul
ti
li
nkedSt
ruct
ures
I
s__
___
___
_?

(
(OPTI
ON_
A))
Spar
semat
ri
x
(
(OPTI
ON_
B))
Li
nkedl
i
st

(
(OPTI
ON_
C))
Tr
ee

(
(OPTI
ON_
D))
St
ack

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Gi
ON) venaar
bit
rar
ypoi
ntert
oanel
ementi
nasi
ngl
yli
nked
l
i
st,
thet
imecompl
exi
tyf
ori
tsdel
eti
on_
___
___
___
_.

(
(OPTI
ON_
A))
O(
n/2)

(
(OPTI
ON_
B))
O(
n*n)

(
(OPTI
ON_
C))
O(
n)

(
(OPTI
ON_
D))
O(
n*n/
2)

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) nCl
anguaget
oimpl
ementt
hehet
erogeneousl
i
nked
l
i
st_
___
___
___poi
nteri
suse
(
(OPTI
ON_
A)) Voi
d

(
(OPTI
ON_
B)) Nul
l

(
(OPTI
ON_
C)) I
nt

(
(OPTI
ON_
D)) St
ruct
ure

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Se
ON) ar
chi
ngal
i
nkedl
i
str
equi
resl
i
nkedl
i
stbecr
eat
ed

(
(OPTI
ON_
A))
I
nsor
tedor
deronl
y

(
(OPTI
ON_
B))
I
nanyor
der

(
(OPTI
ON_
C))
Wi
thoutunderf
lowcondi
ti
on

(
(OPTI
ON_
D))
None

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTI
ONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) nli
nkedl
i
stt
hel
ogi
cal
orderofel
ement
s–

(
(OPTI
ON_
A))
i
ssameast
hei
rphy
sical
arr
angement

(
(OPTI
ON_
B))
Isnotnecessar
il
yequi
val
ent
 tot
hei
rphy
sical
arr
angement

(
(OPTI
ON_
C))
I
sdet
ermi
nedbyt
hei
rlogi
cal
arr
angement

(
(OPTI
ON_
D))
None

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ac
ON) cor
dingt
oSt
oragest
rat
egi
esLi
nkedl
i
sti
sa

(
(OPTI
ON_
A))
Nonl
i
near

(
(OPTI
ON_
B))
Li
near

(
(OPTI
ON_
C))
Sequent
ial

(
(OPTI
ON_
D))
dy
nami
c

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI )  
ON) Impl
ement
ati
onofal
i
sti
nady
nami
cfashi
oni
s

(
(OPTI
ON_
A))
Tocall
upont
hesyst
em t
oal
l
ocat
eandf
reest
oragemay
notbeti
meconsumi
ng

(
(OPTI
ON_
B))
Asetofnodesnotr
eser
vedi
nadv
ancef
oruse

(
(OPTI
ON_
C))
Theaddr
esscomput
ati
on i
scompl
ex

(
(OPTI
ON_
D))
None
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) fyouar
eusi
ng Cl
anguage t
oimpl
ementa
heter
ogeneous l
i
nkedl
i
st,
theoi
ntert
ypeuwi
l
lpr
eferi
s
___
_ _
___
(
(OPTI
ON_
A)) I
nt*

(
(OPTI
ON_
B)) nul
l

(
(OPTI
ON_
C)) Voi
d*

(
(OPTI
ON_
D)) Fl
oat
*

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
choft
hef
oll
owi
ngst
atementi
str
ue

(
(OPTI
ON_
A) 

  
 Thenextaddr
essf
iel
doft
henodecanbeempt
y

(
(OPTI
ON_
B) 

  
 Al
i
stcanexi
stwi
thnonodes

(
(OPTI
ON_
C) 

  
  
Inasi
ngl
yli
nkedl
i
stt
hest
art
ingaddr
essoft
hel
i
sti
s
st
oredi
ntheaddr
essf
iel
doft
hel
astnode 
  
(
(OPTI
ON_
D)Al
) All
oftheabov
e

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
)
Ty
peofst
oragei
susedt
orepr
esentLi
sts

(
(OPTI
ON_
A)) Random

(
(OPTI
ON_
B)) Sequent
ial

(
(OPTI
ON_
C)) Dy
nami
c

(
(OPTI
ON_
D)) Logi
cal

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
)
Thenodei
nasi
ngl
yli
nkedl
i
stcanbedel
eted,

(
(OPTI
ON_
A))
Wi
thoutt
rav
ersi
ngt
hel
i
st

(
(OPTI
ON_
B))
Byt
rav
ersi
ngt
hel
i
stf
rom t
hehead

(
(OPTI
ON_
C))
Byt
rav
ersi
ngt
hel
i
stf
rom t
het
ail

(
(OPTI
ON_
D))
 Al
loft
heabov
e

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
choft
hef
oll
owi
ngoper
ati
onsi
snotef
fi
ci
ent
ly
suppor
ted
byasingl
y-l
i
nkedl
i
st?
 

(
(OPTI
ON_
A))  
  
  
accessi
ngt
heel
ementi
nthecur
rentposi
ti
on 
  
  

(
(OPTI
ON_
B)) i
nser
ti
onaf
tert
hecur
rentposi
ti
on 
  
  
 

(
(OPTI
ON_
C)) i
nser
ti
onbef
oret
hecur
rentposi
ti
on 
  
  

(
(OPTI
ON_
D)) movi
ngt
otheposi
ti
oni
mmedi
atel
yfol
l
owi
ngt
hecur
rent
posi
ti
on

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) ati
sanor
der
edl
i
st
 
  
  
  
  
(
(OPTI
ON_
A)w
)hWheret
headdr
essisor
der
ed
 
  
  
  
  
(
(OPTI
ON_
B)w
)hwheret
hesmal
leri
temspr
ecedet
hel
argerones

(
(OPTI
ON_
C) 
 

  
 bot
haandb
 
  
  
  
 
(
(OPTI
ON_
D)n
)onone

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ac
ON) cor
dingt
oAccessst
rat
egi
esLi
nkedl
i
sti
sa

(
(OPTI
ON_
A))  
Nonl
i
near
  
  
 

(
(OPTI
ON_
B)) Li
near
  
  
  

(
(OPTI
ON_
C)) Nonsequent
ial
 
  
  

(
(OPTI
ON_
D)) dynami
c

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ho
ON) wmanynodesar
eaccessed,
ont
heav
erage,
in
i
nser
ti
nganewel
ementi
ntoanor
der
edl
i
stwi
thnnodes

(
(OPTI
ON_
A)) (
n+1)
/2

(
(OPTI
ON_
B)) n/
2

(
(OPTI
ON_
C)) 1/
(n+1)

(
(OPTI
ON_
D)) None

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI )  
ON) Apr
ior
it
yQueuei
mpl
ement
edasanor
der
edl
i
nkedl
i
st
requi
resexaminingan 
  av
erageofappr
oxi
mat
ely_
___
___
nodesforinser
ti
on
(
(OPTI
ON_
A)) (n+1)
/2

(
(OPTI
ON_
B)) 1/
(n+1)

(
(OPTI
ON_
C)) n/
2

(
(OPTI
ON_
D)) one

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI )  
ON) Apr
ior
it
yQueuei
mpl
ement
edasanor
der
edl
i
nkedl
i
st
requi
resexami
ninganav
erageofappr
oxi
mat
ely_
___
___
nodesfordel
eti
on
(
(OPTI
ON_
A)) (n+1)
/2

(
(OPTI
ON_
B)) 1/
(n+1)

(
(OPTI
ON_
C)) n/
2

(
(OPTI
ON_
D)) one

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) eadv
ant
ageofl
i
stsov
eranar
rayf
ori
mpl
ement
inga
pri
ori
tyqueuei
s
(
(OPTI
ON_
A)) Ext
raspaceshoul
dbel
eftempt
yint
heendt
oachi
evet
his

(
(OPTI
ON_
B)) Li
stswi
l
ltakel
esst
imecompar
edt
oar
ray
s

(
(OPTI
ON_
C)) Noshi
ft
ingofel
ement
sorgapsar
enecessar
yinal
i
st

(
(OPTI
ON_
D)) Li
stsdon’
thav
edi
rectaccess

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ani
ON) tem canbei
nser
tedi
nto _
___
__,
wit
houtmov
ingany
ot
heri
tems

(
(OPTI
ON_
A)) Li
st

(
(OPTI
ON_
B)) anar
rayi
fext
raspacei
slef
tempt
y

(
(OPTI
ON_
C)) bot
haandb

(
(OPTI
ON_
D)) none

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ane
ON) xt
ranodeatt
hef
rontoft
hel
i
st,
whi
chdoesnot
r
epresentanit
em i
nthel
i
sti
sCal
l
ed
(
(OPTI
ON_
A)) headernode

(
(OPTI
ON_
B)) Li
stnode

(
(OPTI
ON_
C)) Li
stheader

(
(OPTI
ON_
D)) Bot
haandc

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI )  
ON) A__
___
___
__i
sasel
f-
ref
erent
ial
dat
aty
pebecausei
t
cont
ainsapoi
nterorl
i
nkt
oanot
herdat
aoft
hesame
ty
pe.

(
(OPTI
ON_
A))
St
ack

(
(OPTI
ON_
B))
Li
nkedl
i
st

(
(OPTI
ON_
C))
Queue

(
(OPTI
ON_
D))
Pr
ior
it
yqueue

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) L
ON) i
nkedl
i
sts,
atanypoi
nti
nthel
i
sti
nconst
antt
ime,
does 
notal
l
ow_
___
___
___
.
(
(OPTI
ON_
A)) Random Access

(
(OPTI
ON_
B)) I
nser
ti
on

(
(OPTI
ON_
C)) Del
eti
on

(
(OPTI
ON_
D)) I
nser
ti
onatend

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) _
ON) ___
___
___per
mit
sinser
ti
onandr
emov
alofnodesatany
pointi
nthel
i
sti
nconst
antt
ime,
butdonotal
l
owr
andom
access
(
(OPTI
ON_
A)) St
ack

(
(OPTI
ON_
B)) Li
nkedl
i
st

(
(OPTI
ON_
C)) Queue

(
(OPTI
ON_
D)) Pr
ior
it
yqueue

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Tot
ON) rav
ersea_
___
___
___
_,y
oubegi
natanynodeandf
oll
ow
thel
isti
neit
her 
  
  
  
  
  di
rect
ionunt
ily
our
etur
ntot
he
ori
ginal
node.
 

(
(OPTI
ON_
A))
Twowayl
i
nkedl
i
st

(
(OPTI
ON_
B))
Ci
rcul
arl
i
nkedl
i
st

(
(OPTI
ON_
C)) Si
ngl
yli
nkedl
i
st
(
(OPTI
ON_
D)) None

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) epoi
nter
,incaseofaci
rcul
arl
i
nkedl
i
st,
poi
nti
ngt
othe
whol
eli
sti
susual
l
ycal
l
edt
he_
___
___
___
_.

(
(OPTI
ON_
A))
Doubl
epoi
nter

(
(OPTI
ON_
B))
Li
stpoi
nter

(
(OPTI
ON_
C))
Ci
rcul
arpoi
nter

(
(OPTI
ON_
D))
Endpoi
nter
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) na_
___
___
___
___
_,eachnodehasonel
i
nk,
simi
l
arl
ytoan
or
dinar
ysingl
y-
li
nkedl
i
st,
exceptthatt
henextl
i
nkoft
he
l
astnodepoint
sbackt
othefi
rstnode.

(
(OPTI
ON_
A))
Doubl
yli
nkedl
i
st

(
(OPTI
ON_
B))
Si
ngl
y-
cir
cul
arl
y-
li
nkedl
i
st

(
(OPTI
ON_
C))
Doubl
yci
rcul
arl
i
nkedl
i
st

(
(OPTI
ON_
D))
Twowayl
i
nkedl
i
st

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) na_
___
___
___
___
_,eachnodehast
wol
i
nks,
simi
l
arl
yto
doubl
y-
li
nkedli
st,
exceptthatpr
eviousl
inkofthefi
rst
nodepoi
ntstothelastnodeandthenextli
nkofthelast
nodepoi
ntstothefir
stnode.

(
(OPTI
ON_
A))
Doubl
y-
cir
cul
arl
y-
li
nkedl
i
st

(
(OPTI
ON_
B))
Doubl
yli
nkedl
i
st

(
(OPTI
ON_
C))
Si
ngl
y-
cir
cul
arl
y-
li
nkedl
i
st
(
(OPTI
ON_
D))
Twowayl
i
nkedl
i
st

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) na_
___
___
___
,inser
ti
onsandr
emov
alscanbedoneat
anypoi
ntwi
thaccesst
oanynear
bynode.

(
(OPTI
ON_
A))
Doubl
y-
cir
cul
arl
y-
li
nkedl
i
st

(
(OPTI
ON_
B))
Doubl
yli
nkedl
i
st

(
(OPTI
ON_
C))
Si
ngl
y-
cir
cul
arl
y-
li
nkedl
i
st

(
(OPTI
ON_
D))
Twowayl
i
nkedl
i
st

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) _
ON) ___
___
___
___
__ar
emostusef
ulf
ordescr
ibi
ngnat
ural
l
y
ci
rcul
arstr
uct
ures,andhavetheadv
antageofregul
ar
str
uctur
eandbeingabletotr
aver
setheli
stst
arti
ngatany
point
.
(
(OPTI
ON_
A))
Doubl
yli
nkedl
i
st

(
(OPTI
ON_
B))
Twowayl
i
nkedl
i
st

(
(OPTI
ON_
C))
Si
ngl
yli
nkedl
i
st

(
(OPTI
ON_
D))
Ci
rcul
arl
i
nkedl
i
st

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
choft
hef
oll
owi
ngoper
ati
onsi
snotef
fi
ci
ent
ly
support
edbyasingl
y-
li
nkedli
st?
(
(OPTI
ON_
A)) Accessi
ngtheel
ementinthecurr
entposi
ti
on

(
(OPTI
ON_
B)) I
nser
ti
onaf
tert
hecur
rentposi
ti
on

(
(OPTI
ON_
C)) I
nser
ti
onbef
oret
hecur
rentposi
ti
on

(
(OPTI
ON_
D)) Movi
ngt
otheposi
ti
oni
mmedi
atel
yfol
l
owi
ngt
hecur
rent
posi
ti
on

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) eheadernodeofal
i
nkedl
i
st

(
(OPTI
ON_
A)) Si
mpl
i
fiesdel
eti
on

(
(OPTI
ON_
B)) Si
mpl
i
fiesi
nser
ti
on

(
(OPTI
ON_
C)) Poi
ntst
onul
l

(
(OPTI
ON_
D)) Bot
h
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) faheadernodei
sused,
whi
choft
hef
oll
owi
ngi
ndi
cat
es
wi
thonei
tem?
(
(OPTI
ON_
A)) L.
Header
.Next=nul
l

(
(OPTI
ON_
B)) L.
Header
.Next/
=nul
l

(
(OPTI
ON_
C)) L.
Header
.Next/
=nul
landt
henL.
Header
.Next
.Next/
=nul
l

(
(OPTI
ON_
D)) L.
Header
.Next/
=nul
landt
henL.
Header
.Next
.Next=nul
l

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) nser
ti
onofanodei
ntoadoubl
yli
nkedl
i
str
equi
reshow
manychangest
ovar
iousNextandPr
evpoi
nter
s?

(
(OPTI
ON_
A)) Nochanges

(
(OPTI
ON_
B)) 1Next
,1Pr
ev

(
(OPTI
ON_
C)) 2Next
,2Pr
ev

(
(OPTI
ON_
D)) 3Next
,3Pr
ev

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) atoper
ati
oni
ssuppor
tedi
nconst
antt
imebyt
he
doubl
yli
nkedl
i
st,
butnotbyt
hesi
ngl
yli
nkedl
i
st?

(
(OPTI
ON_
A)) Advance

(
(OPTI
ON_
B)) Moveback

(
(OPTI
ON_
C)) Fi
rst

(
(OPTI
ON_
D)) Ret
ri
eve

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Co
ON) nsi
dert
hef
oll
owi
ngst
atement
s.
(i
)Al i
nkedlistconsi stsofaser iesofst r
uct ures,which
arenecessar i
l
yadj acenti nmemor y.
(i
i)Inasinglyli
nkedl i
st,eachst ructurecont ainsan
elementandar eferencet oar ecordcont ainingits
successor.
(i
ii)I
nanar r
ay -
basedl i
st,eveni fthear r
ayi sdy nami call
y
all
ocated,anest i
mat eoft hemaxi mum si zeoft helistis
requir
e
(i
v )I
nanar r
aybasedl i
st,inserti
ngatposi ti
on0r equires
fi
rstpushingtheent irear raydownonespott omake
room.
(v)Inanarray-basedl ist
, deleti
ngel ement sf rom the
mi ddl
ecanbeper formedwi thoutshift
ingt her emaining
elements.
Whi choftheabov est atement sis/arevalidf oralist
?
(
(OPTI
ON_
A))
(
ii
)&(
iv)onl
y

(
(OPTI
ON_
B))
(
ii
),(
ii
i)&(
iv)onl
y

(
(OPTI
ON_
C))
(
ii
i)
,(i
v)&(
v)onl
y

(
(OPTI
ON_
D))
(
ii
)&(
iv)onl
y

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Co
ON) nsi
dert
hef
oll
owi
ngoper
ati
ons.
(i
)Appendanel ementt otheendofal i
st.
(i
i)Concat enatetwol i
sts.
(i
ii)Freeall t
henodesi nal i
st.
(i
v )Reverseal i
st,sothatthelastelementbecomest he
fi
rstandso- on.
(v)Del et
et helastelementfrom alist.
(vi)Delet
et henthelementf rom ali
stwi t
hatleastn
element s.
(vii
)Combi netwoor deredli
stsintoasingleorder
edlist
.
Whi choft heabov earev al
idoperationsinsi
nglyli
nked
l
ists?

(
(OPTI
ON_
A)) (
i)
,(i
i
),(
ii
i)
,(v
),(
vi)&(
vii
)

(
(OPTI
ON_
B))
(
ii
i)
,(i
v),
(v)
,(v
i)&(
vii
)
(
(OPTI
ON_
C))
(
i)
,(i
i
),(
ii
i)
,(i
v),
(vi
)&(
vii
)

(
(OPTI
ON_
D))
(
i)
,(i
i
),(
ii
i)
,(i
v),
(v)
,(v
i)&(
vii
)

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Co
ON) nsi
dert
hef
oll
owi
ngal
gor
it
hm.
(i
)Anempt ynodeiscr eate
(i
i)Thenode’sinformat i
onf i
eldi
sinit
ializedtoani nteger
e1.
(i
ii
)Thenodei sbei ngincludedattheendoft heli
st, and
thenextfi
eldissett onull.
(i
v)Thenodei snowi ncl
udedi nthel
istbymaki ngt he
nextfi
eldofthelastnodeoft heli
star eferencetot he
newlycreatednode.
(v)Thenewnodef ollowsal l
thenodesoft heli
st,butt hi
s
facthastober efl
ect edi
nt heval
ueoft hetail
,whichnow
becomest hereferencet othenewnode.
Whichoft hefoll
owi ngdoest heaboveal gorit
hm
descri
be?

(
(OPTI
ON_
A)) Thepr
ocessofaddi
nganewnodet
othel
astnodeoft
he
t
ree
(
(OPTI
ON_
B))
Thepr
ocessofaddi
nganewnodet
oanyl
ocat
ionoft
he
l
ist

(
(OPTI
ON_
C))
Thepr
ocessofaddi
nganewnodet
otheendoft
hel
i
st

(
(OPTI
ON_
D))
Thepr
ocessofdel
eti
nganodef
rom t
heendoft
hel
i
st
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) nLi
nkedl
i
sti
mpl
ement
ati
on,
anodecar
ri
esi
nfor
mat
ion
r
egar
ding_
___
__?
(
(OPTI
ON_
A)) Li
nk

(
(OPTI
ON_
B)) Dat
aandLi
nk

(
(OPTI
ON_
C)) Dat
a

(
(OPTI
ON_
D)) Noneoft
heabov
e

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) AL
ON) i
nkedl
i
sti
nwhi
cht
hel
astnodeofLi
nkedl
i
stpoi
ntst
o
t
hef
ir
sti
scal
l
eda_
___
___
___

(
(OPTI
ON_
A)) Si
ngl
yLi
nkedLi
st

(
(OPTI
ON_
B)) Ci
rcul
arLi
nkedLi
st

(
(OPTI
ON_
C)) Noneoft
hese

(
(OPTI
ON_
D)) Doubl
yLi
nkedLi
st

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ad
ON) oubl
yli
nkedl
i
stper
for
mst
rav
ersal
in_
___
___
___
___
_

(
(OPTI
ON_
A)) Ci
rcul
ardi
rect
ion

(
(OPTI
ON_
B)) Anydi
rect
ion

(
(OPTI
ON_
C)) Ei
therdi
rect
ion

(
(OPTI
ON_
D)) For
war
ddi
rect
ion

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) L
ON) i
nkedl
i
stdat
ast
ruct
ureusageof
fer
sconsi
der
abl
e
sav
ingi
n

(
(OPTI
ON_
A)) Comput
ati
onal
time

(
(OPTI
ON_
B)) Spaceut
il
izat
ion&comput
ati
onal
time

(
(OPTI
ON_
C)) Spaceut
il
izat
ion

(
(OPTI
ON_
D)) Noneoft
heabov
e
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Co
ON) nsi
derl
i
nkedl
i
sti
susedt
oimpl
ementt
heSt
ackt
hen
whi
chofthef
oll
owi
ngnodei
sconsi
der
edasTopoft
he
St
ack?
(
(OPTI
ON_
A)) Anynode

(
(OPTI
ON_
B)) Fi
rstNode

(
(OPTI
ON_
C)) Mi
ddl
eNode

(
(OPTI
ON_
D)) LastNode

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) el
i
nkf
iel
dint
hel
astnodeoft
hel
i
nkedl
i
stcont
ains
_
___
_

(
(OPTI
ON_
A)) Zer
oval
ue

(
(OPTI
ON_
B)) Li
nkt
othef
ir
stnode

(
(OPTI
ON_
C)) Poi
ntert
othenextel
ementl
ocat
ion

(
(OPTI
ON_
D)) Dat
a
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) ennewel
ementi
saddedi
nthemi
ddl
eofSLLt
hen
_
___
_

(
(OPTI
ON_
A)) Onl
yel
ement
sthatappearbef
oret
henewel
ementneed
tobemov ed
(
(OPTI
ON_
B)) Onlyelement
sthatappearaf
tert
henewel
ementand
beforeneedt
obemov e
(
(OPTI
ON_
C)) Non eedtomoveelement

(
(OPTI
ON_
D)) Onl
yel
ement
sthatappearaf
tert
henewel
ementneedt
o
bemov
e
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
choft
hef
oll
owi
ngoper
ati
oni
sper
for
medmor
e
ef
fi
cientl
yinDLL?
(
(OPTI
ON_
A)) Del
etinganodeatgi
venposi
ti
on

(
(OPTI
ON_
B)) Sear
chi
nganodeatgi
venposi
ti
on

(
(OPTI
ON_
C)) Noneoft
hese

(
(OPTI
ON_
D)) I
nser
ti
nganodeatgi
venposi
ti
on

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) final
i
nkedl
i
staddr
essoff
ir
stnodei
s1020t
henwhat
wi
l
lbet
headdr
essofnodeat5t
hposi
ti
on

(
(OPTI
ON_
A)) 1028

(
(OPTI
ON_
B)) 1036

(
(OPTI
ON_
C)) Noneoft
hese

(
(OPTI
ON_
D)) 1040
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) nCi
rcul
arl
i
nkedl
i
sti
nser
ti
onofanodei
nvol
vest
he
modi
fi
cat
ionof_
___
__l
i
nks.
(
(OPTI
ON_
A)) 4

(
(OPTI
ON_
B)) 1

(
(OPTI
ON_
C)) 2

(
(OPTI
ON_
D)) 3

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
)
Considert
hef
oll
owingl
i
nkedl
i
str
epr
esent
ati
on-
str
uctnode
{
i
ntdata;
str
uctnode*
next;
}st
art=NULL;

st
ructnode*
new_
node;

Whichoft
hef
oll
owi
ngst
atementi
susedt
ocr
eat
ea
node?

(
(OPTI
ON_
A)) new_
node=(
str
uctnode*
)mal
l
oc(
sizeof
(st
ructnode)
);

(
(OPTI
ON_
B)) new_
node=(
str
uct*
)mal
l
oc(
sizeof
(st
ructnode)
);

(
(OPTI
ON_
C)) new_
node=(
str
uctnode)mal
l
oc(
sizeof
(st
ructnode)
);

(
(OPTI
ON_
D)) new_
node=(
str
uctnode*
)mal
l
oc(
sizeof
(st
ructnode*
));

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) .
ON) st
ructnode
{
i
ntdata;
st
ructnode*
next
;
}
*start
;
Consi
dertheabover
epresentat
ionandpredi
ctwhatwil
l
bepri
ntedonthescr
eenbyf oll
owingst
atement:st
art
-
>next
->data?

(
(OPTI
ON_
A)) Accesst
he"
dat
a"f
iel
dof3r
dnode

(
(OPTI
ON_
B)) Accesst
he"
dat
a"f
iel
dof2ndnode

(
(OPTI
ON_
C)) Accesst
he"
dat
a"f
iel
dof1stnode

(
(OPTI
ON_
D)) Noneoft
hese
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) s
ON) t
ructnode*cur
rent=st
art
->next
what"cur
rent
"wi
l
lcont
aini
fiti
svar
iabl
eoft
ypest
ruct
node?

(
(OPTI
ON_
A)) Dat
aFi
eldof2ndnode

(
(OPTI
ON_
B)) Addr
essof2ndnode

(
(OPTI
ON_
C)) Addr
essf
iel
dof2ndnode

(
(OPTI
ON_
D)) noneoft
hese

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) 1
ON) 64.Consi
dert
hef
oll
owi
ngl
i
nkedl
i
st

andf ol
l
owingl
i
nkedl i
str
epr
esent
ati
on
str
uctnode{
intdata;
structnode*next
;
}*
start;

whatwi
l
ltbev
alueoff
oll
owi
ngst
atement
?

st
art
->next
->next
->next
->dat
a

(
(OPTI
ON_
A)) 12

(
(OPTI
ON_
B)) 25

(
(OPTI
ON_
C)) 15
(
(OPTI
ON_
D)) 30

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
)
I2 I 2
~-

L 3225 3226

12~1:: L171~-ul
5:.57~ 5572

Ifst
artispointi
ngtof i
rstnodeoftheli
nkedl
istt
hen
considerthefoll
owingstatement-
star
t=st art
->next
;
curr
ent=st art-
>next
Whatwi llbethevalueofaddressfi
eldofcur
rent
?

(
(OPTI
ON_
A)) 2184

(
(OPTI
ON_
B)) 3225

(
(OPTI
ON_
C)) 5572

(
(OPTI
ON_
D)) 5571

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
choft
hef
oll
owi
ngi
scor
rectsy
ntaxt
opr
intl
i
nkedl
i
st

(
(OPTI
ON_
A)) st
ructnode*
temp;
do{
pri
ntf
("%d"
,t
emp- >dat;
temp=t emp->next;
}
while(
temp!=NULL) ;

(
(OPTI
ON_
B)) st
ructnode* t
emp=st art;
do{
pri
ntf
("%d"
,t
emp- >dat;
temp=t emp->next;
}while(
temp!=NULL) ;

(
(OPTI
ON_
C)) st
ructnode*
temp=st
art
;
do{
temp=t emp->next;
pri
ntf
("%d"
,t
emp- >dat;
}
while(
temp!=NULL) ;

(
(OPTI
ON_
D)) st
ructnode*
temp;
do{
temp=t emp->next;
pri
ntf
("%d"
,t
emp- >dat;
}
whi l
e(t
emp!=NULL) ;

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) ConsidertheSLLhavi
ngnelements.Whatwil
lbethe
ti
met akentoaddannodeattheendofli
nkedli
sti
f
Point
erisini
ti
all
ypoi
nti
ngt
of i
rstnodeoft
heli
st.

(
(OPTI
ON_
A)) O(
n-1)

(
(OPTI
ON_
B)) O(
1)
2
(
(OPTI
ON_
C)) O(
n)

(
(OPTI
ON_
D)) O(
n)

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
)
Whi
choft
hef
oll
owi
ngst
atementi
str
ue?

a.Usi
ngsingl
yli
nkedl
i
standci
rcul
arl
i
st,
i
tispossi
blet
otr
avel
s
backwar
ds.

b.tof
indt
hepredecessoriti
srequi
ret
otr
avel
sthel
i
stf
rom f
ir
st
nodei
ncaseofsinglyl
inkedli
st

(
(OPTI
ON_
A))
Onl
ya

(
(OPTI
ON_
B)) Onl
yb

(
(OPTI
ON_
C)) Bot
ha&b

(
(OPTI
ON_
D)) Noneofabov
e
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
)
Thedi
sadv
ant
agesofci
rcul
arl
i
nkedl
i
sti
s

(
(OPTI
ON_
A))
i
tispossi
blet
ogeti
ntoi
nfi
nit
eloop

(
(OPTI
ON_
B))
l
asti
spoi
nti
ngt
ofi
rstnode

(
(OPTI
ON_
C))
t
imeconsumi
ng

(
(OPTI
ON_
D))
r
equi
redmor
ememor
yspace

(
(CORRECT_
C
HOI
CE)) A
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
)
Deleti
onofanodeinalinkedl
i
sti
nvolv
eskeepi
ngt
rackof
addressofnodewhichcomeimmediatel
y

(
(OPTI
ON_
A))
af
tert
henodet
hati
stobedel
ete
(
(OPTI
ON_
B))
bef
oret
henodet
hati
stobedel
eted

(
(OPTI
ON_
C))
af
tert
hemi
ddl
enode

(
(OPTI
ON_
D))
Noneofabov
e

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
)
I
nadoubl
yli
nkedl
i
stt
rav
ersi
ngcomet
oahal
tat
:

(
(OPTI
ON_
A)) Nul
l
(
(OPTI
ON_
B))
f
ront

(
(OPTI
ON_
C))
Rear

(
(OPTI
ON_
D))
Rear
-1

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
)
LetPbeasinglyl
i
nkedli
st.LetQbethepoint
ertoan
i
nter
mediat
enodexi nt
hel i
st.Whati
stheworst
-case
ti
mecomplexit
yofthebestknownalgor
it
hm todelet
ethe
nodexfr
om theli
st?

(
(OPTI
ON_
A))
O(
1)

(
(OPTI
ON_
B)) O(
log2n)

(
(OPTI
ON_
C)) O(
logn)

(
(OPTI
ON_
D)) O(
n)

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
)
Whataretheti
mecomplexi
ti
esoffindi
ng8thel
ementfrom
begi
nningand8thel
ementfr
om endinasingl
yli
nkedl
ist?
Letnbe
thenumberofnodesinl
i
nkedli
st,
youmayassumet hatn>8.

(
(OPTI
ON_
A)) O(
1)andO(
n)

(
(OPTI
ON_
B)) O(
1)andO(
1)

(
(OPTI
ON_
C)) O(
n)andO(
1)
(
(OPTI
ON_
D))
O(
n)andO(
n)

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
)
.Consi
dert
hef
oll
owi
ngf
unct
iont
otr
aver
seal
i
nkedl
i
st.

v
oidtraverse(
str
uctNode* hea
{
 
  
while(
head->next!=NULL)
 
  
{
 
  
  
  
pri
ntf(
"%d ",
head->dat
;
 
  
  
  
head=head- >next
;
 
  
}
}

Whi
choft
hef
oll
owi
ngi
sFALSEaboutabov
efunct
ion?

(
(OPTI
ON_
A)) Thef
unct
ionmaycr
ashwhent
hel
i
nkedl
i
sti
sempt
y

(
(OPTI
ON_
B)) Thef
unct
iondoesn’
tpr
intt
hel
astnodewhent
hel
i
nkedl
i
sti
snot
empt
y

(
(OPTI
ON_
C)) Thef
unct
ioni
simpl
ement
edi
ncor
rect
lybecausei
tchangeshead

(
(OPTI
ON_
D)) Noneoft
heabov
e

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
)
Youaregivenpointerst
ofir
standlastnodesofasi
ngl
y
l
inkedli
st,whi
choft hefol
l
owingoperati
onsare
dependentonthelengthofthel
inkedli
st?

(
(OPTI
ON_
A)) Del
etet
hef
ir
stel
ement
(
(OPTI
ON_
B)) I
nser
tanewel
ementasaf
ir
stel
ement
(
(OPTI
ON_
C)) Del
etet
hel
astel
ementoft
hel
i
st
(
(OPTI
ON_
D))
Addanewel
ementatt
heendoft
hel
i
st

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
)
Giv
enpoi nt
ertoanodeXi nasingl
yli
nkedli
st.Onlyone
poi
nterisgiven,
poi
ntert
oheadnodei snotgi
v en,
canwe
del
etethenodeXf r
om givenl
i
nkedl i
st?
.

(
(OPTI
ON_
A)) Possi
blei
fXi
snotl
astnode
(
(OPTI
ON_
B))
Usefol
lowi
ngtwosteps1.Copyt
hedataofnextofXtoX.
2Delet
enextofX.Usefol
lowi
ngtwosteps1.Copyt
he
dat
aofnextofXtoX.2.Delet
enextofX.
(
(OPTI
ON_
C)) Possi
blei
fsi
zeofl
i
nkedl
i
sti
sodd

(
(OPTI
ON_
D)) Possi
blei
fXi
snotf
ir
stnode.
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
)
I
sitpossi
blet
ocreat
eadoubl
yli
nkedl
i
stusi
ngonl
yone
poi
nterwi
thever
ynode.

(
(OPTI
ON_
A)) NotPossi
ble
(
(OPTI
ON_
B)) Yes,
possi
blebyst
ori
ngXORofaddr
essesofpr
evi
ous
andnextnodes.
(
(OPTI
ON_
C)) Yes,
possi
blebyst
ori
ngXORofcur
rentnodeandnext
node
(
(OPTI
ON_
D))
Yes,
possi
blebyst
ori
ngXORofcur
rentnodeandpr
evi
ous
node

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
)
Intheworstcase,thenumberofcompar
isonsneededto
searchasingl
ylinkedli
stofl
engt
hnforagivenelement
i
s( GATECS2002)

(
(OPTI
ON_
A))
n

(
(OPTI
ON_
B)) n/
2

(
(OPTI
ON_
C)) .l
og2n
(
(OPTI
ON_
D)) l
og2n–1

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
choft
hef
oll
owi
ngsor
ti
ngal
gor
it
hmscanbeusedt
o
sor
tar
andom l
i
nkedl
i
stwi
thmi
nimum t
imecompl
exi
ty?

(
(OPTI
ON_
A)) I
nser
ti
onSor
t
(
(OPTI
ON_
B)) Qui
ckSor
t
(
(OPTI
ON_
C)) HeapSor
t
(
(OPTI
ON_
D)) Mer
geSor
t

(
(OPTI
ON_
E)) Al
labov
e

(
(CORRECT_
C E
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
choft
hef
oll
owi
ngpoi
ntsi
s/ar
etr
ueaboutLi
nkedLi
st
dat
astructurewhenitiscomparedwithar
ray
(
(OPTI
ON_
A)) Arr
ayshav ebett
ercachelocal
it
ythatcanmaket
hem
bet
teri
nt ermsofperformance.
(
(OPTI
ON_
B)) I
tiseasyt
oinser
tanddel
eteel
ement
sinLi
nkedLi
st
(
(OPTI
ON_
C)) Random accessi
snotal
l
owedi
nat
ypi
cal
impl
ement
ati
on
ofLi
nkedLi
sts
(
(OPTI
ON_
D)) Thesi
zeofar
rayhast
obepr
e-deci
ded,
li
nkedl
i
stscan
changethei
rsi
zeanyt
ime.
(
(OPTI
ON_
E)) Alloft
heabove

(
(CORRECT_
C E
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) atdoest
hef
oll
owi
ngf
unct
iondof
oragi
venLi
nked
Listwithfistnodeashead?
r
voidfun1(structnode*hea
{
 
 i
f (
head==NULL)
 
  
 return;
 
  
 
 fun1(head->next);
 
 printf
("%d ",head-
>dat;
}

(
(OPTI
ON_
A)) Pr
int
sal
lnodesofl
i
nkedl
i
sts
(
(OPTI
ON_
B)) Pr
int
sal
lnodesofl
i
nkedl
i
sti
nrev
erseor
der

(
(OPTI
ON_
C)) Pr
int
sal
ter
nat
enodesofLi
nkedLi
st

(
(OPTI
ON_
D)) Pr
int
sal
ter
nat
enodesi
nrev
erseor
der

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) E
ON) achNodecont
ainmi
nimum t
wof
iel
dsonef
iel
dcal
l
ed
dat
afi
eldt
ost
oredat
aAnot
herf
iel
disoft
ype_
___
___
__.

(
(OPTI
ON_
A)) Poi
ntert
ochar
act
er

(
(OPTI
ON_
B)) poi
ntert
oani
nteger

(
(OPTI
ON_
C)) poi
ntert
onode

(
(OPTI
ON_
D)) Poi
ntert
ocl
ass

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) L
ON) i
nkedl
i
sti
sgener
all
yconsi
der
edasanexampl
eof
__
___
____t
ypeofmemor
yal
l
ocat
ion.
(
(OPTI
ON_
A)) Compil
eTi
me

(
(OPTI
ON_
B)) Dy
nami
c
(
(OPTI
ON_
C)) St
ati
c

(
(OPTI
ON_
D)) Noneoft
hese

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
choft
hef
oll
owi
ngi
snotat
ypeofLi
nkedLi
st?

(
(OPTI
ON_
A)) Hy
bri
dLi
nkedLi
st

(
(OPTI
ON_
B)) Si
ngl
yLi
nkedLi
st

(
(OPTI
ON_
C)) Doubl
yLi
nkedLi
st

(
(OPTI
ON_
D)) Ci
rcul
arLi
nkedLi
st

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Al
ON) i
nearcol
l
ect
ionofdat
ael
ementgi
venbymeanof
point
eri
scal
l
ed
(
(OPTI
ON_
A)) Stack

(
(OPTI
ON_
B)) Li
nkedLi
st

(
(OPTI
ON_
C)) Queue
(
(OPTI
ON_
D)) Gr
aph

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) .
ON) Gener
all
ycol
l
ect
ionofNodesi
scal
l
edas_
___
___
___

(
(OPTI
ON_
A)) Poi
nter

(
(OPTI
ON_
B)) St
ack

(
(OPTI
ON_
C)) Li
nkedl
i
st

(
(OPTI
ON_
D)) Heap

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) nal
i
nkedl
i
stwi
thnnodes,
thet
imet
akent
oinser
tan
el
ementaf
teranel
ementpoi
ntedby
somepoi
nteri
s

(
(OPTI
ON_
A)) O(
1)

(
(OPTI
ON_
B)) O(
logn)

(
(OPTI
ON_
C)) O(
n)

(
(OPTI
ON_
D)) O(
n1ogn)
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) naci
rcul
arl
i
nkedl
i
st

(
(OPTI
ON_
A)) component
sar
eal
ll
inkedt
oget
heri
nsomesequent
ial
manner

(
(OPTI
ON_
B)) t
her
eisnobegi
nni
ngandnoend

(
(OPTI
ON_
C)) component
sar
ear
rangedhi
erar
chi
cal
l
y.

(
(OPTI
ON_
D)) f
orwar
dandbackwar
dtr
aver
sal
wit
hint
hel
i
sti
sper
mit
ted

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Co
ON) nsi
deral
i
nkedl
i
stofnel
ement
s.Whati
sthet
ime
takent
oinsertanel
ementaf
teranel
ementpoi
ntedby
somepointer
?

(
(OPTI
ON_
A)) O(
1)

(
(OPTI
ON_
B)) O(
log2n)

(
(OPTI
ON_
C)) O(
n)

(
(OPTI
ON_
D)) O(
nlog2n)
(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
choft
hef
oll
owi
ngoper
ati
onsi
sper
for
medmor
e
ef
fi
cient
lybydoubl
yli
nkedl
i
stt
hanbysi
ngl
yli
nkedl
i
st?

(
(OPTI
ON_
A)) Del
eti
nganodewhosel
ocat
ioni
ngi
ven

(
(OPTI
ON_
B)) Sear
chi
ngofanunsor
tedl
i
stf
oragi
veni
tem

(
(OPTI
ON_
C)) I
nver
ti
nganodeaf
tert
henodewi
thgi
venl
ocat
ion

(
(OPTI
ON_
D)) Tr
aver
singal
i
stt
opr
ocesseachnode

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Al
ON) i
nearcol
l
ect
ionofdat
ael
ement
swher
ethel
i
nearnode
i
sgivenbymeansofpoi
nteri
scal
l
ed
(
(OPTI
ON_
A)) l
inkedli
st

(
(OPTI
ON_
B)) nodel
i
st

(
(OPTI
ON_
C)) pr
imi
ti
vel
i
st

(
(OPTI
ON_
D)) Noneoft
hese

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) E
ON) achnodecont
ainmi
nimum t
wof
iel
dsonef
iel
dcal
l
ed
dat
afi
eldt
ost
oredatAnot
herf
iel
disoft
ype_
___
___
__
(
(OPTI
ON_
A)) Poi
ntert
ochar
act
er
(
(OPTI
ON_
B)) Poi
ntert
oCl
ass
(
(OPTI
ON_
C)) Poi
ntert
oNode
(
(OPTI
ON_
D)) Poi
ntert
oInt
eger
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) L
ON) i
nkedl
i
sti
sgener
all
yconsi
der
edasanexampl
eof
__
___
_____
___t
ypeofmemor
yal
l
ocat
ion.
(
(OPTI
ON_
A)) Compil
eTime

(
(OPTI
ON_
B)) Noneoft
hese

(
(OPTI
ON_
C)) St
ati
c

(
(OPTI
ON_
D)) dynami
c

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTI
ONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Wh
ON) i
choft
hef
oll
owi
ngi
snotat
ypeofLi
nkedLi
st?

(
(OPTI
ON_
A)) DLL
(
(OPTI
ON_
B)) Hy
bri
dLi
nkedl
i
st

(
(OPTI
ON_
C)) SLL

(
(OPTI
ON_
D)) Ci
rcul
arl
i
nkedl
i
st

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) AL
ON) i
nearcol
l
ect
ionofdat
ael
ementgi
venbymeanof
point
eri
scal
l
ed_
___
___
_?
(
(OPTI
ON_
A)) Graph

(
(OPTI
ON_
B)) Queue

(
(OPTI
ON_
C)) St
ack

(
(OPTI
ON_
D)) Li
nkedl
i
st

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ge
ON) ner
all
ycol
l
ect
ionofnodesi
scal
l
edas_
___
___
_?

(
(OPTI
ON_
A)) Heap

(
(OPTI
ON_
B)) Li
nkedl
i
st

(
(OPTI
ON_
C)) poi
nter

(
(OPTI
ON_
D)) St
ack

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ti
ON) mer
equi
ret
ofi
ndanyel
ementoft
hel
i
nkedl
i
sti
s
_
___
___
_?

(
(OPTI
ON_
A)) Noneoft
hese

(
(OPTI
ON_
B)) O(
n)

(
(OPTI
ON_
C)) O(
1)
2
(
(OPTI
ON_
D)) O(
n)

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI ) Th
ON) econcat
enat
ionoft
wol
i
stsi
stobeper
for
medi
nO(
1)
ti
me.Whi
chofthef
oll
owi
ngi
mpl
ement
ati
onsofal
i
st
coul
dbeused?

(
(OPTI
ON_
A)) SLL

(
(OPTI
ON_
B)) DLL

(
(OPTI
ON_
C)) Ar
rayi
mpl
ement
ati
onofLi
st

(
(OPTI
ON_
D)) Ci
rcul
arDLL

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Co
ON) nsi
deral
i
nkedl
i
stofnel
ement
s.whati
sthet
ime
takentoi
nser
tanel
ementaf
terel
ementpoi
ntedbysame
point
er?
(
(OPTI
ON_
A)) O(
1)
(
(OPTI
ON_
B)) O(
logn)

(
(OPTI
ON_
C)) O(
n)

(
(OPTI
ON_
D)) O(
n-1)

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Po
ON) i
nteri
spoi
nti
ngt
othef
ir
stel
ementoft
henodet
hen
t
imer equi
redt
oinser
tel
ementt
osecondposi
ti
oni
s
__
___ _
____
_?
2
(
(OPTI
ON_
A)) O(n)

(
(OPTI
ON_
B)) O(
1)

(
(OPTI
ON_
C)) O(
n-1)

(
(OPTI
ON_
D)) O(
n)

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) St
ON) acki
sal
soknownas.
..
..
..
..
..
..
..
dat
ast
ruct
ure

(
(OPTI
ON_
A)) LI
FO

(
(OPTI
ON_
B)) FI
FO

(
(OPTI
ON_
C)) UFO

(
(OPTI
ON_
D)) CI
FO

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) St
ON) acki
sal
soknownas.
..
..
..
..
..
..
..
.dat
ast
ruct
ure

(
(OPTI
ON_
A)) FI
LO

(
(OPTI
ON_
B)) FI
FO

(
(OPTI
ON_
C)) UFO

(
(OPTI
ON_
D)) CI
FO

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) ……..
..
..
…….
isi
ntegr
alpar
tof“
funct
ioncal
landr
etur
n”pr
ocessi
n
C/C++

(
(OPTI
ON_
A)) Ar
ray

(
(OPTI
ON_
B)) Li
st

(
(OPTI
ON_
C)) St
ack

(
(OPTI
ON_
D)) Queue

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Local
ON) v
ari
abl
esofanyf unct
iondur
ingpr
ogr
am execut
ionar
e
stor
edon..
..
..
..
..
..
..
..
..
.

(
(OPTI
ON_
A)) Sy
stem St
ack

(
(OPTI
ON_
B)) Sy
stem Ar
ray

(
(OPTI
ON_
C)) Sy
stem Queue

(
(OPTI
ON_
D)) Har
ddi
sk

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Addi
nganel
ementt
ost
acki
sknownas.
..
..
..
..
..
..
..
oper
ati
on

(
(OPTI
ON_
A)) PUSH

(
(OPTI
ON_
B)) POP

(
(OPTI
ON_
C)) TOP

(
(OPTI
ON_
D)) ADDI
TION

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Remov
inganel
ementf
rom st
acki
sknownas.
..
..
..
..
..
..
..
oper
ati
on

(
(OPTI
ON_
A)) PUSH

(
(OPTI
ON_
B)) POP

(
(OPTI
ON_
C)) TOP

(
(OPTI
ON_
D)) ADDI
TION

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Theendatwhi
chel
ement
sar
eaddedt
ost
acki
sknownas…………….
.

(
(OPTI
ON_
A)) TOP
(
(OPTI
ON_
B)) POP

(
(OPTI
ON_
C)) REAR

(
(OPTI
ON_
D)) FRONT

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Theendfr
om whi
chel
ement
sar
eremov
edf
rom st
acki
sknown
as……………..

(
(OPTI
ON_
A)) TOP

(
(OPTI
ON_
B)) POP

(
(OPTI
ON_
C)) REAR

(
(OPTI
ON_
D)) FRONT

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) St
ackcanbei
mpl
ement
edwi
th.
..
..
..
..
..
..
..
..

(
(OPTI
ON_
A)) Ar
ray

(
(OPTI
ON_
B)) Li
nkedLi
st

(
(OPTI
ON_
C)) Bot
hAandB

(
(OPTI
ON_
D)) Noneoft
heabov
e
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) PUSHoperat
ionofastackimpl
ement
edwi
thSi
ngl
yLi
nkedLi
st
(SLL)i
snot
hingbut
..
..
..
..
..
.

(
(OPTI
ON_
A)) Addatbegi
nofSLL

(
(OPTI
ON_
B)) AddatendofSLL

(
(OPTI
ON_
C)) Addatmi
ddl
eofSLL

(
(OPTI
ON_
D)) Noneoft
heabov
e

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) POPoper
ati
onofast acki
mpl
ement
edwi
thSi
ngl
yLi
nkedLi
st(
SLL)
i
snot
hingbut
..
..
..
..
..
.

(
(OPTI
ON_
A)) Del
eteatbegi
nofSLL

(
(OPTI
ON_
B)) Del
eteatendofSLL

(
(OPTI
ON_
C)) Del
eteatmi
ddl
eofSLL

(
(OPTI
ON_
D)) Noneoft
heabov
e

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Fol
lowi
ngdatast
ruct
ureisusedt
ocheckwhet
heranexpr
essi
on
hasmatchi
ngpar
enthesi
sornot.
(
(OPTI
ON_
A)) Ar
ray

(
(OPTI
ON_
B)) Li
nkedLi
st

(
(OPTI
ON_
C)) Queue

(
(OPTI
ON_
D)) St
ack

(
(CORRECT_
CH D
OI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

1
(
(MARKS))
(
1/2/
3..
.)

(
(QUESTI
ON)
) Foreval
uat
ionofpost
fi
xexpr
essi
on……………….
.dat
ast
ruct
urei
s
used.

(
(OPTI
ON_
A)) Ar
ray

(
(OPTI
ON_
B)) Li
nkedLi
st

(
(OPTI
ON_
C)) Queue

(
(OPTI
ON_
D)) St
ack

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Anarraywhichi
srest
ri
ctedforreadandwr
it
eusageatal
ltheends
exceptoneendi
snothingbut…………

(
(OPTI
ON_
A)) Ar
ray

(
(OPTI
ON_
B)) Rest
ri
ctedAr
ray

(
(OPTI
ON_
C)) Queue

(
(OPTI
ON_
D)) St
ack

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) ASi
nglyl
inkedli
sthasapoint
erpoint
ingt
oit
sfi
rstelement
.Ifwe
r
est
ri
ctadditi
onanddelet
ionofel
ementsonl
yatfi
rstposi
ti
onthen
i
tgi
vesaccessordersameas…….

(
(OPTI
ON_
A)) Sat
ck

(
(OPTI
ON_
B)) Si
ngl
yLi
nkedLi
st

(
(OPTI
ON_
C)) Queue

(
(OPTI
ON_
D)) Tr
ee

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) ASi
nglyl
inkedli
sthasapoi
nterpoi
nti
ngtoit
sfi
rstelement
.Ifwe
r
est
ri
ctadditi
onanddel
eti
onofelementsonl
yatfi
rstposi
ti
onthen
i
tgi
ves..
..
..
…….

(
(OPTI
ON_
A)) LI
FOor
der

(
(OPTI
ON_
B)) FI
FOor
der

(
(OPTI
ON_
C)) Random or
der

(
(OPTI
ON_
D)) UFOOr
der

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)
) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) ASi
nglyl
inkedli
sthasapoi
nterpoi
nti
ngtoit
sfi
rstelement
.Ifwe
r
est
ri
ctadditi
onanddel
eti
onofelementsonl
yatfi
rstposi
ti
onthen
i
tgi
ves..
..
..
…….

(
(OPTI
ON_
A)) FI
LOor
der

(
(OPTI
ON_
B)) LI
FOor
der

(
(OPTI
ON_
C)) Random or
der

(
(OPTI
ON_
D)) Bot
hAandB

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Thecasewit
hwhi
chr
ecur
siont
ermi
nat
esi
sknownas.
..
..
..
..
..
.of
recur
sion

(
(OPTI
ON_
A)) BASECASE

(
(OPTI
ON_
B)) BESTCASE

(
(OPTI
ON_
C)) AVERAGECASE

(
(OPTI
ON_
D)) WORSTCASE

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
) Recur
sionwor
kswi
tht
hehel
pof.
..
..
..
..
..
..
..
..
..
..
..
dat
a
st
ruct
ure

(
(OPTI
ON_
A)) Ar
ray

(
(OPTI
ON_
B)) Li
st
(
(OPTI
ON_
C)) Queue
(
(OPTI
ON_
D)) St
ack
(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Sy
stem St
acki
spar
tof
………….
..

(
(OPTI
ON_
A)) RAM

(
(OPTI
ON_
B)) ROM

(
(OPTI
ON_
C)) Har
ddi
sk

(
(OPTI
ON_
D)) Cache

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
) Whenaf
unct
ioncal
l
sit
sel
f,i
tisknownas……….

(
(OPTI
ON_
A)) Sel
fRef
erent
ial

(
(OPTI
ON_
B)) Recur
sion

(
(OPTI
ON_
C)) Repeat
edCal
l

(
(OPTI
ON_
D)) Loop

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) I
ndi
rectr
ecur
sioni
sal
socal
l
edas……………………

(
(OPTI
ON_
A)) Mut
ual
Recur
sion

(
(OPTI
ON_
B)) Redi
rectRecur
sion

(
(OPTI
ON_
C)) Tai
lRecur
sion

(
(OPTI
ON_
D)) Noneoft
heAbov
e

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Mut
ual
recur
sioni
sal
socal
l
edas……………………

(
(OPTI
ON_
A)) I
ndi
rectRecur
sion
(
(OPTI
ON_
B)) Redi
rectRecur
sion

(
(OPTI
ON_
C)) Tai
lRecur
sion

(
(OPTI
ON_
D)) Noneoft
heAbov
e

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Arecur
siv
efuncti
onissai
dtobe…………….r
ecur
sivei
fther
eareno
pendi
ngoper
ationst
obeperfor
medonret
urnfr
om arecursi
vecal
l
.

(
(OPTI
ON_
A)) End

(
(OPTI
ON_
B)) Tai
l

(
(OPTI
ON_
C)) Li
near

(
(OPTI
ON_
D)) Bi
nar
y

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)
(
(QUESTI
ON)
) Thesi
mpl
estf
orm ofRecur
sioni
s…………………

(
(OPTI
ON_
A)) Li
nearRecur
sion

(
(OPTI
ON_
B)) I
ndi
rectRecur
sion

(
(OPTI
ON_
C)) Mut
ual
Recur
sion

(
(OPTI
ON_
D)) Tai
lRecur
sion

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) Fact
(n)

Begi
n

I
f(n<=1)r
etur
n1;

El
ser
etur
nn*f
act
(n-
1)

End

(
(OPTI
ON_
A)) Funct
ioni
sexampl
eofDi
rectRecur
sion

(
(OPTI
ON_
B)) Funct
ioni
sexampl
eofI
ndi
rectRecur
sion

(
(OPTI
ON_
C)) Funct
ioni
sexampl
eofMut
ual
Recur
sion

(
(OPTI
ON_
D)) Bot
hAandB

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) Fact
(n)

Begi
n

I
f(n<=1)r
etur
n1;

El
ser
etur
nn*Dummy(
n-1)

End

Dummy(
n)

Begi
n

Fact
(n)

End

(
(OPTI
ON_
A)) Funct
ioni
sexampl
eofDi
rectRecur
sion

(
(OPTI
ON_
B)) Funct
ioni
sexampl
eofI
ndi
rectRecur
sion

(
(OPTI
ON_
C)) Funct
ioni
sexampl
eofMut
ual
Recur
sion

(
(OPTI
ON_
D)) Bot
hCandB

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)
(
(QUESTI
ON)
) Ast
ackf
ramei
nrecur
sionconsi
stsof
..
..
..
..
..
..
..
..
.

(
(OPTI
ON_
A)) Par
amet
erst
obepr
ocessedbyt
hecal
l
edf
unct
ion

(
(OPTI
ON_
B)) Local
var
iabl
esi
nthecal
l
ingf
unct
ion

(
(OPTI
ON_
C)) Ther
etur
naddr
ess

(
(OPTI
ON_
D)) Al
labov
e

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) nrecur
siv
ecal
lther
etur
naddr
essofcal
l
edf
unct
ioni
s
st
oredon.
..
..
..
..
..
..

(
(OPTI
ON_
A)) St
ackf
rame

(
(OPTI
ON_
B)) Queue

(
(OPTI
ON_
C)) Tr
ee

(
(OPTI
ON_
D)) Cache

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whenrecur
siv
ecal
li
sthel
astst
atementi
nthef
unct
ion,
iti
s
cal
l
ed………………….

(
(OPTI
ON_
A)) Endr
ecur
sion

(
(OPTI
ON_
B)) Tai
lRecur
sion

(
(OPTI
ON_
C)) BaseCase

(
(OPTI
ON_
D)) I
ndi
rectRecur
sion

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) ef
oll
owi
ngoper
ati
oncannotbeper
for
medonst
ack
wi
thoutr
emov
ingel
ement
sfr
om i
t.
(
(OPTI
ON_
A)) Sor
ti
ng

(
(OPTI
ON_
B)) Pr
int
ing

(
(OPTI
ON_
C)) Tr
aver
sal

(
(OPTI
ON_
D)) Al
labov
e

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) esi
tuat
ionwheni
nal
i
nkedi
mpl
ement
ati
onofst
ack
TOP=NULLi
s..
..
..
..
..
..

(
(OPTI
ON_
A)) Under
fl
ow

(
(OPTI
ON_
B)) Ov
erf
low

(
(OPTI
ON_
C)) Housef
ul

(
(OPTI
ON_
D)) Sat
urat
ed

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) esi
tuat
ionwheni
nal
i
nkedi
mpl
ement
ati
onofst
ack,
whi
l
eaddi
ngnewel
ement
,memor
yal
l
ocat
ionf
ail
ure
occur
sitcanbeconsi
der
edas.
..
..
.

(
(OPTI
ON_
A)) Under
fl
ow

(
(OPTI
ON_
B)) Ov
erf
low

(
(OPTI
ON_
C)) Housef
ul

(
(OPTI
ON_
D)) Sat
urat
ed

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) esi
tuat
ionwheni
nal
i
nkedi
mpl
ement
ati
onofst
ack
ov
erf
lowoccur
s,wecannotper
for
m..
..
..
..
..
..
..

(
(OPTI
ON_
A)) PUSHoper
ati
on

(
(OPTI
ON_
B)) POPoper
ati
on

(
(OPTI
ON_
C)) Bot
hAandB

(
(OPTI
ON_
D)) Noneofabov
e

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

1
(
(MARKS))
(
1/2/
3..
.)

(
(QUESTI ) Th
ON) esi
tuat
ionwheni
nal
i
nkedi
mpl
ement
ati
onofst
ack
ov
erf
lowoccur
s;i
tmaybebecauseof
..
..
..
..
..
..
..

(
(OPTI
ON_
A)) Nospaceav
ail
abl
einst
ack

(
(OPTI
ON_
B)) Memor
yAl
l
ocat
ionFai
l
ure

(
(OPTI
ON_
C)) Bot
hAandB

(
(OPTI
ON_
D)) Noneofabov
e
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) I
nlinkedi
mplementat
ionofstackift
opi
stheonl
ypoi
nterandi
ts
v
alueisNULL,i
tindi
cates.
..
..
..
..
..
..

(
(OPTI
ON_
A)) St
ackUnder
fl
ow

(
(OPTI
ON_
B)) St
ackOv
erf
low

(
(OPTI
ON_
C)) St
acknotCr
eat
ed

(
(OPTI
ON_
D)) AorC

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) Foranempt
ystacki
fweexecut
efol
l
owi
ngoper
ati
onswhatwi
l
lbe
stat
eoft
hestack
POP()
PUSH(
5)
PUSH(
2)
POP()

(
(OPTI
ON_
A)) Under
fl
ow,
TOP=5

(
(OPTI
ON_
B)) Under
fl
ow,
TOP=2
(
(OPTI
ON_
C)) TOP=2

(
(OPTI
ON_
D)) TOP=5

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Fol
ON) lowi
ngi
spr
ecedencef
reef
orm ofexpr
essi
on:

(
(OPTI
ON_
A)) I
nfi
x

(
(OPTI
ON_
B)) Pr
efi
x

(
(OPTI
ON_
C)) Post
fi
x

(
(OPTI
ON_
D)) Bot
hBandC

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) WedonotneedBODMASr
ON) ulef
oreval
uat
ionoft
he
………….
.
(
(OPTI
ON_
A)) I
nfi
xexpr
essi
on

(
(OPTI
ON_
B)) Ful
l
ypar
ent
hesi
zedexpr
essi
on

(
(OPTI
ON_
C)) Pr
efi
xexpr
essi
on

(
(OPTI
ON_
D)) Post
fi
xexpr
essi
on

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Post
fi
xexpr
essi
oni
s………………….
.f
orm ofexpr
essi
on

(
(OPTI
ON_
A)) Par
ent
hesi
sfr
ee

(
(OPTI
ON_
B)) Pr
ecedencef
ree

(
(OPTI
ON_
C)) Sy
ntaxf
ree

(
(OPTI
ON_
D)) Bot
hAandB

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Pr
efi
xexpr
essi
oni
s………………….
.f
orm ofexpr
essi
on

(
(OPTI
ON_
A)) Par
ent
hesi
sfr
ee
(
(OPTI
ON_
B)) Pr
ecedencef
ree

(
(OPTI
ON_
C)) Sy
ntaxf
ree

(
(OPTI
ON_
D)) Bot
hAandB

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Wel
lfor
mednessofpar
ent
hesi
sischeckedusi
ng…………

(
(OPTI
ON_
A)) Li
st

(
(OPTI
ON_
B)) Queue

(
(OPTI
ON_
C)) St
ack

(
(OPTI
ON_
D)) Tr
ee

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) St
ri
ngr
ever
sal
canbedoneusi
ng………………

(
(OPTI
ON_
A)) Li
st

(
(OPTI
ON_
B)) Queue
(
(OPTI
ON_
C)) St
ack

(
(OPTI
ON_
D)) Tr
ee

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Deci
maltobi
nar
ynumberconv
ersi
oni
sdoneusi
ng…………….
dat
a
st
ruct
ure

(
(OPTI
ON_
A)) Li
st

(
(OPTI
ON_
B)) Queue

(
(OPTI
ON_
C)) St
ack

(
(OPTI
ON_
D)) Tr
ee

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Post
fi
xexpr
essi
oni
smer
elyr
ever
seofpr
efi
xexpr
essi
on

(
(OPTI
ON_
A)) Tr
ue

(
(OPTI
ON_
B)) Fal
se
(
(OPTI
ON_
C)) Dependsonexpr
essi
on

(
(OPTI
ON_
D)) Noneofabov
e

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Pr
efi
xexpr
essi
oni
smer
elyr
ever
seofpost
fi
xexpr
essi
on

(
(OPTI
ON_
A)) Tr
ue

(
(OPTI
ON_
B)) Fal
se

(
(OPTI
ON_
C)) Dependsonexpr
essi
on

(
(OPTI
ON_
D)) Noneofabov
e

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Post
fi
xfor
mismor
esui
tabl
efor
………….
.asi
tispr
ecedencef
ree.

(
(OPTI
ON_
A)) Comput
er
(
(OPTI
ON_
B)) Human

(
(OPTI
ON_
C)) Bot
h

(
(OPTI
ON_
D)) Noneofabov
e

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) nar r
ayi mplementat
ionofst
ackTOPi
sgener
all
y
i
nit
ializedto………..

(
(OPTI
ON_
A)) 0

(
(OPTI
ON_
B)) 1

(
(OPTI
ON_
C)) -
1

(
(OPTI
ON_
D)) N

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Ret
ON) urn(
stack[
top]
)mustbei
nst
ruct
ioni
nfol
lowi
ng
funct
ion
(
(OPTI
ON_
A)) PUSH(
Add)

(
(OPTI
ON_
B)) POP(
Remov
e)

(
(OPTI
ON_
C)) TOP(
foraccessi
ngTOPv
alue)

(
(OPTI
ON_
D)) Noneofabov
e

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whatdat
astruct
urewouldyoumostl
yli
kel
yseei
nanonr
ecur
siv
e
i
mplementat
ionofarecur
siv
ealgor
it
hm

(
(OPTI
ON_
A)) Li
nkedl
i
st

(
(OPTI
ON_
B)) Ar
ray

(
(OPTI
ON_
C)) St
ack

(
(OPTI
ON_
D)) Queue

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) Thepost
fi
xfor
m ofA*
B+C/
Dis.
..
..
..
..
..
..
..
..
..
..
..
..
..
.

(
(OPTI
ON_
A)) *
AB/
CD+
(
(OPTI
ON_
B)) AB*
CD/
+

(
(OPTI
ON_
C)) A*
BC+/
D

(
(OPTI
ON_
D)) ABCD+/
*

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Thepr
ON) efi
xfor
m ofA-
B/(
C*D⋀E)i
s

(
(OPTI
ON_
A)) -
/*⋀ACBDE

(
(OPTI
ON_
B)) -
ABCD*
⋀DE

(
(OPTI
ON_
C)) -
A/B*
C⋀DE

(
(OPTI
ON_
D)) -
A/BC*
⋀DE

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whatistheresul
toft
hef
oll
owi
ngoper
ati
on
Top(Push(S,X))

(
(OPTI
ON_
A)) X

(
(OPTI
ON_
B)) NULL
(
(OPTI
ON_
C)) S

(
(OPTI
ON_
D)) None

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) Thepr
efi
xfor
m ofani
nfi
xexpr
essi
onp+q-r*t

(
(OPTI
ON_
A)) +pq-*
rt

(
(OPTI
ON_
B)) -+pqr*t

(
(OPTI
ON_
C)) -+pq*r
t

(
(OPTI
ON_
D)) -+*pqr
t

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Ther
ON) esul
tofev
aluat
ingt
hepost
fi
xexpr
essi
on5,
4,6,
+,*
,4,
9,
3,/
,+,*is

(
(OPTI
ON_
A)) 600

(
(OPTI
ON_
B)) 350

(
(OPTI
ON_
C)) 650

(
(OPTI
ON_
D)) 588
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) Conver
tt hef
oll
owinginfi
xexpressi
onsi
ntoi
ts
equi
valentpost
fixexpr
essions
(
A+B⋀D)/(
E-F) +G
(
(OPTI
ON_
A)) (
ABD⋀+EF- /G+)

(
(OPTI
ON_
B)) (
ABD+⋀EF-/G+)

(
(OPTI
ON_
C)) (
ABD⋀+EF/
-G+)

(
(OPTI
ON_
D)) None

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) Conv
ertt
hef
oll
owi
ngI
nfi
xexpr
essi
ont
oPost
fi
xfor
m usi
ngast
ack

x+y*z+(p*q+r )*s,Fol
lowusual
precedencer
uleandassume
t
hatt
heexpr
essi
onislegal
.

(
(OPTI
ON_
A)) xy
z*+pq*
r+s*
+

(
(OPTI
ON_
B)) xy
z*+pq*
r+s+*

(
(OPTI
ON_
C)) xy
z+*
pq*
r+s*
+

(
(OPTI
ON_
D)) A
(
(CORRECT_
C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whichoft
hefol
lowingst
atement
(s)aboutst
ackdat
ast
ruct
ure
i
s/areNOTcorr
ect?

(
(OPTI
ON_
A)) St
ackdat
ast
ruct
urecanbei
mpl
ement
edusi
ngl
i
nkedl
i
st

(
(OPTI
ON_
B)) Newnodecanonl
ybeaddedatt
het
opoft
hest
ack

(
(OPTI
ON_
C)) St
acki
stheFI
FOdat
ast
ruct
ure

(
(OPTI
ON_
D)) Thel
astnodeatt
hebot
tom oft
hest
ackhasaNULLl
i
nk

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Consi
dert
heli
nkedl
istimpl
ement
ati
onofastack.Whi
choft
he
fol
l
owingnodei
sconsider
edasTopoft
hestack?

(
(OPTI
ON_
A)) Fi
rstnode

(
(OPTI
ON_
B)) Lastnode

(
(OPTI
ON_
C)) Anynode

(
(OPTI
ON_
D)) Mi
ddl
enode

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) Consi
derthefol
lowingoperat
ionperf
ormedonast ackofsi
ze5.
Push(
1);Pop();Push(2);Push(3)
;Pop()
;Push(4);
Pop()
;Pop(); Push(5)
;Aft
erthecompleti
onofall
operati
on,t
heno
ofel
ementpresentonstackare

(
(OPTI
ON_
A)) 1

(
(OPTI
ON_
B)) 2

(
(OPTI
ON_
C)) 3

(
(OPTI
ON_
D)) 4

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

1
(
(MARKS))
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whi
choft
hef
oll
owi
ngi
snotani
nher
entappl
i
cat
ionofst
ack?

(
(OPTI
ON_
A)) Rev
ersi
ngast
ri
ng

(
(OPTI
ON_
B)) Ev
aluat
ionofpost
fi
xexpr
essi
on

(
(OPTI
ON_
C)) I
mpl
ement
ati
onofr
ecur
sion

(
(OPTI
ON_
D)) Jobschedul
i
ng

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whichoft
hefol
l
owingoperat
iont
akewor
stcasel
i
neart
imei
nthe
ar
rayimpl
ement
ati
onofstack?

(
(OPTI
ON_
A)) Push

(
(OPTI
ON_
B)) Pop

(
(OPTI
ON_
C)) I
sEmpt
y

(
(OPTI
ON_
D)) None

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Thet
ypeofexpr
essi
oni
nwhi
choper
atorsucceedsi
tsoper
andsi
s

(
(OPTI
ON_
A)) I
nfi
xExpr
essi
on

(
(OPTI
ON_
B)) pr
efi
xExpr
essi
on

(
(OPTI
ON_
C)) post
fi
xExpr
essi
on

(
(OPTI
ON_
D)) None

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)
) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whi
choft
hef
oll
owi
ngappl
i
cat
iongener
all
yuseast
ack?

(
(OPTI
ON_
A)) Par
ent
hesi
sbal
anci
ngpr
ogr
am

(
(OPTI
ON_
B)) Sy
ntaxanal
yzeri
ncompi
l
er

(
(OPTI
ON_
C)) Keepi
ngt
rackofl
ocal
var
iabl
esatr
unt
ime

(
(OPTI
ON_
D)) Al
loft
heabov
e

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) Consi
dert
hef
oll
owi
ngar
rayi
mpl
ement
ati
onofst
ack:
#defi
neMAX10
Str
uctSTACK
{
I
ntarr[MAX]
;
I
nttop=-1;
}

I
fthearr
ayindexst
art
swith0,t
hemaxi
mum v
alueoft
opwhi
ch
doesnotcausest
ackover
flowi
s?

(
(OPTI
ON_
A)) 8

(
(OPTI
ON_
B)) 9

(
(OPTI
ON_
C)) 10

(
(OPTI
ON_
D)) 11

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whati
sthemini
mum numberofst
acksofsi
zenr
equi
redt
o
i
mplementaqueueofsi
zen?

(
(OPTI
ON_
A)) 1

(
(OPTI
ON_
B)) 2

(
(OPTI
ON_
C)) 3

(
(OPTI
ON_
D)) 4

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Assumet
ON) hattheoperat
ors+,-
,Xarelef
tassoci
ati
veand⋀i s
ri
ghtassociat
ive.Theorderofpr
ecedence(f
rom hi
ghestt
o
l
owest
)is⋀,
X,+,
-.Thepost
fi
xexpr
essi
oncor
respondi
ngt
othe
i
nfi
xexpr
essi
ona+bXc–d⋀e⋀fi
s

(
(OPTI
ON_
A)) abcX+def⋀⋀-
 

(
(OPTI
ON_
B)) abcX+de⋀f
⋀- 

(
(OPTI
ON_
C)) ab+cXd–e⋀f

(
(OPTI
ON_
D)) -
+aXbc⋀⋀def

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) I
ftheelement
s“A”,“
B”,“C”and“
D”areplacedi
nastackandar
e
del
etedoneatati
me, i
nwhatorderwi
ll
theyberemoved?

(
(OPTI
ON_
A)) ABCD

(
(OPTI
ON_
B)) DCBA

(
(OPTI
ON_
C)) DCAB

(
(OPTI
ON_
D)) ABDC

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O B
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) Considert
heusual i
mplementati
onofparent
hesesbal
ancing
progr
am usingstack.Whati
st hemaximum numberofparent
heses
thatwil
lappearonstackatanyinst
anceofti
meduringtheanaly
sis
of(()(())(())) ?

(
(OPTI
ON_
A)) 1

(
(OPTI
ON_
B)) 2

(
(OPTI
ON_
C)) 3

(
(OPTI
ON_
D)) 4

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Post
ON) fixf
orm ofexpr
essi
on(
a+(
b*(
c/d)
-e)
)is………

(
(OPTI
ON_
A)) abcd*
/+e-

(
(OPTI
ON_
B)) abc*
d/+e-

(
(OPTI
ON_
C)) a*
bcd/
e-+

(
(OPTI
ON_
D)) abcd/
*e-
+

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Whi
ON) choft
hefoll
owi ngi
sessenti
alforconvert
ingt
he
i
nfi
xexpressi
ont opostf
ixf
orm eff
ici
ently?

(
(OPTI
ON_
A)) Oper
atorSt
ack

(
(OPTI
ON_
B)) Oper
andSt
ack

(
(OPTI
ON_
C)) Bot
hAandB

(
(OPTI
ON_
D)) Par
seTr
ee

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)
) 1
(
1/2/
3..
.)

(
(QUESTI ) St
ON) ackcanbeusef
ulf
ori
mpl
ement
ing…….

(
(OPTI
ON_
A)) Radi
xsor
t

(
(OPTI
ON_
B)) Br
eadt
hFi
rstSear
ch

(
(OPTI
ON_
C)) Recur
sion

(
(OPTI
ON_
D)) Noneofabov
e

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Whendat
ait
em i
spushedont
hest
ackt
henon–t
opel
ementoft
he
st
acki
s…….

(
(OPTI
ON_
A)) Mov
edupwar
ds

(
(OPTI
ON_
B)) Mov
eddownwar
ds

(
(OPTI
ON_
C)) Remai
nsatsamel
ocat
ion

(
(OPTI
ON_
D)) Noneofabov
e

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Post
ON) fi
xexpr
essi
oneval
uat
ionoper
ati
oni
s
perf
ormed………..

(
(OPTI
ON_
A)) Accor
dingt
opr
esetconv
ent
ion
(
(OPTI
ON_
B)) Fr
om l
eftt
ori
ght

(
(OPTI
ON_
C)) Asperpar
ent
hesi
s

(
(OPTI
ON_
D)) Ri
ghtt
olef
t

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Theempt
ON) ycondi
tioni
nar
rayi
mpl
ement
ati
onofst
ack
ischeckedby……………

(
(OPTI
ON_
A)) Top==-
1

(
(OPTI
ON_
B)) Top==0

(
(OPTI
ON_
C)) Fr
ont
==r
ear

(
(OPTI
ON_
D)) Fr
ont
<rear

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) fther
eisonl
yoneel
ementi
nst
ackt
hent
heval
ueof
t
opis……….
.

(
(OPTI
ON_
A)) 1

(
(OPTI
ON_
B)) 2

(
(OPTI
ON_
C)) -
1

(
(OPTI
ON_
D)) 0

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) I
ON) fMAXisthearraysi
zefori
mplementi
ngst
ack,t
hen
stackf
ullcondi
tioni
scheckedby…………

(
(OPTI
ON_
A)) Top>=MAX

(
(OPTI
ON_
B)) Top<Max

(
(OPTI
ON_
C)) Rear
==MAX

(
(OPTI
ON_
D)) Rear
<Max

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ther
ON) esultofat
tempttoremoveanel
ementf
rom
emptyst
ackiscal
led…………..

(
(OPTI
ON_
A)) St
ackov
erf
low

(
(OPTI
ON_
B)) St
ackunder
fl
ow

(
(OPTI
ON_
C)) St
ackexcept
ion

(
(OPTI
ON_
D)) Noneofabov
e

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Ther
ON) esultofat
temptt
oaddanel
ementt
oful
lst
ack
iscal
led…………..

(
(OPTI
ON_
A)) St
ackov
erf
low

(
(OPTI
ON_
B)) St
ackunder
fl
ow

(
(OPTI
ON_
C)) St
ackexcept
ion

(
(OPTI
ON_
D)) Noneofabov
e

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Thet
ON) imecompl
exi
tyofpost
fixexpr
essi
oneval
uat
ion
is……

(
(OPTI
ON_
A)) O(
n)

(
(OPTI
ON_
B)) O(
nlogn)

(
(OPTI
ON_
C)) O(
1)

(
(OPTI
ON_
D)) O(
logn)

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Thet
ON) imecompl
exi
tyofpopoper
ati
oni
s……

(
(OPTI
ON_
A)) O(
n)

(
(OPTI
ON_
B)) O(
nlogn)

(
(OPTI
ON_
C)) O(
1)

(
(OPTI
ON_
D)) O(
logn)

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Thet
ON) imecompl
exi
tyofPushoper
ati
oni
s……

(
(OPTI
ON_
A)) O(
n)

(
(OPTI
ON_
B)) O(
nlogn)

(
(OPTI
ON_
C)) O(
1)

(
(OPTI
ON_
D)) O(
logn)

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Thet
ON) imecompl
exi
tyofvi
ew_t
opoper
ati
oni
s……

(
(OPTI
ON_
A)) O(
n)

(
(OPTI
ON_
B)) O(
nlogn)

(
(OPTI
ON_
C)) O(
1)

(
(OPTI
ON_
D)) O(
logn)

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Whati
ON) sout
putoff
oll
owi
ngcode

Voi
dmai
n()

I
ntf
un(
int
,int
,int
)

Pr
int
f(“
%d”,
fun(
3,2,
6))
;

I
ntf
un(
intn,
inta,
intm)

I
f(n==1)Ret
urna;

El
ser
etur
nm+f
un(
n-1,
a,m)
;
}

(
(OPTI
ON_
A)) 20

(
(OPTI
ON_
B)) 14

(
(OPTI
ON_
C)) 10

(
(OPTI
ON_
D)) 8

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) The8queenspr
ON) obl
em canbesol
vedusi
ng….
.

(
(OPTI
ON_
A)) Di
vi
deandconquer

(
(OPTI
ON_
B)) Gr
eedyMet
hod

(
(OPTI
ON_
C)) Backt
racki
ng

(
(OPTI
ON_
D)) Noneofabov
e

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Post
ON) fixf
orm ofexpr
essi
onA+B+C+Di
s………

(
(OPTI
ON_
A)) AB+C+D+

(
(OPTI
ON_
B)) ABCD+++

(
(OPTI
ON_
C)) ABC++D+

(
(OPTI
ON_
D)) AB++CD+

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Pr
ON) efi
xfor
m ofexpr
essi
onA+B+C+Di
s………

(
(OPTI
ON_
A)) +++ABCD

(
(OPTI
ON_
B)) ABCD+++

(
(OPTI
ON_
C)) ABC++D+

(
(OPTI
ON_
D)) AB++CD+

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Post
ON) fixf
orm ofexpr
essi
onA*B*C*Di
s………

(
(OPTI
ON_
A)) AB*
C*D*

(
(OPTI
ON_
B)) ABCD*
**

(
(OPTI
ON_
C)) ABC*
*D*

(
(OPTI
ON_
D)) AB*
*CD*

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Pr
ON) efi
xfor
m ofexpr
essi
onA*B*C*Di
s………

(
(OPTI
ON_
A)) *
**ABCD

(
(OPTI
ON_
B)) *
*AB*
CD

(
(OPTI
ON_
C)) A*
*BC*
D

(
(OPTI
ON_
D)) AB*
*CD*

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) I
nfi
xfor
m ofex
pressi
on………AB+C+D+i
s……….

(
(OPTI
ON_
A)) A+B+C+D

(
(OPTI
ON_
B)) A+(
B+C)
+D

(
(OPTI
ON_
C)) (
A+B)
+(C+D)

(
(OPTI
ON_
D)) A+B+(
C+D)

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Expr
ON) essi
on+++ABCDi
sinf
ixf
orm of………….
.

(
(OPTI
ON_
A)) A+B+C+D

(
(OPTI
ON_
B)) (
A+B)
+(C+D)

(
(OPTI
ON_
C)) (
A+B)
+C+D

(
(OPTI
ON_
D)) A&C

(
(CORRECT_
C D
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Post
ON) fixf
orm ofexpr
essi
on(
A+B)
+(C+D)i
s

(
(OPTI
ON_
A)) AB+CD++

(
(OPTI
ON_
B)) ABCD+++

(
(OPTI
ON_
C)) ABC++D+

(
(OPTI
ON_
D)) AB++CD+

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Pr
ON) efi
xfor
m ofexpr
essi
on(
A+B)
+(C+D)i
s……….
.

(
(OPTI
ON_
A)) ++AB+CD

(
(OPTI
ON_
B)) +++ABCD

(
(OPTI
ON_
C)) ++ABC+D

(
(OPTI
ON_
D)) AB++CD+

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Pr
ON) efi
xfor
m ofAB+CD++i
s

(
(OPTI
ON_
A)) ++AB+CD

(
(OPTI
ON_
B)) +++ABCD

(
(OPTI
ON_
C)) ++ABC+D

(
(OPTI
ON_
D)) AB++CD+

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Post
ON) fixf
orm ofexpr
essi
onA+B+(
C+D)i
s……….
.

(
(OPTI
ON_
A)) AB+CD++

(
(OPTI
ON_
B)) AB+C+D+

(
(OPTI
ON_
C)) ABCD+++

(
(OPTI
ON_
D)) None

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Pr
ON) efi
xfor
m ofexpr
essi
onA+B+(
C+D)i
s……….
.

(
(OPTI
ON_
A)) ++AB+CD

(
(OPTI
ON_
B)) +++ABCD

(
(OPTI
ON_
C)) +AB++CD

(
(OPTI
ON_
D)) None

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Pr
ON) efi
xfor
m ofexpr
essi
onAB+CD++wi
llbe
(
(OPTI
ON_
A)) ++AB+CD

(
(OPTI
ON_
B)) +++ABCD

(
(OPTI
ON_
C)) +AB++CD

(
(OPTI
ON_
D)) None

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Post
ON) fixf
orm ofexpr
essi
on++AB+CDwi
llbe

(
(OPTI
ON_
A)) AB+CD++

(
(OPTI
ON_
B)) AB+C+D+

(
(OPTI
ON_
C)) ABCD+++

(
(OPTI
ON_
D)) None

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Post
ON) fixf
orm ofexpr
essi
onA+B*C-
Dis………

(
(OPTI
ON_
A)) AB+C*
D-

(
(OPTI
ON_
B)) ABC*
+D-

(
(OPTI
ON_
C)) AB+C*
D-

(
(OPTI
ON_
D)) AB*
CD+-

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Pr
ON) efi
xfor
m ofexpr
essi
onA+B*C-
Dis………

(
(OPTI
ON_
A)) +-A*
BCD

(
(OPTI
ON_
B)) -
+A*
BCD

(
(OPTI
ON_
C)) +A*
B-CD

(
(OPTI
ON_
D)) -
+*ABCD

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Post
ON) fixf
orm ofexpr
essi
on(
A+B)
*C-
Dis………

(
(OPTI
ON_
A)) ABC+*
D-

(
(OPTI
ON_
B)) AB+C*
D-

(
(OPTI
ON_
C)) ABC*
+D-

(
(OPTI
ON_
D)) ABCD*
+-

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Post
ON) fixf
orm ofexpr
essi
on(
A+B)
*(C-
D)i
s………

(
(OPTI
ON_
A)) AB+CD-
*

(
(OPTI
ON_
B)) AB+CD-
*

(
(OPTI
ON_
C)) AB+CD*
-

(
(OPTI
ON_
D)) AB+C*
D-

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Post
ON) fixf
orm ofexpr
essi
onA*B/C-
Dis………

(
(OPTI
ON_
A)) ABC/
*D-

(
(OPTI
ON_
B)) AB*
C/D-

(
(OPTI
ON_
C)) ABC*
/D-

(
(OPTI
ON_
D)) ABCD*
/-

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Post
ON) fixf
orm ofexpr
essi
onA*(
B/C)
-Di
s………

(
(OPTI
ON_
A)) ABC*
/D-

(
(OPTI
ON_
B)) ABC/
*D-

(
(OPTI
ON_
C)) ABC/
D*-

(
(OPTI
ON_
D)) ABC*
D/-

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Post
ON) fixf
orm ofexpr
essi
onA*B-
C/Di
s………
(
(OPTI
ON_
A)) ABCD*
/-

(
(OPTI
ON_
B)) AB*
CD/
-

(
(OPTI
ON_
C)) AB-
*CD/

(
(OPTI
ON_
D)) ABCD*
-/

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Post
ON) fixf
orm ofexpr
essi
onA+B-
C*D^Ei
s………

(
(OPTI
ON_
A)) AB+C*
DE-
^

(
(OPTI
ON_
B)) AB+CDE^
*-

(
(OPTI
ON_
C)) ABC*
+DE^
-

(
(OPTI
ON_
D)) AB+CD*
E^-

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Post
ON) fixf
orm ofexpr
essi
onA+(
B-C)
*D/Ei
s………

(
(OPTI
ON_
A)) ABC+-
D*E/

(
(OPTI
ON_
B)) ABC-
D*E/
+
(
(OPTI
ON_
C)) ABC-
+DE*
/

(
(OPTI
ON_
D)) ABC+-
DE*
/

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Post
ON) fixf
orm ofexpr
essi
on(
A+(
B-C)
)*D/Ei
s………

(
(OPTI
ON_
A)) ABC+-
D*E/

(
(OPTI
ON_
B)) ABC-
+D*
E/

(
(OPTI
ON_
C)) ABC-
+DE/
*

(
(OPTI
ON_
D)) ABC-
+DE*
/

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Post
ON) fixf
orm ofexpr
essi
on(
A+B-
C)*D^Ei
s………

(
(OPTI
ON_
A)) ABC+-
DE^
*

(
(OPTI
ON_
B)) AB+C-
DE^
*

(
(OPTI
ON_
C)) AB+C-
DE*
^

(
(OPTI
ON_
D)) ABC+-
DE^
*
(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Pr
ON) efi
xfor
m ofexpr
essi
on(
A+B)
*C-
Dis………

(
(OPTI
ON_
A)) *
-+ABCD

(
(OPTI
ON_
B)) -
*+ABCD

(
(OPTI
ON_
C)) -
+*ABCD

(
(OPTI
ON_
D)) *
+AB-
CD

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Pr
ON) efi
xfor
m ofexpr
essi
on(
A+B)
*(C-
D)i
s………

(
(OPTI
ON_
A)) +*
AB-
CD

(
(OPTI
ON_
B)) *
+AB-
CD

(
(OPTI
ON_
C)) *
+-ABCD

(
(OPTI
ON_
D)) +AB*
-CD

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)
(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Pr
ON) efi
xfor
m ofexpr
essi
onA*B/C-
Dis………

(
(OPTI
ON_
A)) /
-*ABCD

(
(OPTI
ON_
B)) -
/*ABCD

(
(OPTI
ON_
C)) -
*/ABCD

(
(OPTI
ON_
D)) /
*AB-
CD

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Pr
ON) efi
xfor
m ofexpr
essi
onA*(
B/C)
-Di
s………

(
(OPTI
ON_
A)) *
-A/
BCD

(
(OPTI
ON_
B)) -
*A/
BCD

(
(OPTI
ON_
C)) -
*/ABCD

(
(OPTI
ON_
D)) *
A/B-
CD

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Pr
ON) efi
xfor
m ofexpr
essi
onA*B-
C/Di
s………

(
(OPTI
ON_
A)) *
-AB/
CD

(
(OPTI
ON_
B)) -
*AB/
CD

(
(OPTI
ON_
C)) -
*/ABCD

(
(OPTI
ON_
D)) -
/*ABCD

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Pr
ON) efi
xfor
m ofexpr
essi
onA+B-
C*D^Ei
s………

(
(OPTI
ON_
A)) +A-
B*CD^
DE

(
(OPTI
ON_
B)) -
+AB*
CD^
DE

(
(OPTI
ON_
C)) +-
AB*
CD^
DE

(
(OPTI
ON_
D)) -
+*ABCD^
DE

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Pr
ON) efi
xfor
m ofexpr
essi
onA+(
B-C)
*D/Ei
s………

(
(OPTI
ON_
A)) +A*
/-BCDE

(
(OPTI
ON_
B)) +A/
*-BCDE

(
(OPTI
ON_
C)) +A/
-BC*
DE

(
(OPTI
ON_
D)) +A*
-BC/
DE

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Pr
ON) efi
xfor
m ofexpr
essi
on(
A+(
B-C)
)*D/Ei
s………

(
(OPTI
ON_
A)) *
/+A-
BCDE

(
(OPTI
ON_
B)) /
*+A-
BCDE

(
(OPTI
ON_
C)) -
+/*
ABCDE

(
(OPTI
ON_
D)) None

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI ) Pr
ON) efi
xfor
m ofexpr
essi
on(
A+B-
C)*D^Ei
s………

(
(OPTI
ON_
A)) -
+*^
ABCDE

(
(OPTI
ON_
B)) *
-+ABC^
DE

(
(OPTI
ON_
C)) +_
*^ABCDE

(
(OPTI
ON_
D)) -
*+ABC^
DE

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) ……….
.dat
ast
ruct
urei
susedi
neval
uat
ionof
Post
fixexpr
essi
on

(
(OPTI
ON_
A))
Tr
ee

(
(OPTI
ON_
B))
St
ack

(
(OPTI
ON_
C))
Queue

(
(OPTI
ON_
D)) Gr
aph

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) ……….
.dat
ast
ruct
urei
susedi
neval
uat
ionof
pr
efi
xexpr
essi
on
(
(OPTI
ON_
A))
Tr
ee

(
(OPTI
ON_
B))
St
ack

(
(OPTI
ON_
C))
Queue

(
(OPTI
ON_
D)) Gr
aph

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Thecor
ON) rectPUSH oper
ati
oni
s………

(
(OPTI
ON_
A)) Dat
a[++t
op]
=val
ue

(
(OPTI
ON_
B)) Dat
a[t
op]
=val
ue

(
(OPTI
ON_
C)) Dat
a[t
op++]
=val
ue

(
(OPTI
ON_
D)) Dat
a[-
-t
op]
=val
ue

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) Thecor
ON) rectPOPoper
ati
oni
s………

(
(OPTI
ON_
A)) Ret
urn(
Dat
a[++t
op]
)

(
(OPTI
ON_
B)) Ret
urn(
Dat
a[t
op-
-]
)

(
(OPTI
ON_
C)) Ret
urn(
Dat
a[t
op++]
)

(
(OPTI
ON_
D)) Ret
urn(
Dat
a[-
-t
op]
)

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
)
Ev
aluat
efol
l
owi
ngpost
fi
xexpr
essi
on:

ABC+*
DE\
-wher
eA=5,
B=6,
C=2,
D=12,
E=4

(
(OPTI
ON_
A))
25

(
(OPTI
ON_
B))
36

(
(OPTI
ON_
C))
37

(
(OPTI
ON_
D))
34

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTI
ONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
)
Ev
aluat
efol
l
owi
ngpost
fi
xexpr
essi
on:

562+*124/-
(
(OPTI
ON_
A)) 25

(
(OPTI
ON_
B)) 36

(
(OPTI
ON_
C)) 37

(
(OPTI
ON_
D)) 34
(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
)
Ev
aluat
efol
l
owi
ngpost
fi
xexpr
essi
on:

623+-
382/
+*2$3+

(
(OPTI
ON_
A)) 52

(
(OPTI
ON_
B)5
)0 50

(
(OPTI
ON_
C)) 32

(
(OPTI
ON_
D)) 38

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 2
(
1/2/
3..
.)

(
(QUESTI
ON)
) Twost
acki
mpl
ement
ati
oni
nsi
ngl
ear
rayshoul
d

St
acksgr
owi
ngi
n…………
(
(OPTI
ON_
A)) For
war
ddi
rect
ion

(
(OPTI
ON_
B)) Backwar
dDi
rect
ion

(
(OPTI
ON_
C)) Opposi
teDi
rect
ions

(
(OPTI
ON_
D)) Noneofabov
e

(
(CORRECT_
C C
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Pol
ishnot
ati
oni
sal
socal
led……….

(
(OPTI
ON_
A)) Pr
efi
x

(
(OPTI
ON_
B)) Post
fi
x

(
(OPTI
ON_
C)) I
nfi
x

(
(OPTI
ON_
D)) Noneofabov
e

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI
ON)
) Rever
sePol
ishnot
ati
oni
sal
socal
led……….

(
(OPTI
ON_
A)) Pr
efi
x

(
(OPTI
ON_
B)) Post
fi
x

(
(OPTI
ON_
C)) I
nfi
x

(
(OPTI
ON_
D)) Noneofabov
e

(
(CORRECT_
C B
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)

(
(MARKS)) 1
(
1/2/
3..
.)

(
(QUESTI ) ………………dat
ON) ast
ruct
urei
susef
uli
nUNDOoper
ati
on
ofWindows
(
(OPTI
ON_ ) St
A) ack

(
(OPTI
ON_
B)) Queue

(
(OPTI
ON_
C)) Ar
ray

(
(OPTI
ON_
D)) None

(
(CORRECT_
C A
HOI
CE))
(
A/B/C/
D)

(
(EXPLANATI
O
N))
(
OPTIONAL)
((MARKS)) (1/2/3...) 1

((QUESTION)) What will be the output of the program ?


#include<stdio.h>

int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
return 0;
}

((OPTION_A)) 2,1,15

((OPTION_B)) 1,2,5

((OPTION_C)) 3,2,15

((OPTION_D)) 2,3,20

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION)) Step 1: int a[5] = {5, 1, 15, 20, 25}; The variable arr is declared as an
(OPTIONAL) integer array with a size of 5 and it is initialized to
a[0] = 5, a[1] = 1, a[2] = 15, a[3] = 20, a[4] = 25 .
Step 2: int i, j, m; The variable i,j,m are declared as an integer type.
Step 3: i = ++a[1]; becomes i = ++1; Hence i = 2 and a[1] = 2
Step 4: j = a[1]++; becomes j = 2++; Hence j = 2 and a[1] = 3.
Step 5: m = a[i++]; becomes m = a[2]; Hence m = 15 and i is
incremented by 1(i++ means 2++ so i=3)
Step 6: printf("%d, %d, %d", i, j, m); It prints the value of the
variables i, j, m
Hence the output of the program is 3, 2, 15

((MARKS)) (1/2/3...) 1
((QUESTION)) In C, if you pass an array as an argument to a function, what actually gets
passed?
((OPTION_A)) Value of elements in array
First element of the array
((OPTION_B))

((OPTION_C)) Base address of the array

((OPTION_D)) Address of the last element of array

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION)) The statement 'C' is correct. When we pass an array as a funtion


(OPTIONAL) argument, the base address of the array will be passed.

((MARKS)) (1/2/3...) 1
Which of the following statements are correct about 6 used in the
((QUESTION))
program?
int num[6];
num[6]=21;
((OPTION_A)) In the first statement 6 specifies a particular element, whereas in the
second statement it specifies a type.
((OPTION_B)) In the first statement 6 specifies a array size, whereas in the second
statement it specifies a particular element of array.

((OPTION_C)) In the first statement 6 specifies a particular element, whereas in the


second statement it specifies a array size.
((OPTION_D)) In both the statement 6 specifies array size.

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION)) The statement 'B' is correct, because int num[6]; specifies the size of
(OPTIONAL) array and num[6]=21; designates the particular element(7thelement) of
the array.

((MARKS)) (1/2/3...) 1

((QUESTION)) What does the following declaration mean?


int (*ptr)[10];
((OPTION_A)) ptr is array of pointers to 10 integers

((OPTION_B)) ptr is a pointer to an array of 10 integers

((OPTION_C)) ptr is an array of 10 integers

((OPTION_D)) ptr is an pointer to array

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Which of the following statements are correct about an array?


1. The array int num[26]; can store 26 elements.
2. The expression num[1] designates the very first element in the
array.
3. It is necessary to initialize the array at the time of declaration.
4. The declaration num[SIZE] is allowed if SIZE is a macro.
1
((OPTION_A))

1,4
((OPTION_B))

2,3
((OPTION_C))

2,4
((OPTION_D))

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION)) 1. The array int num[26]; can store 26 elements. This statement is
(OPTIONAL) true.
2. The expression num[1] designates the very first element in the
array. This statement is false, because it designates the second
element of the array.
3. It is necessary to initialize the array at the time of declaration. This
statement is false.
4. The declaration num[SIZE] is allowed if SIZE is a macro. This
statement is true, because the MACRO just replaces the symbol SIZE
with given value.
Hence the statements '1' and '4' are correct statements.

((MARKS)) (1/2/3...) 1

((QUESTION)) The smallest element of an array index called……

Lower bound
((OPTION_A))

Upper bound
((OPTION_B))

Range
((OPTION_C))

None of Above
((OPTION_D))

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Which of the following function is used to find the first occurrence of a
given string in another string?

((OPTION_A)) strchr()

((OPTION_B)) strrchr()

((OPTION_C)) strstr()
((OPTION_D)) strnset()

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION)) char *strstr(const char *s1, const char *s2);


(OPTIONAL) Return Value:
On success, strstr returns a pointer to the element
in s1 where s2 begins (points to s2 in s1).
On error (if s2 does not occur in s1), strstr returns null.
Example:
#include <stdio.h>
#include <string.h>
int main(void)
{
char *str1 = "IndiaBIX", *str2 = "ia", *ptr;
ptr = strstr(str1, str2);
printf("The substring is: %s\n", ptr);
return 0;
}
Output: The substring is: iaBIX

((MARKS)) (1/2/3...) 1
which of the following is not an asymptotic notation?
((QUESTION))

BIG-O
((OPTION_A))
Omega
((OPTION_B))
Phi
((OPTION_C))

((OPTION_D)) Theta

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)
((MARKS)) (1/2/3...) 1
Step count for the following loop is
((QUESTION))
For(int i=5; i>0; i++)

5 times
((OPTION_A))
N+1 times
((OPTION_B))
Infinite
((OPTION_C))
No execution
((OPTION_D))

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1
Time Complexity is
((QUESTION))

Time required for the machine to compile the program.


((OPTION_A))

Time required for the machine to execute the program.


((OPTION_B))

Time required for the machine to debug the program.


((OPTION_C))

None
((OPTION_D))

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Which of the following data structure is not linear data


structure?
Array
((OPTION_A))

Linked list
((OPTION_B))

All of above
((OPTION_C))

None of above
((OPTION_D))

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Which of the followings are application of data structure?


Facebook
((OPTION_A))

Searching
((OPTION_B))

Sorting
((OPTION_C))

All of above
((OPTION_D))

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Which data structure is used for implementing recursion?

Queue
((OPTION_A))

Stack
((OPTION_B))
Array
((OPTION_C))

List
((OPTION_D))

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Representation of data structure in memory is known


as………….
((OPTION_A)) recursive

((OPTION_B)) Abstract Data Type

((OPTION_C)) Storage Structure

((OPTION_D)) File Structure

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) In a linked list with n nodes, the time taken to insert an


element after an element pointed by some pointer is……..
((OPTION_A)) O (1)
O(log n)
((OPTION_B))

O(n)
((OPTION_C))

O(n log n)
((OPTION_D))
((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) In a circular linked list……….


((OPTION_A)) components are all linked together in some sequential
manner.

((OPTION_B)) there is no beginning and no end.

((OPTION_C)) components are arranged hierarchically.

((OPTION_D)) forward and backward traversal within the list is permitted.


((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Which of the following operators takes only integer


operands?

+
((OPTION_A))

/
((OPTION_B))

%
((OPTION_C))

*
((OPTION_D))

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) NULL pointer is used to define .....

End of the linked list


((OPTION_A))

Empty list
((OPTION_B))

Empty pointer field of the structure


((OPTION_C))

All of above
((OPTION_D))

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) The function that return memory to heap is called...........

Allloc()
((OPTION_A))

Malloc()
((OPTION_B))

Calloc()
((OPTION_C))

Free()
((OPTION_D))

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)
((MARKS)) (1/2/3...) 1

((QUESTION)) Two main measures for the efficiency of an algorithm are

((OPTION_A)) Processor and memory

((OPTION_B)) Complexity and capacity

((OPTION_C)) Time and space

((OPTION_D)) Data and space

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1
((QUESTION)) Which of the following case does not exist in complexity theory

((OPTION_A)) Best case

Worst case
((OPTION_B))

((OPTION_C)) Average case

((OPTION_D)) Null case

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1
The Worst case occur in linear search algorithm when
((QUESTION))

((OPTION_A)) Item is somewhere in the middle of the array

((OPTION_B)) Item is not in the array at all


((OPTION_C)) Item is the last element in the array

((OPTION_D)) Item is the last element in the array or is not there at all

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION)) .
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) The complexity of merge sort algorithm is

((OPTION_A)) O(n)

((OPTION_B)) O(log n)

((OPTION_C)) O(n2)

((OPTION_D)) O(n log n)

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) The input to a merge sort is 6,5,4,3,2,1 and the same input is applied to
quick sort then which is the best algorithm in this case

Merge sort
((OPTION_A))

((OPTION_B)) Quick sort

((OPTION_C)) Both have same time complexity in this case as they have same running
time
((OPTION_D)) Cannot be decided

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1
If there exists two functions f(n) and g(n). The constant c>0 and there exists
((QUESTION))
an integer constant n0>=1. If f(n)<=c*g(n) for every integer n>= n0 then we
say that____
f(n)=O(g(n))
((OPTION_A))
f(n)=Θ (g(n))
((OPTION_B))

((OPTION_C)) f(n)=𝛺 (g(n))


f(n)=Θ (g(n)) f(n)=o(g(n))

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION)) Basic definition of big oh notation


(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) In practice ______ is used to define tight upper bound on growth of


function f(n)

((OPTION_A)) Big oh

((OPTION_B)) Big omega

((OPTION_C)) Big theta

((OPTION_D)) None of these

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION)) The definition of big oh notation is f(n)<=c*g(n) which defines the


(OPTIONAL) upper bound on growth of the function f(n)
((MARKS)) (1/2/3...) 1

((QUESTION)) Examples of O(1) are ______

((OPTION_A)) Multiplying two numbers

((OPTION_B)) Assigning some value to a variable

((OPTION_C)) Displaying some integer on console

((OPTION_D)) All of the above

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION)) All these operations are computed by single line expression


(OPTIONAL) evaluation

((MARKS)) (1/2/3...) 1

((QUESTION)) Examples of O(n2) algorithms are

((OPTION_A)) Adding two matrices

((OPTION_B)) Finding transpose of a matrix

((OPTION_C)) Initializing all elements of the matrix by 0

((OPTION_D)) All of the above

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION)) Within two for loops(nested), all these operations are performed.
(OPTIONAL)

((MARKS)) (1/2/3...) 1
Choose the correct time complexity of following code__
((QUESTION))
while(n>0)
{
n=n/10
}
O(1)
((OPTION_A))
O(n)
((OPTION_B))
O(log n)
((OPTION_C))

((OPTION_D)) O(n2)

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

The time complexity of binary search is_____


((QUESTION))
O(n)
((OPTION_A))
O(log n)
((OPTION_B))
O(n log n)
((OPTION_C))

((OPTION_D)) O(n2)

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION)) The list is divided at the mid and then the element is searched in
(OPTIONAL) either left half or right half.

((MARKS)) (1/2/3...) 1

((QUESTION)) Consider recurrence relation as


T(0)=c1
T(n)=T(n-1)+c2
This can be expressed as
O(n)
((OPTION_A))
O(log n)
((OPTION_B))
O(n log n)
((OPTION_C))

((OPTION_D)) O(n2)

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION)) T(n)=T(n-1)+c2
(OPTIONAL) =T(n-2)+2c2
=T(n-3)+3c2
=T(n-k)+kc2
If k=n then T(n)=c1+nc2 Hence, T(n)=O(n)

((MARKS)) (1/2/3...) 1

((QUESTION)) Consider recurrence relation as


T(0)=c1 and T(1)=c2
T(n)=T(n/2)+c3
This can be expressed as
O(n)
((OPTION_A))
O(log n)
((OPTION_B))
O(n log n)
((OPTION_C))

((OPTION_D)) O(n2)

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Following is the method of solving recurrence relation

((OPTION_A)) Greedy method


((OPTION_B)) Backtracking

((OPTION_C)) Forward substitution method

((OPTION_D)) Divide and Conquer method

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1
The recurrence relation for factorial function is of the form _______
((QUESTION))

((OPTION_A)) T(n)=T(n-1)+c

((OPTION_B)) T(n)=T(n-1)+T(n-2)+c

((OPTION_C)) T(n/2)+c

((OPTION_D)) None of these

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION)) The factorial function is as follows-


(OPTIONAL) fact(n)
{
if n=1
return 1
else
return n * fact(n-1)
}

((MARKS)) (1/2/3...) 1

((QUESTION)) The recurrence relation for fibonacci function is of the form _______

((OPTION_A)) T(n)=T(n-1)+c

((OPTION_B)) T(n)=T(n-1)+T(n-2)+c
((OPTION_C)) T(n/2)+c

((OPTION_D)) None of these

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION)) The fibonacci function is as follows-


(OPTIONAL) fibb(n)
{
if n = = 0
return 0
if n = = 1
return 1
else
return (fibb(n-1) + fibb(n-2))
}

((MARKS)) (1/2/3...) 1

((QUESTION)) The frequency count of following code is____


for(i=0;i<m;i++)
{
for(j=0;i<n;j++)
{
C[i][j]=a[i][j]+b[i][j];
}
}

((OPTION_A)) m + mn + mn

((OPTION_B)) m + n + mn

((OPTION_C)) m + n2 + mn

((OPTION_D)) (m+1) + m(n+1) + mn

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)
((MARKS)) (1/2/3...) 1

((QUESTION)) Consider T(n)=15n3 + n2 + 4. Select the correct statement

((OPTION_A)) T(n)=O(n4)

((OPTION_B)) T(n)=𝛺 (n3)

((OPTION_C)) T(n)=𝛺 (n2)

((OPTION_D)) All of the above

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Give the frequency count of 3rd Statement

for(i=1;i<=n;i++)
for(j=1;j<=i;j++)
x=x+1;

((OPTION_A)) ½(n2+n)

((OPTION_B)) ½(n2+3n)

((OPTION_C)) n2

((OPTION_D)) (n+1)2

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) There are four algorithms for solving a problem. Their time complexities
are O(n), O(n2), O(log n) and O(n log n). Which is the best algorithm?

((OPTION_A)) O(n)

((OPTION_B)) O(n2)

((OPTION_C)) O(log n)

((OPTION_D)) O(n log n)

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) The order of the recurrence relation ar-7ar-1+10ar-2=0 is ______.

((OPTION_A)) 3

((OPTION_B)) 2

((OPTION_C)) 1

((OPTION_D)) B

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Characteristic roots of the recurrence relation a r-2ar-1+ar-2=0 are _______

((OPTION_A)) 1, -1

((OPTION_B)) -1, -1

((OPTION_C)) 1, 1
((OPTION_D)) None of these

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Charactristic polynomial of the recurrence relation b n=-3bn-1-bn-2 is


________.

((OPTION_A)) Z2-3Z-2=0

((OPTION_B)) Z2+3Z-2=0

((OPTION_C)) Z2+3Z+2=0

((OPTION_D)) None of these

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) The general solution of the recurrence relation a r-2ar-1=0 is _____.

((OPTION_A)) ar=c1(-2)r

((OPTION_B)) ar=c2(2)r

((OPTION_C)) ar=c1(1)r

((OPTION_D)) None of these

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Consider the recurrence relation, an=an-1+2an-2 with a9=3 and a10=5. Find a7.

((OPTION_A)) 1

((OPTION_B)) 3

((OPTION_C)) 5

((OPTION_D)) None

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Charactristic polynomial of the recurrence relation a r+2-ar-2=0 is ______.

((OPTION_A)) Z-1=0

((OPTION_B)) Z2-1=0

((OPTION_C)) (Z-1)2=0

((OPTION_D)) None

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION)) Given homogeneous recurrence relation can be written as


(OPTIONAL) ar+2+0ar+1+0ar+0ar-1-ar-2=0
Order of this recurrence relation is 4.
Hence characteristic polynomial is Z4-1=0
((MARKS)) (1/2/3...) 1

((QUESTION)) The postfix equivalent of the prefix *+ab-cd is ______.

((OPTION_A)) ab+cd-*

((OPTION_B)) ab+cd*-

((OPTION_C)) abcd+*-

((OPTION_D)) ab-cd+*

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) What does the following function check for? (all necessary headers to
be included and function is called from main)

#define MAX 10

typedef struct stack


{
int top;
int item[MAX];
}stack;

int function(stack *s)


{
if(s->top == -1)
return 1;
else return 0;
}

full stack
((OPTION_A))
invalid index
((OPTION_B))
empty stack
((OPTION_C))

((OPTION_D)) infinite stack


((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION)) Answer: c
(OPTIONAL) Explanation: An empty stack is represented with the top-of-the-stack(‘top’
in this case) to be equal to -1.
MCQs

Suppose we are sorting an array of eight integers using a some quadratic sorting
algorithm. After four iterations of the algorithm’s main loop, the array elements are
ordered as shown here:2 4 5 7 8 1 3 6 *
Insertion sort
Selection sort
either of a and b
none of the above

The running time of insertion sort is *


O(n^2)
O(n)
O(log n)
O(n log n)

Which of the following sorting procedure is the slowest ? *


Quick sort
Heap sort
Shell sort
Bubble sort

A sort which compares adjacent elements in a list and switches where necessary is *
insertion sort
heap sort
quick sort
bubble sort

The correct order of the efficiency of the following sorting algorithms according to their
overall running time comparision is *
Insertion>selection>bubble
Insertion>bubble>selection
Selection>bubble>insertion
bubble>selection>insertion

A sort which iteratively passes through a list to exchange the first element with any
element less than it and then repeats with a new first element is called *
insertion sort
selection sort
heap sort
quick sort
The number of swappings needed to sort the numbers 8, 22, 7, 9, 31, 19, 5, 13 in
ascending order, using bubble sort is *
10
9
13
14

The way a card game player arranges his cards as he picks them one by one can be
compared to *
Quick sort
Merge sort
Insertion sort
Bubble sort

Which among the following is the best when the list is already sorted *
Insertion sort
Bubble sort
Merge sort
Selection sort

As part of the maintenance work, you are entrusted with the work of rearranging the
library books in a shelf in proper order, at the end of each day. The ideal choice will
be *
Bubble sort
Insertion sort
Selection sort
Merge sort
MCQs

1. Which of these best describes an array?


a) A data structure that shows a hierarchical behavior
b) Container of objects of similar types
c) Container of objects of mixed types
d) All of the mentioned
Answer: b
Explanation: Array contains elements only of the same type.

2. How do you initialize an array in C?


a) int arr[3] = (1,2,3);
b) int arr(3) = {1,2,3};
c) int arr[3] = {1,2,3};
d) int arr(3) = (1,2,3);
Answer: c
Explanation: This is the syntax to initialize an array in C.

3. How do you instantiate an array in Java?


a) int arr[] = new int(3);
b) int arr[];
c) int arr[] = new int[3];
d) int arr() = new int(3);
Answer: c
Explanation: Note that option b is declaration whereas option c is to instantiate an array.

4. Which of the following is a correct way to declare a multidimensional array in Java?


a) int[][] arr;
b) int arr[][];
c) int []arr[];
d) All of the mentioned
Answer: d
Explanation: All the options are syntactically correct.

5. What is the output of the following piece of code?

public class array


{
public static void main(String args[])
{
int []arr = {1,2,3,4,5};
System.out.println(arr[2]);
System.out.println(arr[4]);
}
}

a) 3 and 5
b) 5 and 3
c) 2 and 4
d) 4 and 2
Answer: a
Explanation: Array indexing starts from 0.

6. What is the output of the following piece of code?

public class array


{
public static void main(String args[])
{
int []arr = {1,2,3,4,5};
System.out.println(arr[5]);
}
}

a) 4
b) 5
c) ArrayIndexOutOfBoundsException
d) InavlidInputException
Answer: c
Explanation: Trying to access an element beyond the limits of an array gives
ArrayIndexOutOfBoundsException.

7. When does the ArrayIndexOutOfBoundsException occur?


a) Compile-time
b) Run-time
c) Not an error
d) None of the mentioned
Answer: b
Explanation: ArrayIndexOutOfBoundsException is a run-time exception and the compilation is
error-free.

8. Which of the following concepts make extensive use of arrays?


a) Binary trees
b) Scheduling of processes
c) Caching
d) Spatial locality
Answer: d
Explanation: Whenever a particular memory location is referred, it is likely that the locations
nearby are also referred, arrays are stored as contigous blocks in memory, so if you want to
access array elements, spatial locality makes it to access quickly.

9. What are the advantages of arrays?


a) Easier to store elements of same data type
b) Used to implement other data structures like stack and queue
c) Convenient way to represent matrices as a 2D array
d) All of the mentioned
Answer: d
Explanation: Arrays are simple to implement when it comes to matrices of fixed size and type, or
to implement other data structures.

10. What are the disadvantages of arrays?


a) We must know before hand how many elements will be there in the array
b) There are chances of wastage of memory space if elements inserted in an array are lesser than
than the allocated size
c) Insertion and deletion becomes tedious
d) All of the mentioned
Answer: d
Explanation: Arrays are of fixed size, hence during the compile time we should know its size and
type, since arrays are stored in contigous locations, insertion and deletion becomes time
consuming.

11. Assuming int is of 4bytes, what is the size of int arr[15];?


a) 15
b) 19
c) 11
d) 60
Answer: d
Explanation: Since there are 15 int elements and each int is of 4bytes, we get 15*4 = 60bytes.

Queues:

1. A linear list of elements in which deletion can be done from one end (front) and insertion can
take place only at the other end (rear) is known as a ?
a) Queue
b) Stack
c) Tree
d) Linked list
Answer: a
Explanation: Self Explanatory.

3. A queue is a ?
a) FIFO (First In First Out) list
b) LIFO (Last In First Out) list
c) Ordered array
d) Linear tree
View Answer

Answer: a
Explanation: Self Explanatory.

4. In Breadth First Search of Graph, which of the following data structure is used?
a) Stack
b) Queue
c) Linked list
d) None of the mentioned
View Answer

Answer: b
Explanation: Self Explanatory.

5. If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time, in
what order will they be removed?
a) ABCD
b) DCBA
c) DCAB
d) ABCD
Answer: a
Explanation: Queue follows FIFO approach.

6. A data structure in which elements can be inserted or deleted at/from both the ends but not in
the middle is?
a) Queue
b) Circular queue
c) Dequeue
d) Priority queue
Answer: c
Explanation: Self Explanatory.

7. A normal queue, if implemented using an array of size MAX_SIZE, gets full when
a) Rear = MAX_SIZE – 1
b) Front = (rear + 1)mod MAX_SIZE
c) Front = rear + 1
d) Rear = front
Answer: a
Explanation: Condition for size of queue.

8. Queues serve major role in


a) Simulation of recursion
b) Simulation of arbitrary linked list
c) Simulation of limited resource allocation
d) All of the mentioned
Answer: c
Explanation: Rest all are implemented using other data structures.

9. Which of the following is not the type of queue?


a) Ordinary queue
b) Single ended queue
c) Circular queue
d) Priority queue
Answer: b
Explanation: Queue always has two ends.

10. In linked list implementation of queue, if only front pointer is maintained, which of the
following operation take worst case linear time?
a) Insertion
b) Deletion
c) To empty a queue
d) Both a and c
Answer: d
Explanation: Since front pointer is used for deletion, so worst time for the other two cases.

11. In linked list implementation of a queue, where does a new element be inserted?
a) At the head of link list
b) At the centre position in the link list
c) At the tail of the link list
d) None of the mentioned
Answer: c
Explanation: Since queue follows FIFO so new element inserted at last.

12. In linked list implementation of a queue, front and rear pointers are tracked. Which of these
pointers will change during an insertion into a NONEMPTY queue?
a) Only front pointer
b) Only rear pointer
c) Both front and rear pointer
d) None of the mentioned
Answer: b
Explanation: Since queue follows FIFO so new element inserted at last.
((MARKS)) (1/2/3...) 1

((QUESTION)) What will be the output of the program ?


#include<stdio.h>

int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
return 0;
}

((OPTION_A)) 2,1,15

((OPTION_B)) 1,2,5

((OPTION_C)) 3,2,15

((OPTION_D)) 2,3,20

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION)) Step 1: int a[5] = {5, 1, 15, 20, 25}; The variable arr is declared as an
(OPTIONAL) integer array with a size of 5 and it is initialized to
a[0] = 5, a[1] = 1, a[2] = 15, a[3] = 20, a[4] = 25 .
Step 2: int i, j, m; The variable i,j,m are declared as an integer type.
Step 3: i = ++a[1]; becomes i = ++1; Hence i = 2 and a[1] = 2
Step 4: j = a[1]++; becomes j = 2++; Hence j = 2 and a[1] = 3.
Step 5: m = a[i++]; becomes m = a[2]; Hence m = 15 and i is
incremented by 1(i++ means 2++ so i=3)
Step 6: printf("%d, %d, %d", i, j, m); It prints the value of the
variables i, j, m
Hence the output of the program is 3, 2, 15

((MARKS)) (1/2/3...) 1
((QUESTION)) In C, if you pass an array as an argument to a function, what actually gets
passed?
((OPTION_A)) Value of elements in array
First element of the array
((OPTION_B))

((OPTION_C)) Base address of the array

((OPTION_D)) Address of the last element of array

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION)) The statement 'C' is correct. When we pass an array as a funtion


(OPTIONAL) argument, the base address of the array will be passed.

((MARKS)) (1/2/3...) 1
Which of the following statements are correct about 6 used in the
((QUESTION))
program?
int num[6];
num[6]=21;
((OPTION_A)) In the first statement 6 specifies a particular element, whereas in the
second statement it specifies a type.
((OPTION_B)) In the first statement 6 specifies a array size, whereas in the second
statement it specifies a particular element of array.

((OPTION_C)) In the first statement 6 specifies a particular element, whereas in the


second statement it specifies a array size.
((OPTION_D)) In both the statement 6 specifies array size.

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION)) The statement 'B' is correct, because int num[6]; specifies the size of
(OPTIONAL) array and num[6]=21; designates the particular element(7thelement) of
the array.

((MARKS)) (1/2/3...) 1

((QUESTION)) What does the following declaration mean?


int (*ptr)[10];

((OPTION_A)) ptr is array of pointers to 10 integers

((OPTION_B)) ptr is a pointer to an array of 10 integers

((OPTION_C)) ptr is an array of 10 integers

((OPTION_D)) ptr is an pointer to array


((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Which of the following statements are correct about an array?


1. The array int num[26]; can store 26 elements.
2. The expression num[1] designates the very first element in the
array.
3. It is necessary to initialize the array at the time of declaration.
4. The declaration num[SIZE] is allowed if SIZE is a macro.
1
((OPTION_A))

1,4
((OPTION_B))

2,3
((OPTION_C))

2,4
((OPTION_D))

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION)) 1. The array int num[26]; can store 26 elements. This statement is
(OPTIONAL) true.
2. The expression num[1] designates the very first element in the
array. This statement is false, because it designates the second
element of the array.
3. It is necessary to initialize the array at the time of declaration. This
statement is false.
4. The declaration num[SIZE] is allowed if SIZE is a macro. This
statement is true, because the MACRO just replaces the symbol SIZE
with given value.
Hence the statements '1' and '4' are correct statements.
((MARKS)) (1/2/3...) 1

((QUESTION)) If the two strings are identical, then strcmp() function returns
-1
((OPTION_A))

1
((OPTION_B))

0
((OPTION_C))

Yes
((OPTION_D))

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION)) strcmp(const char *s1, const char*s2);


(OPTIONAL) The strcmp return an int value that is
if s1 < s2 returns a value < 0
if s1 == s2 returns 0
if s1 > s2 returns a value > 0

((MARKS)) (1/2/3...) 1

((QUESTION)) Which of the following function is used to find the first occurrence of a
given string in another string?

((OPTION_A)) strchr()

((OPTION_B)) strrchr()

((OPTION_C)) strstr()

((OPTION_D)) strnset()

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION)) char *strstr(const char *s1, const char *s2);


(OPTIONAL) Return Value:
On success, strstr returns a pointer to the element
in s1 where s2 begins (points to s2 in s1).
On error (if s2 does not occur in s1), strstr returns null.
Example:
#include <stdio.h>
#include <string.h>
int main(void)
{
char *str1 = "IndiaBIX", *str2 = "ia", *ptr;
ptr = strstr(str1, str2);
printf("The substring is: %s\n", ptr);
return 0;
}
Output: The substring is: iaBIX

((MARKS)) (1/2/3...) 1

((QUESTION)) The library function used to find the last occurrence of a character in a
string is

((OPTION_A)) strnstr()

((OPTION_B)) laststr()

((OPTION_C)) strrchr()

((OPTION_D)) strstr()

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION)) Declaration: char *strrchr(const char *s, int c);


(OPTIONAL) It scans a string s in the reverse direction, looking for a specific
character c.
Example:
#include <string.h>
#include <stdio.h>

int main(void)
{
char text[] = "I learn through IndiaBIX.com";
char *ptr, c = 'i';
ptr = strrchr(text, c);
if (ptr)
printf("The position of '%c' is: %d\n", c, ptr-text);
else
printf("The character was not found\n");
return 0;
}
Output:
The position of 'i' is: 19

((MARKS)) (1/2/3...) 1

((QUESTION)) How will you print \n on the screen?

((OPTION_A)) printf("\n");

((OPTION_B)) echo "\\n";

((OPTION_C)) printf('\n');

((OPTION_D)) printf("\\n");

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION)) The statement printf("\\n"); prints '\n' on the screen.


(OPTIONAL)

((MARKS)) (1/2/3...) 1
Which of the following data structures cannot store non-homogeneous
((QUESTION))
elements?

Arrays
((OPTION_A))

Structure
((OPTION_B))

Linked List
((OPTION_C))
File
((OPTION_D))

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1
In arrays ____ and _____ are costly but ____ is easy operation
((QUESTION))

Searching, insertion, deletion


((OPTION_A))

Insertion, deletion, searching


((OPTION_B))

Deletion, searching, insertion


((OPTION_C))

None of these
((OPTION_D))

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1
void main()
((QUESTION))
{
int a[5]={1,2};
printf(“\n%d%d%d”,a[2],a[3],a[4]);
}
What will be the output?
122
((OPTION_A))
211
((OPTION_B))

000
((OPTION_C))

((OPTION_D)) Garbage Value

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Find the output:


void main()
{
int i=0,a[3];
a[i]=i++;
printf(“%d”,a[i]);
}

((OPTION_A)) 0

((OPTION_B)) 1

((OPTION_C)) Garbage value

((OPTION_D)) Syntax error

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) While passing the array as actual argument, the function call must have
array name_____

((OPTION_A)) alone
((OPTION_B)) With empty braces

((OPTION_C)) With its size

((OPTION_D)) None of these

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Which code will run faster?


1. for(i=0;i<100;i++)
for(j=0;j<10;j++)
a[i][j]=0;
2. for(i=0;i<10;i++)
for(j=0;j<100;j++)
a[i][j]=0;

((OPTION_A)) Code 1

((OPTION_B)) Code 2

((OPTION_C)) Both run equally

((OPTION_D)) None of these

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Consider an integer array int arr[4][5]. If base address is 1020, find the
ess of element arr[3][4] with row major representation. Size of int is 2 bytes.

((OPTION_A)) 1020

((OPTION_B)) 1038

((OPTION_C)) 1039
((OPTION_D)) 1058

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Consider the statement int Val[2][4]={1,2,3,4,5,6,7,8}. The element 4 will


be at____

((OPTION_A)) Val[0][3]

((OPTION_B)) Val[0][4]

((OPTION_C)) Val[1][1]

((OPTION_D)) None of these

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1
void main()
((QUESTION))
{
int a[2][3]={2,3};
printf(“\n%d%d%d%d”,a[0][0],a[0][1],a[1][0],a[1][1]);
}
What will be the output?
((OPTION_A)) 0023

((OPTION_B)) 2300

((OPTION_C)) 2030

((OPTION_D)) 2003

((CORRECT_CHOICE)) B
(A/B/C/D)
((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) The getchar() library function returns________

((OPTION_A)) Character when any key is pressed

((OPTION_B)) Character when enter key is pressed

((OPTION_C)) Display character on the screen when any key is pressed

((OPTION_D)) None of these

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Find the output:


void main()
{
printf(“%c”,100);
}

((OPTION_A)) Prints 100

((OPTION_B)) Prints ASCII equivalent of 100

((OPTION_C)) Prints garbage value

((OPTION_D)) Syntax error

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)
((MARKS)) (1/2/3...) 1

((QUESTION)) Which of the foolowing is more appropriate for reading a multi-word


string?

((OPTION_A)) printf

((OPTION_B)) scanf

((OPTION_C)) put

((OPTION_D)) gets

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Find the output:


int main()
{
char p[]=”%c\n”;
p[1]=’d’;
printf(p,65);
return 0;
}

((OPTION_A)) a

((OPTION_B)) A

((OPTION_C)) c

((OPTION_D)) 65

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1
((QUESTION)) Sparse matrix have______

((OPTION_A)) Many zero entries

((OPTION_B)) Many non zero entries

((OPTION_C)) High dimension

((OPTION_D)) Many negative entries

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) The sequential representation of sparse matrix is given by

((OPTION_A)) stack

((OPTION_B)) Queues

((OPTION_C)) Arrays

((OPTION_D)) Linked List

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) If polynomial is 5x^3+3x^2+10x+2, the degree is

((OPTION_A)) 3

((OPTION_B)) 2

((OPTION_C)) 1

((OPTION_D)) 0

((CORRECT_CHOICE)) A
(A/B/C/D)
((EXPLANATION))
(OPTIONAL)
((MARKS)) (1/2/3...) 1

((QUESTION)) Two main measures for the efficiency of an algorithm are

((OPTION_A)) Processor and memory

((OPTION_B)) Complexity and capacity

((OPTION_C)) Time and space

((OPTION_D)) Data and space

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1
((QUESTION)) Which of the following case does not exist in complexity theory

((OPTION_A)) Best case

Worst case
((OPTION_B))

((OPTION_C)) Average case

((OPTION_D)) Null case

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1
The Worst case occur in linear search algorithm when
((QUESTION))

((OPTION_A)) Item is somewhere in the middle of the array

((OPTION_B)) Item is not in the array at all

((OPTION_C)) Item is the last element in the array

((OPTION_D)) Item is the last element in the array or is not there at all
((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION)) .
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) The complexity of merge sort algorithm is

((OPTION_A)) O(n)

((OPTION_B)) O(log n)

((OPTION_C)) O(n2)

((OPTION_D)) O(n log n)

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) The input to a merge sort is 6,5,4,3,2,1 and the same input is applied to
quick sort then which is the best algorithm in this case

Merge sort
((OPTION_A))

((OPTION_B)) Quick sort

((OPTION_C)) Both have same time complexity in this case as they have same running
time
((OPTION_D)) Cannot be decided

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1
If there exists two functions f(n) and g(n). The constant c>0 and there exists
((QUESTION))
an integer constant n0>=1. If f(n)<=c*g(n) for every integer n>= n0 then we
say that____
f(n)=O(g(n))
((OPTION_A))
f(n)=Θ (g(n))
((OPTION_B))

((OPTION_C)) f(n)= (g(n))


f(n)=Θ (g(n)) f(n)=o(g(n))

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION)) Basic definition of big oh notation


(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) In practice ______ is used to define tight upper bound on growth of


function f(n)

((OPTION_A)) Big oh

((OPTION_B)) Big omega

((OPTION_C)) Big theta

((OPTION_D)) None of these

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION)) The definition of big oh notation is f(n)<=c*g(n) which defines the


(OPTIONAL) upper bound on growth of the function f(n)

((MARKS)) (1/2/3...) 1

((QUESTION)) Examples of O(1) are ______

((OPTION_A)) Multiplying two numbers

((OPTION_B)) Assigning some value to a variable

((OPTION_C)) Displaying some integer on console

((OPTION_D)) All of the above


((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION)) All these operations are computed by single line expression


(OPTIONAL) evaluation

((MARKS)) (1/2/3...) 1

((QUESTION)) Examples of O(n2) algorithms are

((OPTION_A)) Adding two matrices

((OPTION_B)) Finding transpose of a matrix

((OPTION_C)) Initializing all elements of the matrix by 0

((OPTION_D)) All of the above

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION)) Within two for loops(nested), all these operations are performed.
(OPTIONAL)

((MARKS)) (1/2/3...) 1
Choose the correct time complexity of following code__
((QUESTION))
while(n>0)
{
n=n/10
}

O(1)
((OPTION_A))
O(n)
((OPTION_B))
O(log n)
((OPTION_C))

((OPTION_D)) O(n2)

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)
((MARKS)) (1/2/3...) 1
The time complexity of binary search is_____
((QUESTION))
O(n)
((OPTION_A))
O(log n)
((OPTION_B))
O(n log n)
((OPTION_C))

((OPTION_D)) O(n2)

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION)) The list is divided at the mid and then the element is searched in
(OPTIONAL) either left half or right half.

((MARKS)) (1/2/3...) 1

((QUESTION)) Consider recurrence relation as


T(0)=c1
T(n)=T(n-1)+c2
This can be expressed as
O(n)
((OPTION_A))
O(log n)
((OPTION_B))
O(n log n)
((OPTION_C))

((OPTION_D)) O(n2)

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION)) T(n)=T(n-1)+c2
(OPTIONAL) =T(n-2)+2c2
=T(n-3)+3c2
=T(n-k)+kc2
If k=n then T(n)=c1+nc2 Hence, T(n)=O(n)
((MARKS)) (1/2/3...) 1

((QUESTION)) Consider recurrence relation as


T(0)=c1 and T(1)=c2
T(n)=T(n/2)+c3
This can be expressed as
O(n)
((OPTION_A))
O(log n)
((OPTION_B))
O(n log n)
((OPTION_C))

((OPTION_D)) O(n2)

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Following is the method of solving recurrence relation

((OPTION_A)) Greedy method

((OPTION_B)) Backtracking

((OPTION_C)) Forward substitution method

((OPTION_D)) Divide and Conquer method

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1
The recurrence relation for factorial function is of the form _______
((QUESTION))

((OPTION_A)) T(n)=T(n-1)+c

((OPTION_B)) T(n)=T(n-1)+T(n-2)+c
((OPTION_C)) T(n/2)+c

((OPTION_D)) None of these

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION)) The factorial function is as follows-


(OPTIONAL) fact(n)
{
if n=1
return 1
else
return n * fact(n-1)
}

((MARKS)) (1/2/3...) 1

((QUESTION)) The recurrence relation for fibonacci function is of the form _______

((OPTION_A)) T(n)=T(n-1)+c

((OPTION_B)) T(n)=T(n-1)+T(n-2)+c

((OPTION_C)) T(n/2)+c

((OPTION_D)) None of these

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION)) The fibonacci function is as follows-


(OPTIONAL) fibb(n)
{
if n = = 0
return 0
if n = = 1
return 1
else
return (fibb(n-1) + fibb(n-2))
}

((MARKS)) (1/2/3...) 1

((QUESTION)) The frequency count of following code is____


for(i=0;i<m;i++)
{
for(j=0;i<n;j++)
{
C[i][j]=a[i][j]+b[i][j];
}
}

((OPTION_A)) m + mn + mn

((OPTION_B)) m + n + mn

((OPTION_C)) m + n2 + mn

((OPTION_D)) (m+1) + m(n+1) + mn

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Consider T(n)=15n3 + n2 + 4. Select the correct statement

((OPTION_A)) T(n)=O(n4)

((OPTION_B)) T(n)= (n3)

((OPTION_C)) T(n)= (n2)

((OPTION_D)) All of the above

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Give the frequency count of 3rd Statement

for(i=1;i<=n;i++)

for(j=1;j<=i;j++)

x=x+1;
((OPTION_A)) ½(n2+n)

((OPTION_B)) ½(n2+3n)

((OPTION_C)) n2

((OPTION_D)) (n+1)2

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) There are four algorithms for solving a problem. Their time complexities
are O(n), O(n2), O(log n) and O(n log n). Which is the best algorithm?

((OPTION_A)) O(n)

((OPTION_B)) O(n2)

((OPTION_C)) O(log n)

((OPTION_D)) O(n log n)

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) The order of the recurrence relation ar-7ar-1+10ar-2=0 is ______.

((OPTION_A)) 3

((OPTION_B)) 2

((OPTION_C)) 1

((OPTION_D)) B

((CORRECT_CHOICE)) D
(A/B/C/D)
((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Characteristic roots of the recurrence relation a r-2ar-1+ar-2=0 are _______

((OPTION_A)) 1, -1

((OPTION_B)) -1, -1

((OPTION_C)) 1, 1

((OPTION_D)) None of these

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Charactristic polynomial of the recurrence relation b n=-3bn-1-bn-2 is


________.

((OPTION_A)) Z2-3Z-2=0

((OPTION_B)) Z2+3Z-2=0

((OPTION_C)) Z2+3Z+2=0

((OPTION_D)) None of these

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) The general solution of the recurrence relation a r-2ar-1=0 is _____.

((OPTION_A)) ar=c1(-2)r
((OPTION_B)) ar=c2(2)r

((OPTION_C)) ar=c1(1)r

((OPTION_D)) None of these

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Consider the recurrence relation, an=an-1+2an-2 with a9=3 and a10=5. Find a7.

((OPTION_A)) 1

((OPTION_B)) 3

((OPTION_C)) 5

((OPTION_D)) None

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Charactristic polynomial of the recurrence relation a r+2-ar-2=0 is ______.

((OPTION_A)) Z-1=0

((OPTION_B)) Z2-1=0

((OPTION_C)) (Z-1)2=0

((OPTION_D)) None

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION)) Given homogeneous recurrence relation can be written as


(OPTIONAL) ar+2+0ar+1+0ar+0ar-1-ar-2=0
Order of this recurrence relation is 4.
Hence characteristic polynomial is Z4-1=0

((MARKS)) (1/2/3...) 1

((QUESTION)) Which of the following is not a homogeneous linear recurrence relation

((OPTION_A)) ar+2-ar-2=0

((OPTION_B)) ar=ar-1+ar-2

((OPTION_C)) ar-2ar-1=-ar-2

((OPTION_D)) ar+3+6ar+2.ar+1-4ar=0

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) If 4 and -1 are the characteristic roots of the recurrence relation then its
homogeneous solution becomes _______

((OPTION_A)) ar=c1(-1)r+c2(4)r

((OPTION_B)) ar=c0(-1)r+c2

((OPTION_C)) ar=(c1+c2.r)(-1)r

((OPTION_D)) None

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)
((MARKS)) (1/2/3...) 1

((QUESTION)) A recurrence relation of degree 1 is called ______.

((OPTION_A)) Linear

((OPTION_B)) Homogeneous

((OPTION_C)) Quadratic

((OPTION_D)) None

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) The generating function for the sequence 1, a, a 2, a3, ….. is ______

((OPTION_A)) 1/(1-z)

((OPTION_B)) 1/(1-az)

((OPTION_C)) 1/(1+az)

((OPTION_D)) None

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)
D Y Patil College of Engineering, Akurdi-44
Department of Computer Engineering

__________________________________________________________________________________
Question Bank for Online Examination
Subject: Data Structures and Algorithms
Compiled By: Rahul Y. Pawar

Which of the following data structures are indexed structures?


A. linear arrays
B. linked lists
C. both of above
D. none of above
ANSWER: A

Which of the following is not the required condition for binary search algorithm?
A. The list must be sorted
B. there should be the direct access to the middle element in any sublist
C. There must be mechanism to delete and/or insert elements in list
D. none of above
ANSWER: C

When new data are to be inserted into a data structure, but there is no available space; this
situation is usually called
A. underflow
B. overflow
C. housefull
D. saturated
ANSWER: B

Which of the following is two way list?


A. grounded header list
B. circular header list
C. linked list with header and trailer nodes
D. none of above
ANSWER: D

A data structure where elements can be added or removed at either end but not in the middle
A. Linked lists
B. Stacks
C. Queues
D. Deque
ANSWER: C
Two main measures for the efficiency of an algorithm are
A. Processor and memory
B. Complexity and capacity
C. Time and space
D. Data and space
ANSWER: C

The complexity of linear search algorithm is


A. O(n)
B. O(log n)
C. O(n2)
D. O(n log n)
ANSWER: A

Which of the following data structure is not linear data structure?


A. Arrays
B. Linked lists
C. Both of above
D. None of above
ANSWER: D

Each array declaration need not give, implicitly or explicitly, the information about
A. the name of array
B. the data type of array
C. the first data from the set to be stored
D. the index set of the array
ANSWER: C

To represent hierarchical relationship between elements, which data structure is suitable?


A. Deque
B. Priority
C. Tree
D. All of above
ANSWER: C

Identify the data structure which allows deletions at both ends of the list but insertion at only
one enD.
A. Input-restricted deque
B. Output-restricted deque
C. Priority queues
D. None of above
ANSWER: A

Linked lists are best suited


A. for relatively permanent collections of data
B. for the size of the structure and the data in the structure are constantly changing
C. for both of above situation
D. for none of above situation
ANSWER: B

Which of the following data structure is linear data structure?


A. Trees
B. Graphs
C. Arrays
D. None of above
ANSWER: C

Which of the following case does not exist in complexity theory


A. Best case
B. Worst case
C. Average case
D. Null case
ANSWER: D

An algorithm that calls itself directly or indirectly is known as


A. Sub algorithm
B. Recursion
C. Polish notation
D. Traversal algorithm
ANSWER: B

Finding the location of the element with a given value is:


A. Traversal
B. Search
C. Sort
D. None of above
ANSWER: B

Which of these is not an application of linked list?


A.To implement file systems
B.For separate chaining in hash-tables
C.To implement non-binary trees
D.Random Access of elements
ANSWER: D

What should be added in place of *ADD A STATEMENT HERE*, so that the function
correctly reverses a linked list.
A. *head_ref = prev;
B. *head_ref = current;
C. *head_ref = next;
D. *head_ref = NULL;
ANSWER: A

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
ANSWER: D

Given pointer to a node X in a singly linked list. Only one pointer is given, pointer to head
node is not given, can we delete the node X from given linked list?
A. Possible if X is not last node
B. Possible if size of linked list is even
C. Possible if size of linked list is odd
D. Possible if X is not first node
ANSWER: A

You are given pointers to first and last nodes of a singly linked list, which of the following
operations are dependent on the length of the linked list?
A. Delete the first element
B. Insert a new element as a first element
C. Delete the last element of the list
D. Add a new element at the end of the list
ANSWER: C

In the worst case, the number of comparisons needed to search a singly linked list of length n
for a given element is
A. log2 n
B. n/2
C. log2 n – 1
D. n
ANSWER: D

What is the time complexity to count the number of elements in the linked list?
A. O(1)
B. O(n)
C. O(logn)
D. O(n2)
ANSWER: B
Which of these is not an application of linked list?
A. To implement file systems
B. For separate chaining in hash-tables
C. To implement non-binary trees
D. Random Access of elements
ANSWER: D

What is a memory efficient double linked list?


A. Each node has only one pointer to traverse the list back and forth
B. The list has breakpoints for faster traversal
C. An auxiliary singly linked list acts as a helper list to traverse through the doubly linked list
D. A doubly linked list that uses bitwise AND operator for storing addresses
ANSWER: A

How do you calculate the pointer difference in a memory efficient double linked list?
A. head xor tail
B. pointer to previous node xor pointer to next node
C. pointer to previous node – pointer to next node
D. pointer to next node – pointer to previous node
ANSWER: B

What is the worst case time complexity of inserting a node in a doubly linked list?
A. O(nlogn)
B. O(logn)
C. O(n)
D. O(1)
ANSWER: C

What differentiates a circular linked list from a normal linked list?


A. You cannot have the ‘next’ pointer point to null in a circular linked list
B. It is faster to traverse the circular linked list
C. You may or may not have the ‘next’ pointer point to null in a circular linked list
D. Head node is known in circular linked list
ANSWER: C

Which of the following application makes use of a circular linked list?


A. Undo operation in a text editor
B. Recursive function calls
C. Allocating CPU to resources
D. Implement Hash Tables
ANSWER: C

Which of the following is false about a circular linked list?


A. Every node has a successor
B. Time complexity of inserting a new node at the head of the list is O(1)
C. Time complexity for deleting the last node is O(n)
D. We can traverse the whole circular linked list by starting from any point
ANSWER: B

Which of the following real world scenarios would you associate with a stack data structure?
A. piling up of chairs one above the other
B. people standing in a line to be serviced at a counter
C. offer services based on the priority of the customer
D. all of the mentioned
ANSWER: A

What does stack underflow refer to?


A. accessing item from an undefined stack
B. adding items to a full stack
C. removing items from an empty stack
D. index out of bounds exception
ANSWER: C

What is the time complexity of pop() operation when the stack is implemented using an
array?
A. O(1)
B. O(n)
C. O(logn)
D. O(nlogn)
ANSWER: A

Array implementation of Stack is not dynamic, which of the following statements supports
this argument?
A. space allocation for array is fixed and cannot be changed during run-time
B. user unable to give the input for stack operations
C. a runtime exception halts execution
D. all of the mentioned
ANSWER: A

Which of the following data structures can be used for parentheses matching?
A. n-ary tree
B. queue
C. priority queue
D. stack
ANSWER: D

When determining the efficiency of algorithm, the space factor is measured by


A. Counting the maximum memory needed by the algorithm
B. Counting the minimum memory needed by the algorithm
C. Counting the average memory needed by the algorithm
D. Counting the maximum disk space needed by the algorithm

The complexity of Bubble sort algorithm is


A. O(n)
B. O(log n)
C. O(n2)
D. O(n log n)

Linked lists are best suited


A. for relatively permanent collections of data
B. for the size of the structure and the data in the structure are constantly changing
C. for both of above situation
D. for none of above situation

If the values of a variable in one module is indirectly changed by another module, this
situation is called
A. internal change
B. inter-module change
C. side effect
D. side-module update

In linear search algorithm the Worst case occurs when


A. The item is somewhere in the middle of the array
B. The item is not in the array at all
C. The item is the last element in the array
D. The item is the last element in the array or is not there at all

For an algorithm the complexity of the average case is


A. Much more complicated to analyze than that of worst case
B. Much more simpler to analyze than that of worst case
C. Sometimes more complicated and some other times simpler than that of worst case
D. None or above

The complexity of merge sort algorithm is


A. O(n)
B. O(log n)
C. O(n2)
D. O(n log n)

The complexity of linear search algorithm is


A. O(n)
B. O(log n)
C. O(n2)
D. O(n log n)

When determining the efficiency of algorithm the time factor is measured by


A. Counting microseconds
B. Counting the number of key operations
C. Counting the number of statements
D. Counting the kilobytes of algorithm

Which of the following data structure is linear data structure?


A. Trees
B. Graphs
C. Arrays
D. None of above

The elements of an array are stored successively in memory cells because


A. by this way computer can keep track only the address of the first element and the
addresses of other elements can be calculated
B. the architecture of computer memory does not allow arrays to store other than serially
C. both of above
D. none of above

Which of the following data structure is not linear data structure?


A. Arrays
B. Linked lists
C. Both of above
D. None of above

The Average case occur in linear search algorithm


A. When Item is somewhere in the middle of the array
B. When Item is not in the array at all
C. When Item is the last element in the array
D. When Item is the last element in the array or is not there at all

Two main measures for the efficiency of an algorithm are


A. Processor and memory
B. Complexity and capacity
C. Time and space
D. Data and space

Finding the location of the element with a given value is:


A. Traversal
B. Search
C. Sort
D. None of above

Which of the following case does not exist in complexity theory


A. Best case
B. Worst case
C. Average case
D. Null case

The operation of processing each element in the list is known as


A. Sorting
B. Merging
C. Inserting
D. Traversal

Arrays are best data structures


A. for relatively permanent collections of data
B. for the size of the structure and the data in the structure are constantly changing
C. for both of above situation
D. for none of above situation

Each array declaration need not give, implicitly or explicitly, the information about
A. the name of array
B. the data type of array
C. the first data from the set to be stored
D. the index set of the array

The complexity of Binary search algorithm is


A. O(n)
B. O(log )
C. O(n2)
D. O(n log n

What is the worst case time complexity of linear search algorithm?


A - Ο(1)
B - Ο(n)
C - Ο(log n)
D - Ο(n2)

Stack is used for


A - CPU Resource Allocation
B - Breadth First Traversal
C - Recursion
D - None of the above
Which of the following asymptotic notation is the worst among all?
A - Ο(n+9378)
B - Ο(n3)
C - nΟ(1)
D - 2Ο(n)

Which of the following searching techniques do not require the data to be in sorted form
A - Binary Search
B - Interpolation Search
C - Linear Search
D - All of the above

Which of the following is example of in-place algorithm?


A - Bubble Sort
B - Merge Sort
C - Insertion Sort
D - All of the above

Which of the below given sorting techniques has highest best-case runtime complexity −
A - quick sort
B - selection sort
C - insertion sort
D - bubble sort

Which of the following uses memoization?


A - Greedy approach
B - Divide and conquer approach
C - Dynamic programming approach
D - None of the above!

Recursion uses more memory space than iteration because


A - it uses stack instead of queue.
B - every recursive call has to be storeD.
C - both A & B are true.
D - None of the above are true.

The following sorting algorithms maintain two sub-lists, one sorted and one to be sorted −
A - Selection Sort
B - Insertion Sort
C - Merge Sort
D - both A &am; B

Interpolation search is an improved variant of binary search. It is necessary for this search
algorithm to work that −
A - data collection should be in sorted form and equally distributeD.
B - data collection should be in sorted form and but not equally distributeD.
C - data collection should be equally distributed but not sorteD.
D - None of the above.

Which data structure allows deleting data elements from front and inserting at rear?
A. Stacks
B. Queues
C. Deques
D. Binary search tree

Identify the data structure which allows deletions at both ends of the list but insertion at only
one enD.
A. Input-restricted deque
B. Output-restricted deque
C. Priority queues
D. None of above

Which of the following data structure is non-linear type?


A. Strings
B. Lists
C. Stacks
D. None of above

Which of the following data structure is linear type?


A. Strings
B. Lists
C. Queues
D. All of above

To represent hierarchical relationship between elements, which data structure is suitable?


A. Deque
B. Priority
C. Tree
D. All of above

A binary tree whose every node has either zero or two children is called
A. Complete binary tree
B. Binary search tree
C. Extended binary tree
D. None of above

The depth of a complete binary tree is given by


A. Dn = n log2n
B. Dn = n log2n+1
C. Dn = log2n
D. Dn = log2n+1

When representing any algebraic expression E which uses only binary operations in a 2-tree,
A. the variable in E will appear as external nodes and operations in internal nodes
B. the operations in E will appear as external nodes and variables in internal nodes
C. the variables and operations in E will appear only in internal nodes
D. the variables and operations in E will appear only in external nodes

A binary tree can easily be converted into q 2-tree


A. by replacing each empty sub tree by a new internal node
B. by inserting an internal nodes for non-empty node
C. by inserting an external nodes for non-empty node
D. by replacing each empty sub tree by a new external node

When converting binary tree into extended binary tree, all the original nodes in binary tree
are
A. internal nodes on extended tree
B. external nodes on extended tree
C. vanished on extended tree
D. None of above

The post order traversal of a binary tree is DEBFCA. Find out the pre order traversal
A. ABFCDE
B. ADBFEC
C. ABDECF
D. ABDCEF

Which of the following sorting algorithm is of divide-and-conquer type?


A. Bubble sort
B. Insertion sort
C. Quick sort
D. All of above

An algorithm that calls itself directly or indirectly is known as


A. Sub algorithm
B. Recursion
C. Polish notation
D. Traversal algorithm

In a binary tree, certain null entries are replaced by special pointers which point to nodes
higher in the tree for efficiency. These special pointers are called
A. Leaf
B. branch
C. path
D. thread

The in order traversal of tree will yield a sorted listing of elements of tree in
A. Binary trees
B. Binary search trees
C. Heaps
D. None of above

In a Heap tree
A. Values in a node is greater than every value in left sub tree and smaller than right sub tree
B. Values in a node is greater than every value in children of it
C. Both of above conditions applies
D. None of above conditions applies

In a graph if e=[u, v], Then u and v are called


A. endpoints of e
B. adjacent nodes
C. neighbors
D. all of above

A connected graph T without any cycles is called


A. a tree graph
B. free tree
C. a tree
D. All of above

In a graph if e=(u, v) means


A. u is adjacent to v but v is not adjacent to u
B. e begins at u and ends at v
C. u is processor and v is successor
D. both b and c

If every node u in G is adjacent to every other node v in G, A graph is said to be


A. isolated
B. complete
C. finite
D. strongly connected

Match the following.


A. Completeness i) How long does it take to find a solution
B. Time Complexity ii) How much memory need to perform the search.
C. Space Complexity iii) Is the strategy guaranteed to find the solution when there in one.
A. a-iii, b-ii, c-i
B. a-i, b-ii, c-iii
C. a-iii, b-i, c-ii
D. a-i, b-iii, c-ii

The number of comparisons done by sequential search is ………………


A. (N/2)+1
B. (N+1)/2
C. (N-1)/2
D. (N+2)/2

In ……………, search start at the beginning of the list and check every element in the list.
A. Linear search
B. Binary search
C. Hash Search
D. Binary Tree search

State True or False.


i) Binary search is used for searching in a sorted array.
ii) The time complexity of binary search is O(logn).
A. True, False
B. False, True
C. False, False
D. True, True

Which of the following is not the internal sort?


A. Insertion Sort
B. Bubble Sort
C. Merge Sort
D. Heap Sort

State True or False.


i) An undirected graph which contains no cycles is called forest.
ii) A graph is said to be complete if there is an edge between every pair of vertices.
A. True, True
B. False, True
C. False, False
D. True, False

In a queue, the initial values of front pointer f rare pointer r should be …….. and ………..
respectively.
A. 0 and 1
B. 0 and -1
C. -1 and 0
D. 1 and 0

In a circular queue the value of r will be ..


A. r=r+1
B. r=(r+1)% [QUEUE_SIZE – 1]
C. r=(r+1)% QUEUE_SIZE
D. r=(r-1)% QUEUE_SIZE

Which of the following statement is true?


i) Using singly linked lists and circular list, it is not possible to traverse the list backwards.
ii) To find the predecessor, it is required to traverse the list from the first node in case of
singly linked list.
A. i-only
B. ii-only
C. Both i and ii
D. None of both

The advantage of …………….. is that they solve the problem if sequential storage
representation. But disadvantage in that is they are sequential lists.

A. Lists
B. Linked Lists
C. Trees
D. Queues

What will be the value of top, if there is a size of stack STACK_SIZE is 5


A. 5
B. 6
C. 4
D. None

………… is not the operation that can be performed on queue.


A. Insertion
B. Deletion
C. Retrieval
D. Traversal

There is an extra element at the head of the list called a ……….


A. Antinel
B. Sentinel
C. List header
D. List head
In general, the binary search method needs no more than ……………. comparisons.
A. [log2n]-1
B. [logn]+1
C. [log2n]
D. [log2n]+1
UNIT-1
Marks distribution for Unit 1

4 + 4+ 2 +2 +1 = 13 Marks (Only 2 Question will be asked for 4 marks , 2 Questions will be asked for 2 Marks,
1 Question will be asked for 1 Mark )
Syllabus for Unit-1

Algorithms- Problem Solving, Introduction to Algorithms, Characteristics of algorithms, Algorithm design


tools: Pseudo code and flowchart, Analysis of Algorithms, Complexity of algorithms- Space complexity, Time
complexity, Asymptotic notation- Big-O, Theta and Omega, standard measures of efficiency.
Data Structures- Data structure, Abstract Data Types (ADT), Concept of linear and Non-linear, static and
dynamic, persistent and ephemeral data structures, and relationship among data, data structure, and algorithm,
From Problem to Program.
Algorithmic Strategies- Introduction to algorithm design strategies- Divide and Conquer, and Greedy strategy.
Recurrence relation - Recurrence Relation, Linear Recurrence Relations, With constant Coefficients,
Homogeneous Solutions. Solving recurrence relations
Reference Book:

• “Fundamentals of Algorithmics”, Brassard & Bratley, ISBN 13-9788120311312


Id 1
Question The most common data types are..............
A Numeric, character, and logical.
B Array, integer and float
C Variable, Character and logical
D main, float and print
Answer A
Marks 2

Id 2
Question Numeric data include...........
A Double and Float
B integers and real numbers

C long int and short int


D None of these
Answer B
Marks 2

Id 3
Question Range for Positive & Negative Integers numbers are.......
A 4,792 or -637
B 5,297 or -376
C 9724 or -367
D 3,297 or -376
Answer B
Marks 2

Page 1
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Id 4
Question structure chart Or interactivity chart Shows -----------------
A input, the processing, and the output;
B a beginning analysis of the problem
C overall layout or structure of the solution;
D a language like solution
Answer C
Marks 2
Unit 1

Id 5
Question IPO chart, shows -----------------
A a language like solution
B a beginning analysis of the problem
C overall layout or structure of the solution;
D input, the processing, and the output;
Answer Correct Option D
Marks 2
Unit 1

Id 6
Question pseudo code shows --------------
A input, the processing, and the output;
B a beginning analysis of the problem
C overall layout or structure of the solution;
D a language like solution
Answer Correct Option D
Marks 2
Unit 1

Id 7
Question ---------------shows the relationship between the modules and the data needed for the
modules.
A coupling diagram and Data Dictionary
B IPO chart
C interactivity chart
D pseudo code
Answer Correct Option A
Marks 2
Unit 1

Page 2
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Id 8
Question Identify the correct sequence of problem analysis chart.
A 1)Given Data, 2)Solution Alternatives,3)Processing Required , 4)Required Results
B 1) Given Data, 2) Required Results , 3) Processing Required , 4)Solution Alternatives
C 1)Processing Required, 2) Required Results , 3)Given Data, 4)Solution Alternatives
D 1) Given Data, 2) Required Results , 3) Solution Alternatives, 4)Processing Required
Answer Correct Option B
Marks 2
Unit 1

Id 9
Question In interactivity chart Dark circle • on module link shows
A module is part of a set but that are not processed many times
B module is not a part of set that are processed many times & in a loop.
C module is part of a set that are processed many times & in a loop.
D None of these
Answer Correct Option C
Marks 2
Unit 1

Id 13
Question arrange the essential data items for IPO Chart in correct order
A 1)Output 2)Processing 3)Module Reference 4)Input
B 1)Input 2)Module 3) Processing Reference 4)Output
C 1)Input 2)Processing 3)Module Reference 4)Output
D None of these
Answer Correct Option C
Marks 4
Unit 1
Id Keep it blank

Id 10
Question If max is a function that returns the larger of the two integers, given as arguments,
then which of the following statements finds the largest of three given numbers
A max(max(a,b),max (a,c))
B max(max(a,b),max (b,c))
C max(b,max (a,c))
D All of these
Answer Correct Option D
Marks 4

Page 3
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 11
Question A function can make…………..
A One throw
B One throw of each scale type
C One throw of each programmer defined type
D As many throws of as many types as necessary
Answer Correct Option D
Marks 2
Unit 1

Id 12
Question Consider the function
find ( int x, int y)
{
return (( x < y ) ? 0 : ( x - y ));
}
Let a, b be two non-negative integers.
The call find{ a, find(a, b)} can be used to find the
A maximum of a,b
B positive difference of a,b
C sum of a,b
D minimum of a,b
Answer Correct Option D
Marks 4
Unit 1

Id 13
Question Let a, b be two non-negative integers. Which of the following calls, finds the positive
difference of a and b ?
A find(a,b) + find(b,a)
B find(a, find(a,b))
C a + find(a,b)
D b + find(a,b)
Answer Correct Option A
Marks 4
Unit 1

Id 14
Question The default parameter passing mechanism is
A call by value

Page 4
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

B call by reference
C call by value result
D none of the above
Answer Correct Option A
Marks 2
Unit 1

Id 15
Question Use of functions
A helps to avoid repeating a set of statements many times
B enhances the logical clarity of the program
C helps to avoid repeated programming across programs
D all of the above
Answer Correct Option D
Marks 2
Unit 1

Id 15
Question Pick the correct statements
A The body of a function should have only one return statement
B The body of a function may have many return statements
C A function can return only one value to the calling environment
D Both (b) and (c )
Answer Correct Option D
Marks 2
Unit 1

Id 16
Question Forward declaration is absolutely necessary
A if a function returns a non integer quantity
B lithe function call precedes its definition
C if the function call precedes its definition and the function returns a non integer
quantity
D none of the above
Answer Correct Option C
Marks 2
Unit 1

Id 17
Question void can be used…………
A as a data type of a function that returns nothing to its calling environment

Page 5
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

B inside the brackets of a function that does not need any argument
C in an expression
D Both (a) and (b)
Answer Correct Option D
Marks 2
Unit 1

Id 18
Question Any C++ program
A must contain at least one function
B need not contain any function
C needs input data
D none of these
Answer Correct Option A
Marks 1
Unit 1

Id 19
Question In a certain language, the expression 5-3+2 x 4+1, evaluates to 0. Which of the
following conclusions about the precedence and associativity of the operators +, -, *
are correct?
A + has precedence over - and - has precedence over *
B All these have equal precedence and associate to the right
C All these have equal precedence and associate to the left
D + and – have equal precedence, which is over * and all associate to the left
Answer A
Marks 2
Unit 1

Id 20
Question Which of the following comparison between static and dynamic type checking is
Incorrect?
A Dynamic type checking slows down execution
B Dynamic type checking offers more flexibility to the programmers
C Dynamic type checking is more reliable
D Dynamic type checking is done during compilation, unlike static type checking
Answer A
Marks 2
Unit 1

Id 21

Page 6
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Question The period of time between an allocation and its subsequent disposal is called
A Scope
B (dynamic) binding
C Lifetime
D Longevity
Answer C
Marks 2
Unit 1

Id 22
Question Consider the following sequence of statements
Statement 1: A := B+C
Statement 2: D := A+C
Statement 3: E := A+B
Statement 4: G := D-E
Statement 5: H := E+A
Statement 6: I := H+G
Which of the statements can be executed in parallel?

A 2 and 4
B 4 and 5
C 5 and 6
D 4, 5 and 6
Answer A
Marks 2
Unit 1

Id 23
Question If instructions are executed in parallel, whenever the required operands are
available, then the execution time of the previous problem is logically same as that of
sequential algorithm consisting of
A 3 statements
B 2 statements
C 4 statements
D 5 statements
Answer C
Marks 2
Unit 1

Id 24
Question
A recursive function f(x), is defined as follows:
if(x>100)
return(x-10)
else return(f(f(x+11)))
For which of the values of x, f(x) = 91?

Page 7
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

A 100
B 91
C 1
D 101
Answer A
Marks 2
Unit 1

Id 25
Question English language uses full stop as a sentence, while C++ uses ……….
A Separator
B Terminator
C Delimiter
D All of the above
Answer B
Marks 2
Unit 1

Id 26
Question The ASCII (American Standard Code for Information Interchange) character set
contains ------------- characters.
A 652
B 562
C 256
D 265
Answer C
Marks 2
Unit 1

Id 27
Question The character data set, sometimes called alphanumeric data set, consists of all------
A a, A
B A, Z
C #, &
D a, A, Z, 3, #, &
Answer D
Marks 2
Unit 1

Id 33
Question Character data or string data can be joined together with the + operator in an

Page 8
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

operation called-----------
A Palindrome
B Join
C Reverse String
D concatenation
Answer D
Marks 1
Unit 1

Id 34
Question When two pieces of character data are joined, the concatenation results in “4” + “4”
= ? (Replace? With suitable option)
A “44”
B 8
C “8”
D 4+4
Answer A
Marks 2
Unit 1

Id 35
Question Identify the data type for following data set : The price of an Item: 7.39, 12.98
A Numeric: real
B Character string
C Numeric: integer
D Logical
Answer A
Marks 1
Unit 1

Id 36
Question Identify the data type for following data set : An account number: “A2453,” “2987”
A Numeric: real
B Character string
C Numeric: integer
D Logical
Answer B
Marks 2
Unit 1

Id 37

Page 9
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Question Identify the data type for following data set :A quantity:12389
A Numeric: real
B Numeric: integer
C Reverse String
D Logical
Answer B
Marks 1
Unit 1

Id 38
Question Identify the data type for following data set :A credit check: True, False
A Numeric: real
B Numeric: integer
C Logical
D Character string
Answer C
Marks 1
Unit 1

Id 39
Question Choose the correct syntax for defining the function
A Function(Data);
B DefineFunction(value)
C FunctionName(Value)

D FunctionName(Value)
Answer C
Marks 1
Unit 1

Id 40
Question Absolute value, or a random number are belongs to which function type?
A Mathematical functions
B String functions.

C Conversion functions.
D Statistical functions.
Answer A
Marks 1
Unit 1

Id 41

Page 10
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Question Unrestricted use of goto is harmful because


A It makes debugging difficult
B It increase the running time of program
C It increase memory requirements of program
D It result in the compiler generating longer machine code
Answer Correct option A
Marks 1
Unit 1

Id 42
Question The recurrence relation that arises in relation with the complexity of binary search
is
A T(n)=T(n/2)+k, where k is constant
B T(n)=2T(n/2)+k, where k is constant
C T(n)=T(n/2)+log(n)
D T(n)=T(n/2)+n
Answer Correct option A
Marks 1
Unit 1

Id 43
Question Which of the following algorithm design technique is used in the quick sort
algorithm
A Dynamic programming
B Backtracking
C Divide & conquer
D Greedy method
Answer Correct option C
Marks 1
Unit 1

Id 44
Question Literal means
A a string
B a string constant
C a character
D an alphabet
Answer Correct Option B
Marks 2
Unit Unit 1

Page 11
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Id 45
Question The value of an automatic variable that is declared but not initialized will be
A 0
B -1
C unpredictable(garbage value)

D none of these
Answer Correct Option C
Marks 2
Unit Unit 1

Id 46
Question Which of the following is true of external variables?
A they provide a way for two way communication between functions
B their scope extends from the point of definition through the remainder of the
program
C if they are not initialized, they will be initilised to zero
D All of these
Answer Correct Option D
Marks 2
Unit Unit 1

Id 47
Question The declaration
int x : 4;
means
A x is a four digit integer
B x cannot be greater than a four digit integer
C x is a four-bit integer
D none of these
Answer Correct Option C
Marks 4
Unit Unit 1

Id 48
Question What is the correct way to round off x from a float, to an int value?

A y=(int) (x+0.5)
B y=int (x+0.5)
C y=(int) x+0.5
D y=(int)(int) x+0.50
Answer Correct Option A
Marks 4
Unit Unit 1

Page 12
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Id Keep it blank
Question By default, any real number in 'C' is treated as ……..
A A float
B A double
C A long double
D Depends on the memory model you are using
Answer Correct Option B
Marks 2
Unit Unit 1

Id 49
Question To print out a and b given below, which printf() statement would you use?
float a = 3.14;
double b = 3.14;
A printf("%f%f",a,b);
B printf("%Lf%f",a,b);
C printf("%f%Lf",a,b);
D printf("%Lf%Lf",a,b);
Answer Correct Option A
Marks 4
Unit Unit 1

Id 50
Question In the following 'C' code, in which order the functions would be called ?
a = ( f1(23,14 ) * f2 (12/14)) + f3 () ;
A f1,f2,f3
B f3,f2,f1
C The order may vary from compiler to compiler
D None of these
Answer Correct Option A
Marks 4

Unit Unit 1

Id 51
Question Which one of the following is not the step in ensuring best decision
A Identify the problem.
B Understand the problem.
C Discard the problem & solution
D Evaluate the solution.
Answer C
Marks 2

Page 13
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 52
Question Solutions that cannot be reached through a direct set of steps are called..........
A algorithmic solutions.
B alternative Solution
C heuristic solutions.
D straightforward Solution
Answer C
Marks 2
Unit 1

Id 53
Question A problem that can be solved with a series of actions is called............
A Heuristic solutions.
B Algorithmic solutions.
C straightforward Solution
D alternative Solution
Answer B
Marks 2
Unit 1

Id 54
Question A heuristic type of problems is called..........
A Operation Research

B Artificial intelligence
C Fuzzy Logic
D None of these
Answer B
Marks 2
Unit 1

Id 55
Question The.................... steps in problem solving lead to the best possible solution to a
problem.
A Six
B Four
C Five
D Seven
Answer A
Marks 1

Page 14
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 56
Question The..................solutions are reached in a series of steps.
A algorithmic solutions
B heuristic solutions
C Artificial intelligence
D straightforward Solution
Answer A
Marks 1
Unit 1

Id 57
Question The...................... solutions are attained through trial and error.
A straightforward Solution
B alternative Solution
C algorithmic solutions.
D heuristic solutions.
Answer D
Marks 1
Unit 1

Id 58
The programmer defines each .............and ............... in a problem solution as a
Question particular data type
A Pointer , Array
B Integer , Double
C String , Float
D constant , variable
Answer D
Marks 1
Unit 1

Id 59
Question Variable also known as .....
A Font
B Constant
C Identifier
D File
Answer C
Marks 1

Page 15
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 60
Question A constant is a value that never changes during the processing of all the instructions
in a solution
A FALSE
B None of these
C TRUE
D Both A &C
Answer D
Marks 1
Unit 1

Id 61
Question In UML Sequence diagram used to indicate----------

A to create a logical model of your solution


B how a system functions from the user‟s standpoint
C describe how a class functions
D interactivity between objects
Answer D
Marks 2
Unit 1

Id 62
Question In UML Use case diagrams Used to indicate----------
A how a system functions from the user‟s standpoint
B to create a logical model of your solution
C describe how a class functions
D interactivity between objects
Answer A
Marks 2
Unit 1

Id 63
Question In UML Class diagrams Used to indicate----------
A describe how a class functions
B how a system functions from the user‟s standpoint
C to create a logical model of your solution
D interactivity between objects
Answer A
Marks 2

Page 16
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 64
Question Two main measures for the efficiency of an algorithm are
A Processor and memory
B Complexity and Capacity
C Time and Space
D Data and Space
Answer C
Marks 2
Unit 1

Id 65
Question The time factor while determining the efficiency of algorithm is measured by
A Counting microseconds
B Counting the number of key operations
C Counting the number of statements
D Counting the kilobytes of algorithm
Answer B
Marks 2
Unit 1

Id 66
Question The worst case occur in linear search algorithm when
A Item is somewhere in the middle of the array
B Item is not in the array at all
C Item is the last element in the array
D Item is the last element in the array or is not there at all
Answer D
Marks 2
Unit 1

Id 67
Question In case of ordinary int variables
A leftmost bit is reserved for sign
B rightmost bit is reserved for sign
C no bit is reserved for sign
D none of these
Answer A
Marks 2

Page 17
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 68
Question The variables which can be accessed by all modules in a program are known as

A Local variables
B Internal variables
C External variables
D Global variables
Answer Correct Option (D)
Marks 2
Unit 1

ID 69
Question The basic unit of information is the
A Byte
B Bit
C Block
D Sector
Answer B
Marks 2
Unit 1

ID 70
Question The most widely used method for interpreting bit setting as nonnegative integer is
the
A Octal number system
B ASCII
C ANS!
D Binary number system
Answer D
Marks 2
Unit 1

ID 71
Question The method used by the computers to represent real number is
A Floating-point notation
B Mantissa
C ANSI
D Binary number system
Answer D
Marks 2

Page 18
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

ID 72
Question The variable which can be accessed by all modules in a program, are known as
A Local variable
B Internal variable
C External variable
D Global variable
Answer D
Marks 2
Unit 1

ID 73
Question In which kind of storage structure for string , one can easily insert ,delete,
concatenate ,and rearrange substring?
A Fixed length storage structure
B Variable length storage structure
C Linked list storage
D Array type storage
Answer C
Marks 2
Unit 1

ID 74
Question Which of the following sorting procedure is the slowest ?
A Quick sort
B Heap sort
C Shell sort
D Bubble sort
Answer B
Marks 2
Unit 1

ID 75
Question The smallest element of an array‟s index is called its

A Lower bound
B Upper bound
C Range
D Extraction
Answer A

Page 19
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Marks 2
Unit 1

ID 76
Question The preliminary evaluation of a top-down design before programs are written is
referred to as a (an)
A Informal design review
B Structured walk through
C formal design review
D Scheduled review
Answer A
Marks 2
Unit 1

ID 77
Question Which of the following is not an example of program documentation
A Source code
B Object code
C Specification
D Identifier names
Answer B
Marks 1
Unit 2

ID 78
Question Which of the following is non-essential to stepwise refinement?
I. Refining the subprogram
II. Decomposing the problem into subprograms
III. Declaring all variables
IV. Stating the problem simply
V. Inputing the data

A 2
B 3 and 4
C 4 and 5
D 5
Answer D
Marks 4
Unit 1

ID 79
Question A top-down approach to programming calls for
1. Working from the general to the specific

Page 20
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

2. Postponing the minor decisions


3. A systematic approach
4. Immediate coding of the problem

A 1
B 1 and 2
C 1,2 and 3
D 1,2 and 4
Answer C
Marks 4
Unit 1

ID 80
Question Repeated execution of simple computation of
A Round-off errors
B Syntax errors
C Run-time errors
D Logic errors
Answer A
Marks 2
Unit 1

ID 81
Question Which of the following boolean expression is true?
A 2*2+3=10
B (2.4)and not(4.3)
C (5.6)or(3 div 3 = 1)
D -7 * 2 + 2 * 7 = 1
Answer C
Marks 2
Unit 1

id 82
Question In C++ programming language, which of the following type of operators have the
highest precedence
A Relation operators
B Equality operators
C Logical operators
D Arithmetic operators
Answer D
Marks 2
Unit 1

Page 21
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

196 83
Question In C++ programming language, which of the following operators has the highest
precedence
A Unary +
B *
C ≥
D ==
Answer A
Marks 2
Unit 1

197 84
In C++ programming language, if the first and the second operands of operator + are
Question of types int and float,respectively,the result will be of type
A int
B float
C char
D Long int
Answer B
Marks 2
Unit 1

199 85
Question In C++ language, the bitwise operators can be applied to which of the following
operands
A char
B Short,long
C Int
D All of the above
Answer D
Marks 2
Unit 1

Id 86
Question Consider the n elements are to be sorted. what is the worst case time complexity of
20 bubble sort?
A O(1)
B O(log2 n)
C O(n)
2
D O(n )
Answer Correct Option (D)

Page 22
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Marks 4
Unit 1

Id 87
Question Consider that n elements are to be sorted. What is the worst case time complexity of
21 shell sort?
A O(n)
B O(n log2 n)

C O(n1.2)
D O(n)

Answer Correct Option (C)


Marks 4
Unit 1

Id 88
Question What is the worst case time Complexity of straight insertion sort algorithm to sort n
22 elements
A O (n)
B O (n Log2 n)

C O(n1.2)
D O(n2)
Answer Correct Option(D)
Marks 4
Unit 1

Id 89
Question What is the worst space time complexity of binary insertion sort algorithm to sort n
23 elements
A O(n)
B O(n log2 n)

C O(n1.2)
D O(n2)
Answer Correct Option (D)
Marks 4
Unit 1

Id 90
Question 25 Which of the following sorting procedure in the slowest?
A Quick sort
B Heap sort
C Shell sort

Page 23
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

D Bubble sort
Answer Correct option (D)
Marks 2
Unit 1

Id 91
Question In a 'C++' expression involving || operator, evaluation
A Will be stopped if one of its components evaluates to false
B Will be stopped if one of its components evaluates to true
C Takes place from right to left
D Will be stopped if both of its components evaluates to true
Answer Correct Option B
Marks 2
Unit 1

Id 92
Question In C programming language, which of the following type of operators have the
highest precedence
A Relational Operators
B Equality Operators
C Logical Operators
D Arithmetic Operators
Answer Correct Option D
Marks 2
Unit 1

Id 93
Question In C programming language, which of the following operators has the highest
precedence?
A Unary +
B *
C >=
D Equals (==)
Answer Correct Option A
Marks 2
Unit 1

Id 94
Question Which of the following operators takes only integer operands ?
A +
B *

Page 24
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

C /
D %
Answer Correct Option D
Marks 2
Unit 1

Id 95
Question In an operation involving || operator, evaluation
A takes palce from left to right
B Will be stopped if one of its components evaluates to true
C Takes place from right to left
D Both (a) and (b)
Answer Correct Option D
Marks 2
Unit 1

Id 96
Question Pick the operators that associate from the left
A +
B ,
C <
D All the above
Answer Correct Option D
Marks 2
Unit 1

Id 97
Question The operators . , || , < , = , if arranged in the ascending order of precedence reads
A . , || , < , =
B (=, < , ||, .)
C (=, || , < , .)

D (< , || , = , .)
Answer Correct Option C
Marks 2
Unit 1

Id 98
Question The expression 4 + 6 / 3 * 2 - 2 + 7 % 3 evaluates to
A 3
B 5

Page 25
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

C 6
D 7
Answer Correct Option D
Marks 4
Unit 1

Id 99
Question Which of the following sorting algorithm is stable
A insertion sort.
B bubble sort.
C quick sort.
D heap sort.
Answer Correct Option D
Marks 2
Unit 1

Id 100
Question The number of elements that can be sorted in Θ(logn) time using heap sort is
A Θ(1)
B Θ(√logn)
C Θ(√logn)
D Θ(logn)
Answer Correct Option A
Marks 2
Unit 1

Id 101
Question A sort which relatively passes through a list to exchange the first element with any
element less than it and then repeats with a new first element is called
A Insertion sort
B Selection sort
C Heap sort
D Quick sort
Answer Correct Option D
Marks 2
Unit 1

Id 102
Question A sorting technique which uses the binary tree concept such that label of any node is
larger than all the labels in the subtrees, is called
A Selection sort

Page 26
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

B Insertion sort
C Insertion sort
D Quick sort
Answer Correct Option C
Marks 2
Unit 1

Id 103
Question A sort which uses binary tree concept such that any number is larger than all the
numbers in the subtree below it,is called
A Selection sort
B Insertion sort
C Heap sort
D Quick sort
Answer Correct Option C
Marks 2
Unit 1

Id 104
Question Which sorting algorithm uses the median-of-3 partitioning?
A heap sort

B merge sort
C quick sort
D Shell sort
Answer Correct Option
Marks 2
Unit 1

Id 105
Question Which data type is not a primary data type?
A int
B array
C float
D char
Answer Correct Option B
Marks 1
Unit 1

Id 106
Question How much memory is required to store a value of type double
A 4bytes

Page 27
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

B 6 bytes
C 8 bytes
D 10 bytes
Answer Correct Option C
Marks 1
Unit 1

Id 107
Question The modifier which is used to declare a variable as constant
A short
B signed
C unsigned
D const
Answer Correct Option D
Marks 1
Unit 1

Id 108
Question A declaration "short int" is used for variables
A which have a short duration in a program
B which have short names
C which may require less storage than normal integer
D all of these
Answer Correct Option C
Marks 1
Unit 1

Id 109
Question 5 The number of swapping needed to sort the number 8,12,7,9,31,19,5,13 in ascending
order, using bubble sort is
A 11
B 12
C 13
D 14
Answer D
Marks 4
Unit 1

Id 110
Question 6 Given 2 sorted list of size „m‟ and „n‟ respectively. The number of comparisons needed
in the worst case by the merge sort algorithm will be

Page 28
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

A mn
B max (m,n)
C min (m,n)
D M+n-1
Answer B
Marks 4
Unit 1

Id 111

A hash table with 10 buckets with one slot per bucket is depicted. The symbols, S1 to
Question 8 S7 are initially entered using a hashing function with linear probing. The maximum
number of comparisons needed in searching an item that is not present is
A 4
B 5
C 6
D 3
Answer B
Marks 4
Unit 1

Id 112
Question 9 A binary tree in which every non-leaf node has non-empty left and right sub-trees is
called a strictly binary tree. Such a tree with 10 leaves
A Cannot have more than 19 node
B Has exactly 19 nodes
C Has exactly 17 nodes
D Cannot have more than 17 nodes
Answer A
Marks 4
Unit 1

Id 113
Question 87 The variables which can be accessed by all modules in a program, are called
A local variables
B internal variables
C external variables
D global variable
Answer D
Marks 2
Unit 1

Page 29
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Id 114
Question 90 A static variable
A cannot be initialized
B is initialized once at the commencement of execution and cannot be changed at run
time

C retains its value throughout the file of the program


D is same as an automatic variable but is placed at the head of the program
Answer C
Marks 2
Unit 1

Id 115
Question 31 To find the length or the number of characters in the string, which function type you
will use?
A String Functions
B Mathematical functions.
C Conversion functions.
D Statistical functions.
Answer A
Marks 1
Unit 1

Id 116
Question 32 Match the Definitions from given options, for the function Sqrt(N)
A Returns the absolute value of N
B Returns the square root of N.
C Returns the rounded value of N to the n1 place.
D Returns a random number between 0 and 1
Answer B
Marks 2
Unit 1

Id Keep it blank
Question 33 Match the Definitions from given options, for the function Abs(N)
A Returns the square root of N.
B Returns the absolute value of N.
C Returns the rounded value of N to the n1 place.
D Returns a random number between 0 and 1
Answer B
Marks 2
Unit 1

Page 30
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .40

Id 117
Question 34 If we use function Integer (5.7269) then what will be the result it will return.
A 5.72
B 5.7269
C 5
D 5.7
Answer C
Marks 4
Unit 1

Id 118
Question 35 If we use function Abs (-3)then what will be the result it will return.
A -3
B -3
C 3
D A3.0
Answer C
Marks 4
Unit 1

Id 119
Question Replace blank space with suitable option :- ----------- are used to calculate things
such as maximum values, minimum values, and so forth..
A Statistical functions.
B Mathematical functions.
C String functions.
D Conversion functions
Answer A
Marks 1
Unit 1

Id 120
Question Select appropriate definition from given options for the function Value(S)
A Changes a string value into a numeric value.
B Changes a numeric value into a string value.

Page 31
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .41

C Returns the average of a list of numbers.


D Returns the maximum value from a list of numbers.
Answer A
Marks 2
Unit 1

Id 121
Question Select appropriate definition from given options for the function String(N)
A Changes a string value into a numeric value.
B Changes a numeric value into a string value.
C Returns the average of a list of numbers.
D Returns the maximum value from a list of numbers..
Answer B
Marks 2
Unit 1

Id 122
Question Which of the following sorting algorithms does not have a worst case running time of
o(n2)
A Insertion sort
B Merge sort
C Quick sort
D Bubble sort
Answer Correct Option (B)
Marks 2
Unit 1

Id 123
Question Identify the operator & operand from given expression 5 + 7
A 5 and 7 are operator, + is the operand
B 5 is operator & 7 is operand
C + is the operator, 5 and 7 are the operand
D None of these
Answer C
Marks 1
Unit 1

Page 32
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Id 124
Question Calculate the resultant for the operation like 9 MOD 4
A 2
B 0.44
C 2.25

D 1
Answer D
Marks 2
Unit 1

Id 125
Question Choose the correct resultant for the logical operation like:- True AND True
A TRUE
B FALSE
C Both A&B
D None of these
Answer A
Marks 2
Unit 1

Id 126
Question Construct the expression for”a 40-hour work week and overtime pay at 1.5 times
regular pay, calculated overtime pay would subtract 40 from the hours worked and
multiply the result by the regular wage times 1.5”
A (Hours-40)*Wage*1.5
B (Wage-40)*Hours*1.5
C (Hours-1.5)*Wage*40
D (Overtime-40)*Regular Pay*1.5
Answer A
Marks 2
Unit 1

Id 127
Question --------------------refers to the rules governing the computer operating system, the
language, and the application.
A Bug.
B Syntax
C Debugging.
D Testing
Answer B
Marks 2

Page 33
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 128
Question Problem analysis chart shows -----------------
A input, the processing, and the output;
B overall layout or structure of the solution;
C a beginning analysis of the problem
D a language like solution
Answer C
Marks 1
Unit 1

Id 129
Question Which of the following case does not exist in complexity theory?
A Best case
B Worst case
C Average case
D Null case
Answer D
Marks 1
Unit 1

Id 130
Question The complexity of linear search algorithm is
A O(n)
B O(log n)
C O(n2)
D O(n log n)
Answer A
Marks 1
Unit 1

Id 131
Question The complexity of Binary search algorithm is
A O(n)
B O(log n)
C O(n2)
D O(n log n)
Answer B
Marks 1
Unit 1

Id 132
Question The complexity of merge sort algorithm is
A O(n)
B O(log n)
C O(n2)

Page 34
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

D O(n log n)
Answer D
Marks 1
Unit 1

Id 133
Question The complexity of Bubble sort algorithm is
A O(n)
B O(log n)
C O(n2)
D O(n log n)
Answer C
Marks 1
Unit 1

Id 134
Question The Worst case occur in linear search algorithm when
A Item is somewhere in the middle of the array
B Item is not in the array at all
C Item is the last element in the array
D Item is the last element in the array or is not there at all
Answer D
Marks 1
Unit 1

Id 135
Question The worst case complexity for insertion sort is
A O(n)
B O(log n)
C O(n2)
D O(n log n)
Answer C
Marks 1
Unit 1

Id 136
Question The complexity of Fibonacci series is
A O(2n)
B O(log n)
C O(n2)
D O(n log n)
Answer A
Marks 1
Unit 1

Id 137
Question If f(x) = 3x2 + x3logx, then f(x) is
A O(x2)
B O(x3)

Page 35
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

C O(x)
D O(1)
Answer B
Marks 1
Unit 1

Id 138
Question The big-O notation for f(n) = (nlogn + n2)(n3 + 2) is
A O(n2)
B O(3n)
C O(n4)
D O(n5)
Answer D
Marks 1
Unit 1

Id 139
Question The big-O notation for f(n) = 2log(n!) + (n2 + 1)logn is
A n
B n2
C nlogn
D n2logn
Answer D
Marks 1
Unit 1

Id 140
Question The big-theta notation for function f(n) = 2n3 + n – 1 is
A n
B n2
C n3
D n4
Answer C
Marks
Unit

Id 141
Question The big-theta notation for f(n) = nlog(n2 + 1) + n2logn is
A n2logn
B n2
C logn
D nlog(n2)
Answer A
Marks 1
Unit 1

Id 142
Question The big-omega notation for f(x, y) = x5y3 + x4y4 + x3y5 is
A x5y3

Page 36
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

B x5y5
C x3y3
D x4y4
Answer C
Marks 1
Unit 1

Id 143
Question If f1(x) is O(g(x)) and f2(x) is o(g(x)), then f1(x) + f2(x) is
A O(g(x))
B o(g(x))
C O(g(x)) + o(g(x))
D None of these
Answer A
Marks 1
Unit 1

Id 144
Question The big-O notation for f(x) = 5logx is
A 1
B X
C X2
D X3
Answer B
Marks 1
Unit 1

Id 145
Question Which if the following is/are the levels of implementation of data structure
A Abstract level
B Application level
C Implementation level
D All of the above
Answer D
Marks 1
Unit 1

Id 146
Question ……………….. level is where the model becomes compatible executable code
A Abstract level
B Application level
C Implementation level
D All of the above
Answer C
Marks 1
Unit 1

Id 147
Question Stack is also called as

Page 37
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

A Last in first out


B First in last out
C Last in last out
D First in first out
Answer A
Marks 1
Unit 1

Id 148
Which of the following is true about the characteristics of abstract data types?
i) It exports a type.
Question ii) It exports a set of operations
A True, False
B False, True
C True, True
D False, False
Answer C
Marks 1
Unit 1

Id 149
Question …………… is not the component of data structure.
A Operations
B Storage Structures
C Algorithms
D None of above
Answer D
Marks 1
Unit 1

Id 150
Question Which of the following is not the part of ADT description?
A Data
B Operations
C Both of the above
D None of the above
Answer D
Marks 1
Unit 1

Id 151
Inserting an item into the stack when stack is not full is called …………. Operation
and deletion of item form the stack, when stack is not empty is called
Question ………..operation.
A push, pop
B pop, push
C insert, delete
D delete, insert
Answer A
Marks 2

Page 38
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 152
……………. Is a pile in which items are added at one end and removed from the
Question other.
A Stack
B Queue
C List
D None of the above
Answer B
Marks 1
Unit 1

Id 153
………… is very useful in situation when data have to stored and then retrieved in
Question reverse order.
A Stack
B Queue
C List
D Link list
Answer A
Marks 1
Unit 1

Id 154
Question Which data structure allows deleting data elements from and inserting at rear?
A Stacks
B Queues
C Dequeues
D Binary search tree
Answer B
Marks 1
Unit 1

Id 155
Which of the following data structure can't store the non-homogeneous data
Question elements?
A Arrays
B Records
C Pointers
D Stacks
Answer A
Marks 1
Unit 1

Id 156
A ....... is a data structure that organizes data similar to a line in the supermarket,
Question where the first one in line is the first one out.
A Queue linked list
B Stacks linked list

Page 39
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

C Both of them
D Neither of them
Answer A
Marks 1
Unit 1

Id 157
Identify the data structure which allows deletions at both ends of the list but
Question insertion at only one end.
A Input-restricted deque
B Output-restricted deque
C Priority queues
D None of above
Answer A
Marks 1
Unit 1

Id 158
Question Which of the following data structure is non-linear type?
A Strings
B Lists
C Stacks
D None of above
Answer D
Marks 1
Unit 1

Id 159
Question Which of the following data structure is linear type?
A Strings
B Lists
C Queues
D All of above
Answer D
Marks 1
Unit 1

Id 160
To represent hierarchical relationship between elements, which data structure is
Question suitable?
A Deque
B Priority
C Tree
D All of above
Answer C
Marks 1
Unit 1

Id 161

Page 40
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Question An algorithm that calls itself directly or indirectly is known as


A Sub algorithm
B Recursion
C Polish notation
D Traversal algorithm
Answer B
Marks 1
Unit 1

Id 162
Question A mathematical-model with a collection of operations defined on that model is called
A Data Structure
B Abstract Data Type
C Primitive Data Type
D Algorithm
Answer B
Marks 1
Unit 1

Page 41
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

UNIT-2
Marks distribution for Unit 2

4 + 4+ 2 +2 +1 = 13 Marks (Only 2 Question will be asked for 4 marks , 2 Questions will be asked for 2
Marks, 1 Question will be asked for 1 Mark )
Syllabus for Unit-2

Sequential Organization, Linear Data Structure Using Sequential Organization, Array as an Abstract
Data Type, Memory Representation and Address Calculation, Inserting an element into an array,
Deleting an element, Multidimensional Arrays, Two-dimensional arrays, n- dimensional arrays, Concept
of Ordered List, Single Variable Polynomial, Representation using arrays, Polynomial as array of
structure, Polynomial addition, Polynomial multiplication, Sparse Matrix, Sparse matrix representation,
Sparse matrix addition, Transpose of sparse matrix, String Manipulation Using Array.
Case Study- Use of sparse matrix in Social Networks and Maps.
Reference Book:
• “Data Structures Using C++”, Varsha H. Patil, ISBN 13-9780198066231
Id 1
What will happen if in a C++ program, you assign a value to an array element whose
Question subscript exceeds the size of array?
A The element will be set to 0.
B The compiler would report an error
C The program may crash if some important data gets overwritten.
D The array size would appropriately grow.
Answer C
Marks 2

Id 2
What does the following declaration mean?
Question int (*ptr)[10];
A ptr is array of pointers to 10 integers
B ptr is a pointer to an array of 10 integers
C ptr is an array of 10 integers
D ptr is an pointer to array
Answer B
Marks 2

Id 3
Question In C++, if you pass an array as an argument to a function, what actually gets passed?
A Value of elements in array
B First element of the array
C Base address of the array
D Address of the last element of array
Answer C
Marks 2

Id 4
What is meaning of following declaration ?
Question int arr[20];

Page 1
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

A None of these
B Integer Array of size 20
C Array of Size 20
D Array of size 20 that can have integer address
Answer B
Marks 2

Id 5

int a[20];
What will be the size of above array element ?
Question
A 20
B 19
C 22
D 21
Answer A
Marks 2

Id 6
Question What is meaning of the following statement? int *ptr[20];
A None of these
B Array of Integer Pointers of size 20
C Integer Array to Integer Pointers having size 20
D Integer Array of size 20 pointing to an Integer Pointer
Answer B
Marks 2

Id 7
Question In C++ Programming, If we need to store word "INDIA" then syntax is as below -
char name[]; name = "INDIA";
A
char name[6] = {'I','N','D','I','A'}
B
char name[6] = {"I","N","D","I","A"}
C
char name[6] = {'I','N','D','I','A','\0'}
D
Answer D
Marks 2

Id 8

int RollNum[30][4];
Above is an example of:
Question
A 2-D Array
B 1-D Array
C 3-D Array
D 4-D Array

Page 2
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Answer A
Marks 2

Id 9
What is the output of this C code?
#include <stdio.h>
void main()
{
int a[2][3] = {1, 2, 3, 4, 5};
int i = 0, j = 0;
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
printf("%d", a[i][j]);
Question }
A 123450
B 1 2 3 4 5 junk
C 123455
D Run time error
Answer A
Marks 4

Id 10
What is the output of this C code?
#include <stdio.h>
void main()
{
int a[2][3] = {1, 2, 3, , 4, 5};
Question
int i = 0, j = 0;
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
printf("%d", a[i][j]);
}
A 1 2 3 junk 4 5
B Compile time error
C 123045
D 123345
Answer B
Marks 4
Unit

Id 11
What is the output of this C code?
#include <stdio.h>
void f(int a[ ][3])
{
a[0][1] = 3;
int i = 0, j = 0;
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
printf("%d", a[i][j]);
}
void main()
Question {

Page 3
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

int a[2][3] = {0};


f(a);
}
A 030000
B Junk 3 junk junk junk junk
C Compile time error
D All junk values
Answer A
Marks 4
Unit

Id 12
What is the output of this C code?
#include <stdio.h>
void f(int a[ ][ ])
{
a[0][1] = 3;
int i = 0, j = 0;
for (i = 0;i < 2; i++)
for (j = 0;j < 3; j++)
printf("%d", a[i][j]);
}
void main()
{
int a[2][3] = {0};
f(a);
Question }
A 030000
B Junk 3 junk junk junk junk
C Compile time error
D All junk values
Answer C
Marks 4
Unit

Id 13
Which of the following statements are correct about 6 used in the program?
int num[6];
Question num[6]=21;
In the first statement 6 specifies a particular element, whereas in the second
A statement it specifies a type.
In the first statement 6 specifies a array size, whereas in the second statement it
B specifies a particular element of array.
In the first statement 6 specifies a particular element, whereas in the second
C statement it specifies a array size.
D In both the statement 6 specifies array size.
Answer B
Marks 2
Unit

Id 14
Which of the following statements are correct about an array?
1: The array int num[26]; can store 26 elements.
Question 2: The expression num[1] designates the very first

Page 4
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

element in the array.


3: It is necessary to initialize the array at the time of
declaration.
4: The declaration num[SIZE] is allowed if SIZE is a
macro.

A 1
B 1,4
C 2,3
D 2,4
Answer B
Marks 2
Unit

Id 15
What will be the output of the program ?
#include<stdio.h>

int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
return 0;
Question }
A 2,1,15
B 1,2,5
C 3,2,15
D 2,3,20
Answer C
Marks 4
Unit

Id 16
Question What will be the output of the program ?
#include<stdio.h>
int main()
{
static int a[2][2] = {1, 2, 3, 4};
int i, j;
static int *p[] = {(int*)a, (int*)a+1, (int*)a+2};
for(i=0; i<2; i++)
{
for(j=0; j<2; j++)
{
printf("%d, %d, %d, %d\n", *(*(p+i)+j), *(*(j+p)+i),
*(*(i+p)+j), *(*(p+j)+i));
}
}
return 0;
}
1, 1, 1, 1
A 2, 3, 2, 3

Page 5
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

3, 2, 3, 2
4, 4, 4, 4
1, 2, 1, 2
2, 3, 2, 3
3, 4, 3, 4
B 4, 2, 4, 2
1, 1, 1, 1
2, 2, 2, 2
2, 2, 2, 2
C 3, 3, 3, 3
1, 2, 3, 4
2, 3, 4, 1
3, 4, 1, 2
D 4, 1, 2, 3
Answer C
Marks 4
Unit

Id 17
What will be the output of the program ?
#include<stdio.h>
void fun(int **p);

int main()
{
int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 8, 7, 8, 9, 0};
int *ptr;
ptr = &a[0][0];
fun(&ptr);
return 0;
}
void fun(int **p)
{
printf("%d\n", **p);
Question }
A 1
B 2
C 3
D 4
Answer A
Marks 4

Id 18
Question The extra key inserted at the end of the array is called a
A End Key
B Stop Key
C Sentinel
D Transposition
Answer C
Marks 1

Id 19
Question The size of array int a[5]={1,2} is
A 4
B 12

Page 6
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

C 10
D 6
Answer C
Marks 2

Id 20
The output of the following statements is
char ch[6]={„e‟, „n‟, „d‟, „\0‟, „p‟};
Question printf(“%s”, ch);
A endp
B end0p
C end
D error
Answer C
Marks 2

Id 21
Question To declare an array S that holds a 5-character string, you would write
A char S[5]
B String S[5]
C char S[6]
D String S[6]
Answer A
Marks 1

Id 22
Question If x is one dimensional array, then pick up the correct answer
A *(x + i) is same as &x[i]
B *&x[i] is same as x + i
C *(x + i) is same as x[i] +1
D *(x + i) is same as *x[i]
Answer A
Marks 2
Unit

Id 23
What will be the output of the following code segment?
main( ) {
char s[10];
strcpy(s, “abc”);
printf(“%d %d”, strlen(s), sizeof(s));
Question }
A 3 10
B 33
C 10 3
D 10 10
Answer A

Page 7
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Marks 2
Unit

Id 24
Question What is the output of the following C++ program?
# include <stdio.h>
main ( )
{
int a, b=0;
static int c [10]={1,2,3,4,5,6,7,8,9,0};
for (a=0; a<10;+ + a)
if ((c[a]%2)= = 0) b+ = c [a];
cout<< b;
}
A 20
B 25
C 45
D 90
Answer A
Marks 2
Unit

Id 25
Question Sparse matrices have?
A no zero
B many zero
C higher dimension
D none
Answer B
Marks 1
Unit

Id 26
Consider the polynomial p(x) = a0 + a1x + a2x^2 +a3x^3, where ai != 0, for all i. The
Question minimum number of multiplications needed to evaluate p on an input x is:
A 3
B 4
C 6
D 9
Answer A
Marks 2
Unit

Id 27

Page 8
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Question Which of the following data structure is linear data structure?


A Trees
B Graphs
C Arrays
D None of above
Answer C
Marks 1
Unit

Id 28
Question The elements of an array are stored successively in memory cells because
by this way computer can keep track only the address of the first element and the
A addresses of other elements can be calculated
the architecture of computer memory does not allow arrays to store other than
B serially
C both of above
D none of above
Answer A
Marks 1
Unit

Id 29
Question
Which of the following data structure is not linear data structure?
A Arrays
B Linked lists
C Both of above
D None of above
Answer D
Marks 1
Unit

Id 30
Question Finding the location of the element with a given value is:
A Traversal
B Search
C Sort
D None of above
Answer B
Marks 1
Unit

Id 31

Page 9
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Question Arrays are best data structures


A for relatively permanent collections of data
B for the size of the structure and the data in the structure are constantly changing
C for both of above situation
D for none of above situation
Answer A
Marks 1
Unit

Id 32
Question Each array declaration need not give, implicitly or explicitly, the information about
A the name of array
B the data type of array
C the first data from the set to be stored
D the index set of the array
Answer C
Marks 1
Unit

Id 33
Question Which of the following data structure is non-linear type?

A Strings
B Lists
C Stacks
D Tree
Answer D
Marks 1
Unit 2

Id 34
Question Which of the following data structure is linear type?
A Array
B Tree
C Graphs
D Hierarchy
Answer A
Marks 1
Unit 2

Id 35
Question The logical or mathematical model of a particular organization of data is called a

Page 10
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

.........

A Data structure
B Data arrangement
C Data configuration
D Data formation
Answer A
Marks 1
Unit 2

Id 36

Question The simplest type of data structure is ..................


A Multidimensional array
B Linear array
C Two dimensional array
D Three dimensional array
Answer A
Marks 1
Unit 2

Id 37
Question Arrays are best data structures ............
A For relatively permanent collections of data.
B For the size of the structure and the data in the structure are constantly changing
C For both of above situation
D For none of the above
Answer A
Marks 1
Unit 2

Id 38
Question Which of the following data structures are indexed structures?
A Linear arrays
B Linked lists
C Graphs
D Trees
Answer A
Marks
Unit

Id 39

Page 11
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Question Each node in a linked list has two pairs of .............. and ...................
A Link field and information field
B Link field and avail field
C Avail field and information field

D Address field and link field


Answer A
Marks 1
Unit 2

Id 40
Question A ........................ does not keep track of address of every element in the list.
A Stack
B String

C Linear array
D Queue
Answer A
Marks 1
Unit 2

Id 41
Question To implement Sparse matrix dynamically, the following data structure is used
A Trees
B Graphs
C Priority Queues
D Linked List
Answer D
Marks 1
Unit 2

Id 42
Question Sparse matrix has?
A Many zero entries
B Many non-zero entries
C Higher dimension
D None of the above
Answer A
Marks 1
Unit 2

Id 43

Page 12
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

The linked list implementation of sparse matrices is superior to the generalized dope
Question vector method because it is?
A Conceptually easier
B Completely dynamic
C Efficient in accessing an entry
D A and B
Answer D
Marks 1
Unit 2

Id 44
Question An array is a collection of:
A Different data types scattered throughout memory
B Same data types scattered throughout memory
C Same data types placed next to each other in memory
D Different data types placed next to each other in memory
Answer C
Marks 1
Unit 2

Id 45
Question Which of the declaration of array are correct?
A int a(25);
B int size = 10, b[size];
C int c = {0, 1, 2};

D None of the above


Answer D
Marks 1
Unit 2

Id 46
What is the difference between the 5‟s in these two expressions?(Select the correct
option)
int num[5];
Question num[5] = 11;
A First is particular element, second is type
B First is array size, second is particular element
C First is particular element, second is array size
D Both specify array size
Answer B
Marks 2
Unit 2

Page 13
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Id 47
Let A be a square matrix of size n x n. Consider the following program. What is the
expected output?
C = 100
for i = 1 to n do
for j = 1 to n do
{
Temp = A[i][j] + C
A[i][j] = A[j][i]
A[j][i] = Temp - C
}
for i = 1 to n do
for j = 1 to n do
Question Output(A[i][j]);
A The matrix A itself
B Transpose of matrix A
Adding 100 to the upper diagonal elements and subtracting 100 from diagonal
C elements of A
D None of the above
Answer A
Marks 4
Unit 2

Id 48
The minimum number of arithmetic operations required to evaluate the polynomial
Question P(X) = X5 + 4X3 + 6X + 5 for a given value of X using only one temporary variable.

A 6
B 7
C 8
D 9
Answer B
Marks 2
Unit 2

Id 49
Consider the following C++ function in which size is the number of elements in the
array E:
The value returned by the function MyX is the
int MyX(int *E, unsigned int size)
{
int Y = 0;
int Z;
int i, j, k;

for (i = 0; i < size; i++)


Y = Y + E[i];

for (i = 0; i < size; i++)


for (j = i; j < size; j++)
{
Question Z = 0;

Page 14
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

for (k = i; k <= j; k++)


Z = Z + E[k];
if (Z > Y)
Y = Z;
}
return Y;
}
A maximum possible sum of elements in any sub-array of array E.
B maximum element in any sub-array of array E.
C sum of the maximum elements in all possible sub-arrays of array E
D the sum of all the elements in the array E.
Answer A
Marks 4
Unit 2

Id 50
If array A is made to hold the string “abcde”, which of the following four test cases
will be successful in exposing the flaw in this procedure?
(1) oldc = "abc", newc = "dab"
(2) oldc = "cde", newc = "bcd"
(3) oldc = "bca", newc = "cda"
Question (4) oldc = "abc", newc = "bac"
A None
B 2 only
C 3 and 4 only
D 4 only
Answer C
Marks 4
Unit 2

Id 51
A program P reads in 500 integers in the range [0..100] representing the scores of
500 students. It then prints the frequency of each score above 50. What would be the
Question best way for P to store the frequencies?
A An array of 50 numbers
B An array of 100 numbers
C An array of 500 numbers
D A dynamically allocated array of 550 numbers
Answer A
Marks 4

Unit 2

Id 52
Consider the following C++ program that attempts to locate an element x in an
array Y[] using binary search. The program is erroneous.
f(int Y[10], int x) {
int i, j, k;
Question i = 0; j = 9;

Page 15
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

do {
k = (i + j) /2;
if( Y[k] < x) i = k; else j = k;
} while(Y[k] != x && i < j);
if(Y[k] == x) cout<<"x is in the array " ;
else cout<<" x is not in the array " ;
}
On which of the following contents of Y and x does the program fail?
A Y is [1 2 3 4 5 6 7 8 9 10] and x < 10
B Y is [1 3 5 7 9 11 13 15 17 19] and x < 1
C Y is [2 2 2 2 2 2 2 2 2 2] and x > 2
D Y is [2 4 6 8 10 12 14 16 18 20] and 2 < x < 20 and x is even
Answer C
Marks 4
Unit 2

Id 53
Consider the following C++ program that attempts to locate an element x in an
array Y[] using binary search. The program is erroneous.
f(int Y[10], int x) {
int i, j, k;
i = 0; j = 9;
do {
k = (i + j) /2;
if( Y[k] < x) i = k; else j = k;
} while(Y[k] != x && i < j);
if(Y[k] == x) cout<<"x is in the array " ;
else cout<<" x is not in the array " ;
}
Question What is the correction needed in the program to make it work properly?
A Change line 6 to: if (Y[k] < x) i = k + 1; else j = k-1;
B Change line 6 to: if (Y[k] < x) i = k - 1; else j = k+1;
C Change line 6 to: if (Y[k] <= x) i = k; else j = k;
D Change line 7 to: } while ((Y[k] == x) && (i < j));
Answer A
Marks 4
Unit 2

Id 54
A set X can be represented by an array x[n] as follows:

Consider the following algorithm in which x,y and z are Boolean arrays of size n:
algorithm zzz(x[] , y[], z [])
{
int i;
for (i=O; i<n; ++i)
z[i] = (x[i] ^ ~y[i]) V (~x[i] ^ y[i])
}
Question The set Z computed by the algorithm is:

Page 16
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

A (X Intersection Y)
B (X Union Y)
C (X-Y) Intersection (Y-X)
D (X-Y) Union (Y-X)
Answer D
Marks 4
Unit 2

Id 55
Question Array name indicates________
A Just the name of array

B Address of starting element


C Value of starting element
D None of the above
Answer B
Marks 1
Unit 2

Id 56
Question The array subscript always start at ________
A 1
B -1
C 0
D Any position
Answer C
Marks 1
Unit 2

Id 57
Question Array elements occupy______
A Varying length of memory locations for each element
B Subsequent memory locations
C Random memory locations
D None of these
Answer B
Marks 1
Unit 2

Id 58
Question In arrays ______ and ______ are difficult but ______ is easy operation.

Page 17
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

A Insertion, deletion, searching


B Searching, insertion, deletion
C Deletion, searching, insertion
D None of these.
Answer A
Marks 2
Unit 2

Id 59
What is the output for following program?
void main()
{
int a[5]={3,4};
cout<<a[2]<<a[3]<<a[4];
Question }
A 211
B Garbage value
C 122
D 000
Answer D
Marks 1
Unit 2

Id 60
What is the output for following program?
void main()
{
int i=0,a[3];
a[i] = i++;
cout<<a[i];
Question }
A Garbage value
B Syntax error
C 1
D 0
Answer A
Marks 1
Unit 2

Id 61
Question In Linked list, the logical order of elements ________
A Is determined by their physical arrangement
B Cannot be determined by their physical arrangement
C Is the same as their physical arrangement
D None of these.

Page 18
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Answer B
Marks 1
Unit 2

Id 62
Question In CLL, insertion of a record involves modification of……
A 1 pointer
B 2 pointers
C No pointer
D 3 pointers
Answer B
Marks 2
Unit 2

Id 63
Question For traversing a list, which pointer do you need?
A NULL
B Insertion
C Beginning
D Walking
Answer C
Marks 1
Unit 2

Id 64
Question The nth node in SLL, is accessed via ________
A Tail node
B Head node
C (n-1) nodes
D None of these
Answer B
Marks 1
Unit 2

Id 65
What is the output of this c++ code?
void main()
{
int a[2][3] = {1,2,3,4,5}
int i=0,j=0;
for(i=0 ; i<2 ; i++)
for(j=0 ; j<3 ; j++)
Question cout<<a[i][j];

Page 19
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

A 1 2 3 4 5 junk
B 123455
C 123450
D Run time error
Answer C
Marks 2
Unit 2

Id 66
Question Which of the following data structures are indexed structure?
A L
Trees
B Linked list
C Linear arrays
D All of these
Answer B
Marks 1
Unit 2

Id 67
When new data is to be inserted into a data structure, but there is no available space
Question is called ________________
A Overflow
B Saturated
C Houseful
D Underflow
Answer B
Marks 1
Unit

Id 68
Question Array name is ______
A An array variable
B A common name shared by all elements
C A keyword
D Not used in a program
Answer B
Marks 1
Unit 2

Id

Page 20
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Question To initialize a 5 element array all having value 1 is given by ……


A int num[ ] = (1);
B int num[ ] = {1,1,1,1,1};
C int num[ 5 ] = (1);
D int num[ 4 ] = (1,1,1,1,1);
Answer B
Marks 1
Unit 2

ID 69
Question Missing elements of partially initialized arrays are ………
A Set to zero
B Not defined
C Invalid
D Set to one
Answer C
Marks 1
Unit 2

ID 70
Question Two-way list may be maintained in memory by means of .............
A Queues
B Linear arrays
C Non linear arrays
D Stacks
Answer B
Marks 1
Unit 2

ID 71
Question Sparse matrices have?
A many zero entries
B many non- zero entries
C higher dimension
D none of above
Answer A
Marks 1
Unit 2

ID 72
Question Two dimensional arrays are also called ?

Page 21
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

A Matrix Array
B Table Array
C Both a and b
D None of the Above
Answer C
Marks 1
Unit 2

ID 73
Question Which of the following function sets first n characters of a string to a given character?
A strinit()
B strnset()
C strset()
D strcset()
Answer B
Marks 1
Unit 2

ID 74
Question If the two strings are identical, then strcmp() function returns
A -1
B 1
C 0
D 2
Answer C
Marks 1
Unit 2

ID 75
Question The library function used to find the last occurrence of a character in a string is
A strnstr()
B laststr()
C strrchr()
D strstr()
Answer C
Marks 1
Unit 2

ID 76
Which of the following function is used to find the first occurrence of a given string
Question in another string?
A strchr()

Page 22
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

B strrchr()
C strstr()
D strnset()
Answer C
Marks 1
Unit 2

ID 77
Which of the following function is more appropriate for reading in a multi-word
Question string?
A printf();
B scanf();
C gets();
D puts();
Answer C
Marks 1
Unit 2

ID 78
Question Which of the following function is correct that finds the length of a string?
int xstrlen(char *s)
{
int length=0;
while(*s!='\0')
{ length++; s++; }
return (length);
}
A
int xstrlen(char s)
{
int length=0;
while(*s!='\0')
length++; s++;
return (length);
}
B
int xstrlen(char *s)
{
int length=0;
while(*s!='\0')
length++;
return (length);
}
C
int xstrlen(char *s)
{
int length=0;
while(*s!='\0')
s++;
return (length);
}
D
Answer A
Marks 4
Unit 2

ID 79

Page 23
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Question An array elements are always stored in ________ memory locations.


A Sequential
B Random
C Sequential and Random
D None of the above
Answer A
Marks 1
Unit 2

ID 80
Question
A
B
C
D
Answer
Marks
Unit 2

ID 81
What will be printed after execution of the following code?
void main()
{
int arr[10] = {1,2,3,4,5};
printf("%d", arr[5]);
Question }
A Garbage Value
B 5
C 6
D 0
Answer D
Marks 1
Unit 2

ID 82
Question What is right way to Initialize array?
A int num[6] = { 21, 41, 2, 15, 4, 5 };
B int n{} = { 21, 41, 2, 15, 4, 5 };
C int n{6} = { 21, 41, 2 };
D int n(6) = { 21, 41, 2, 15, 4, 5 };
Answer A
Marks 1
Unit 2

Page 24
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

ID 83
What will be the output of the following code?\
#include"stdio.h"
void main()
{
int a[10];
printf("%d %d", a[-1], a[12]);
Question }
A 00
B Garbage value 0
C 0 Garbage Value
D Garbage value Garbage Value
Answer D
Marks 2
Unit 2

ID 84
Let x be an array. Which of the following operations are illegal?
1. ++X
2. X+1
3. X++
Question 4. X*2
A I and II
B I, II and III
C II and III
D I, III and IV
Answer D
Marks 2
Unit 2

ID 85
Question What is the maximum number of dimensions an array in C may have?
A 2
B 8
C 20
D Theoretically no limit. The only practical limits are memory size and compilers
Answer D
Marks 1
Unit 2

ID 86
What will be the output of the program?
#include"stdio.h"
int main()
Question {

Page 25
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

int arr[5] = {10};


printf("%d", 0[arr]);

return 0;
}
A 1
B 0
C 10
D 6
Answer C
Marks 2
Unit 2

ID
Question
A
B
C
D
Answer
Marks
Unit

ID
Question
A
B
C
D
Answer
Marks
Unit

ID
Question
A
B
C
D
Answer
Marks
Unit

Page 26
Question: 1
A data structure in which linear sequence is maintained by pointers is known as
(A) Array
(B) Stack
(C) Linked list
(D) Pointer-based data structure
Ans: C
Linked list
Question: 2
Which of the following data structure works on the principle of First Come First
Serve?
(A) Priority queue
(B) Heap
(C) Stack
(D) Queue
Ans: D
Queue
Question: 3
A ____ is a linear collection of self-referential structures, called nodes, connected by
pointer links.
(A) Queue
(B) Linked list
(C) Tree
(D) Stack
Ans: B
Linked list
Question: 4
A queue where all elements have equal priority is a
(A) ILFO data structure
(B) LILO data structure
(C) FIFO data structure
(D) LIFO data structure
Ans: C
FIFO data structure
Question: 5
A file that is only read by a program is known as ____
(A) Input file
(B) Temporary file
(C) Work file
(D) Input/output file
Ans: A
Input file

Question: 6
Which of the following sorting algorithm is the slowest?
(A) Bubble sort
(B) Heap sort
(C) Shell sort
(D) Quick sort
Ans: A
Bubble sort
Question: 7
Which of the following data structure can be used to represent many-to-many
relation?
(A) B-tree
(B) Binary tree
(C) Graph
(D) All of above
Ans: C
Graph
Question: 8
Which of the following statement is not true about linked lists?
(A) Element in a linked list, if it is sorted, can be quickly searched by applying binary
search technique
(B) Elements are not necessarily stored in contiguous locations
(C) Insertions and deletions can be performed efficiently as compared to arrays
(D) Linked list is a dynamic structure
Ans: A
Element in a linked list, if it is sorted, can be quickly searched by applying binary
search technique
Question: 9
Which of the following is not a linear data structure?
(A) Stack
(B) Queue
(C) Linked list
(D) Binary tree
Ans: D
Binary tree
Question: 10
Which of the following data structure permits insertion and deletion operations only
on one end of the structure?
(A) Linked list
(B) Array
(C) Stack
(D) Queue
Ans: C
Stack

Question: 1
Which of the following data structure is more appropriate to represent a heap?
(A) Two-dimensional array
(B) Doubly linked list
(C) Linear Array
(D) Linked list
Ans: C
Linear Array
Question: 2
Minimum number of fields in each node of a doubly linked list is ____
(A) 2
(B) 3
(C) 4
(D) None of the above
Ans: B
3
Question: 3
A graph in which all vertices have equal degree is known as ____
(A) Complete graph
(B) Regular graph
(C) Multi graph
(D) Simple graph
Ans: A
Complete graph
Question: 4
A vertex of in-degree zero in a directed graph is called a/an
(A) Root vertex
(B) Isolated vertex
(C) Sink
(D) Articulation point
Ans: C
Sink
Question: 5
A graph is a tree if and only if graph is
(A) Directed graph
(B) Contains no cycles
(C) Planar
(D) Completely connected
Ans: B
Contains no cycles

Question: 6
Which of the following piece of information does the data type to the compiler
provide?
(A) The way the data is to be interpreted
(B) Range of values
(C) Amount of memory a data element uses
(D) All of above
Ans: D
All of above
Question: 7
The elements of a linked list are stored
(A) In a structure
(B) In an array
(C) Anywhere the computer has space for them
(D) In contiguous memory locations
Ans: C
Anywhere the computer has space for them
Question: 8
A parentheses checker program would be best implemented using
(A) List
(B) Queue
(C) Stack
(D) Any of the above
Ans: C
Stack
Question: 9
To perform level-order traversal on a binary tree, which of the following data
structure will be required?
(A) Hash table
(B) Queue
(C) Binary search tree
(D) Stack
Ans: B
Queue
Question: 10
Which of the following data structure is required to convert arithmetic expression in
infix to its equivalent postfix notation?
(A) Queue
(B) Linked list
(C) Binary search tree
(D) None of above
Ans: D
None of above

Question: 11
A binary tree in which all its levels except the last, have maximum numbers of nodes,
and all the nodes in the last level have only one child it will be its left child. Name the
tree.
(A) Threaded tree
(B) Complete binary tree
(C) M-way search tree
(D) Full binary tree
Ans: B
Complete binary tree
Question: 12
Which of following data structure is more appropriate for implementing quick sort
iteratively?
(A) Deque
(B) Queue
(C) Stack
(D) Priority queue
Ans: C
Stack
Question: 13
The number of edges in a complete graph of n vertices is
(A) n(n+1)/2
(B) n(n-1)/2
(C) n2/2
(D) n
Ans: B
n(n-1)/2
Question: 14
If two trees have same structure and but different node content, then they are called
___
(A) Synonyms trees
(B) Joint trees
(C) Equivalent trees
(D) Similar trees
Ans: D
Similar trees
Question: 15
If two trees have same structure and node content, then they are called ____
(A) Synonyms trees
(B) Joint trees
(C) Equivalent trees
(D) Similar trees
Ans: C
Equivalent trees

Question: 1
What is the worst-case time for serial search finding a single item in an array?
(A) Quadratic time
(B) Linear time
(C) Logarithmic time
(D) Constant time
Ans: B
Linear time
Question: 2
A non-circular doubly linked list can best and most generally be defined as a ___
(A) Set of elements, each with two pointers
(B) Set of elements chained together with pointers
(C) Linear sequence of elements in sequential memory locations
(D) Linear sequence of elements chained together with pointers
Ans: D
Linear sequence of elements chained together with pointers
Question: 3
Which of the following operations is a dictionary operation?
(A) Search
(B) Delete
(C) Insert
(D) All of above
Ans: D
All of above
Question: 4
To create a linked structure, each node must have one member, which is ____
(A) A pointer to the head of the list
(B) A pointer to NULL
(C) A pointer to the node type
(D) A reference to the element type
Ans: C
A pointer to the node type
Question: 5
Each attribute of an entity has a defined set of values. This set of values is called a
(A) Mapping
(B) Entity set
(C) Domain
(D) Range
Ans: C
Domain

Question: 6
Which of the following is not an open addressing technique to resolve collisions?
(A) Linear probing
(B) Cubic probing
(C) Double hashing
(D) Quadratic probing
Ans: B
Cubic probing
Question: 7
Which of the following file organizations is not suitable for an interactive application?
(A) Indexed sequential file organization
(B) Inverted file organization
(C) Sequential file organization
(D) Relative file organization
Ans: C
Sequential file organization
Question: 8
Which of following is not a type of a I/O channel?
(A) Block multiplexer
(B) Multiplexer
(C) Selector
(D) Demultiplexer
Ans: D
Demultiplexer

Question: 1
The average case complexity of quick sort for sorting n numbers is
(A) O(n2)
(B) O(nlog2n)
(C) O(n)
(D) O(log2n)
Ans: B
O(nlog2n)
Question: 2
A dequeue operation removes an element
(A) From the front of the queue
(B) From any place in the queue
(C) From the rear of the queue
(D) None of above
Ans: A
From the front of the queue
Question: 3
What is the minimum number of nodes in a complete binary tree with depth 3?
(A) 4
(B) 5
(C) 6
(D) 7
Question: 4
What is the number of nodes in a full binary tree with depth 3?
(A) 5
(B) 6
(C) 7
(D) 8
Ans: C
7
Question: 5
Which of the following operation is not supported by a queue?
(A) Inserting element at rear
(B) Removing element from front
(C) Removing element from middle
(D) None of above
Ans: C
Removing element from middle

Question: 6
An enqueue operation adds an element
(A) At any position in the queue
(B) To the front of the queue
(C) To the rear of the queue
(D) None of above
Ans: C
To the rear of the queue
Question: 7
Which of the following is not an entity?
(A) Book
(B) Student
(C) Employee
(D) Roll number
Ans: D
Roll number
Question: 8
What kind of list is best to answer many questions such as “what is the item at
position n?”
(A) Singly-linked lists
(B) Doubly-linked lists
(C) Lists implemented with an array
(D) Circular- linked lists
Ans: C
Lists implemented with an array
Question: 9
Which of following operations are generally not performed on report files?
(A) Updation
(B) Maintenance
(C) Retrieval
(D) All of above
Ans: D
All of above
Question: 10
When is insertion sort a good choice for sorting an array?
(A) The array has only a few elements out of place
(B) Each element of array requires a small amount of memory
(C) The processor speed is fast
(D) Each element of array requires a large amount of memory
Ans: A
The array has only a few elements out of place

Question: 1
Name the tree in which, for every node, the height of left sub tree and height of right
sub tree can differ by at most one
(A) AVL tree
(B) B-tree
(C) Threaded tree
(D) Complete tree
Ans: A
AVL tree
Question: 2
Which of the following statements about a binary tree is correct?
(A) No binary tree is both complete and full
(B) Every full binary tree is also a complete binary tree
(C) Every complete binary tree is also a full binary tree
(D) Every binary tree is either complete or full
Ans: B
Every full binary tree is also a complete binary tree
Question: 3
What is the worst-case time for binary search finding a single item in an array?
(A) Quadratic time
(B) Linear time
(C) Logarithmic time
(D) Constant time
Ans: C
Logarithmic time
Question: 4
If a binary tree satisfies shape and order property, it is known as
(A) Rooted tree
(B) Heap
(C) Sequential search tree
(D) Binary search tree
Ans: B
Heap
Question: 5
With an array-based stack, the algorithm for push is
(A) Increment top and add item to the new top location
(B) Add item to the top location and then increment top
(C) Return the top item and increment top
(D) Return the top item and decrement top
Ans: A
Increment top and add item to the new top location

Question: 1
What is the worst case time for quick sort to sort an array of n elements?
(A) 0(n)
(B) 0(nlog2n)
(C) 0(log2n)
(D) 0(log2n)
Ans: D
0(log2n)
Question: 2
The best way to find an item in an unsorted implemented using an array list is with
(A) Binary search
(B) Linear search
(C) Direct search
(D) Random search
Ans: B
Linear search
Question: 3
Which of the following data structure is used to represent a relationship between
pairs, where relationship is not hierarchical?
(A) Priority queue
(B) Heap
(C) Tree
(D) Graph
Ans: D
Graph
Question: 4
A data item that cannot be divided into sub items is known as
(A) Elementary data item
(B) Group data item
(C) Primary key
(D) Primary data item
Ans: B
Group data item
Question: 5
The best way to find an item in a sorted list implemented using an array is with ___
(A) Direct search
(B) Random search
(C) Binary search
(D) Linear search
Ans: C
Binary search

Question: 1
An index is a pair of elements comprising key and a file pointer or record number. A
file in which indices are is known as ____
(A) Index file
(B) Sort file
(C) Key file
(D) None of above
Ans: A
Index file
Question: 2
A data item that can be used to distinguish between two entities (records) is known
as
(A) Alternate key
(B) Primary key
(C) Primary data item
(D) Unique data item
Ans: B
Primary key
Question: 3
A data structure whose elements form a sequence is known as
(A) Heterogeneous data structure
(B) Homogeneous data structure
(C) Linear data structures
(D) Non- linear data structure
Ans: C
Linear data structures
Question: 4
Which of the following data structure is used to represent hierarchical relationship
among its elements?
(A) Queue
(B) Hash table
(C) Tree
(D) Graph
Ans: C
Tree
Question: 5
Which of the following statements about a binary tree is not correct?
(A) Every binary tree has at least one node
(B) Every non-empty tree has exactly one root node
(C) Every node has at most two children
(D) Every non-root node has exactly one parent
Ans: A
Every binary tree has at least one node
FOR ALL SANFOUNDRY MCQ (1000+
MCQ) JOIN telegram group >>
https://t.me/edcsppu

Data Structure Questions and Answers –


Array and Array Operations
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Array and Array Operations―.

1. Which of these best describes an array?


a) A data structure that shows a hierarchical behavior
b) Container of objects of similar types
c) Arrays are immutable once initialised
d) Array is not a data structure
View Answer

advertisement

2. How do you initialize an array in C?


a) int arr[3] = (1,2,3);
b) int arr(3) = {1,2,3};
c) int arr[3] = {1,2,3};
d) int arr(3) = (1,2,3);
View Answer

3. How do you instantiate an array in Java?


a) int arr[] = new int(3);
b) int arr[];
c) int arr[] = new int[3];
d) int arr() = new int(3);
View Answer

4. Which of the following is the correct way to declare a multidimensional array in Java?
a) int[] arr;
b) int arr[[]];
c) int[][]arr;
d) int[[]] arr;
View Answer

5. What is the output of the following Java code?


advertisement
public class array
{
public static void main(String args[])
{
int []arr = {1,2,3,4,5};
System.out.println(arr[2]);
System.out.println(arr[4]);
}
}

a) 3 and 5
b) 5 and 3
c) 2 and 4
d) 4 and 2
View Answer

6. What is the output of the following Java code?

public class array


{
public static void main(String args[])
{
int []arr = {1,2,3,4,5};
System.out.println(arr[5]);
}
}

a) 4
b) 5
c) ArrayIndexOutOfBoundsException
d) InavlidInputException
View Answer

advertisement

7. When does the ArrayIndexOutOfBoundsException occur?


a) Compile-time
b) Run-time
c) Not an error
d) Not an exception at all
View Answer

8. Which of the following concepts make extensive use of arrays?


a) Binary trees
b) Scheduling of processes
c) Caching
d) Spatial locality
View Answer

9. What are the advantages of arrays?


a) Objects of mixed data types can be stored
b) Elements in an array cannot be sorted
c) Index of first element of an array is 1
d) Easier to store elements of same data type
View Answer

10. What are the disadvantages of arrays?


a) Data structure like queue or stack cannot be implemented
b) There are chances of wastage of memory space if elements inserted in an array are lesser
than the allocated size
c) Index value of an array can be negative
d) Elements are sequentially accessed
View Answer

11. Assuming int is of 4bytes, what is the size of int arr[15];?


a) 15
b) 19
c) 11
d) 60
View Answer

advertisement

12. In general, the index of the first element in an array is __________


a) 0
b) -1
c) 2
d) 1
View Answer

13. Elements in an array are accessed _____________


a) randomly
b) sequentially
c) exponentially
d) logarithmically
View Answer

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
» Next - Data Structure Questions and Answers – Stack Operations – 1
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Best Reference Books – Current Trends in Agronomy
Data Structure Questions and Answers – Stack Operations – 1
advertisement
advertisement

Recommended Posts:

1. Data Science Questions and Answers


2. Java Programming Examples on Collection API
3. Java Programming Examples on Exception Handling
4. Java Programming Examples on Java.Lang
5. C# Programming Examples on Sorting
6. C Programming Examples on Searching and Sorting
7. Data Structures & Algorithms II – Questions and Answers
8. Java Programming Examples on Combinatorial Problems & Algorithms
9. Java Programming Examples
10. C# Programming Examples on Data Structures
11. Java Programming Examples on Utility Classes
12. C Programming Examples on Arrays
13. C Programming Examples on Stacks & Queues
14. C++ Programming Examples on Data-Structures
15. C Programming Examples on Data-Structures
16. C# Programming Examples on Arrays
17. Java Programming Examples on Arrays
18. Java Programming Examples on Collections
19. Java Programming Examples on Data-Structures
20. Data Structure Questions and Answers

advertisement

Data Structure Questions and Answers –


Stack Operations – 1
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Stack Operations – 1―.

1. Process of inserting an element in stack is called ____________


a) Create
b) Push
c) Evaluation
d) Pop
View Answer

Answer: b
Explanation: Push operation allows users to insert elements in the stack. If the stack is filled
completely and trying to perform push operation stack – overflow can happen.
advertisement
2. Process of removing an element from stack is called __________
a) Create
b) Push
c) Evaluation
d) Pop
View Answer

Answer: d
Explanation: Elements in the stack are removed using pop operation. Pop operation removes
the top most element in the stack i.e. last entered element.

3. In a stack, if a user tries to remove an element from an empty stack it is called _________
a) Underflow
b) Empty collection
c) Overflow
d) Garbage Collection
View Answer

Answer: a
Explanation: Underflow occurs when the user performs a pop operation on an empty stack.
Overflow occurs when the stack is full and the user performs a push operation. Garbage
Collection is used to recover the memory occupied by objects that are no longer used.

4. Pushing an element into stack already having five elements and stack size of 5, then stack
becomes ___________
a) Overflow
b) Crash
c) Underflow
d) User flow
View Answer

Answer: a
Explanation: The stack is filled with 5 elements and pushing one more element causes a stack
overflow. This results in overwriting memory, code and loss of unsaved work on the
computer.

5. Entries in a stack are “ordered―. What is the meaning of this statement?


a) A collection of stacks is sortable
b) Stack entries may be compared with the ‘<‘ operation
c) The entries are stored in a linked list
d) There is a Sequential entry that is one by one
View Answer

Answer: d
Explanation: In stack data structure, elements are added one by one using push operation.
Stack follows LIFO Principle i.e. Last In First Out(LIFO).
advertisement

6. Which of the following is not the application of stack?


a) A parentheses balancing program
b) Tracking of local variables at run time
c) Compiler Syntax Analyzer
d) Data Transfer between two asynchronous process
View Answer

Answer: d
Explanation: Data transfer between the two asynchronous process uses the queue data
structure for synchronisation. The rest are all stack applications.

7. Consider the usual algorithm for determining whether a sequence of parentheses is


balanced. The maximum number of parentheses that appear on the stack AT ANY ONE
TIME when the algorithm analyzes: (()(())(()))?
a) 1
b) 2
c) 3
d) 4 or more
View Answer

Answer: c
Explanation: In the entire parenthesis balancing method when the incoming token is a left
parenthesis it is pushed into stack. A right parenthesis makes pop operation to delete the
elements in stack till we get left parenthesis as top most element. 3 elements are there in stack
before right parentheses comes. Therefore, maximum number of elements in stack at run time
is 3.

8. Consider the usual algorithm for determining whether a sequence of parentheses is


balanced. Suppose that you run the algorithm on a sequence that contains 2 left parentheses
and 3 right parentheses (in some order). The maximum number of parentheses that appear on
the stack AT ANY ONE TIME during the computation?
a) 1
b) 2
c) 3
d) 4 or more
View Answer

Answer: b
Explanation: In the entire parenthesis balancing method when the incoming token is a left
parenthesis it is pushed into stack. A right parenthesis makes pop operation to delete the
elements in stack till we get left parenthesis as top most element. 2 left parenthesis are pushed
whereas one right parenthesis removes one of left parenthesis. 2 elements are there before
right parenthesis which is the maximum number of elements in stack at run time.

9. What is the value of the postfix expression 6 3 2 4 + – *?


a) 1
b) 40
c) 74
d) -18
View Answer
Answer: d
Explanation: Postfix Expression is (6*(3-(2+4))) which results -18 as output.
advertisement

10. Here is an infix expression: 4 + 3*(6*3-12). Suppose that we are using the usual stack
algorithm to convert the expression from infix to postfix notation. The maximum number of
symbols that will appear on the stack AT ONE TIME during the conversion of this
expression?
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: d
Explanation: When we perform the conversion from infix to postfix expression +, *, (, *
symbols are placed inside the stack. A maximum of 4 symbols are identified during the entire
conversion.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Array and Array Operations
» Next - Data Structure Questions and Answers – Stack Operations – 2
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Data Structure Questions and Answers – Array and Array Operations
Data Structure Questions and Answers – Stack Operations – 2
advertisement
advertisement

Recommended Posts:

1. Data Science Questions and Answers


2. Java Programming Examples on Graph Problems & Algorithms
3. C# Programming Examples on Conversions
4. C Programming Examples on Searching and Sorting
5. Java Programming Examples on Collections
6. C++ Programming Examples on Graph Problems & Algorithms
7. C Programming Examples on Arrays
8. C Programming Examples on Linked List
9. Python Programming Examples on Linked Lists
10. C Programming Examples on Graph Problems & Algorithms
11. C# Programming Examples on Sorting
12. C# Programming Examples on Exceptions
13. Data Structures & Algorithms II – Questions and Answers
14. Python Programming Examples on Stacks & Queues
15. C++ Programming Examples on Data-Structures
16. C Programming Examples on Data-Structures
17. Java Programming Examples on Data-Structures
18. C Programming Examples on Stacks & Queues
19. C# Programming Examples on Data Structures
20. Data Structure Questions and Answers

advertisement

Data Structure Questions and Answers –


Stack Operations – 2
« Prev
Next »

This set of Data Structure Interview Questions and Answers focuses on “Stack Operations
– 2―.

1. The postfix form of the expression (A+ B)*(C*D- E)*F / G is?


a) AB+ CD*E – FG /**
b) AB + CD* E – F **G /
c) AB + CD* E – *F *G /
d) AB + CDE * – * F *G /
View Answer

Answer: c
Explanation: (((A+ B)*(C*D- E)*F) / G) is converted to postfix expression as
(AB+(*(C*D- E)*F )/ G)
(AB+CD*E-*F) / G
(AB+CD*E-*F * G/). Thus Postfix expression is AB+CD*E-*F*G/
advertisement

2. The data structure required to check whether an expression contains a balanced parenthesis
is?
a) Stack
b) Queue
c) Array
d) Tree
View Answer

Answer: a
Explanation: The stack is a simple data structure in which elements are added and removed
based on the LIFO principle. Open parenthesis is pushed into the stack and a closed
parenthesis pops out elements till the top element of the stack is its corresponding open
parenthesis. If the stack is empty, parenthesis is balanced otherwise it is unbalanced.
3. What data structure would you mostly likely see in non recursive implementation of a
recursive algorithm?
a) Linked List
b) Stack
c) Queue
d) Tree
View Answer

Answer: b
Explanation: In recursive algorithms, the order in which the recursive process comes back is
the reverse of the order in which it goes forward during execution. The compiler uses the
stack data structure to implement recursion. In the forwarding phase, the values of local
variables, parameters and the return address are pushed into the stack at each recursion level.
In the backing-out phase, the stacked address is popped and used to execute the rest of the
code.

4. The process of accessing data stored in a serial access memory is similar to manipulating
data on a ________
a) Heap
b) Binary Tree
c) Array
d) Stack
View Answer

Answer: d
Explanation: In serial access memory data records are stored one after the other in which they
are created and are accessed sequentially. In stack data structure, elements are accessed
sequentially. Stack data structure resembles the serial access memory.

5. The postfix form of A*B+C/D is?


a) *AB/CD+
b) AB*CD/+
c) A*BC+/D
d) ABCD+/*
View Answer

Answer: b
Explanation: Infix expression is (A*B)+(C/D)
AB*+(C/D)
AB*CD/+. Thus postfix expression is AB*CD/+.
advertisement

6. Which data structure is needed to convert infix notation to postfix notation?


a) Branch
b) Tree
c) Queue
d) Stack
View Answer
Answer: d
Explanation: The Stack data structure is used to convert infix expression to postfix
expression. The purpose of stack is to reverse the order of the operators in the expression. It
also serves as a storage structure, as no operator can be printed until both of its operands have
appeared.

7. The prefix form of A-B/ (C * D ^ E) is?


a) -/*^ACBDE
b) -ABCD*^DE
c) -A/B*C^DE
d) -A/BC*^DE
View Answer

Answer: c
Explanation: Infix Expression is (A-B)/(C*D^E)
(-A/B)(C*D^E)
-A/B*C^DE. Thus prefix expression is -A/B*C^DE.

8. What is the result of the following operation?


Top (Push (S, X))
a) X
b) X+S
c) S
d) XS
View Answer

Answer: a
Explanation: The function Push(S,X) pushes the value X in the stack S. Top() function gives
the value which entered last. X entered into stack S at last.

9. The prefix form of an infix expression (p + q) – (r * t) is?


a) + pq – *rt
b) – +pqr * t
c) – +pq * rt
d) – + * pqrt
View Answer

Answer: c
Explanation: Given Infix Expression is ((p+q)-(r*t))
(+pq)-(r*t)
(-+pq)(r*t)
-+pq*rt. Thus prefix expression is -+pq*rt.
advertisement

10. Which data structure is used for implementing recursion?


a) Queue
b) Stack
c) Array
d) List
View Answer
Answer: b
Explanation: Stacks are used for the implementation of Recursion.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure for Interviews, here is complete set of 1000+ Multiple
Choice Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Stack Operations – 1
» Next - Data Structure Questions and Answers – Stack Operations – 3
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Data Structure Questions and Answers – Stack Operations – 1
Data Structure Questions and Answers – Stack Operations – 3
advertisement
advertisement

Recommended Posts:

1. C++ Algorithms, Problems & Programming Examples


2. Java Algorithms, Problems & Programming Examples
3. Python Programming Examples on Trees
4. C Programming Examples
5. C Programming Examples using Recursion
6. C# Programming Examples on Conversions
7. Python Programming Examples on Linked Lists
8. C Programming Examples on Linked List
9. C Programming Examples without using Recursion
10. C++ Programming Examples on Graph Problems & Algorithms
11. Data Structures & Algorithms II – Questions and Answers
12. Java Programming Examples on Graph Problems & Algorithms
13. C# Programming Examples on Data Structures
14. C Programming Examples on Graph Problems & Algorithms
15. C++ Programming Examples on Data-Structures
16. Python Programming Examples on Stacks & Queues
17. C Programming Examples on Data-Structures
18. C Programming Examples on Stacks & Queues
19. Java Programming Examples on Data-Structures
20. Data Structure Questions and Answers – Preorder Traversal

advertisement

Data Structure Questions and Answers –


Stack Operations – 3
« Prev
Next »

This set of Data Structure Questions and Answers for Freshers focuses on “Stack
Operations – 3―.

1. The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is?


a) 600
b) 350
c) 650
d) 588
View Answer

Answer: b
Explanation: The postfix expression is evaluated using stack. We will get the infix expression
as
(5*(4+6))*(4+9/3). On solving the Infix Expression, we get
(5*(10))*(4+3)
= 50*7
= 350.
advertisement

2. Convert the following infix expressions into its equivalent postfix expressions.
(A + B ⋀D)/(E – F)+G
a) (A B D ⋀ + E F – / G +)
b) (A B D +⋀ E F – / G +)
c) (A B D â‹€ + E F/- G +)
d) (A B D E F + ⋀ / – G +)
View Answer

Answer: a
Explanation: The given infix expression is (A + B ⋀D)/(E – F)+G.
(A B D ^ + ) / (E – F) +G
(A B D ^ + E F – ) + G. ‘/’ is present in stack.
A B D ^ + E F – / G +. Thus Postfix Expression is A B D ^ + E F – / G +.

3. Convert the following Infix expression to Postfix form using a stack.


x + y * z + (p * q + r) * s, Follow usual precedence rule and assume that the expression is
legal.
a) xyz*+pq*r+s*+
b) xyz*+pq*r+s+*
c) xyz+*pq*r+s*+
d) xyzp+**qr+s*+
View Answer

Answer: a
Explanation: The Infix Expression is x + y * z + (p * q + r) * s.
(x y z ) + (p * q + r) * s. ‘+’, ‘*’ are present in stack.
(x y z * + p q * r) * s. ‘+’ is present in stack.
x y z * + p q * r + s * +. Thus Postfix Expression is x y z * + p q * r + s * +.
4. Which of the following statement(s) about stack data structure is/are NOT correct?
a) Linked List are used for implementing Stacks
b) Top of the Stack always contain the new node
c) Stack is the FIFO data structure
d) Null link is present in the last node at the bottom of the stack
View Answer

Answer: c
Explanation: Stack follows LIFO.

5. Consider the following operation performed on a stack of size 5.

Push(1);
Pop();
Push(2);
Push(3);
Pop();
Push(4);
Pop();
Pop();
Push(5);
advertisement

After the completion of all operation, the number of elements present in stack is?
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: a
Explanation: Number of elements present in stack is equal to the difference between number
of push operations and number of pop operations. Number of elements is 5-4=1.

6. Which of the following is not an inherent application of stack?


a) Reversing a string
b) Evaluation of postfix expression
c) Implementation of recursion
d) Job scheduling
View Answer

Answer: d
Explanation: Job Scheduling is not performed using stacks.

7. The type of expression in which operator succeeds its operands is?


a) Infix Expression
b) Prefix Expression
c) Postfix Expression
d) Both Prefix and Postfix Expressions
View Answer
Answer: c
Explanation: The expression in which operator succeeds its operands is called postfix
expression. The expression in which operator precedes the operands is called prefix
expression. If an operator is present between two operands, then it is called infix expressions.

8. Assume that the operators +,-, X are left associative and ^ is right associative. The order of
precedence (from highest to lowest) is ^, X, +, -. The postfix expression for the infix
expression a + b X c – d ^ e ^ f is?
a) abc X+ def ^^ –
b) abc X+ de^f^ –
c) ab+c Xd – e ^f^
d) -+aXbc^ ^def
View Answer

Answer: b
Explanation: Given Infix Expression is a + b X c – d ^ e ^ f.
(a b c X +) (d ^ e ^ f). ‘–‘ is present in stack.
(a b c X + d e ^ f ^ -). Thus the final expression is (a b c X + d e ^ f ^ -).
advertisement

9. If the elements “A―, “B―, “C― and “D― are placed in a stack and
are deleted one at a time, what is the order of removal?
a) ABCD
b) DCBA
c) DCAB
d) ABDC
View Answer

Answer: b
Explanation: Stack follows LIFO(Last In First Out). So the removal order of elements are
DCBA.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure for Freshers, here is complete set of 1000+ Multiple
Choice Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Stack Operations – 2
» Next - Data Structure Questions and Answers – Queue Operations
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Data Structure Questions and Answers – Stack Operations – 2
Data Structure Questions and Answers – Queue Operations
advertisement
advertisement
Recommended Posts:

1. Compilers Questions and Answers


2. C Programming Examples on Linked List
3. Automata Theory Questions and Answers
4. Java Programming Examples on Graph Problems & Algorithms
5. Python Programming Examples on Linked Lists
6. C++ Programming Examples on Graph Problems & Algorithms
7. Petroleum Production Operations Questions and Answers
8. C Tutorials
9. Data Structures & Algorithms II – Questions and Answers
10. C Programming Examples on Bitwise Operations
11. C Programming Examples on Graph Problems & Algorithms
12. Data Science Questions and Answers
13. C++ Programming Examples on Data-Structures
14. Python Programming Examples on Stacks & Queues
15. Java Programming Examples on Data-Structures
16. C Programming Examples on Data-Structures
17. C# Programming Examples on Conversions
18. C Programming Examples on Stacks & Queues
19. C# Programming Examples on Data Structures
20. Data Structure Questions and Answers

advertisement

Data Structure Questions and Answers –


Queue Operations
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Queue Operations―.

1. A linear list of elements in which deletion can be done from one end (front) and insertion
can take place only at the other end (rear) is known as _____________
a) Queue
b) Stack
c) Tree
d) Linked list
View Answer

Answer: a
Explanation: Linear list of elements in which deletion is done at front side and insertion at
rear side is called Queue. In stack we will delete the last entered element first.
advertisement
2. The data structure required for Breadth First Traversal on a graph is?
a) Stack
b) Array
c) Queue
d) Tree
View Answer

Answer: c
Explanation: In Breadth First Search Traversal, BFS, starting vertex is first taken and
adjacent vertices which are unvisited are also taken. Again, the first vertex which was added
as an unvisited adjacent vertex list will be considered to add further unvisited vertices of the
graph. To get the first unvisited vertex we need to follows First In First Out principle. Queue
uses FIFO principle.

3. A queue follows __________


a) FIFO (First In First Out) principle
b) LIFO (Last In First Out) principle
c) Ordered array
d) Linear tree
View Answer

Answer: a
Explanation: Element first added in queue will be deleted first which is FIFO principle.

4. Circular Queue is also known as ________


a) Ring Buffer
b) Square Buffer
c) Rectangle Buffer
d) Curve Buffer
View Answer

Answer: a
Explanation: Circular Queue is also called as Ring Buffer. Circular Queue is a linear data
structure in which last position is connected back to the first position to make a circle. It
forms a ring structure.
advertisement

5. If the elements “A―, “B―, “C― and “D― are placed in a queue and
are deleted one at a time, in what order will they be removed?
a) ABCD
b) DCBA
c) DCAB
d) ABDC
View Answer

Answer: a
Explanation: Queue follows FIFO approach. i.e. First in First Out Approach. So, the order of
removal elements are ABCD.
6. A data structure in which elements can be inserted or deleted at/from both ends but not in
the middle is?
a) Queue
b) Circular queue
c) Dequeue
d) Priority queue
View Answer

Answer: c
Explanation: In dequeuer, we can insert or delete elements from both the ends. In queue, we
will follow first in first out principle for insertion and deletion of elements. Element with
least priority will be deleted in a priority queue.

7. A normal queue, if implemented using an array of size MAX_SIZE, gets full when?
a) Rear = MAX_SIZE – 1
b) Front = (rear + 1)mod MAX_SIZE
c) Front = rear + 1
d) Rear = front
View Answer

Answer: a
Explanation: When Rear = MAX_SIZE – 1, there will be no space left for the elements to
be added in queue. Thus queue becomes full.
advertisement

8. Queues serve major role in ______________


a) Simulation of recursion
b) Simulation of arbitrary linked list
c) Simulation of limited resource allocation
d) Simulation of heap sort
View Answer

Answer: c
Explanation: Simulation of recursion uses stack data structure. Simulation of arbitrary linked
lists uses linked lists. Simulation of resource allocation uses queue as first entered data needs
to be given first priority during resource allocation. Simulation of heap sort uses heap data
structure.

9. Which of the following is not the type of queue?


a) Ordinary queue
b) Single ended queue
c) Circular queue
d) Priority queue
View Answer

Answer: b
Explanation: Queue always has two ends. So, single ended queue is not the type of queue.

Sanfoundry Global Education & Learning Series – Data Structure.


advertisement

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Stack Operations – 3
» Next - Data Structure Questions and Answers – Singly Linked List Operations – 1
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Data Structure Questions and Answers – Stack Operations – 3
Data Structure Questions and Answers – Singly Linked List Operations – 1
advertisement
advertisement

Recommended Posts:

1. Java Programming Examples on Collections


2. C Programming Examples using Recursion
3. C++ Programming Examples on Graph Problems & Algorithms
4. C++ Algorithms, Problems & Programming Examples
5. C Programming Examples without using Recursion
6. C Algorithms, Problems & Programming Examples
7. Java Algorithms, Problems & Programming Examples
8. C Programming Examples
9. Data Science Questions and Answers
10. C++ Programming Examples on STL
11. Data Structures & Algorithms II – Questions and Answers
12. Python Programming Examples on Stacks & Queues
13. C Programming Examples on Linked List
14. C Programming Examples on Stacks & Queues
15. Python Programming Examples on Linked Lists
16. C Programming Examples on Data-Structures
17. C++ Programming Examples on Data-Structures
18. C# Programming Examples on Data Structures
19. Java Programming Examples on Data-Structures
20. Data Structure Questions and Answers

advertisement

Data Structure Questions and Answers –


Singly Linked List Operations – 1
« Prev
Next »
This set of Data Structure Interview Questions & Answers focuses on “Singly Linked List
Operations – 1―.

1. A linear collection of data elements where the linear node is given by means of pointer is
called?
a) Linked list
b) Node list
c) Primitive list
d) Unordered list
View Answer

Answer: a
Explanation: In Linked list each node has its own data and the address of next node. These
nodes are linked by using pointers. Node list is an object that consists of a list of all nodes in
a document with in a particular selected set of nodes.
advertisement

2. Consider an implementation of unsorted singly linked list. Suppose it has its representation
with a head pointer only. Given the representation, which of the following operation can be
implemented in O(1) time?

i) Insertion at the front of the linked list


ii) Insertion at the end of the linked list
iii) Deletion of the front node of the linked list
iv) Deletion of the last node of the linked list

a) I and II
b) I and III
c) I, II and III
d) I, II and IV
View Answer

Answer: b
Explanation: We know the head node in the given linked list. Insertion and deletion of
elements at the front of the linked list completes in O (1) time whereas for insertion and
deletion at the last node requires to traverse through every node in the linked list. Suppose
there are n elements in a linked list, we need to traverse through each node. Hence time
complexity becomes O(n).

3. In linked list each node contains a minimum of two fields. One field is data field to store
the data second field is?
a) Pointer to character
b) Pointer to integer
c) Pointer to node
d) Node
View Answer

Answer: c
Explanation: Each node in a linked list contains data and a pointer (reference) to the next
node. Second field contains pointer to node.
advertisement
4. What would be the asymptotic time complexity to add a node at the end of singly linked
list, if the pointer is initially pointing to the head of the list?
a) O(1)
b) O(n)
c) θ(n)
d) θ(1)
View Answer

Answer: c
Explanation: In case of a linked list having n elements, we need to travel through every node
of the list to add the element at the end of the list. Thus asymptotic time complexity is θ(n).

5. What would be the asymptotic time complexity to insert an element at the front of the
linked list (head is known)?
a) O(1)
b) O(n)
c) O(n2)
d) O(n3)
View Answer

Answer: a
Explanation: To add an element at the front of the linked list, we will create a new node
which holds the data to be added to the linked list and pointer which points to head position
in the linked list. The entire thing happens within O (1) time. Thus the asymptotic time
complexity is O (1).

6. What would be the asymptotic time complexity to find an element in the linked list?
a) O(1)
b) O(n)
c) O(n2)
d) O(n4)
View Answer

Answer: b
Explanation: If the required element is in the last position, we need to traverse the entire
linked list. This will take O (n) time to search the element.

7. What would be the asymptotic time complexity to insert an element at the second position
in the linked list?
a) O(1)
b) O(n)
c) O(n2)
d) O(n3)
View Answer

Answer: a
Explanation: A new node is created with the required element. The pointer of the new node
points the node to which the head node of the linked list is also pointing. The head node
pointer is changed and it points to the new node which we created earlier. The entire process
completes in O (1) time. Thus the asymptotic time complexity to insert an element in the
second position of the linked list is O (1).
advertisement

8. The concatenation of two lists can be performed in O(1) time. Which of the following
variation of the linked list can be used?
a) Singly linked list
b) Doubly linked list
c) Circular doubly linked list
d) Array implementation of list
View Answer

Answer: c
Explanation: We can easily concatenate two lists in O (1) time using singly or doubly linked
list, provided that we have a pointer to the last node at least one of the lists. But in case of
circular doubly linked lists, we will break the link in both the lists and hook them together.
Thus circular doubly linked list concatenates two lists in O (1) time.

9. Consider the following definition in c programming language.

struct node
{
int data;
struct node * next;
}
typedef struct node NODE;
NODE *ptr;

Which of the following c code is used to create new node?


a) ptr = (NODE*)malloc(sizeof(NODE));
b) ptr = (NODE*)malloc(NODE);
c) ptr = (NODE*)malloc(sizeof(NODE*));
d) ptr = (NODE)malloc(sizeof(NODE));
View Answer

Answer: a
Explanation: As it represents the right way to create a node.
advertisement

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure for Interviews, here is complete set of 1000+ Multiple
Choice Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Queue Operations
» Next - Data Structure Questions and Answers – Singly Linked List Operations – 2
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Data Structure Questions and Answers – Queue Operations
Data Structure Questions and Answers – Singly Linked List Operations – 2
advertisement
advertisement

Recommended Posts:

1. Python Programming Examples


2. Java Programming Examples on Collections
3. Home
4. C Programming Examples on Trees
5. C++ Programming Examples on Combinatorial Problems & Algorithms
6. C Programming Examples using Recursion
7. Java Programming Examples on Combinatorial Problems & Algorithms
8. C Programming Examples on Stacks & Queues
9. Data Science Questions and Answers
10. C Tutorials
11. C Programming Examples on Combinatorial Problems & Algorithms
12. Data Structures & Algorithms II – Questions and Answers
13. C Programming Examples without using Recursion
14. C# Programming Examples on Data Structures
15. Java Programming Examples on Data-Structures
16. C Programming Examples on Data-Structures
17. C++ Programming Examples on Data-Structures
18. Data Structure Questions and Answers
19. Python Programming Examples on Linked Lists
20. C Programming Examples on Linked List

advertisement

Data Structure Questions and Answers –


Singly Linked List Operations – 2
« Prev
Next »

This set of Data Structure Interview Questions and Answers for freshers focuses on
“Singly Linked Lists Operations – 2―.

1. What kind of linked list is best to answer questions like “What is the item at position
n?―
a) Singly linked list
b) Doubly linked list
c) Circular linked list
d) Array implementation of linked list
View Answer

Answer: d
Explanation: Arrays provide random access to elements by providing the index value within
square brackets. In the linked list, we need to traverse through each element until we reach
the nth position. Time taken to access an element represented in arrays is less than the singly,
doubly and circular linked lists. Thus, array implementation is used to access the item at the
position n.
advertisement

2. Linked lists are not suitable for the implementation of ___________


a) Insertion sort
b) Radix sort
c) Polynomial manipulation
d) Binary search
View Answer

Answer: d
Explanation: It cannot be implemented using linked lists.

3. Linked list is considered as an example of ___________ type of memory allocation.


a) Dynamic
b) Static
c) Compile time
d) Heap
View Answer

Answer: a
Explanation: As memory is allocated at the run time.

4. In Linked List implementation, a node carries information regarding ___________


a) Data
b) Link
c) Data and Link
d) Node
View Answer

Answer: b
Explanation: A linked list is a collection of objects linked together by references from an
object to another object. By convention these objects are names as nodes. Linked list consists
of nodes where each node contains one or more data fields and a reference(link) to the next
node.

5. Linked list data structure offers considerable saving in _____________


a) Computational Time
b) Space Utilization
c) Space Utilization and Computational Time
d) Speed Utilization
View Answer

Answer: c
Explanation: Linked lists saves both space and time.
advertisement
6. Which of the following points is/are not true about Linked List data structure when it is
compared with an array?
a) Arrays have better cache locality that can make them better in terms of performance
b) It is easy to insert and delete elements in Linked List
c) Random access is not allowed in a typical implementation of Linked Lists
d) Access of elements in linked list takes less time than compared to arrays
View Answer

Answer: d
Explanation: To access an element in a linked list, we need to traverse every element until we
reach the desired element. This will take more time than arrays as arrays provide random
access to its elements.

7. What does the following function do for a given Linked List with first node as head?

void fun1(struct node* head)


{
if(head == NULL)
return;
fun1(head->next);
printf("%d ", head->data);
}

a) Prints all nodes of linked lists


b) Prints all nodes of linked list in reverse order
c) Prints alternate nodes of Linked List
d) Prints alternate nodes in reverse order
View Answer

Answer: b
Explanation: fun1() prints the given Linked List in reverse manner.
For Linked List 1->2->3->4->5, fun1() prints 5->4->3->2->1.
advertisement

8. Which of the following sorting algorithms can be used to sort a random linked list with
minimum time complexity?
a) Insertion Sort
b) Quick Sort
c) Heap Sort
d) Merge Sort
View Answer

Answer: d
Explanation: Both Merge sort and Insertion sort can be used for linked lists. The slow
random-access performance of a linked list makes other algorithms (such as quicksort)
perform poorly, and others (such as heapsort) completely impossible. Since worst case time
complexity of Merge Sort is O(nLogn) and Insertion sort is O(n2), merge sort is preferred.

Sanfoundry Global Education & Learning Series – Data Structure.


To practice all areas of Data Structure for Interviews, here is complete set of 1000+ Multiple
Choice Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Singly Linked List Operations – 1
» Next - Data Structure Questions and Answers – Singly Linked List Operations – 3
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Data Structure Questions and Answers – Singly Linked List Operations – 1
Data Structure Questions and Answers – Singly Linked List Operations – 3
advertisement
advertisement

Recommended Posts:

1. Java Programming Examples on Collections


2. C Programming Examples on Searching and Sorting
3. Data Structures & Algorithms II – Questions and Answers
4. C Programming Examples on Arrays
5. C# Programming Examples on Sorting
6. C Programming Examples on Trees
7. C Programming Examples
8. C Programming Examples on Stacks & Queues
9. Java Programming Examples on Combinatorial Problems & Algorithms
10. C++ Programming Examples on Combinatorial Problems & Algorithms
11. C Programming Examples without using Recursion
12. C Programming Examples using Recursion
13. C# Programming Examples on Data Structures
14. C Programming Examples on Combinatorial Problems & Algorithms
15. Java Programming Examples on Data-Structures
16. C Programming Examples on Data-Structures
17. C++ Programming Examples on Data-Structures
18. Data Structure Questions and Answers
19. Python Programming Examples on Linked Lists
20. C Programming Examples on Linked List

advertisement

Data Structure Questions and Answers –


Singly Linked List Operations – 3
« Prev
Next »

This set of Data Structure Questions and Answers for Experienced people focuses on
“Singly Linked Lists Operations – 3―.
1. The following function reverse() is supposed to reverse a singly linked list. There is one
line missing at the end of the function.

advertisement
/* Link list node */
struct node
{
int data;
struct node* next;
};

/* head_ref is a double pointer which points to head (or start) pointer


of linked list */
static void reverse(struct node** head_ref)
{
struct node* prev = NULL;
struct node* current = *head_ref;
struct node* next;
while (current != NULL)
{
next = current->next;
current->next = prev;
prev = current;
current = next;
}
/*ADD A STATEMENT HERE*/
}

What should be added in place of “/*ADD A STATEMENT HERE*/―, so that the


function correctly reverses a linked list.
a) *head_ref = prev;
b) *head_ref = current;
c) *head_ref = next;
d) *head_ref = NULL;
View Answer

Answer: a
Explanation: *head_ref = prev; At the end of while loop, the prev pointer points to the last
node of original linked list.
We need to change *head_ref so that the head pointer now starts pointing to the last node.

2. 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
View Answer

Answer: d
Explanation: fun() prints alternate nodes of the given Linked List, first from head to end, and
then from end to head.
If Linked List has even number of nodes, then skips the last node.
advertisement

3. The following C function takes a simply-linked list as an input argument. It modifies the
list by moving the last element to the front of the list and returns the modified list. Some part
of the code is left blank. Choose the correct alternative to replace the blank line.

typedef struct node


{
int value;
struct node *next;
}Node;

Node *move_to_front(Node *head)


{
Node *p, *q;
if ((head == NULL: || (head->next == NULL))
return head;
q = NULL; p = head;
while (p-> next !=NULL)
{
q = p;
p = p->next;
}
_______________________________
return head;
}

a) q = NULL; p->next = head; head = p;


b) q->next = NULL; head = p; p->next = head;
c) head = p; p->next = q; q->next = NULL;
d) q->next = NULL; p->next = head; head = p;
View Answer

Answer: d
Explanation: When while loop completes its execution, node ‘p’ refers to the last node
whereas the ‘q’ node refers to the node before ‘p’ in the linked list. q-
>next=NULL makes q as the last node. p->next=head places p as the first node. the head
must be modified to ‘p’ as ‘p’ is the starting node of the list (head=p). Thus the
sequence of steps are q->next=NULL, p->next=head, head=p.

4. The following C function takes a single-linked list of integers as a parameter and


rearranges the elements of the list. The function is called with the list containing the integers
1, 2, 3, 4, 5, 6, 7 in the given order. What will be the contents of the list after the function
completes execution?
advertisement
struct node
{
int value;
struct node *next;
};
void rearrange(struct node *list)
{
struct node *p, * q;
int temp;
if ((!list) || !list->next)
return;
p = list;
q = list->next;
while(q)
{
temp = p->value;
p->value = q->value;
q->value = temp;
p = q->next;
q = p?p->next:0;
}
}

a) 1, 2, 3, 4, 5, 6, 7
b) 2, 1, 4, 3, 6, 5, 7
c) 1, 3, 2, 5, 4, 7, 6
d) 2, 3, 4, 5, 6, 7, 1
View Answer

Answer: b
Explanation: The function rearrange() exchanges data of every node with its next node. It
starts exchanging data from the first node itself.

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
View Answer

Answer: d
Explanation: In the worst case, the element to be searched has to be compared with all
elements of the linked list.

6. Given pointer to a node X in a singly linked list. Only one pointer is given, pointer to head
node is not given, can we delete the node X from given linked list?
a) Possible if X is not last node
b) Possible if size of linked list is even
c) Possible if size of linked list is odd
d) Possible if X is not first node
View Answer
Answer: a
Explanation: Following are simple steps.
struct node *temp = X->next;
X->data = temp->data;
X->next = temp->next;
free(temp);

7. You are given pointers to first and last nodes of a singly linked list, which of the following
operations are dependent on the length of the linked list?
a) Delete the first element
b) Insert a new element as a first element
c) Delete the last element of the list
d) Add a new element at the end of the list
View Answer

Answer: c
Explanation: Deletion of the first element of the list is done in O (1) time by deleting memory
and changing the first pointer.
Insertion of an element as a first element can be done in O (1) time. We will create a node
that holds data and points to the head of the given linked list. The head pointer was changed
to a newly created node.
Deletion of the last element requires a pointer to the previous node of last, which can only be
obtained by traversing the list. This requires the length of the linked list.
Adding a new element at the end of the list can be done in O (1) by changing the pointer of
the last node to the newly created node and last is changed to a newly created node.
advertisement

8. In the worst case, the number of comparisons needed to search a singly linked list of length
n for a given element is?
a) log2 n
b) nâ•„2
c) log2 n – 1
d) n
View Answer

Answer: d
Explanation: The worst-case happens if the required element is at last or the element is absent
in the list. For this, we need to compare every element in the linked list. If n elements are
there, n comparisons will happen in the worst case.

Sanfoundry Global Education & Learning Series – Data Structure.

TTo practice all areas of Data Structure for Experienced people, here is complete set of
1000+ Multiple Choice Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Singly Linked List Operations – 2
» Next - Data Structure Questions and Answers – Singly Linked List
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Data Structure Questions and Answers – Singly Linked List Operations – 2
Data Structure Questions and Answers – Singly Linked List
advertisement
advertisement

Recommended Posts:

1. Python Programming Examples on Trees


2. Java Programming Examples on Collections
3. Heat Transfer Operations Questions and Answers
4. C Programming Examples on Arrays
5. C Programming Examples on Bitwise Operations
6. C Programming Examples on Combinatorial Problems & Algorithms
7. C Tutorials
8. C Programming Examples on Stacks & Queues
9. Data Science Questions and Answers
10. C Programming Examples on Trees
11. C Programming Examples using Recursion
12. Data Structures & Algorithms II – Questions and Answers
13. C Programming Examples without using Recursion
14. C Programming Examples on Data-Structures
15. Java Programming Examples on Data-Structures
16. C# Programming Examples on Data Structures
17. C++ Programming Examples on Data-Structures
18. Data Structure Questions and Answers
19. Python Programming Examples on Linked Lists
20. C Programming Examples on Linked List

advertisement

Data Structure Questions and Answers –


Singly Linked List
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Singly Linked List―.

1. Which of the following is not a disadvantage to the usage of array?


a) Fixed size
b) There are chances of wastage of memory space if elements inserted in an array are lesser
than the allocated size
c) Insertion based on position
d) Accessing elements at specified positions
View Answer
Answer: d
Explanation: Array elements can be accessed in two steps. First, multiply the size of the data
type with the specified position, second, add this value to the base address. Both of these
operations can be done in constant time, hence accessing elements at a given index/position is
faster.
advertisement

2. What is the time complexity of inserting at the end in dynamic arrays?


a) O(1)
b) O(n)
c) O(logn)
d) Either O(1) or O(n)
View Answer

Answer: d
Explanation: Depending on whether the array is full or not, the complexity in dynamic array
varies. If you try to insert into an array that is not full, then the element is simply stored at the
end, this takes O(1) time. If you try to insert into an array which is full, first you will have to
allocate an array with double the size of the current array and then copy all the elements into
it and finally insert the new element, this takes O(n) time.

3. What is the time complexity to count the number of elements in the linked list?
a) O(1)
b) O(n)
c) O(logn)
d) O(n2)
View Answer

Answer: b
Explanation: To count the number of elements, you have to traverse through the entire list,
hence complexity is O(n).

4. Which of the following performs deletion of the last element in the list? Given below is the
Node class.

class Node
{
protected Node next;
protected Object ele;
Node(Object e,Node n)
{
ele = e;
next = n;
}
public void setNext(Node n)
{
next = n;
}
public void setEle(Object e)
{
ele = e;
}
public Node getNext()
{
return next;
}
public Object getEle()
{
return ele;
}
}
class SLL
{
Node head;
int size;
SLL()
{
size = 0;
}
}

a)

public Node removeLast()


{
if(size == 0)
return null;
Node cur;
Node temp;
cur = head;
while(cur.getNext() != null)
{
temp = cur;
cur = cur.getNext();
}
temp.setNext(null);
size--;
return cur;
}

b)

advertisement
public void removeLast()
{
if(size == 0)
return null;
Node cur;
Node temp;
cur = head;
while(cur != null)
{
temp = cur;
cur = cur.getNext();
}
temp.setNext(null);
return cur;
}

c)

public void removeLast()


{
if(size == 0)
return null;
Node cur;
Node temp;
cur = head;
while(cur != null)
{
cur = cur.getNext();
temp = cur;
}
temp.setNext(null);
return cur;
}

d)

public void removeLast()


{
if(size == 0)
return null;
Node cur;
Node temp;
cur = head;
while(cur.getNext() != null)
{
cur = cur.getNext();
temp = cur;
}
temp.setNext(null);
return cur;
}
View Answer
Answer: a
Explanation: Since you have to traverse to the end of the list and delete the last node, you
need two reference pointers. ‘cur’ to traverse all the way and find the last node, and
‘temp’ is a trailing pointer to ‘cur’. Once you reach the end of the list, setNext of
‘temp’ to null, ‘cur’ is not being pointed to by any node, and hence it is available
for garbage collection.

5. What is the functionality of the following code?

advertisement
public void function(Node node)
{
if(size == 0)
head = node;
else
{
Node temp,cur;
for(cur = head; (temp = cur.getNext())!=null; cur = temp);
cur.setNext(node);
}
size++;
}
a) Inserting a node at the beginning of the list
b) Deleting a node at the beginning of the list
c) Inserting a node at the end of the list
d) Deleting a node at the end of the list
View Answer

Answer: c
Explanation: The for loop traverses through the list and then inserts a new node as
cur.setNext(node);

6. What is the space complexity for deleting a linked list?


a) O(1)
b) O(n)
c) Either O(1) or O(n)
d) O(logn)
View Answer

Answer: a
Explanation: You need a temp variable to keep track of current node, hence the space
complexity is O(1).

7. How would you delete a node in the singly linked list? The position to be deleted is given.
a)

public void delete(int pos)


{
if(pos < 0)
pos = 0;
if(pos > size)
pos = size;
if( size == 0)
return;
if(pos == 0)
head = head.getNext();
else
{
Node temp = head;
for(int i=1; i<pos; i++)
{
temp = temp.getNext();
}
temp.setNext(temp.getNext().getNext());
}
size--;
}

b)

public void delete(int pos)


{
if(pos < 0)
pos = 0;
if(pos > size)
pos = size;
if( size == 0)
return;
if(pos == 0)
head = head.getNext();
else
{
Node temp = head;
for(int i=1; i<pos; i++)
{
temp = temp.getNext();
}
temp.setNext(temp.getNext());
}
size--;
}

c)

advertisement
public void delete(int pos)
{
if(pos < 0)
pos = 0;
if(pos > size)
pos = size;
if( size == 0)
return;
if(pos == 0)
head = head.getNext();
else
{
Node temp = head;
for(int i=1; i<pos; i++)
{
temp = temp.getNext().getNext();
}
temp.setNext(temp.getNext().getNext());
}
size--;
}

d)

public void delete(int pos)


{
if(pos < 0)
pos = 0;
if(pos > size)
pos = size;
if( size == 0)
return;
if(pos == 0)
head = head.getNext();
else
{
Node temp = head;
for(int i=0; i<pos; i++)
{
temp = temp.getNext();
}
temp.setNext(temp.getNext().getNext());
}
size--;
}
View Answer
Answer: a
Explanation: Loop through the list to get into position one behind the actual position given.
temp.setNext(temp.getNext().getNext()) will delete the specified node.

8. Which of these is not an application of a linked list?


a) To implement file systems
b) For separate chaining in hash-tables
c) To implement non-binary trees
d) Random Access of elements
View Answer

Answer: d
Explanation: To implement file system, for separate chaining in hash-tables and to implement
non-binary trees linked lists are used. Elements are accessed sequentially in linked list.
Random access of elements is not an applications of linked list.

9. Which of the following piece of code has the functionality of counting the number of
elements in the list?
a)

public int length(Node head)


{
int size = 0;
Node cur = head;
while(cur!=null)
{
size++;
cur = cur.getNext();
}
return size;
}

b)

public int length(Node head)


{
int size = 0;
Node cur = head;
while(cur!=null)
{
cur = cur.getNext();
size++;
}
return size;
}

c)

public int length(Node head)


{
int size = 0;
Node cur = head;
while(cur!=null)
{
size++;
cur = cur.getNext();
}
}

d)

public int length(Node head)


{
int size = 0;
Node cur = head;
while(cur!=null)
{
size++;
cur = cur.getNext().getNext();
}
return size;
}
View Answer
Answer: a
Explanation: ‘cur’ pointer traverses through list and increments the size variable until
the end of list is reached.

10. How do you insert an element at the beginning of the list?


a)

public void insertBegin(Node node)


{
node.setNext(head);
head = node;
size++;
}

b)

public void insertBegin(Node node)


{
head = node;
node.setNext(head);
size++;
}

c)

public void insertBegin(Node node)


{
Node temp = head.getNext()
node.setNext(temp);
head = node;
size++;
}

d)

public void insertBegin(Node node)


{
Node temp = head.getNext()
node.setNext(temp);
node = head;
size++;
}
View Answer
Answer: a
Explanation: Set the ‘next’ pointer point to the head of the list and then make this new
node as the head.

11. What is the functionality of the following piece of code?

public int function(int data)


{
Node temp = head;
int var = 0;
while(temp != null)
{
if(temp.getData() == data)
{
return var;
}
var = var+1;
temp = temp.getNext();
}
return Integer.MIN_VALUE;
}

a) Find and delete a given element in the list


b) Find and return the given element in the list
c) Find and return the position of the given element in the list
d) Find and insert a new element in the list
View Answer

Answer: c
Explanation: When temp is equal to data, the position of data is returned.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Singly Linked List Operations – 3
» Next - Data Structure Questions and Answers – Doubly Linked List
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Data Structure Questions and Answers – Singly Linked List Operations – 3
Data Structure Questions and Answers – Doubly Linked List
advertisement
advertisement

Recommended Posts:

1. C Programming Examples using Recursion


2. C Programming Examples on Searching and Sorting
3. C++ Programming Examples on Combinatorial Problems & Algorithms
4. Data Science Questions and Answers
5. Python Programming Examples on Trees
6. Java Programming Examples on Arrays
7. Java Programming Examples on Combinatorial Problems & Algorithms
8. Java Programming Examples on Collections
9. C Programming Examples on Trees
10. C Programming Examples on Combinatorial Problems & Algorithms
11. C Programming Examples on Arrays
12. C# Programming Examples on Arrays
13. Data Structures & Algorithms II – Questions and Answers
14. C# Programming Examples on Data Structures
15. Java Programming Examples on Data-Structures
16. C Programming Examples on Data-Structures
17. C++ Programming Examples on Data-Structures
18. Data Structure Questions and Answers
19. Python Programming Examples on Linked Lists
20. C Programming Examples on Linked List

advertisement

Data Structure Questions and Answers –


Doubly Linked List
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Doubly Linked List―.

1. Which of the following is false about a doubly linked list?


a) We can navigate in both the directions
b) It requires more space than a singly linked list
c) The insertion and deletion of a node take a bit longer
d) Implementing a doubly linked list is easier than singly linked list
View Answer
Answer: d
Explanation: A doubly linked list has two pointers ‘left’ and ‘right’ which enable
it to traverse in either direction. Compared to singly liked list which has only a ‘next’
pointer, doubly linked list requires extra space to store this extra pointer. Every insertion and
deletion requires manipulation of two pointers, hence it takes a bit longer time. Implementing
doubly linked list involves setting both left and right pointers to correct nodes and takes more
time than singly linked list.
advertisement

2. Given the Node class implementation, select one of the following that correctly inserts a
node at the tail of the list.

public class Node


{
protected int data;
protected Node prev;
protected Node next;
public Node(int data)
{
this.data = data;
prev = null;
next = null;
}
public Node(int data, Node prev, Node next)
{
this.data = data;
this.prev = prev;
this.next = next;
}
public int getData()
{
return data;
}
public void setData(int data)
{
this.data = data;
}
public Node getPrev()
{
return prev;
}
public void setPrev(Node prev)
{
this.prev = prev;
}
public Node getNext
{
return next;
}
public void setNext(Node next)
{
this.next = next;
}
}
public class DLL
{
protected Node head;
protected Node tail;
int length;
public DLL()
{
head = new Node(Integer.MIN_VALUE,null,null);
tail = new Node(Integer.MIN_VALUE,null,null);
head.setNext(tail);
length = 0;
}
}

a)

public void insertRear(int data)


{
Node node = new Node(data,tail.getPrev(),tail);
node.getPrev().setNext(node);
tail.setPrev(node);
length++;
}

b)

public void insertRear(int data)


{
Node node = new Node(data,tail.getPrev(),tail);
node.getPrev().getPrev().setNext(node);
tail.setPrev(node);
length++;
}

c)

advertisement
public void insertRear(int data)
{
Node node = new Node(data,tail.getPrev(),tail);
node.getPrev().setNext(tail);
tail.setPrev(node);
length++;
}

d)

public void insertRear(int data)


{
Node node = new Node(data,head,tail);
node.getPrev().setNext(node);
tail.setPrev(node);
length++;
}
View Answer
Answer: a
Explanation: First create a new node whose ‘prev’ points to the node pointed to by the
‘prev’ of tail. The ‘next’ of the new node should point to tail. Set the
‘prev’ of tail to point to new node and the ‘prev’ of new node to point to the new
node.
3. What is a memory efficient double linked list?
a) Each node has only one pointer to traverse the list back and forth
b) The list has breakpoints for faster traversal
c) An auxiliary singly linked list acts as a helper list to traverse through the doubly linked list
d) A doubly linked list that uses bitwise AND operator for storing addresses
View Answer

Answer: a
Explanation: Memory efficient doubly linked list has only one pointer to traverse the list back
and forth. The implementation is based on pointer difference. It uses bitwise XOR operator to
store the front and rear pointer addresses. Instead of storing actual memory address, every
node store the XOR address of previous and next nodes.

4. Which of the following piece of code removes the node from a given position?
a)

public void remove(int pos)


{
if(pos<0 || pos>=size)
{
System.out.println("Invalid position");
return;
}
else
{
if(head == null)
return;
if(pos == 0)
{
head = head.getNext();
if(head == null)
tail = null;
}
else
{
Node temp = head;
for(int i=1; i<position; i++)
temp = temp.getNext();
}
temp.getNext().setPrev(temp.getPrev());
temp.getPrev().setNext(temp.getNext());
}
size--;
}

b)

advertisement
public void remove(int pos)
{
if(pos<0 || pos>=size)
{
System.out.println("Invalid position");
return;
}
else
{
if(head == null)
return;
if(pos == 0)
{
head = head.getNext();
if(head == null)
tail = null;
}
else
{
Node temp = head;
for(int i=1; i<position; i++)
temp = temp.getNext();
}
temp.getNext().setPrev(temp.getNext());
temp.getPrev().setNext(temp.getPrev());
}
size--;
}

c)

public void remove(int pos)


{
if(pos<0 || pos>=size)
{
System.out.println("Invalid position");
return;
}
else
{
if(head == null)
return;
if(pos == 0)
{
head = head.getNext();
if(head == null)
tail = null;
}
else
{
Node temp = head;
for(int i=1; i<position; i++)
temp = temp.getNext().getNext();
}
temp.getNext().setPrev(temp.getPrev());
temp.getPrev().setNext(temp.getNext());
}
size--;
}

d)

public void remove(int pos)


{
if(pos<0 || pos>=size)
{
System.out.println("Invalid position");
return;
}
else
{
if(head == null)
return;
if(pos == 0)
{
head = head.getNext();
if(head == null)
tail = null;
}
else
{
Node temp = head;
for(int i=1; i<position; i++)
temp = temp.getNext().getNext();
}
temp.getNext().setPrev(temp.getNext());
temp.getPrev().setNext(temp.getPrev());
}
size--;
}
View Answer
Answer: a
Explanation: If the position to be deleted is not the head, advance to the given position and
manipulate the previous and next pointers of next and previous nodes respectively.

5. How do you calculate the pointer difference in a memory efficient double linked list?
a) head xor tail
b) pointer to previous node xor pointer to next node
c) pointer to previous node – pointer to next node
d) pointer to next node – pointer to previous node
View Answer

Answer: b
Explanation: The pointer difference is calculated by taking XOR of pointer to previous node
and pointer to the next node.

6. What is the worst case time complexity of inserting a node in a doubly linked list?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(1)
View Answer

Answer: c
Explanation: In the worst case, the position to be inserted maybe at the end of the list, hence
you have to traverse through the entire list to get to the correct position, hence O(n).
advertisement

7. How do you insert a node at the beginning of the list?


a)
public class insertFront(int data)
{
Node node = new Node(data, head, head.getNext());
node.getNext().setPrev(node);
head.setNext(node);
size++;
}

b)

public class insertFront(int data)


{
Node node = new Node(data, head, head);
node.getNext().setPrev(node);
head.setNext(node);
size++;
}

c)

public class insertFront(int data)


{
Node node = new Node(data, head, head.getNext());
node.getNext().setPrev(head);
head.setNext(node);
size++;
}

d)

public class insertFront(int data)


{
Node node = new Node(data, head, head.getNext());
node.getNext().setPrev(node);
head.setNext(node.getNext());
size++;
}
View Answer
Answer: a
Explanation: The new node’s previous pointer will point to head and next pointer will
point to the current next of head.

8. Consider the following doubly linked list: head-1-2-3-4-5-tail. What will be the list after
performing the given sequence of operations?

Node temp = new Node(6,head,head.getNext());


Node temp1 = new Node(0,tail.getPrev(),tail);
head.setNext(temp);
temp.getNext().setPrev(temp);
tail.setPrev(temp1);
temp1.getPrev().setNext(temp1);

a) head-0-1-2-3-4-5-6-tail
b) head-1-2-3-4-5-6-tail
c) head-6-1-2-3-4-5-0-tail
d) head-0-1-2-3-4-5-tail
View Answer

Answer: c
Explanation: The given sequence of operations performs addition of nodes at the head and
tail of the list.

9. What is the functionality of the following piece of code?

public int function()


{
Node temp = tail.getPrev();
tail.setPrev(temp.getPrev());
temp.getPrev().setNext(tail);
size--;
return temp.getItem();
}

a) Return the element at the tail of the list but do not remove it
b) Return the element at the tail of the list and remove it from the list
c) Return the last but one element from the list but do not remove it
d) Return the last but one element at the tail of the list and remove it from the list
View Answer

Answer: b
Explanation: The previous and next pointers of the tail and the last but one element are
manipulated, this suggests that the last node is being removed from the list.

10. Consider the following doubly linked list: head-1-2-3-4-5-tail. What will be the list after
performing the given sequence of operations?

Node temp = new Node(6,head,head.getNext());


head.setNext(temp);
temp.getNext().setPrev(temp);
Node temp1 = tail.getPrev();
tail.setPrev(temp1.getPrev());
temp1.getPrev().setNext(tail);

a) head-6-1-2-3-4-5-tail
b) head-6-1-2-3-4-tail
c) head-1-2-3-4-5-6-tail
d) head-1-2-3-4-5-tail
View Answer

Answer: b
Explanation: A new node is added to the head of the list and a node is deleted from the tail
end of the list.

Sanfoundry Global Education & Learning Series – Data Structure.


To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Singly Linked List
» Next - Data Structure Questions and Answers – Circular Linked List
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Data Structure Questions and Answers – Singly Linked List
Data Structure Questions and Answers – Circular Linked List
advertisement
advertisement

Recommended Posts:

1. C Programming Examples on Combinatorial Problems & Algorithms


2. Python Programming Examples
3. Electrical Machines Questions and Answers
4. C Programming Examples
5. Java Algorithms, Problems & Programming Examples
6. C Programming Examples on Trees
7. C Programming Examples on Stacks & Queues
8. Object Oriented Programming Questions and Answers
9. Data Science Questions and Answers
10. C Programming Examples using Recursion
11. Data Structures & Algorithms II – Questions and Answers
12. C Tutorials
13. C Programming Examples without using Recursion
14. C Programming Examples on Data-Structures
15. C# Programming Examples on Data Structures
16. Java Programming Examples on Data-Structures
17. Data Structure Questions and Answers
18. C++ Programming Examples on Data-Structures
19. Python Programming Examples on Linked Lists
20. C Programming Examples on Linked List

advertisement

Data Structure Questions and Answers –


Circular Linked List
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Circular Linked List―.
1. What differentiates a circular linked list from a normal linked list?
a) You cannot have the ‘next’ pointer point to null in a circular linked list
b) It is faster to traverse the circular linked list
c) You may or may not have the ‘next’ pointer point to null in a circular linked list
d) Head node is known in circular linked list
View Answer

Answer: c
Explanation: The ‘next’ pointer points to null only when the list is empty, otherwise it
points to the head of the list. Every node in a circular linked list can be a starting point(head).
advertisement

2. How do you count the number of elements in the circular linked list?
a)

public int length(Node head)


{
int length = 0;
if( head == null)
return 0;
Node temp = head.getNext();
while(temp != head)
{
temp = temp.getNext();
length++;
}
return length;
}

b)

public int length(Node head)


{
int length = 0;
if( head == null)
return 0;
Node temp = head.getNext();
while(temp != null)
{
temp = temp.getNext();
length++;
}
return length;
}

c)

public int length(Node head)


{
int length = 0;
if( head == null)
return 0;
Node temp = head.getNext();
while(temp != head && temp != null)
{
temp = head.getNext();
length++;
}
return length;
}

d)

advertisement
public int length(Node head)
{
int length = 0;
if( head == null)
return 0;
Node temp = head.getNext();
while(temp != head && temp == null)
{
temp = head.getNext();
length++;
}
return length;
}
View Answer
Answer: a
Explanation: If the head is null, it means that the list is empty. Otherwise, traverse the list
until the head of the list is reached.

3. What is the functionality of the following piece of code? Select the most appropriate.

public void function(int data)


{
int flag = 0;
if( head != null)
{
Node temp = head.getNext();
while((temp != head) && (!(temp.getItem() == data)))
{
temp = temp.getNext();
flag = 1;
break;
}
}
if(flag)
System.out.println("success");
else
System.out.println("fail");
}

a) Print success if a particular element is not found


b) Print fail if a particular element is not found
c) Print success if a particular element is equal to 1
d) Print fail if the list is empty
View Answer

Answer: b
Explanation: The function prints fail if the given element is not found. Note that this option is
inclusive of option “Print fail if the list is empty―, the list being empty is one of the
cases covered.

4. What is the time complexity of searching for an element in a circular linked list?
a) O(n)
b) O(nlogn)
c) O(1)
d) O(n2)
View Answer

Answer: a
Explanation: In the worst case, you have to traverse through the entire list of n elements.

5. Which of the following application makes use of a circular linked list?


a) Undo operation in a text editor
b) Recursive function calls
c) Allocating CPU to resources
d) Implement Hash Tables
View Answer

Answer: c
Explanation: Generally, round robin fashion is employed to allocate CPU time to resources
which makes use of the circular linked list data structure. Recursive function calls use stack
data structure. Undo Operation in text editor uses doubly linked lists. Hash tables uses singly
linked lists.
advertisement

6. Choose the code snippet which inserts a node to the head of the list?
a)

public void insertHead(int data)


{
Node temp = new Node(data);
Node cur = head;
while(cur.getNext() != head)
cur = cur.getNext()
if(head == null)
{
head = temp;
head.setNext(head);
}
else
{
temp.setNext(head);
head = temp;
cur.setNext(temp);
}
size++;
}

b)

public void insertHead(int data)


{
Node temp = new Node(data);
while(cur != head)
cur = cur.getNext()
if(head == null)
{
head = temp;
head.setNext(head);
}
else
{
temp.setNext(head.getNext());
cur.setNext(temp);
}
size++;
}

c)

public void insertHead(int data)


{
Node temp = new Node(data);
if(head == null)
{
head = temp;
head.setNext(head);
}
else
{
temp.setNext(head.getNext());
head = temp;
}
size++;
}

d)

public void insertHead(int data)


{
Node temp = new Node(data);
if(head == null)
{
head = temp;
head.setNext(head.getNext());
}
else
{
temp.setNext(head.getNext());
head = temp;
}
size++;
}
View Answer
Answer: a
Explanation: If the list is empty make the new node as ‘head’, otherwise traverse the
list to the end and make its ‘next’ pointer point to the new node, set the new node’s
next point to the current head and make the new node as the head.
7. What is the functionality of the following code? Choose the most appropriate answer.

advertisement
public int function()
{
if(head == null)
return Integer.MIN_VALUE;
int var;
Node temp = head;
while(temp.getNext() != head)
temp = temp.getNext();
if(temp == head)
{
var = head.getItem();
head = null;
return var;
}
temp.setNext(head.getNext());
var = head.getItem();
head = head.getNext();
return var;
}

a) Return data from the end of the list


b) Returns the data and deletes the node at the end of the list
c) Returns the data from the beginning of the list
d) Returns the data and deletes the node from the beginning of the list
View Answer

Answer: d
Explanation: First traverse through the list to find the end node, then manipulate the
‘next’ pointer such that it points to the current head’s next node, return the data
stored in head and make this next node as the head.

8. What is the functionality of the following code? Choose the most appropriate answer.

public int function()


{
if(head == null)
return Integer.MIN_VALUE;
int var;
Node temp = head;
Node cur;
while(temp.getNext() != head)
{
cur = temp;
temp = temp.getNext();
}
if(temp == head)
{
var = head.getItem();
head = null;
return var;
}
var = temp.getItem();
cur.setNext(head);
return var;
}
a) Return data from the end of the list
b) Returns the data and deletes the node at the end of the list
c) Returns the data from the beginning of the list
d) Returns the data and deletes the node from the beginning of the list
View Answer

Answer: b
Explanation: First traverse through the list to find the end node, also have a trailing pointer to
find the penultimate node, make this trailing pointer’s ‘next’ point to the head and
return the data stored in the ‘temp’ node.

9. Which of the following is false about a circular linked list?


a) Every node has a successor
b) Time complexity of inserting a new node at the head of the list is O(1)
c) Time complexity for deleting the last node is O(n)
d) We can traverse the whole circular linked list by starting from any point
View Answer

Answer: b
Explanation: Time complexity of inserting a new node at the head of the list is O(n) because
you have to traverse through the list to find the tail node.

10. Consider a small circular linked list. How to detect the presence of cycles in this list
effectively?
a) Keep one node as head and traverse another temp node till the end to check if its ‘next
points to head
b) Have fast and slow pointers with the fast pointer advancing two nodes at a time and slow
pointer advancing by one node at a time
c) Cannot determine, you have to pre-define if the list contains cycles
d) Circular linked list itself represents a cycle. So no new cycles cannot be generated
View Answer

Answer: b
Explanation: Advance the pointers in such a way that the fast pointer advances two nodes at a
time and slow pointer advances one node at a time and check to see if at any given instant of
time if the fast pointer points to slow pointer or if the fast pointer’s ‘next’ points to
the slow pointer. This is applicable for smaller lists.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Doubly Linked List
» Next - Data Structure Questions and Answers – Stack using Array
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Data Structure Questions and Answers – Doubly Linked List
Data Structure Questions and Answers – Stack using Array
advertisement
advertisement

Recommended Posts:

1. Java Programming Examples on Collections


2. Java Algorithms, Problems & Programming Examples
3. Python Programming Examples on Trees
4. C Programming Examples on Combinatorial Problems & Algorithms
5. C Programming Examples
6. Object Oriented Programming Questions and Answers
7. C Programming Examples on Trees
8. C Tutorials
9. C Programming Examples on Stacks & Queues
10. Data Science Questions and Answers
11. C Programming Examples using Recursion
12. Data Structures & Algorithms II – Questions and Answers
13. C Programming Examples without using Recursion
14. C Programming Examples on Data-Structures
15. Java Programming Examples on Data-Structures
16. C++ Programming Examples on Data-Structures
17. C# Programming Examples on Data Structures
18. Data Structure Questions and Answers
19. Python Programming Examples on Linked Lists
20. C Programming Examples on Linked List

advertisement

Data Structure Questions and Answers –


Stack using Array
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Stack using Array―.

1. Which of the following real world scenarios would you associate with a stack data
structure?
a) piling up of chairs one above the other
b) people standing in a line to be serviced at a counter
c) offer services based on the priority of the customer
d) tatkal Ticket Booking in IRCTC
View Answer
Answer: a
Explanation: Stack follows Last In First Out (LIFO) policy. Piling up of chairs one above the
other is based on LIFO, people standing in a line is a queue and if the service is based on
priority, then it can be associated with a priority queue. Tatkal Ticket Booking Follows First
in First Out Policy. People who click the book now first will enter the booking page first.
advertisement

2. What does the following function check for? (all necessary headers to be included and
function is called from main)

#define MAX 10

typedef struct stack


{
int top;
int item[MAX];
}stack;

int function(stack *s)


{
if(s->top == -1)
return 1;
else return 0;
}

a) full stack
b) invalid index
c) empty stack
d) infinite stack
View Answer

Answer: c
Explanation: An empty stack is represented with the top-of-the-stack(‘top’ in this case)
to be equal to -1.

3. What does ‘stack underflow’ refer to?


a) accessing item from an undefined stack
b) adding items to a full stack
c) removing items from an empty stack
d) index out of bounds exception
View Answer

Answer: c
Explanation: Removing items from an empty stack is termed as stack underflow.
advertisement

4. What is the output of the following program?

public class Stack


{
protected static final int CAPACITY = 100;
protected int size,top = -1;
protected Object stk[];
public Stack()
{
stk = new Object[CAPACITY];
}

public void push(Object item)


{
if(size_of_stack==size)
{
System.out.println("Stack overflow");
return;
}
else
{
top++;
stk[top]=item;
}
}
public Object pop()
{
if(top<0)
{
return -999;
}
else
{
Object ele=stk[top];
top--;
size_of_stack--;
return ele;
}
}
}

public class StackDemo


{
public static void main(String args[])
{
Stack myStack = new Stack();
myStack.push(10);
Object element1 = myStack.pop();
Object element2 = myStack.pop();
System.out.println(element2);
}
}

a) stack is full
b) 20
c) 0
d) -999
View Answer

Answer: d
Explanation: The first call to pop() returns 10, whereas the second call to pop() would result
in stack underflow and the program returns -999.

5. What is the time complexity of pop() operation when the stack is implemented using an
array?
a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn)
View Answer

Answer: a
Explanation: pop() accesses only one end of the structure, and hence constant time.

6. Which of the following array position will be occupied by a new element being pushed for
a stack of size N elements(capacity of stack > N)?
a) S[N-1]
b) S[N]
c) S[1]
d) S[0]
View Answer

Answer: b
Explanation: Elements are pushed at the end, hence N.
advertisement

7. What happens when you pop from an empty stack while implementing using the Stack
ADT in Java?
a) Undefined error
b) Compiler displays a warning
c) EmptyStackException is thrown
d) NoStackException is thrown
View Answer

Answer: c
Explanation: The Stack ADT throws an EmptyStackException if the stack is empty and a
pop() operation is tried on it.

8. What is the functionality of the following piece of Java code?


Assume: ‘a’ is a non empty array of integers, the Stack class creates an array of
specified size and provides a top pointer indicating TOS(top of stack), push and pop have
normal meaning.

public void some_function(int[] a)


{
Stack S=new Stack(a.length);
int[] b=new int[a.length];
for(int i=0;i<a.length;i++)
{
S.push(a[i]);
}
for(int i=0;i<a.length;i++)
{
b[i]=(int)(S.pop());
}
System.out.println("output :");
for(int i=0;i<b.length;i++)
{
System.out.println(b[i]);
}
}

a) print alternate elements of array


b) duplicate the given array
c) parentheses matching
d) reverse the array
View Answer

Answer: d
Explanation: Every element from the given array ‘a’ is pushed into the stack, and then
the elements are popped out into the array ‘b’. Stack is a LIFO structure, this results in
reversing the given array.

9. Array implementation of Stack is not dynamic, which of the following statements supports
this argument?
a) space allocation for array is fixed and cannot be changed during run-time
b) user unable to give the input for stack operations
c) a runtime exception halts execution
d) improper program compilation
View Answer

Answer: a
Explanation: You cannot modify the size of an array once the memory has been allocated,
adding fewer elements than the array size would cause wastage of space, and adding more
elements than the array size at run time would cause Stack Overflow.
advertisement

10. Which of the following array element will return the top-of-the-stack-element for a stack
of size N elements(capacity of stack > N)?
a) S[N-1]
b) S[N]
c) S[N-2]
d) S[N+1]
View Answer

Answer: a
Explanation: Array indexing start from 0, hence N-1 is the last index.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Circular Linked List
» Next - Data Structure Questions and Answers – Stack using Linked List
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Data Structure Questions and Answers – Circular Linked List
Data Structure Questions and Answers – Stack using Linked List
advertisement
advertisement

Recommended Posts:

1. C# Programming Examples on Exceptions


2. Microprocessor Questions & Answers
3. C Programming Examples using Recursion
4. Java Programming Examples on Java.Lang
5. Java Programming Examples on Multithreading
6. C# Programming Examples on Threads
7. C++ Programming Examples on STL
8. Data Structures & Algorithms II – Questions and Answers
9. Data Science Questions and Answers
10. Java Programming Examples on Inheritance
11. Python Programming Examples on Searching and Sorting
12. C Programming Examples on Searching and Sorting
13. Object Oriented Programming Questions and Answers
14. Python Programming Examples on Stacks & Queues
15. C# Programming Examples on Data Structures
16. C Programming Examples on Stacks & Queues
17. C++ Programming Examples on Data-Structures
18. C Programming Examples on Data-Structures
19. Java Programming Examples on Data-Structures
20. Data Structure Questions and Answers

advertisement

Data Structure Questions and Answers –


Stack using Linked List
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Stack using Linked List―.

1. What is the best case time complexity of deleting a node in a Singly Linked list?
a) O (n)
b) O (n2)
c) O (nlogn)
d) O (1)
View Answer
Answer: d
Explanation: Deletion of the head node in the linked list is taken as the best case. The
successor of the head node is changed to head and deletes the predecessor of the newly
assigned head node. This process completes in O(1) time.
advertisement

2. Which of the following statements are not correct with respect to Singly Linked List(SLL)
and Doubly Linked List(DLL)?
a) Complexity of Insertion and Deletion at known position is O(n) in SLL and O(1) in DLL
b) SLL uses lesser memory per node than DLL
c) DLL has more searching power than SLL
d) Number of node fields in SLL is more than DLL
View Answer

Answer: d
Explanation: To insert and delete at known positions requires complete traversal of the list in
worst case in SLL, SLL consists of an item and a node field, while DLL has an item and two
node fields, hence SLL occupies lesser memory, DLL can be traversed both ways(left and
right), while SLL can traverse in only one direction, hence more searching power of DLL.
Node fields in SLL is 2 (data and address of next node) whereas in DLL is 3(data, address to
next node, address to previous node).

3. Given below is the Node class to perform basic list operations and a Stack class with a no
arg constructor.
Select from the options the appropriate pop() operation that can be included in the Stack
class. Also ‘first’ is the top-of-the-stack.

class Node
{
protected Node next;
protected Object ele;
Node()
{
this(null,null);
}
Node(Object e,Node n)
{
ele=e;
next=n;
}
public void setNext(Node n)
{
next=n;
}
public void setEle(Object e)
{
ele=e;
}
public Node getNext()
{
return next;
}
public Object getEle()
{
return ele;
}
}

class Stack
{
Node first;
int size=0;
Stack()
{
first=null;
}
}

a)

public Object pop()


{
if(size == 0)
System.out.println("underflow");
else
{
Object o = first.getEle();
first = first.getNext();
size--;
return o;
}
}

b)

advertisement
public Object pop()
{
if(size == 0)
System.out.println("underflow");
else
{
Object o = first.getEle();
first = first.getNext().getNext();
size--;
return o;
}
}

c)

public Object pop()


{
if(size == 0)
System.out.println("underflow");
else
{
first = first.getNext();
Object o = first.getEle();
size--;
return o;
}
}
d)

public Object pop()


{
if(size == 0)
System.out.println("underflow");
else
{
first = first.getNext().getNext();
Object o = first.getEle();
size--;
return o;
}
}
View Answer
Answer: a
Explanation: pop() should return the Object pointed to by the node ‘first’. The
sequence of operations is, first, get the element stored at node ‘first’ using getEle(), and
second, make the node point to the next node using getNext().

4. What does the following function do?

public Object some_func()throws emptyStackException


{
if(isEmpty())
throw new emptyStackException("underflow");
return first.getEle();
}

a) pop
b) delete the top-of-the-stack element
c) retrieve the top-of-the-stack element
d) push operation
View Answer

Answer: c
Explanation: This code is only retrieving the top element, note that it is not equivalent to pop
operation as you are not setting the ‘next’ pointer point to the next node in sequence.
advertisement

5. What is the functionality of the following piece of code?

public void display()


{
if(size == 0)
System.out.println("underflow");
else
{
Node current = first;
while(current != null)
{
System.out.println(current.getEle());
current = current.getNext();
}
}
}

a) reverse the list


b) display the list
c) display the list excluding top-of-the-stack-element
d) reverse the list excluding top-of-the-stack-element
View Answer

Answer: b
Explanation: An alias of the node ‘first’ is created which traverses through the list and
displays the elements.

6. What does ‘stack overflow’ refer to?


a) accessing item from an undefined stack
b) adding items to a full stack
c) removing items from an empty stack
d) index out of bounds exception
View Answer

Answer: b
Explanation: Adding items to a full stack is termed as stack underflow.

7. Given below is the Node class to perform basic list operations and a Stack class with a no
arg constructor. Select from the options the appropriate push() operation that can be included
in the Stack class. Also ‘first’ is the top-of-the-stack.

class Node
{
protected Node next;
protected Object ele;
Node()
{
this(null,null);
}
Node(Object e,Node n)
{
ele=e;
next=n;
}
public void setNext(Node n)
{
next=n;
}
public void setEle(Object e)
{
ele=e;
}
public Node getNext()
{
return next;
}
public Object getEle()
{
return ele;
}
}

class Stack
{
Node first;
int size=0;
Stack()
{
first=null;
}
}

a)

advertisement
public void push(Object item)
{
Node temp = new Node(item,first);
first = temp;
size++;
}

b)

public void push(Object item)


{
Node temp = new Node(item,first);
first = temp.getNext();
size++;
}

c)

public void push(Object item)


{
Node temp = new Node();
first = temp.getNext();
first.setItem(item);
size++;
}

d)

public void push(Object item)


{
Node temp = new Node();
first = temp.getNext.getNext();
first.setItem(item);
size++;
}
View Answer
Answer: a
Explanation: To push an element into the stack, first create a new node with the next pointer
point to the current top-of-the-stack node, then make this node as top-of-the-stack by
assigning it to ‘first’.
8. Consider these functions:
push() : push an element into the stack
pop() : pop the top-of-the-stack element
top() : returns the item stored in top-of-the-stack-node
What will be the output after performing these sequence of operations

push(20);
push(4);
top();
pop();
pop();
pop();
push(5);
top();

a) 20
b) 4
c) stack underflow
d) 5
View Answer

Answer: d
Explanation: 20 and 4 which were pushed are popped by the two pop() statements, the recent
push() is 5, hence top() returns 5.

9. Which of the following data structures can be used for parentheses matching?
a) n-ary tree
b) queue
c) priority queue
d) stack
View Answer

Answer: d
Explanation: For every opening brace, push it into the stack, and for every closing brace, pop
it off the stack. Do not take action for any other character. In the end, if the stack is empty,
then the input has balanced parentheses.

10. Minimum number of queues to implement stack is ___________


a) 3
b) 4
c) 1
d) 2
View Answer

Answer: c
Explanation: Use one queue and one counter to count the number of elements in the queue.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.
Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Stack using Array
» Next - Data Structure Questions and Answers – Queue using Array
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Data Structure Questions and Answers – Stack using Array
Data Structure Questions and Answers – Queue using Array
advertisement
advertisement

Recommended Posts:

1. C Programming Examples on Trees


2. Data Science Questions and Answers
3. Object Oriented Programming Questions and Answers
4. C Programming Examples on Searching and Sorting
5. C# Programming Examples on Exceptions
6. Data Structures & Algorithms II – Questions and Answers
7. Java Programming Examples on Event Handling
8. Python Programming Examples on Searching and Sorting
9. Python Programming Examples on Stacks & Queues
10. C Programming Examples using Recursion
11. C Programming Examples without using Recursion
12. Java Programming Examples on Collections
13. C Programming Examples on Stacks & Queues
14. Java Programming Examples on Data-Structures
15. C Programming Examples on Data-Structures
16. C++ Programming Examples on Data-Structures
17. Data Structure Questions and Answers
18. Python Programming Examples on Linked Lists
19. C# Programming Examples on Data Structures
20. C Programming Examples on Linked List

advertisement

Data Structure Questions and Answers –


Queue using Array
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Queue using Array―.

1. Which of the following properties is associated with a queue?


a) First In Last Out
b) First In First Out
c) Last In First Out
d) Last In Last Out
View Answer

Answer: b
Explanation: Queue follows First In First Out structure.
advertisement

2. In a circular queue, how do you increment the rear end of the queue?
a) rear++
b) (rear+1) % CAPACITY
c) (rear % CAPACITY)+1
d) rear–
View Answer

Answer: b
Explanation: Ensures rear takes the values from 0 to (CAPACITY-1).

3. What is the term for inserting into a full queue known as?
a) overflow
b) underflow
c) null pointer exception
d) program won’t be compiled
View Answer

Answer: a
Explanation: Just as stack, inserting into a full queue is termed overflow.

4. What is the time complexity of enqueue operation?


a) O(logn)
b) O(nlogn)
c) O(n)
d) O(1)
View Answer

Answer: d
Explanation: Enqueue operation is at the rear end, it takes O(1) time to insert a new item into
the queue.

5. What does the following Java code do?

public Object function()


{
if(isEmpty())
return -999;
else
{
Object high;
high = q[front];
return high;
}
}

a) Dequeue
b) Enqueue
c) Return the front element
d) Return the last element
View Answer

Answer: c
Explanation: q[front] gives the element at the front of the queue, since we are not moving the
‘front’ to the next element,
it is not a dequeue operation.
advertisement

6. What is the need for a circular queue?


a) effective usage of memory
b) easier computations
c) to delete elements based on priority
d) implement LIFO principle in queues
View Answer

Answer: a
Explanation: In a linear queue, dequeue operation causes the starting elements of the array to
be empty, and there is no way you can use that space, while in a circular queue, you can
effectively use that space. Priority queue is used to delete the elements based on their priority.
Higher priority elements will be deleted first whereas lower priority elements will be deleted
next. Queue data structure always follows FIFO principle.

7. Which of the following represents a dequeue operation? (count is the number of elements
in the queue)
a)

public Object dequeue()


{
if(count == 0)
{
System.out.println("Queue underflow");
return 0;
}
else
{
Object ele = q[front];
q[front] = null;
front = (front+1)%CAPACITY;
count--;
return ele;
}
}

b)

public Object dequeue()


{
if(count == 0)
{
System.out.println("Queue underflow");
return 0;
}
else
{
Object ele = q[front];
front = (front+1)%CAPACITY;
q[front] = null;
count--;
return ele;
}
}

c)

public Object dequeue()


{
if(count == 0)
{
System.out.println("Queue underflow");
return 0;
}
else
{
front = (front+1)%CAPACITY;
Object ele = q[front];
q[front] = null;
count--;
return ele;
}
}

d)

advertisement
public Object dequeue()
{
if(count == 0)
{
System.out.println("Queue underflow");
return 0;
}
else
{
Object ele = q[front];
q[front] = null;
front = (front+1)%CAPACITY;
return ele;
count--;
}
}
View Answer
Answer: a
Explanation: Dequeue removes the first element from the queue, ‘front’ points to the
front end of the queue and returns the first element.
8. Which of the following best describes the growth of a linear queue at runtime? (Q is the
original queue, size() returns the number of elements in the queue)
a)

private void expand()


{
int length = size();
int[] newQ = new int[length<<1];
for(int i=front; i<=rear; i++)
{
newQ[i-front] = Q[i%CAPACITY];
}
Q = newQ;
front = 0;
rear = size()-1;
}

b)

private void expand()


{
int length = size();
int[] newQ = new int[length<<1];
for(int i=front; i<=rear; i++)
{
newQ[i-front] = Q[i%CAPACITY];
}
Q = newQ;
}

c)

private void expand()


{
int length = size();
int[] newQ = new int[length<<1];
for(int i=front; i<=rear; i++)
{
newQ[i-front] = Q[i];
}
Q = newQ;
front = 0;
rear = size()-1;
}

d)

advertisement
private void expand()
{
int length = size();
int[] newQ = new int[length*2];
for(int i=front; i<=rear; i++)
{
newQ[i-front] = Q[i%CAPACITY];
}
Q = newQ;
}
View Answer
Answer: a
Explanation: A common technique to expand the size of array at run time is simply to double
the size. Create a new array of double the previous size and copy all the elements, after
copying do not forget to assign front = 0 and rear = size()-1, as these are necessary to
maintain the decorum of the queue operations.

9. What is the space complexity of a linear queue having n elements?


a) O(n)
b) O(nlogn)
c) O(logn)
d) O(1)
View Answer

Answer: a
Explanation: Because there are n elements.

10. What is the output of the following Java code?

public class CircularQueue


{
protected static final int CAPACITY = 100;
protected int size,front,rear;
protected Object q[];
int count = 0;

public CircularQueue()
{
this(CAPACITY);
}
public CircularQueue (int n)
{
size = n;
front = 0;
rear = 0;
q = new Object[size];
}

public void enqueue(Object item)


{
if(count == size)
{
System.out.println("Queue overflow");
return;
}
else
{
q[rear] = item;
rear = (rear+1)%size;
count++;
}
}
public Object dequeue()
{
if(count == 0)
{
System.out.println("Queue underflow");
return 0;
}
else
{
Object ele = q[front];
q[front] = null;
front = (front+1)%size;
count--;
return ele;
}
}
public Object frontElement()
{
if(count == 0)
return -999;
else
{
Object high;
high = q[front];
return high;
}
}
public Object rearElement()
{
if(count == 0)
return -999;
else
{
Object low;
rear = (rear-1)%size;
low = q[rear];
rear = (rear+1)%size;
return low;
}
}
}
public class CircularQueueDemo
{
public static void main(String args[])
{
Object var;
CircularQueue myQ = new CircularQueue();
myQ.enqueue(10);
myQ.enqueue(3);
var = myQ.rearElement();
myQ.dequeue();
myQ.enqueue(6);
var = mQ.frontElement();
System.out.println(var+" "+var);
}
}

a) 3 3
b) 3 6
c) 6 6
d) 10 6
View Answer

Answer: a
Explanation: First enqueue 10 and 3 into the queue, followed by a dequeue(removes 10),
followed by an enqueue(6), At this point, 3 is at the front end of the queue and 6 at the rear
end, hence a call to frontElement() will return 3 which is displayed twice.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Stack using Linked List
» Next - Data Structure Questions and Answers – Queue using Linked List
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Data Structure Questions and Answers – Stack using Linked List
Data Structure Questions and Answers – Queue using Linked List
advertisement
advertisement

Recommended Posts:

1. C Programming Examples
2. C Programming Examples without using Recursion
3. Python Programming Examples on Trees
4. Data Structures & Algorithms II – Questions and Answers
5. Java Programming Examples on Multithreading
6. C Programming Examples on Trees
7. Java Programming Examples on Arrays
8. Data Science Questions and Answers
9. C++ Programming Examples on STL
10. Java Programming Examples on Collections
11. C# Programming Examples on Data Structures
12. Python Programming Examples on Linked Lists
13. C Programming Examples on Linked List
14. C Programming Examples on Arrays
15. C Programming Examples on Data-Structures
16. C++ Programming Examples on Data-Structures
17. Java Programming Examples on Data-Structures
18. Python Programming Examples on Stacks & Queues
19. C Programming Examples on Stacks & Queues
20. Data Structure Questions and Answers

advertisement
Data Structure Questions and Answers –
Queue using Linked List
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Queue using Linked List―.

1. In linked list implementation of queue, if only front pointer is maintained, which of the
following operation take worst case linear time?
a) Insertion
b) Deletion
c) To empty a queue
d) Both Insertion and To empty a queue
View Answer

Answer: d
Explanation: Since front pointer is used for deletion, so worst time for the other two cases.
advertisement

2. In linked list implementation of a queue, where does a new element be inserted?


a) At the head of link list
b) At the centre position in the link list
c) At the tail of the link list
d) At any position in the linked list
View Answer

Answer: c
Explanation: Since queue follows FIFO so new element inserted at last.

3. In linked list implementation of a queue, front and rear pointers are tracked. Which of
these pointers will change during an insertion into a NONEMPTY queue?
a) Only front pointer
b) Only rear pointer
c) Both front and rear pointer
d) No pointer will be changed
View Answer

Answer: b
Explanation: Since queue follows FIFO so new element inserted at last.

4. In linked list implementation of a queue, front and rear pointers are tracked. Which of
these pointers will change during an insertion into EMPTY queue?
a) Only front pointer
b) Only rear pointer
c) Both front and rear pointer
d) No pointer will be changed
View Answer

Answer: c
Explanation: Since its the starting of queue, so both values are changed.

5. In case of insertion into a linked queue, a node borrowed from the __________ list is
inserted in the queue.
a) AVAIL
b) FRONT
c) REAR
d) NULL
View Answer

Answer: a
Explanation: All the nodes are collected in AVAIL list.
advertisement

6. In linked list implementation of a queue, from where is the item deleted?


a) At the head of link list
b) At the centre position in the link list
c) At the tail of the link list
d) Node before the tail
View Answer

Answer: a
Explanation: Since queue follows FIFO so new element deleted from first.

7. In linked list implementation of a queue, the important condition for a queue to be empty
is?
a) FRONT is null
b) REAR is null
c) LINK is empty
d) FRONT==REAR-1
View Answer

Answer: a
Explanation: Because front represents the deleted nodes.

8. The essential condition which is checked before insertion in a linked queue is?
a) Underflow
b) Overflow
c) Front value
d) Rear value
View Answer

Answer: b
Explanation: To check whether there is space in the queue or not.
9. The essential condition which is checked before deletion in a linked queue is?
a) Underflow
b) Overflow
c) Front value
d) Rear value
View Answer

Answer: a
Explanation: To check whether there is element in the list or not.
advertisement

10. Which of the following is true about linked list implementation of queue?
a) In push operation, if new nodes are inserted at the beginning of linked list, then in pop
operation, nodes must be removed from end
b) In push operation, if new nodes are inserted at the beginning, then in pop operation, nodes
must be removed from the beginning
c) In push operation, if new nodes are inserted at the end, then in pop operation, nodes must
be removed from end
d) In push operation, if new nodes are inserted at the end, then in pop operation, nodes must
be removed from beginning
View Answer

Answer: a
Explanation: It can be done by both the methods.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Queue using Array
» Next - Data Structure Questions and Answers – Priority Queue
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Data Structure Questions and Answers – Queue using Array
Data Structure Questions and Answers – Priority Queue
advertisement
advertisement

Recommended Posts:

1. C# Programming Examples
2. Java Algorithms, Problems & Programming Examples
3. C Programming Examples on Combinatorial Problems & Algorithms
4. Python Programming Examples on Trees
5. C Programming Examples on Arrays
6. Data Structures & Algorithms II – Questions and Answers
7. C++ Algorithms, Problems & Programming Examples
8. C Programming Examples using Recursion
9. Python Programming Examples on Stacks & Queues
10. C Programming Examples on Trees
11. C Programming Examples
12. C Programming Examples without using Recursion
13. C Programming Examples on Data-Structures
14. C# Programming Examples on Data Structures
15. Java Programming Examples on Data-Structures
16. C Programming Examples on Stacks & Queues
17. Data Structure Questions and Answers
18. C++ Programming Examples on Data-Structures
19. Python Programming Examples on Linked Lists
20. C Programming Examples on Linked List

advertisement

Data Structure Questions and Answers –


Priority Queue
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Priority Queue―.

1. With what data structure can a priority queue be implemented?


a) Array
b) List
c) Heap
d) Tree
View Answer

Answer: d
Explanation: Priority queue can be implemented using an array, a list, a binary search tree or
a heap, although the most efficient one being the heap.
advertisement

2. Which of the following is not an application of priority queue?


a) Huffman codes
b) Interrupt handling in operating system
c) Undo operation in text editors
d) Bayesian spam filter
View Answer

Answer: c
Explanation: Undo operation is achieved using a stack.
3. Select the appropriate code that inserts elements into the list based on the given key value.
(head and trail are dummy nodes to mark the end and beginning of the list, they do not
contain any priority or element)
a)

public void insert_key(int key,Object item)


{
if(key<0)
{
Systerm.our.println("invalid");
System.exit(0);
}
else
{
Node temp = new Node(key,item,null);
if(count == 0)
{
head.setNext(temp);
temp.setNext(trail);
}
else
{
Node dup = head.getNext();
Node cur = head;
while((key>dup.getKey()) && (dup!=trail))
{
dup = dup.getNext();
cur = cur.getNext();
}
cur.setNext(temp);
temp.setNext(dup);
}
count++;
}
}

b)

advertisement
public void insert_key(int key,Object item)
{
if(key<0)
{
Systerm.our.println("invalid");
System.exit(0);
}
else
{
Node temp = new Node(key,item,null);
if(count == 0)
{
head.setNext(temp);
temp.setNext(trail);
}
else
{
Node dup = head.getNext();
Node cur = dup;
while((key>dup.getKey()) && (dup!=trail))
{
dup = dup.getNext();
cur = cur.getNext();
}
cur.setNext(temp);
temp.setNext(dup);
}
count++;
}
}

c)

public void insert_key(int key,Object item)


{
if(key<0)
{
Systerm.our.println("invalid");
System.exit(0);
}
else
{
Node temp = new Node(key,item,null);
if(count == 0)
{
head.setNext(temp);
temp.setNext(trail);
}
else
{
Node dup = head.getNext();
Node cur = head;
while((key>dup.getKey()) && (dup!=trail))
{
dup = dup.getNext();
cur = cur.getNext();
}
cur.setNext(dup);
temp.setNext(cur);
}
count++;
}
}

d)

public void insert_key(int key,Object item)


{
if(key<0)
{
Systerm.our.println("invalid");
System.exit(0);
}
else
{
Node temp = new Node(key,item,null);
if(count == 0)
{
head.setNext(temp);
temp.setNext(trail);
}
else
{
Node dup = head.getNext();
Node cur = head;
while((key>dup.getKey()) && (dup!=trail))
{
dup = cur
cur = cur.getNext();
}
cur.setNext(dup);
temp.setNext(cur);
}
count++;
}
}
View Answer
Answer: a
Explanation: Have two temporary pointers ‘dup’ and ‘cur’ with ‘cur’
trailing behind ‘dup’. Traverse through the list until the given key is greater than some
element with a lesser key, insert the new node ‘temp’ in that position.

4. What is the time complexity to insert a node based on key in a priority queue?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
View Answer

Answer: c
Explanation: In the worst case, you might have to traverse the entire list.
advertisement

5. What is the functionality of the following piece of code?

public Object delete_key()


{
if(count == 0)
{
System.out.println("Q is empty");
System.exit(0);
}
else
{
Node cur = head.getNext();
Node dup = cur.getNext();
Object e = cur.getEle();
head.setNext(dup);
count--;
return e;
}
}
a) Delete the second element in the list
b) Return but not delete the second element in the list
c) Delete the first element in the list
d) Return but not delete the first element in the list
View Answer

Answer: c
Explanation: A pointer is made to point at the first element in the list and one more to point to
the second element, pointer manipulations are done such that the first element is no longer
being pointed by any other pointer, its value is returned.

6. What is not a disadvantage of priority scheduling in operating systems?


a) A low priority process might have to wait indefinitely for the CPU
b) If the system crashes, the low priority systems may be lost permanently
c) Interrupt handling
d) Indefinite blocking
View Answer

Answer: c
Explanation: The lower priority process should wait until the CPU completes the processing
higher priority process. Interrupt handling is an advantage as interrupts should be given more
priority than tasks at hand so that interrupt can be serviced to produce desired results.
advertisement

7. Which of the following is not an advantage of a priority queue?


a) Easy to implement
b) Processes with different priority can be efficiently handled
c) Applications with differing requirements
d) Easy to delete elements in any case
View Answer

Answer: d
Explanation: In worst case, the entire queue has to be searched for the element having the
highest priority. This will take more time than usual. So deletion of elements is not an
advantage.

8. What is the time complexity to insert a node based on position in a priority queue?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
View Answer

Answer: c
Explanation: In the worst case, you might have to traverse the entire list.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.
Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Queue using Linked List
» Next - Data Structure Questions and Answers – Double Ended Queue (Dequeue)
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Data Structure Questions and Answers – Queue using Linked List
Data Structure Questions and Answers – Double Ended Queue (Dequeue)
advertisement
advertisement

Recommended Posts:

1. C Programming Examples using Recursion


2. Java Programming Examples on Multithreading
3. C Programming Examples on Arrays
4. Data Structures & Algorithms II – Questions and Answers
5. Python Programming Examples on Trees
6. C Programming Examples on Trees
7. Java Programming Examples on Collections
8. Object Oriented Programming Questions and Answers
9. C Programming Examples without using Recursion
10. C++ Programming Examples on STL
11. Data Science Questions and Answers
12. C# Programming Examples on Data Structures
13. C Programming Examples on Linked List
14. Python Programming Examples on Stacks & Queues
15. Python Programming Examples on Linked Lists
16. C Programming Examples on Data-Structures
17. C Programming Examples on Stacks & Queues
18. Java Programming Examples on Data-Structures
19. C++ Programming Examples on Data-Structures
20. Data Structure Questions and Answers

advertisement

Data Structure Questions and Answers –


Double Ended Queue (Dequeue)
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Double Ended Queue (Dequeue)―.

1. What is a dequeue?
a) A queue with insert/delete defined for both front and rear ends of the queue
b) A queue implemented with a doubly linked list
c) A queue implemented with both singly and doubly linked lists
d) A queue with insert/delete defined for front side of the queue
View Answer

Answer: a
Explanation: A dequeue or a double ended queue is a queue with insert/delete defined for
both front and rear ends of the queue.
advertisement

2. Select the function which performs insertion at the front end of the dequeue?
a)

public void function(Object item)


{
Node temp = new Node(item,null);
if(isEmpty())
{
temp.setNext(trail);
head.setNext(temp);
}
else
{
Node cur = head.getNext();
temp.setNext(cur);
head.setNext(temp);
}
size++;
}

b)

public void function(Object item)


{
Node temp = new Node(item,null);
if(isEmpty())
{
temp.setNext(trail);
head.setNext(trail);
}
else
{
Node cur = head.getNext();
temp.setNext(cur);
head.setNext(temp);
}
size++;
}

c)

public void function(Object item)


{
Node temp = new Node(item,null);
if(isEmpty())
{
Node cur = head.getNext();
temp.setNext(cur);
head.setNext(temp);
}
else
{
temp.setNext(trail);
head.setNext(temp);
}
size++;
}

d)

advertisement
public void function(Object item)
{
Node temp = new Node(item,null);
if(isEmpty())
{
Node cur = head.getNext();
temp.setNext(cur);
cur.setNext(temp);
}
else
{
head.setNext(trail);
trail.setNext(temp);
}
size++;
}
View Answer
Answer: a
Explanation: Create a new node, if the current list is empty, the ‘head’ points to this
node and this new node points to ‘trail’. Otherwise, ‘head’ points to the new
node and this in turn points to the current first element(head.getNext()).

3. What is the functionality of the following piece of code?


public void function(Object item)
{
Node temp=new Node(item,trail);
if(isEmpty())
{
head.setNext(temp);
temp.setNext(trail);
}
else
{
Node cur=head.getNext();
while(cur.getNext()!=trail)
{
cur=cur.getNext();
}
cur.setNext(temp);
}
size++;
}
a) Insert at the front end of the dequeue
b) Insert at the rear end of the dequeue
c) Fetch the element at the rear end of the dequeue
d) Fetch the element at the front end of the dequeue
View Answer

Answer: b
Explanation: If the list is empty, this new node will point to ‘trail’ and will be pointed
at by ‘head’. Otherwise, traverse till the end of the list and insert the new node there.

4. What are the applications of dequeue?


a) A-Steal job scheduling algorithm
b) Can be used as both stack and queue
c) To find the maximum of all sub arrays of size k
d) To avoid collision in hash tables
View Answer

Answer: d
Explanation: All of the mentioned can be implemented with a dequeue.

5. Which of the following can be used to delete an element from the front end of the queue?
a)

public Object deleteFront() throws emptyDEQException


{
if(isEmpty())
throw new emptyDEQException("Empty");
else
{
Node temp = head.getNext();
Node cur = temp;
Object e = temp.getEle();
head.setNext(cur);
size--;
return e;
}
}

b)

advertisement
public Object deleteFront() throws emptyDEQException
{
if(isEmpty())
throw new emptyDEQException("Empty");
else
{
Node temp = head.getNext();
Node cur = temp.getNext();
Object e = temp.getEle();
head.setNext(cur);
size--;
return e;
}
}
c)

public Object deleteFront() throws emptyDEQException


{
if(isEmpty())
throw new emptyDEQException("Empty");
else
{
Node temp = head.getNext();
Node cur = temp.getNext();
Object e = temp.getEle();
head.setNext(temp);
size--;
return e;
}
}

d)

public Object deleteFront() throws emptyDEQException


{
if(isEmpty())
throw new emptyDEQException("Empty");
else
{
Node temp = head.getNext();
Node cur = temp.getNext();
Object e = temp.getEle();
temp.setNext(cur);
size--;
return e;
}
}
View Answer
Answer: b
Explanation: Have two pointers, one(temp) pointing to the first element and the other(cur)
pointing to the second element. Make the ‘head’ point to the second element, this
removes all reference for ‘temp’.

6. Which of the following can be used to delete an element from the rear end of the queue?
a)
public Object deleteRear() throws emptyDEQException
{
if(isEmpty())
throw new emptyDEQException("Empty");
else
{
Node temp = head.getNext();
Node cur = temp;
while(temp.getNext() != trail)
{
temp = temp.getNext();
cur = cur.getNext();
}
Object e = temp.getEle();
cur.setNext(trail);
size--;
return e;
}
}

b)

advertisement
public Object deleteRear() throws emptyDEQException
{
if(isEmpty())
throw new emptyDEQException("Empty");
else
{
Node temp = head.getNext();
Node cur = head;
while(temp != trail)
{
temp = temp.getNext();
cur = cur.getNext();
}
Object e = temp.getEle();
cur.setNext(trail);
size--;
return e;
}
}

c)

public Object deleteRear() throws emptyDEQException


{
if(isEmpty())
throw new emptyDEQException("Empty");
else
{
Node temp = head.getNext();
Node cur = head;
while(temp.getNext()!=trail)
{
temp = temp.getNext();
cur = cur.getNext();
}
Object e = temp.getEle();
cur.setNext(trail);
size--;
return e;
}
}

d)

public Object deleteRear() throws emptyDEQException


{
if(isEmpty())
throw new emptyDEQException("Empty");
else
{
Node temp = head.getNext();
Node cur = head;
while(temp.getNext()!=trail)
{
temp = temp.getNext();
cur = cur.getNext();
}
Object e = temp.getEle();
temp.setNext(trail);
size--;
return e;
}
}
View Answer
Answer: c
Explanation: Traverse till the end of the list with a pointer ‘temp’ and another
‘cur’ which is trailing behind temp, make ‘cur’ point to trail, this removes all
reference for ‘temp’.

7. What is the time complexity of deleting from the rear end of the dequeue implemented
with a singly linked list?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
View Answer
Answer: c
Explanation: Since a singly linked list is used, first you have to traverse till the end, so the
complexity is O(n).

8. After performing these set of operations, what does the final list look contain?

InsertFront(10);
InsertFront(20);
InsertRear(30);
DeleteFront();
InsertRear(40);
InsertRear(10);
DeleteRear();
InsertRear(15);
display();

a) 10 30 10 15
b) 20 30 40 15
c) 20 30 40 10
d) 10 30 40 15
View Answer

Answer: d
Explanation: A careful tracing of the given operation yields the result.
10
20 10
20 10 30
10 30
10 30 40
10 30 40 10
10 30 40
10 30 40 15

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Priority Queue
» Next - Data Structure Questions and Answers – Queue using Stacks
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Data Structure Questions and Answers – Priority Queue
Data Structure Questions and Answers – Queue using Stacks
advertisement
advertisement

Recommended Posts:

1. C Programming Examples on Arrays


2. Javascript Questions and Answers
3. Java Programming Examples on Event Handling
4. C Programming Examples on Searching and Sorting
5. Java Programming Examples on Collections
6. C++ Programming Examples on STL
7. Data Science Questions and Answers
8. C# Programming Examples on Data Structures
9. Object Oriented Programming Questions and Answers
10. Data Structures & Algorithms II – Questions and Answers
11. Java Programming Examples on Exception Handling
12. C Programming Examples on Linked List
13. C Programming Examples on Stacks & Queues
14. Python Programming Examples on Linked Lists
15. C Programming Examples on Data-Structures
16. Python Programming Examples on Stacks & Queues
17. Java Programming Examples on Data-Structures
18. C++ Programming Examples on Data-Structures
19. Data Structure Questions and Answers
20. Java Program to implement Priority Queue

advertisement
Data Structure Questions and Answers –
Queue using Stacks
« Prev
Next »

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Queue using Stacks―.

1. A Double-ended queue supports operations such as adding and removing items from both
the sides of the queue. They support four operations like addFront(adding item to top of the
queue), addRear(adding item to the bottom of the queue), removeFront(removing item from
the top of the queue) and removeRear(removing item from the bottom of the queue). You are
given only stacks to implement this data structure. You can implement only push and pop
operations. What are the total number of stacks required for this operation?(you can reuse the
stack)
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: b
Explanation: The addFront and removeFront operations can be performed using one stack
itself as push and pop are supported (adding and removing element from top of the stack) but
to perform addRear and removeRear you need to pop each element from the current stack and
push it into another stack, push or pop the element as per the asked operation from this stack
and in the end pop elements from this stack to the first stack.
advertisement

2. You are asked to perform a queue operation using a stack. Assume the size of the stack is
some value ‘n’ and there are ‘m’ number of variables in this stack. The time
complexity of performing deQueue operation is (Using only stack operations like push and
pop)(Tightly bound).
a) O(m)
b) O(n)
c) O(m*n)
d) Data is insufficient
View Answer

Answer: a
Explanation: To perform deQueue operation you need to pop each element from the first
stack and push it into the second stack. In this case you need to pop ‘m’ times and need
to perform push operations also ‘m’ times. Then you pop the first element from this
second stack (constant time) and pass all the elements to the first stack (as done in the
beginning)(‘m-1’ times). Therfore the time complexity is O(m).
3. Consider you have an array of some random size. You need to perform dequeue operation.
You can perform it using stack operation (push and pop) or using queue operations itself
(enQueue and Dequeue). The output is guaranteed to be same. Find some differences?
a) They will have different time complexities
b) The memory used will not be different
c) There are chances that output might be different
d) No differences
View Answer

Answer: a
Explanation: To perform operations such as Dequeue using stack operation you need to
empty all the elements from the current stack and push it into the next stack, resulting in a
O(number of elements) complexity whereas the time complexity of dequeue operation itself
is O(1). And there is a need of a extra stack. Therefore more memory is needed.

4. Consider you have a stack whose elements in it are as follows.


5 4 3 2 << top
Where the top element is 2.
You need to get the following stack
6 5 4 3 2 << top
The operations that needed to be performed are (You can perform only push and pop):
a) Push(pop()), push(6), push(pop())
b) Push(pop()), push(6)
c) Push(pop()), push(pop()), push(6)
d) Push(6)
View Answer

Answer: a
Explanation: By performing push(pop()) on all elements on the current stack to the next stack
you get 2 3 4 5 << top.Push(6) and perform push(pop()) you’ll get back 6 5 4 3 2 << top.
You have actually performed enQueue operation using push and pop.

5. A double-ended queue supports operations like adding and removing items from both the
sides of the queue. They support four operations like addFront(adding item to top of the
queue), addRear(adding item to the bottom of the queue), removeFront(removing item from
the top of the queue) and removeRear(removing item from the bottom of the queue). You are
given only stacks to implement this data structure. You can implement only push and pop
operations. What’s the time complexity of performing addFront and addRear? (Assume
‘m’ to be the size of the stack and ‘n’ to be the number of elements)
a) O(m) and O(n)
b) O(1) and O(n)
c) O(n) and O(1)
d) O(n) and O(m)
View Answer

Answer: b
Explanation: addFront is just a normal push operation. Push operation is of O(1). Whereas
addRear is of O(n) as it requires two push(pop()) operations of all elements of a stack.
advertisement
6. Why is implementation of stack operations on queues not feasible for a large dataset
(Asssume the number of elements in the stack to be n)?
a) Because of its time complexity O(n)
b) Because of its time complexity O(log(n))
c) Extra memory is not required
d) There are no problems
View Answer

Answer: a
Explanation: To perform Queue operations such as enQueue and deQueue there is a need of
emptying all the elements of a current stack and pushing elements into the next stack and vice
versa. Therfore it has a time complexity of O(n) and the need of extra stack as well, may not
be feasible for a large dataset.

7. Consider yourself to be in a planet where the computational power of chips to be slow.


You have an array of size 10.You want to perform enqueue some element into this array. But
you can perform only push and pop operations .Push and pop operation both take 1 sec
respectively. The total time required to perform enQueue operation is?
a) 20
b) 40
c) 42
d) 43
View Answer

Answer: d
Explanation: First you have to empty all the elements of the current stack into the temporary
stack, push the required element and empty the elements of the temporary stack into the
original stack. Therfore taking 10+10+1+11+11= 43 seconds.

8. You have two jars, one jar which has 10 rings and the other has none. They are placed one
above the other. You want to remove the last ring in the jar. And the second jar is weak and
cannot be used to store rings for a long time.
a) Empty the first jar by removing it one by one from the first jar and placing it into the
second jar
b) Empty the first jar by removing it one by one from the first jar and placing it into the
second jar and empty the second jar by placing all the rings into the first jar one by one
c) There exists no possible way to do this
d) Break the jar and remove the last one
View Answer

Answer: b
Explanation: This is similar to performing dequeue operation using push and pop only.
Elements in the first jar are taken out and placed in the second jar. After removing the last
element from the first jar, remove all the elements in the second jar and place them in the first
jar.

9. Given only a single array of size 10 and no other memory is available. Which of the
following operation is not feasible to implement (Given only push and pop operation)?
a) Push
b) Pop
c) Enqueue
d) Returntop
View Answer

Answer: c
Explanation: To perform Enqueue using just push and pop operations, there is a need of
another array of same size. But as there is no extra available memeory, the given operation is
not feasible.
advertisement

10. Given an array of size n, let’s assume an element is ‘touched’ if and only if
some operation is performed on it(for example, for performing a pop operation the top
element is ‘touched’). Now you need to perform Dequeue operation. Each element in
the array is touched atleast?
a) Once
b) Twice
c) Thrice
d) Four times
View Answer

Answer: d
Explanation: First each element from the first stack is popped, then pushed into the second
stack, dequeue operation is done on the top of the stack and later the each element of second
stack is popped then pushed into the first stack. Therfore each element is touched four times.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Double Ended Queue (Dequeue)
» Next - Data Structure Questions and Answers – Stack using Queues
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Data Structure Questions and Answers – Double Ended Queue (Dequeue)
Data Structure Questions and Answers – Stack using Queues
advertisement
advertisement

Recommended Posts:

1. Python Programming Examples on Searching and Sorting


2. Java Programming Examples on Combinatorial Problems & Algorithms
3. C Programming Examples using Recursion
4. Data Structures & Algorithms II – Questions and Answers
5. C Programming Examples
6. C# Programming Examples on Sorting
7. C Programming Examples on Combinatorial Problems & Algorithms
8. C Programming Examples on Searching and Sorting
9. C# Programming Examples on Matrix
10. C Programming Examples on Arrays
11. Python Programming Examples on Linked Lists
12. Java Programming Examples on Collections
13. C Programming Examples on Linked List
14. C++ Programming Examples on Data-Structures
15. C Programming Examples on Data-Structures
16. Java Programming Examples on Data-Structures
17. Data Structure Questions and Answers
18. C# Programming Examples on Data Structures
19. C Programming Examples on Stacks & Queues
20. Python Programming Examples on Stacks & Queues

advertisement

Data Structure Questions and Answers –


Stack using Queues
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Stack using Queues―.

1. To implement a stack using queue(with only enqueue and dequeue operations), how many
queues will you need?
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: b
Explanation: Either the push or the pop has to be a costly operation, and the costlier operation
requires two queues.

2. Making the push operation costly, select the code snippet which implements the same.(let
q1 and q2 be two queues)
a)

public void push(int x)


{
if(empty())
{
q1.offer(x);
}
else{
if(q1.size()>0)
{
q2.offer(x);
int size = q1.size();
while(size>0)
{
q2.offer(q1.poll());
size--;
}
}
else if(q2.size()>0)
{
q1.offer(x);
int size = q2.size();
while(size>0)
{
q1.offer(q2.poll());
size--;
}
}
}
}

b)

advertisement
public void push(int x)
{
if(empty())
{
q1.offer(x);
}
else
{
if(q1.size()>0)
{
q1.offer(x);
int size = q1.size();
while(size>0)
{
q2.offer(q1.poll());
size--;
}
}
else if(q2.size()>0)
{
q2.offer(x);
int size = q2.size();
while(size>0)
{
q1.offer(q2.poll());
size--;
}
}
}
}

c)

public void push(int x)


{
if(empty())
{
q1.offer(x);
}
else
{
if(q1.size()>0)
{
q2.offer(x);
int size = q1.size();
while(size>0)
{
q1.offer(q2.poll());
size--;
}
}
else if(q2.size()>0)
{
q1.offer(x);
int size = q2.size();
while(size>0)
{
q2.offer(q1.poll());
size--;
}
}
}
}

d)

public void push(int x)


{
if(empty())
{
q1.offer(x);
}
else
{
if(q1.size()>0)
{
q2.offer(x);
int size = q1.size();
while(size>0)
{
q2.offer(q2.poll());
size--;
}
}
else if(q2.size()>0)
{
q1.offer(x);
int size = q2.size();
while(size>0)
{
q2.offer(q1.poll());
size--;
}
}
}
}
View Answer
Answer: a
Explanation: Stack follows LIFO principle, hence a new item added must be the first one to
exit, but queue follows FIFO principle, so when a new item is entered into the queue, it will
be at the rear end of the queue. If the queue is initially empty, then just add the new element,
otherwise add the new element to the second queue and dequeue all the elements from the
second queue and enqueue it to the first one, in this way, the new element added will be
always in front of the queue. Since two queues are needed to realize this push operation, it is
considered to be costlier.

3. Making the push operation costly, select the code snippet which implements the pop
operation.
a)
advertisement
public void pop()
{
if(q1.size()>0)
{
q2.poll();
}
else if(q2.size()>0)
{
q1.poll();
}
}

b)

public void pop()


{
if(q1.size()>0)
{
q1.poll();
}
else if(q2.size()>0)
{
q2.poll();
}
}

c)

public void pop()


{
q1.poll();
q2.poll();
}

d)

advertisement
public void pop()
{
if(q2.size()>0)
{
q1.poll();
}
else
{
q2.poll();
}
}
View Answer
Answer: b
Explanation: As the push operation is costly, it is evident that the required item is in the front
of the queue, so just dequeue the element from the queue.

4. Select the code snippet which returns the top of the stack.
a)
public int top()
{
if(q1.size()>0)
{
return q1.poll();
}
else if(q2.size()>0)
{
return q2.poll();
}
return 0;
}

b)

public int top()


{
if(q1.size()==0)
{
return q1.peek();
}
else if(q2.size()==0)
{
return q2.peek();
}
return 0;
}

c)

public int top()


{
if(q1.size()>0)
{
return q1.peek();
}
else if(q2.size()>0)
{
return q2.peek();
}
return 0;
}

d)

advertisement
public int top()
{
if(q1.size()>0)
{
return q2.peek();
}
else if(q2.size()>0)
{
return q1.peek();
}
return 0;
}
View Answer
Answer: c
Explanation: Assuming its a push costly implementation, the top of the stack will be in the
front end of the queue, note that peek() just returns the front element, while poll() removes
the front element from the queue.

5. Select the code snippet which return true if the stack is empty, false otherwise.
a)
public boolean empty()
{
return q2.isEmpty();
}

b)

public boolean empty()


{
return q1.isEmpty() || q2.isEmpty();
}

c)

public boolean empty()


{
return q1.isEmpty();
}

d)

public boolean empty()


{
return q1.isEmpty() & q2.isEmpty();
}
View Answer
Answer: b
Explanation: If both the queues are empty, then the stack also is empty.
6. Making the pop operation costly, select the code snippet which implements the same.
a)
public int pop()
{
int res=-999,count=0;
if(q1.size()>0)
{
count = q1.size();
while(count>0)
q2.offer(q1.poll());
res = q1.poll();
}
if(q2.size()>0)
{
count = q2.size();
while(count>0)
q1.offer(q2.poll());
res = q2.poll();
}
return res;
}

b)

public int pop()


{
int res=-999,count=0;
if(q1.size()>0)
{
count = q1.size();
while(count>1)
q2.offer(q1.poll());
res = q2.poll();
}
if(q2.size()>0)
{
count = q2.size();
while(count>1)
q1.offer(q2.poll());
res = q1.poll();
}
return res;
}

c)

public int pop()


{
int res=-999,count=0;
if(q1.size()>0)
{
count = q1.size();
while(count>1)
q2.offer(q1.poll());
res = q1.poll();
}
if(q2.size()>0)
{
count = q2.size();
while(count>1)
q1.offer(q2.poll());
res = q2.poll();
}
return res;
}

d)

public int pop()


{
int res=-999,count=0;
if(q1.size()>0)
{
count = q2.size();
while(count>1)
q2.offer(q1.poll());
res = q1.poll();
}
if(q2.size()>0)
{
count = q1.size();
while(count>1)
q1.offer(q2.poll());
res = q2.poll();
}
return res;
}
View Answer
Answer: c
Explanation: Here the pop operation is costly, hence we need two queues, other than the first
element, all the the elements from one queue are dequeued and enqueued to the second
queue, hence only one element remains in the first queue which is the item we want, so
dequeue it and return the result.

7. What is the functionality of the following piece of code?


public void fun(int x)
{
q1.offer(x);
}

a) Perform push() with push as the costlier operation


b) Perform push() with pop as the costlier operation
c) Perform pop() with push as the costlier operation
d) Perform pop() with pop as the costlier operation
View Answer

Answer: b
Explanation: offer() suggests that it is a push operation, but we see that it is performed with
only one queue, hence the pop operation is costlier.

Sanfoundry Global Education & Learning Series – Data Structure.


To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!
Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Queue using Stacks
» Next - Data Structure Questions and Answers – Decimal to Binary using Stacks
Categories Data Structure MCQs, DS MCQs 1 - Abstract Data Types Post navigation
Data Structure Questions and Answers – Queue using Stacks
Data Structure Questions and Answers – Decimal to Binary using Stacks
advertisement
advertisement

Recommended Posts:

1. Python Programming Examples on Trees


2. C# Programming Examples on Strings
3. C Programming Examples
4. C Programming Examples on Trees
5. C Programming Examples on Bitwise Operations
6. C++ Programming Examples on STL
7. C Programming Examples on Arrays
8. C Programming Examples without using Recursion
9. Data Structures & Algorithms II – Questions and Answers
10. Python Programming Examples on Linked Lists
11. Data Science Questions and Answers
12. Java Programming Examples on Collections
13. C Programming Examples on Linked List
14. C Programming Examples on Data-Structures
15. C++ Programming Examples on Data-Structures
16. Java Programming Examples on Data-Structures
17. C# Programming Examples on Data Structures
18. Data Structure Questions and Answers
19. Python Programming Examples on Stacks & Queues
20. C Programming Examples on Stacks & Queues

advertisement

Data Structure Questions and Answers –


Decimal to Binary using Stacks
« Prev
Next »

This set of Data Structure Interview Questions and Answers for Experienced people focuses
on “Decimal to Binary using Stacks―.
1. Express -15 as a 6-bit signed binary number.
a) 001111
b) 101111
c) 101110
d) 001110
View Answer

Answer: b
Explanation: The first 4 1s from the right represent the number 15, 2 more bits are padded to
make it 6 digits and the leftmost bit is a 1 to represent that it is -15.

2. Which of the following code snippet is used to convert decimal to binary numbers?
a)

public void convertBinary(int num)


{
int bin[] = new int[50];
int index = 0;
while(num > 0)
{
bin[index++] = num%2;
num = num/2;
}
for(int i = index-1;i >= 0;i--)
{
System.out.print(bin[i]);
}
}

b)

advertisement
public void convertBinary(int num)
{
int bin[] = new int[50];
int index = 0;
while(num > 0)
{
bin[++index] = num%2;
num = num/2;
}
for(int i = index-1;i >= 0;i--)
{
System.out.print(bin[i]);
}
}

c)

public void convertBinary(int num)


{
int bin[] = new int[50];
int index = 0;
while(num > 0)
{
bin[index++] = num/2;
num = num%2;
}
for(int i = index-1;i >= 0;i--)
{
System.out.print(bin[i]);
}
}

d)

public void convertBinary(int num)


{
int bin[] = new int[50];
int index = 0;
while(num > 0)
{
bin[++index] = num/2;
num = num%2;
}
for(int i = index-1;i >= 0;i--)
{
System.out.print(bin[i]);
}
}
View Answer
Answer: a
Explanation: Take the modulus by 2 of the number and store in an array while halving the
number during each iteration and then display the contents of the array.

3. Which is the predefined method available in Java to convert decimal to binary numbers?
a) toBinaryInteger(int)
b) toBinaryValue(int)
c) toBinaryNumber(int)
d) toBinaryString(int)
View Answer
Answer: d
Explanation: The method toBinaryString() takes an integer argument and is defined in
java.lang package. Usage is java.lang.Integer.toBinaryString(int) this returns the string
representation of the unsigned integer value.

4. Using stacks, how to obtain the binary representation of the number?


a)

advertisement
public void convertBinary(int num)
{
Stack<Integer> stack = new Stack<Integer>();
while (num != 0)
{
int digit = num / 2;
stack.push(digit);
num = num % 2;
}
System.out.print("\nBinary representation is:");
while (!(stack.isEmpty() ))
{
System.out.print(stack.pop());
}
}

b)

public void convertBinary(int num)


{
Stack<Integer> stack = new Stack<Integer>();
while (num != 0)
{
int digit = num % 2;
stack.push(digit);
}
System.out.print("\nBinary representation is:");
while (!(stack.isEmpty() ))
{
System.out.print(stack.pop());
}
}

c)

public void convertBinary(int num)


{
Stack<Integer> stack = new Stack<Integer>();
while (num != 0)
{
int digit = num % 2;
stack.push(digit);
num = num / 2;
}
System.out.print("\nBinary representation is:");
while (!(stack.isEmpty() ))
{
System.out.print(stack.pop());
}
}

d)

advertisement
public void convertBinary(int num)
{
Stack<Integer> stack = new Stack<Integer>();
while (num != 0)
{
int digit = num % 2;
stack.push(digit%2);
num = num / 2;
}
System.out.print("\nBinary representation is:");
while (!(stack.isEmpty() ))
{
System.out.print(stack.pop());
}
}
View Answer
Answer: c
Explanation: Here instead of adding the digits to an array, you push it into a stack and while
printing, pop it from the stack.

5. What is the time complexity for converting decimal to binary numbers?


a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn)
View Answer
Answer: c
Explanation: Since each time you are halving the number, it can be related to that of a binary
search algorithm, hence the complexity is O(logn).

6. Write a piece of code which returns true if the string contains balanced parenthesis, false
otherwise.
a)

public boolean isBalanced(String exp)


{
int len = exp.length();
Stack<Integer> stk = new Stack<Integer>();
for(int i = 0; i < len; i++)
{
char ch = exp.charAt(i);
if (ch == '(')
stk.push(i);
else if (ch == ')')
{
if(stk.peek() == null)
{
return false;
}
stk.pop();
}
}
return true;
}

b)

public boolean isBalanced(String exp)


{
int len = exp.length();
Stack<Integer> stk = new Stack<Integer>();
for(int i = 0; i < len; i++)
{
char ch = exp.charAt(i);
if (ch == '(')
stk.push(i);
else if (ch == ')')
{
if(stk.peek() != null)
{
return true;
}
stk.pop();
}
}
return false;
}

c)

public boolean isBalanced(String exp)


{
int len = exp.length();
Stack<Integer> stk = new Stack<Integer>();
for(int i = 0; i < len; i++)
{
char ch = exp.charAt(i);
if (ch == ')')
stk.push(i);
else if (ch == '(')
{
if(stk.peek() == null)
{
return false;
}
stk.pop();
}
}
return true;
}

d)

advertisement
public boolean isBalanced(String exp)
{
int len = exp.length();
Stack<Integer> stk = new Stack<Integer>();
for(int i = 0; i < len; i++)
{
char ch = exp.charAt(i);
if (ch == '(')
stk.push(i);
else if (ch == ')')
{
if(stk.peek() != null)
{
return false;
}
stk.pop();
}
}
return true;
}
View Answer
Answer: a
Explanation: Whenever a ‘(‘ is encountered, push it into the stack, and when a ‘)’
is encountered check the top of the stack to see if there is a matching ‘(‘, if not return
false, continue this till the entire string is processed and then return true.
7. What is the time complexity of the following code?
public boolean isBalanced(String exp)
{
int len = exp.length();
Stack<Integer> stk = new Stack<Integer>();
for(int i = 0; i < len; i++)
{
char ch = exp.charAt(i);
if (ch == '(')
stk.push(i);
else if (ch == ')')
{
if(stk.peek() == null)
{
return false;
}
stk.pop();
}
}
return true;
}

a) O(logn)
b) O(n)
c) O(1)
d) O(nlogn)
View Answer

Answer: b
Explanation: All the characters in the string have to be processed, hence the complexity is
O(n).

8. Which of the following program prints the index of every matching parenthesis?
a)

public void dispIndex(String exp)


{
Stack<Integer> stk = new Stack<Integer>();
for (int i = 0; i < len; i++)
{
char ch = exp.charAt(i);
if (ch == '(')
stk.push(i);
else if (ch == ')')
{
try
{
int p = stk.pop() + 1;
System.out.println("')' at index "+(i+1)+" matched with ')' at
index "+p);
}
catch(Exception e)
{
System.out.println("')' at index "+(i+1)+" is unmatched");
}
}
}
while (!stk.isEmpty() )
System.out.println("'(' at index "+(stk.pop() +1)+" is unmatched");
}

b)

public void dispIndex(String exp)


{
Stack<Integer> stk = new Stack<Integer>();
for (int i = 0; i < len; i++)
{
char ch = exp.charAt(i);
if (ch == '(')
stk.push(i);
else if (ch == ')')
{
try
{
int p = stk.pop() + 1;
System.out.println("')' at index "+(i)+" matched with ')' at
index "+p);
}
catch(Exception e)
{
System.out.println("')' at index "+(i)+" is unmatched");
}
}
}
while (!stk.isEmpty() )
System.out.println("'(' at index "+(stk.pop() +1)+" is unmatched");
}

c)

public void dispIndex(String exp)


{
Stack<Integer> stk = new Stack<Integer>();
for (int i = 0; i < len; i++)
{
char ch = exp.charAt(i);
if (ch == ')')
stk.push(i);
else if (ch == '(')
{
try
{
int p = stk.pop() +1;
System.out.println("')' at index "+(i+1)+" matched with ')' at
index "+p);
}
catch(Exception e)
{
System.out.println("')' at index "+(i+1)+" is unmatched");
}
}
}
while (!stk.isEmpty() )
System.out.println("'(' at index "+(stk.pop() +1)+" is unmatched");
}

d)

public void dispIndex(String exp)


{
Stack<Integer> stk = new Stack<Integer>();
for (int i = 0; i < len; i++)
{
char ch = exp.charAt(i);
if (ch == ')')
stk.push(i);
else if (ch == '(')
{
try
{
int p = stk.pop();
System.out.println("')' at index "+(i+1)+" matched with ')' at
index "+p);
}
catch(Exception e)
{
System.out.println("')' at index "+(i+1)+" is unmatched");
}
}
}
while (!stk.isEmpty() )
System.out.println("'(' at index "+(stk.pop() +1)+" is unmatched");
}
View Answer
Answer: a
Explanation: Whenever a ‘(‘ is encountered, push the index of that character into the
stack, so that whenever a corresponding ‘)’ is encountered, you can pop and print it.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure for Interviews, here is complete set of 1000+ Multiple
Choice Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!
Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Stack using Queues
» Next - Data Structure Questions and Answers – Evaluation of an Infix Expression (Not
Parenthesized)
Categories Data Structure MCQs, DS MCQs 2 - Application of Stacks Post navigation
Data Structure Questions and Answers – Stack using Queues
Data Structure Questions and Answers – Evaluation of an Infix Expression (Not
Parenthesized)
advertisement
advertisement

Recommended Posts:
1. C Programming Examples on Strings
2. Python Programming Examples on Linked Lists
3. C++ Programming Examples on STL
4. C Programming Examples on Bitwise Operations
5. C Programming Examples
6. Java Programming Examples on Event Handling
7. Data Science Questions and Answers
8. C# Programming Examples on Exceptions
9. C Programming Examples without using Recursion
10. C Programming Examples using Recursion
11. Java Programming Examples on Collections
12. Data Structures & Algorithms II – Questions and Answers
13. Java Programming Examples on String Handling
14. C++ Programming Examples on Data-Structures
15. Java Programming Examples on Data-Structures
16. C Programming Examples on Data-Structures
17. Data Structure Questions and Answers
18. C# Programming Examples on Data Structures
19. C Programming Examples on Stacks & Queues
20. Python Programming Examples on Stacks & Queues

advertisement

Data Structure Questions and Answers –


Evaluation of an Infix Expression (Not
Parenthesized)
« Prev
Next »

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Evaluation of an Infix Expression (Not Parenthesized)―.

1. How many stacks are required for applying evaluation of infix expression algorithm?
a) one
b) two
c) three
d) four
View Answer

Answer: b
Expression: Two stacks are required for evaluation of infix expression – one for operands
and one for operators.
advertisement

2. How many passes does the evaluation of infix expression algorithm makes through the
input?
a) One
b) Two
c) Three
d) Four
View Answer

Answer: a
Explanation: Evaluation of infix expression algorithm is linear and makes only one pass
through the input.

3. Identify the infix expression from the list of options given below.
a) a/b+(c-d)
b) abc*+d+ab+cd+*ce-f-
c) ab-c-
d) +ab
View Answer

Answer: a
Explanation: a/b+(c-d) is an infix expression since the operators are placed in between the
operands.

4. Which of the following statement is incorrect with respect to evaluation of infix expression
algorithm?
a) Operand is pushed on to the stack
b) If the precedence of operator is higher, pop two operands and evaluate
c) If the precedence of operator is lower, pop two operands and evaluate
d) The result is pushed on to the operand stack
View Answer

Answer: b
Explanation: If the precedence of the operator is higher than the stack operator, then it is
pushed on to the stack operator.

5. Evaluate the following statement using infix evaluation algorithm and choose the correct
answer. 1+2*3-2
a) 3
b) 6
c) 5
d) 4
View Answer

Answer: c
Explanation: According to precedence of operators, * is evaluated first. + and – have equal
priorities. Hence, 1+6-2= 5.
advertisement

6. Evaluation of infix expression is done based on precedence of operators.


a) True
b) False
View Answer
Answer: a
Explanation: During evaluation of infix expression, the operators with higher precedence are
evaluated first, followed by operators with lower precedence.

7. Of the following choices, which operator has the lowest precedence?


a) ^
b) +
c) /
d) #
View Answer

Answer: d
Explanation: The operator with the lowest precedence is #, preceded by +, / and then ^.

8. The system throws an error if parentheses are encountered in an infix expression


evaluation algorithm.
a) True
b) False
View Answer

Answer: b
Explanation: The algorithm holds good for infix expression with parentheses. The system
does not throw error.

9. Evaluate the following and choose the correct answer.


a/b+c*d where a=4, b=2, c=2, d=1.
a) 1
b) 4
c) 5
d) 2
View Answer

Answer: b
Explanation: * and / have higher priority. Hence, they are evaluated first. Then, + is
evaluated. Hence, 2+2=4.
advertisement

10. Evaluate the following statement using infix evaluation algorithm and choose the correct
answer. 4*2+3-5/5
a) 10
b) 11
c) 16
d) 12
View Answer

Answer: a
Explanation: 4*2 and 5/5 are evaluated first and then, 8+3-1 is evaluated and the result is
obtained as 10.
11. Using the evaluation of infix expression, evaluate a^b+c and choose the correct answer.
(a=2, b=2, c=2)
a) 12
b) 8
c) 10
d) 6
View Answer

Answer: d
Explanation: ^ has the highest precedence. Hence, 2^2 is evaluated and then 4+2 gives 6.

12. Evaluate the following infix expression using algorithm and choose the correct answer.
a+b*c-d/e^f where a=1, b=2, c=3, d=4, e=2, f=2.
a) 6
b) 8
c) 9
d) 7
View Answer

Answer: a
Explanation: ^ has the highest order of precedence. Hence, 2^2 is evaluated first, and then,
2*3 and 4/4 are evaluated. Therefore, 1+6-1=6.

13. From the given expression tree, identify the infix expression, evaluate it and choose the
correct result.

a) 5
b) 10
c) 12
d) 16
View Answer

Answer: c
Explanation: From the given expression tree, the result of the infix expression is evaluated to
be 12.
advertisement

Sanfoundry Global Education & Learning Series – Data Structure.


To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Decimal to Binary using Stacks
» Next - Evaluation of a Prefix Expression Multiple Choice Questions and Answers
(MCQs)
Categories Data Structure MCQs, DS MCQs 2 - Application of Stacks Post navigation
Data Structure Questions and Answers – Decimal to Binary using Stacks
Evaluation of a Prefix Expression Multiple Choice Questions and Answers (MCQs)
advertisement
advertisement

Recommended Posts:

1. Ruby Programming Questions and Answers


2. Data Science Questions and Answers
3. C# Programming Examples on Data Structures
4. Unix Questions and Answers
5. C++ Programming Examples on Numerical Problems & Algorithms
6. C++ Programming Examples on Graph Problems & Algorithms
7. C Programming Examples on Numerical Problems & Algorithms
8. C Programming Examples on Data-Structures
9. Java Programming Examples on Numerical Problems & Algorithms
10. Java Programming Examples on Graph Problems & Algorithms
11. C Tutorials
12. Data Structures & Algorithms II – Questions and Answers
13. Python Questions and Answers
14. C Programming Examples on Bitwise Operations
15. C Programming Examples on Graph Problems & Algorithms
16. C Questions and Answers
17. C++ Programming Examples on Data-Structures
18. Java Programming Examples on Data-Structures
19. C# Programming Examples on Conversions
20. Data Structure Questions and Answers

advertisement

Evaluation of a Prefix Expression Multiple


Choice Questions and Answers (MCQs)
« Prev
Next »
This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Evaluation of a Prefix Expression―.

1. How many stacks are required for evaluation of prefix expression?


a) one
b) two
c) three
d) four
View Answer

Answer: b
Explanation: 2 stacks are required for evaluation of prefix expression, one for integers and
one for characters.
advertisement

2. While evaluating a prefix expression, the string is read from?


a) left to right
b) right to left
c) center to right
d) center to left to right
View Answer

Answer: b
Explanation: The string is read from right to left because a prefix string has operands to its
right side.

3. The associativity of an exponentiation operator ^ is right side.


a) True
b) False
View Answer

Answer: a
Explanation: The associativity of ^ is right side while the rest of the operators like +,-,*,/ has
its associativity to its left.

4. How many types of input characters are accepted by this algorithm?


a) one
b) two
c) three
d) four
View Answer

Answer: c
Explanation: Three kinds of input are accepted by this algorithm- numbers, operators and
new line characters.

5. What determines the order of evaluation of a prefix expression?


a) precedence and associativity
b) precedence only
c) associativity only
d) depends on the parser
View Answer

Answer: a
Explanation: Precedence is a very important factor in determining the order of evaluation. If
two operators have the same precedence, associativity comes into action.
advertisement

6. Find the output of the following prefix expression


*+2-2 1/-4 2+-5 3 1
a) 2
b) 12
c) 10
d) 4
View Answer

Answer: a
Explanation: The given prefix expression is evaluated using two stacks and the value is given
by (2+2-1)*(4-2)/(5-3+1)= 2.

7. An error is thrown if the character ‘\n’ is pushed in to the character stack.


a) true
b) false
View Answer

Answer: b
Explanation: The input character ‘\n’ is accepted as a character by the evaluation of
prefix expression algorithm.

8. Using the evaluation of prefix algorithm, evaluate +-9 2 7.


a) 10
b) 4
c) 17
d) 14
View Answer

Answer: d
Explanation: Using the evaluation of prefix algorithm, +-9 2 7 is evaluated as 9-2+7=14.

9. If -*+abcd = 11, find a, b, c, d using evaluation of prefix algorithm.


a) a=2, b=3, c=5, d=4
b) a=1, b=2, c=5, d=4
c) a=5, b=4, c=7,d=5
d) a=1, b=2, c=3, d=4
View Answer

Answer: b
Explanation: The given prefix expression is evaluated as ((1+2)*5)-4 =11 while a=1, b=2,
c=5, d=4.
advertisement
10. In the given C snippet, find the statement number that has error.
//C code to push an element into a stack

1. void push( struct stack *s, int x)


2. {
3. if(s->top==MAX-1)
4. {
5. printf(“stack overflow―);
6. }
7. else
8. {
9. s->items[++s->top]=x;
10. s++;
11. }
12.}

a) 1
b) 9
c) 10
d) 11
View Answer

Answer: c
Explanation: The stack’s top position is incremented twice at the same time. So, when the
next element is pushed, there is unit gap between this element and the previous element.

Sanfoundry Global Education & Learning Series – Data Structure.

advertisement

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Evaluation of an Infix Expression (Not
Parenthesized)
» Next - Evaluation of a Postfix Expression Multiple Choice Questions and Answers
(MCQs)
Categories Data Structure MCQs, DS MCQs 2 - Application of Stacks Post navigation
Data Structure Questions and Answers – Evaluation of an Infix Expression (Not
Parenthesized)
Evaluation of a Postfix Expression Multiple Choice Questions and Answers (MCQs)
advertisement
advertisement

Recommended Posts:

1. C Programming Examples on Strings


2. Java Programming Examples on Collections
3. C Programming Examples using Recursion
4. C Programming Examples on Set & String Problems & Algorithms
5. Java Algorithms, Problems & Programming Examples
6. C Questions and Answers
7. Bioinformatics Questions and Answers
8. C Programming Examples on Graph Problems & Algorithms
9. C++ Programming Examples on Set & String Problems & Algorithms
10. C Programming Examples without using Recursion
11. C Programming Examples on Linked List
12. Python Questions and Answers
13. Python Programming Examples on Linked Lists
14. C++ Programming Examples on Data-Structures
15. Python Programming Examples on Stacks & Queues
16. Java Programming Examples on Data-Structures
17. C Programming Examples on Data-Structures
18. C Programming Examples on Stacks & Queues
19. Data Structure Questions and Answers
20. C# Programming Examples on Data Structures

advertisement

Evaluation of a Postfix Expression Multiple


Choice Questions and Answers (MCQs)
« Prev
Next »

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Evaluation of a Postfix Expression―.

1. What is the other name for a postfix expression?


a) Normal polish Notation
b) Reverse polish Notation
c) Warsaw notation
d) Infix notation
View Answer

Answer: b
Explanation: Reverse polish Notation is the other name for a postfix expression whereas
Polish Notation, Warsaw notation are the other names for a prefix expression.
advertisement

2. Which of the following is an example for a postfix expression?


a) a*b(c+d)
b) abc*+de-+
c) +ab
d) a+b-c
View Answer
Answer: b
Explanation: abc*+de-+ is a postfix expression. +ab is a prefix expression and others are infix
expressions.

3. Reverse Polish Notation is the reverse of a Polish Notation


a) True
b) False
View Answer

Answer: b
Explanation: Reverse Polish Notation is not the reverse of a polish notation. Though both
NPN and RPN read the expression from left to right, they follow different strategies.

4. What is the time complexity of evaluation of postfix expression algorithm?


a) O (N)
b) O (N log N)
c) O (N2)
d) O (M log N)
View Answer

Answer: a
Explanation: The time complexity of evaluation of infix, prefix and postfix expressions is O
(N).

5. In Postfix expressions, the operators come after the operands.


a) True
b) False
View Answer

Answer: a
Explanation: In postfix expressions, the operators follow operands. In prefix expressions, the
operands follow operators.
advertisement

6. Which of these operators have the highest order of precedence?


a) ‘(‘ and ‘)’
b) ‘*’ and ‘/’
c) ‘~’ and ‘^’
d) ‘+’ and ‘-‘
View Answer

Answer: c
Explanation: The highest order of precedence is ~ and ^ followed by ‘*’ ,’ /’,
‘+’ ,’-‘ and then braces ‘(‘ ‘)’.

7. Which of the following is not an application of stack?


a) evaluation of postfix expression
b) conversion of infix to postfix expression
c) balancing symbols
d) line at ticket counter
View Answer

Answer: d
Explanation: Line at ticket counter is an application of queue whereas conversion of infix to
postfix expression, balancing symbols, line at ticket counter are stack applications.

8. While evaluating a postfix expression, when an operator is encountered, what is the correct
operation to be performed?
a) push it directly on to the stack
b) pop 2 operands, evaluate them and push the result on to the stack
c) pop the entire stack
d) ignore the operator
View Answer

Answer: b
Explanation: When an operator is encountered, the first two operands are popped from the
stack, they are evaluated and the result is pushed into the stack.

9. Which of the following statement is incorrect?


a) Postfix operators use value to their right
b) Postfix operators use value to their left
c) Prefix operators use value to their right
d) In postfix expression, operands are followed by operators
View Answer

Answer: a
Explanation: All prefix operators use values to their right and all postfix operators use values
to their left.
advertisement

10. What is the result of the given postfix expression? abc*+ where a=1, b=2, c=3.
a) 4
b) 5
c) 6
d) 7
View Answer

Answer: d
Explanation: The infix expression is a+b*c. Evaluating it, we get 1+2*3=7.

11. What is the result of the following postfix expression?


ab*cd*+ where a=2,b=2,c=3,d=4.
a) 16
b) 12
c) 14
d) 10
View Answer
Answer: a
Explanation: The infix expression is a*b+c*d. Evaluating it, we get, 2*2+3*4=16.

12. Consider the stack


|5|
|4|
|3|
| 2 |.
At this point, ‘*’ is encountered. What has to be done?
a) 5*4=20 is pushed into the stack
b) * is pushed into the stack
c) 2*3=6 is pushed into the stack
d) * is ignored
View Answer

Answer: a
Explanation: When an operator is encountered, the first two operands of the stack are popped,
evaluated and the result is pushed into the stack.

13. Evaluate the postfix expression ab + cd/- where a=5, b=4, c=9, d=3.
a) 23
b) 15
c) 6
d) 10
View Answer

Answer: c
Explanation: The infix expression is (a+b)-c/d. Evaluating it, (5+4)-9/3 gives 6.
advertisement

14. Evaluate and write the result for the following postfix expression
abc*+de*f+g*+ where a=1, b=2, c=3, d=4, e=5, f=6, g=2.
a) 61
b) 59
c) 60
d) 55
View Answer

Answer: b
Explanation: The infix expression is a+b*c+(d*e+f)*g. Evaluating it, 1+2*3+(4*5+6)*2
gives 59.
15. For the given expression tree, write the correct postfix expression.

a) abc*+
b) abc+*
c) ab+c*
d) a+bc*
View Answer

Answer: a
Explanation: Evaluating the given expression tree gives the infix expression a+b*c.
Converting it to postfix, we get, abc*+.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Evaluation of a Prefix Expression Multiple Choice Questions and Answers
(MCQs)
» Next - Infix to Prefix Conversion Multiple Choice Questions and Answers (MCQs)
Categories Data Structure MCQs, DS MCQs 2 - Application of Stacks Post navigation
Evaluation of a Prefix Expression Multiple Choice Questions and Answers (MCQs)
Infix to Prefix Conversion Multiple Choice Questions and Answers (MCQs)
advertisement
advertisement

Recommended Posts:

1. Python Questions and Answers


2. Java Programming Examples on Data-Structures
3. Compilers Questions and Answers
4. C Programming Examples without using Recursion
5. C# Programming Examples on Gaming
6. Simple Java Programs
7. C Programming Examples on Data-Structures
8. C++ Programming Examples on Data-Structures
9. C Tutorials
10. PHP Questions and Answers
11. C++ Programming Examples on Graph Problems & Algorithms
12. Java Programming Examples on Graph Problems & Algorithms
13. C# Programming Examples
14. C Programming Examples on Graph Problems & Algorithms
15. Automata Theory Questions and Answers
16. C# Programming Examples on Data Structures
17. C Programming Examples on Stacks & Queues
18. Python Programming Examples on Stacks & Queues
19. Data Structure Questions and Answers
20. C# Programming Examples on Conversions

advertisement

Infix to Prefix Conversion Multiple Choice


Questions and Answers (MCQs)
« Prev
Next »

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Infix to Prefix Conversion―.

1. What data structure is used when converting an infix notation to prefix notation?
a) Stack
b) Queue
c) B-Trees
d) Linked-list
View Answer

Answer: a
Explanation: First you reverse the given equation and carry out the algorithm of infix to
postfix expression. Here, the data structure used is stacks.
advertisement

2. What would be the Prefix notation for the given equation?

A+(B*C)

a) +A*CB
b) *B+AC
c) +A*BC
d) *A+CB
View Answer

Answer: c
Explanation: Reverse the equation or scan the equation from right to left. Apply the infix-
postfix algorithm. The equation inside the bracket evaluates to CB* and outside the bracket
evaluates to A+ therefore getting CB*A+. Reversing this and we get +A*BC.

3. What would be the Prefix notation for the given equation?

(A*B)+(C*D)

a) +*AB*CD
b) *+AB*CD
c) **AB+CD
d) +*BA*CD
View Answer

Answer: a
Explanation: Reverse the equation or scan the equation from right to left. Apply the infix-
postfix algorithm. The equation inside the brackets evaluate to DC* and BA* respectively
giving us DC*BA*+ in the end. Reversing this we get the +*AB*CD.
advertisement

4. What would be the Prefix notation for the given equation?

A+B*C^D

a) +A*B^CD
b) +A^B*CD
c) *A+B^CD
d) ^A*B+CD
View Answer

Answer: a
Explanation: Reverse the equation or scan the equation from right to left. Apply the infix-
prefix algorithm. The preference order in ascending order are as follows +*^. Operators are
pushed into the stack and popped if its preference is greater than the one which is getting
pushed. In the end all operators are popped. The equation evaluates to DC^B*A+. Reversing
this we get our following answer.

5. Out of the following operators (^, *, +, &, $), the one having highest priority is _________
a) +
b) $
c) ^
d) &
View Answer

Answer: c
Explanation: According to the algorithm (infix-prefix), it follows that the exponentiation will
have the highest priority.

6. Out of the following operators (|, *, +, &, $), the one having lowest priority is ________
a) +
b) $
c) |
d) &
View Answer

Answer: c
Explanation: According to the algorithm (infix-prefix), it follows that the logical OR will
have the lowest priority.

7. What would be the Prefix notation for the given equation?

A^B^C^D

a) ^^^ABCD
b) ^A^B^CD
c) ABCD^^^
d) AB^C^D
View Answer

Answer: a
Explanation: Reverse the equation or scan the equation from right to left. Apply the infix-
prefix algorithm. Here we have to remember that the exponentiation has order of associativity
from right to left. Therefore the stack goes on pushing ^. Therefore resulting in ^^^ABCD.
advertisement

8. What would be the Prefix notation for the given equation?

a+b-c/d&e|f

a) |&-+ab/cdef
b) &|-+ab/cdef
c) |&-ab+/cdef
d) |&-+/abcdef
View Answer

Answer: a
Explanation: Reverse the equation or scan the equation from right to left. Apply the infix-
prefix algorithm. The preference order in ascending order are as follows |&+*/.

9. What would be the Prefix notation for the given equation?

(a+(b/c)*(d^e)-f)

a) -+a*/^bcdef
b) -+a*/bc^def
c) -+a*b/c^def
d) -a+*/bc^def
View Answer

Answer: b
Explanation: Reverse the equation or scan the equation from right to left. Apply the infix-
prefix algorithm. The preference order in ascending order are as follows +*/^. Brackets have
the highest priority. The equations inside the brackets are solved first.

10. What would be the Prefix notation and Postfix notation for the given equation?

advertisement
A+B+C

a) ++ABC and AB+C+


b) AB+C+ and ++ABC
c) ABC++ and AB+C+
d) ABC+ and ABC+
View Answer

Answer: a
Explanation: For prefix notation there is a need of reversing the giving equation and solving
it as a normal infix-postfix question. We see that it doesn’t result as same as normal infix-
postfix conversion.

11. What would be the Prefix notation for the given equation?

a|b&c

a) a|&bc
b) &|abc
c) |a&bc
d) ab&|c
View Answer

Answer: c
Explanation: The order of preference of operators is as follows (descending): & |.
The equation a|b&c will be parenthesized as (a|(b&c)) for evaluation.
Therefore the equation for prefix notation evaluates to |a&bc.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Evaluation of a Postfix Expression Multiple Choice Questions and Answers
(MCQs)
» Next - Infix to Postfix Conversion Multiple Choice Questions and Answers (MCQs)
Categories Data Structure MCQs, DS MCQs 2 - Application of Stacks Post navigation
Evaluation of a Postfix Expression Multiple Choice Questions and Answers (MCQs)
Infix to Postfix Conversion Multiple Choice Questions and Answers (MCQs)
advertisement
advertisement

Recommended Posts:

1. C Programming Examples on Stacks & Queues


2. C++ Programming Examples on Numerical Problems & Algorithms
3. C Programming Examples on Bitwise Operations
4. Simple Java Programs
5. C Programming Examples using Recursion
6. Discrete Mathematics Questions and Answers
7. C Programming Examples on Numerical Problems & Algorithms
8. Java Programming Examples on Numerical Problems & Algorithms
9. C++ Programming Examples on Set & String Problems & Algorithms
10. C Programming Examples on Computational Geometry Problems & Algorithms
11. C# Programming Examples
12. C++ Programming Examples on Computational Geometry Problems & Algorithms
13. Java Programming Examples on Computational Geometry Problems & Algorithms
14. C# Programming Examples on Gaming
15. Numerical Methods Questions and Answers
16. C++ Programming Examples on Graph Problems & Algorithms
17. Java Programming Examples on Graph Problems & Algorithms
18. C Programming Examples on Graph Problems & Algorithms
19. Data Structure Questions and Answers
20. C# Programming Examples on Conversions

advertisement

Infix to Postfix Conversion Multiple Choice


Questions and Answers (MCQs)
« Prev
Next »

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Infix to Postfix Conversion―.

1. When an operand is read, which of the following is done?


a) It is placed on to the output
b) It is placed in operator stack
c) It is ignored
d) Operator stack is emptied
View Answer

Answer: a
Explanation: While converting an infix expression to a postfix expression, when an operand
is read, it is placed on to the output. When an operator is read, it is placed in the operator
stack.
advertisement
2. What should be done when a left parenthesis ‘(‘ is encountered?
a) It is ignored
b) It is placed in the output
c) It is placed in the operator stack
d) The contents of the operator stack is emptied
View Answer

Answer: c
Explanation: When a left parenthesis is encountered, it is placed on to the operator stack.
When the corresponding right parenthesis is encountered, the stack is popped until the left
parenthesis and remove both the parenthesis.

3. Which of the following is an infix expression?


a) (a+b)*(c+d)
b) ab+c*
c) +ab
d) abc+*
View Answer

Answer: a
Explanation: (a+b)*(c+d) is an infix expression. +ab is a prefix expression and ab+c* is a
postfix expression.

4. What is the time complexity of an infix to postfix conversion algorithm?


a) O(N log N)
b) O(N)
c) O(N2)
d) O(M log N)
View Answer

Answer: b
Explanation: The time complexity of an infix to postfix expression conversion algorithm is
mathematically found to be O(N).

5.What is the postfix expression for the corresponding infix expression?

a+b*c+(d*e)

a) abc*+de*+
b) abc+*de*+
c) a+bc*de+*
d) abc*+(de)*+
View Answer

Answer: a
Explanation: Using the infix to postfix expression conversion algorithm, the corresponding
postfix expression is found to be abc*+de*+.
advertisement
6. Parentheses are simply ignored in the conversion of infix to postfix expression.
a) True
b) False
View Answer

Answer: b
Explanation: When a parenthesis is encountered, it is placed on the operator stack. When the
corresponding parenthesis is encountered, the stack is popped until the other parenthesis is
reached and they are discarded.

7. It is easier for a computer to process a postfix expression than an infix expression.


a) True
b) False
View Answer

Answer: a
Explanation: Computers can easily process a postfix expression because a postfix expression
keeps track of precedence of operators.

8. What is the postfix expression for the infix expression?

a-b-c

a) -ab-c
b) ab – c –
c) – -abc
d) -ab-c
View Answer

Answer: b
Explanation: The corresponding postfix expression for the given infix expression is found to
be ab-c- and not abc- -.

9. What is the postfix expression for the following infix expression?

a/b^c-d

a) abc^/d-
b) ab/cd^-
c) ab/^cd-
d) abcd^/-
View Answer

Answer: a
Explanation: Using the infix to postfix conversion algorithm, the corresponding postfix
expression for the infix expression is found to be abc^/d-.
advertisement

10. Which of the following statement is incorrect with respect to infix to postfix conversion
algorithm?
a) operand is always placed in the output
b) operator is placed in the stack when the stack operator has lower precedence
c) parenthesis are included in the output
d) higher and equal priority operators follow the same condition
View Answer

Answer: c
Explanation: Parentheses are not included in the output. They are placed in the operator stack
and then discarded.

11. In infix to postfix conversion algorithm, the operators are associated from?
a) right to left
b) left to right
c) centre to left
d) centre to right
View Answer

Answer: b
Explanation: In infix, prefix and postfix expressions, the operators are associated from left to
right and not right to left.

12. What is the corresponding postfix expression for the given infix expression?

a*(b+c)/d

a) ab*+cd/
b) ab+*cd/
c) abc*+/d
d) abc+*d/
View Answer

Answer: d
Explanation: Using the infix to postfix conversion algorithm, the corresponding postfix
expression is obtained as abc+*d/.

13. What is the corresponding postfix expression for the given infix expression?

a+(b*c(d/e^f)*g)*h)

a) ab*cdef/^*g-h+
b) abcdef^/*g*h*+
c) abcd*^ed/g*-h*+
d) abc*de^fg/*-*h+
View Answer

Answer: b
Explanation: Using the infix to postfix expression conversion algorithm using stack, the
corresponding postfix expression is found to be abcdef^/*g*h*+.
advertisement
14. What is the correct postfix expression for the following expression?

a+b*(c^d-e)^(f+g*h)-i

a) abc^de-fg+*^*+i-
b) abcde^-fg*+*^h*+i-
c) abcd^e-fgh*+^*+i-
d) ab^-dc*+ef^gh*+i-
View Answer

Answer: c
Explanation: The postfix expression for the given infix expression is found to be abcd^e-
fgh*+^*+i- when we use infix to postfix conversion algorithm.

15. From the given Expression tree, identify the correct postfix expression from the list of
options.

a) ab*cd*+
b) ab*cd-+
c) abcd-*+
d) ab*+cd-
View Answer

Answer: b
Explanation: From the given expression tree, the infix expression is found to be (a*b)+(c-d).
Converting it to postfix, we get, ab*cd-+.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Infix to Prefix Conversion Multiple Choice Questions and Answers (MCQs)
» Next - Prefix to Infix Conversion Multiple Choice Questions and Answers (MCQs)
Categories Data Structure MCQs, DS MCQs 2 - Application of Stacks Post navigation
Infix to Prefix Conversion Multiple Choice Questions and Answers (MCQs)
Prefix to Infix Conversion Multiple Choice Questions and Answers (MCQs)
advertisement
advertisement

Recommended Posts:

1. C Programming Examples without using Recursion


2. C# Programming Examples on Exceptions
3. C Tutorials
4. Discrete Mathematics Questions and Answers
5. C Programming Examples on Data-Structures
6. C Programming Examples
7. Automata Theory Questions and Answers
8. C++ Algorithms, Problems & Programming Examples
9. C Programming Examples using Recursion
10. C# Programming Examples on Data Structures
11. C++ Programming Examples on Data-Structures
12. Java Algorithms, Problems & Programming Examples
13. C++ Programming Examples on Graph Problems & Algorithms
14. Java Programming Examples on Data-Structures
15. Java Programming Examples on Graph Problems & Algorithms
16. C Programming Examples on Stacks & Queues
17. Python Programming Examples on Stacks & Queues
18. C Programming Examples on Graph Problems & Algorithms
19. C# Programming Examples on Conversions
20. Data Structure Questions and Answers

advertisement

Prefix to Infix Conversion Multiple Choice


Questions and Answers (MCQs)
« Prev
Next »

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Prefix to Infix Conversion―.

1. What would be the solution to the given prefix notation?

advertisement
- + 5 / 10 5 5

a) 2
b) 5
c) 10
d) 7
View Answer
Answer: a
Explanation: The infix notation of the given prefix notation is 5+10/5-5 which gives us 2 as
our answer.

2. What would be the solution to the given prefix notation?

/ / / / 16 4 2 1

a) 1
b) 4
c) 2
d) 8
View Answer

Answer: a
Explanation: The infix notation to the given prefix notation is 16/4/2/1 which gives us 1 as
our answer. The infix notation is got from the prefix notation by traversing the equation from
the right.
advertisement

3. What would be the solution to the given prefix notation?

+ 9 * 3 / 8 4

a) 14
b) 15
c) 18
d) 12
View Answer

Answer: b
Explanation: The infix notation for the given prefix notation is (9+(3*(8/4))) which solves to
15. So 15 is correct answer.

4. What would be the solution to the given prefix notation?

advertisement
- + 1 2 * 3 / 6 2

a) 6
b) -6
c) 3
d) -3
View Answer

Answer: b
Explanation: The infix notation for the given prefix notation is (1+2)-3*(6/2). The result of
the given equation is -6.

5. What would be the solution to the given prefix notation?


- * 1 5 / * / 6 3 6 2

a) 1
b) 0
c) -1
d) -2
View Answer

Answer: c
Explanation: The infix notation for the given prefix notation is (1*5)-(6/3)*6/2. The result of
the equation is -1.
advertisement

6. What would be the solution to the given prefix notation?

* / + 1 2 / 4 2 + 3 5

a) 12
b) 7.5
c) 9
d) 13.5
View Answer

Answer: a
Explanation: The infix notation of the given prefix notation is ((1+2)/(4/2))*(3+5) which
solves to (3/2)*8 which by solving gives us 12.

7. Given a prefix and a postfix notation what are the difference between them?
a) The postfix equation is solved starting from the left whereas the prefix notation is solved
from the right
b) The postfix equation is solved starting from the right whereas the prefix notation is solved
from the left
c) Both equations are solved starting from the same side(right)
d) Both equations are solved starting from the same side(left)
View Answer

Answer: a
Explanation: The postfix notation is solved starting from left but whereas the prefix notation
is reversed after creating them, therefore it’s solved starting from right.

8. When converting the prefix notation into an infix notation, the first step to be followed is
________
a) Reverse the equation
b) Push the equation to the stack
c) Push the equation onto the queue
d) Push the equation to the stack or queue
View Answer
Answer: a
Explanation: The steps that are followed are: the equation is reversed, pushed onto a stack,
popped one by one and solved. Therefore the first step is reversing the equation.

9. The time complexity of converting a prefix notation to infix notation is _________


a) O(n) where n is the length of the equation
b) O(n) where n is number of operands
c) O(1)
d) O(logn) where n is length of the equation
View Answer

Answer: a
Explanation: The processes that are involved are reversing the equation (O(n)), pushing them
all onto the stack(O(n)), and popping them one by one and solving them (O(n)). Hence the
answer is O(n) where n is the length of the equation.

10. Given two processes (conversion of postfix equation to infix notation and conversion of
prefix notation to infix notation), which of the following is easier to implement?
a) Both are easy to implement
b) Conversion of postfix equation to infix equation is harder than converting a prefix notation
to infix notation
c) Conversion of postfix equation to infix equation is easier than converting a prefix notation
to infix notation
d) Insufficient data
View Answer

Answer: c
Explanation: As the conversion of prefix notation to infix notation involves reversing the
equation, the latter is harder to implement than postfix to infix process.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Infix to Postfix Conversion Multiple Choice Questions and Answers (MCQs)
» Next - Postfix to Infix Conversion Multiple Choice Questions and Answers (MCQs)
Categories Data Structure MCQs, DS MCQs 2 - Application of Stacks Post navigation
Infix to Postfix Conversion Multiple Choice Questions and Answers (MCQs)
Postfix to Infix Conversion Multiple Choice Questions and Answers (MCQs)
advertisement
advertisement

Recommended Posts:
1. Java Programming Examples on Collections
2. Java Algorithms, Problems & Programming Examples
3. C# Programming Examples on Gaming
4. C Programming Examples
5. Automata Theory Questions and Answers
6. Discrete Mathematics Questions and Answers
7. C# Programming Examples
8. C++ Programming Examples on Graph Problems & Algorithms
9. Python Programming Examples on Linked Lists
10. C++ Programming Examples on STL
11. Java Programming Examples on Graph Problems & Algorithms
12. C Programming Examples on Graph Problems & Algorithms
13. C++ Programming Examples on Data-Structures
14. Java Programming Examples on Data-Structures
15. C Programming Examples on Data-Structures
16. C# Programming Examples on Data Structures
17. Python Programming Examples on Stacks & Queues
18. C Programming Examples on Stacks & Queues
19. C# Programming Examples on Conversions
20. Data Structure Questions and Answers

advertisement

Postfix to Infix Conversion Multiple Choice


Questions and Answers (MCQs)
« Prev
Next »

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Postfix to Infix Conversion―.

1. Which of the following data structure is used to convert postfix expression to infix
expression?
a) Stack
b) Queue
c) Linked List
d) Heap
View Answer

Answer: a
Explanation: To convert the postfix expression into infix expression we need stack. We need
stack to maintain the intermediate infix expressions. We use stack to hold operands.
advertisement

2. The postfix expression abc+de/*- is equivalent to which of the following infix expression?
a) abc+-de*/
b) (a+b)-d/e*c
c) a-(b+c)*(d/e)
d) abc+*-(d/e)
View Answer

Answer: c
Explanation: Given postfix expression : abc+de/*-
infix ⇒ a(b+c)(d/e)*-
⇒ a(b+c)*(d/e)-
⇒ a-(b+c)*(d/e)
Hence, correct choice is a-(b+c)*(d/e).

3. The equivalent infix expression and value for the postfix form 1 2 + 3 * 4 5 * – will be
___________
a) 1 + 2 * 3 – 4 * 5 and -13
b) (2 + 1) * (3 – 4) * 5 and 13
c) 1 + 2 * (3 – 4) * 5 and -11
d) (1 + 2) * 3 – (4 * 5) and -11
View Answer

Answer: d
Explanation: Given postfix expression : 1 2 + 3 * 4 5 * –
⇒ (1 + 2) 3 * 4 5 * –
⇒ ((1 + 2) * 3) 4 5 * –
⇒ ((1 + 2) * 3) (4 * 5) –
⇒ ((1 + 2) * 3) – (4 * 5)
So, the equivalent infix expression is (1 + 2) * 3 – (4 * 5) and it’s value is -11.

4. What is the value of the postfix expression 2 3 + 4 5 6 – – *


a) 19
b) 21
c) -4
d) 25
View Answer

Answer: d
Explanation: Given postfix expression : 2 3 + 4 5 6 – – *
infix ⇒ (2 + 3)4 (5 – 6) – *
⇒ (2 + 3)*4 – (5 – 6)
Hence, value = (2 + 3) * (4 – (5 – 6)) = 5 *(4 – (-1)) = 5*5 = 25.
advertisement

5. The prefix expression of the postfix expression AB+CD-* is __________


a) (A+B)*(C-D)
b) +AB*-CD
c) A+*BCD-
d) *+AB-CD
View Answer

Answer: d
Explanation: To convert from postfix to prefix, we first convert it to infix and then to prefix.
postfix : AB+CD-*
infix ⇒ (A+B) * (C-D)
So, prefix ⇒ +AB*-CD,
⇒ *+AB-CD.
Therefore, correct choice is *+AB-CD.

6. Consider the postfix expression 4 5 6 a b 7 8 a c, where a, b, c are operators. Operator a has


higher precedence over operators b and c. Operators b and c are right associative. Then,
equivalent infix expression is
a) 4 a 5 6 b 7 8 a c
b) 4 a 5 c 6 b 7 a 8
c) 4 b 5 a 6 c 7 a 8
d) 4 a 5 b 6 c 7 a 8
View Answer

Answer: c
Explanation: Given postfix expression: 4 5 6 a b 7 8 a c
infix ⇒ 4 (5 a 6) b (7 a 8) c
⇒ (4 b (5 a 6)) (7 a 8) c
⇒ (4 b (5 a 6)) c (7 a 8)
So, the required infix expression is 4 b 5 a 6 c 7 a 8.

7. To convert the postfix expression into the infix expression we use stack and scan the
postfix expression from left to right.
a) True
b) False
View Answer

Answer: a
Explanation: Stack is used to postfix expression to infix expression. And to convert we
follow the following steps: (i) Scan the expression from left to right. (ii) If operand is found,
push it on stack.(iii) If operator is found, the two operands are popped and the combined infix
expression is formed and pushed onto the stack.
advertisement

8. Which of the following is valid reverse polish expression?


a) a op b
b) op a b
c) a b op
d) both op a b and a b op
View Answer

Answer: c
Explanation: The postfix expression is also known as the reverse polish expression. In postfix
expressions, the operators come after the operands. So, the correct expression is a b op and
hence a b op is correct.

9. The result of the postfix expression 5 3 * 9 + 6 / 8 4 / + is _____________


a) 8
b) 6
c) 10
d) 9
View Answer

Answer: b
Explanation: Given postfix expression: 5 3 * 9 + 6 / 8 4 / +
Result = 5 3 * 9 + 6 / 8 4 / +
= (5 * 3) 9 + 6 / (8 / 4) +
= ((5 * 3) + 9) / 6 + ( 8 / 4) = ( 24 / 6) + 2 = 4 + 2 = 6.

Sanfoundry Global Education & Learning Series – Data Structure.

advertisement

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Prefix to Infix Conversion Multiple Choice Questions and Answers (MCQs)
» Next - Data Structure Questions and Answers – Towers of Hanoi
Categories Data Structure MCQs, DS MCQs 2 - Application of Stacks Post navigation
Prefix to Infix Conversion Multiple Choice Questions and Answers (MCQs)
Data Structure Questions and Answers – Towers of Hanoi
advertisement
advertisement

Recommended Posts:

1. Simple Java Programs


2. Discrete Mathematics Questions and Answers
3. Simple C Programs
4. Compilers Questions and Answers
5. C Programming Examples on Linked List
6. C# Programming Examples on Gaming
7. Python Programming Examples on Linked Lists
8. C Programming Examples using Recursion
9. C# Programming Examples on Data Structures
10. C Programming Examples on Data-Structures
11. C++ Programming Examples on Graph Problems & Algorithms
12. Python Programming Examples on Stacks & Queues
13. Java Programming Examples on Graph Problems & Algorithms
14. C++ Programming Examples on Data-Structures
15. C Programming Examples without using Recursion
16. Java Programming Examples on Data-Structures
17. C Programming Examples on Graph Problems & Algorithms
18. C Programming Examples on Stacks & Queues
19. C# Programming Examples on Conversions
20. Data Structure Questions and Answers

advertisement

Data Structure Questions and Answers –


Towers of Hanoi
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Towers of Hanoi―.

1. The optimal data structure used to solve Tower of Hanoi is _________


a) Tree
b) Heap
c) Priority queue
d) Stack
View Answer

Answer: d
Explanation: The Tower of Hanoi involves moving of disks ‘stacked’ at one peg to
another peg with respect to the size constraint. It is conveniently done using stacks and
priority queues. Stack approach is widely used to solve Tower of Hanoi.
advertisement

2. Select the appropriate code for the recursive Tower of Hanoi problem.(n is the number of
disks)
a)

public void solve(int n, String start, String auxiliary, String end)


{
if (n == 1)
{
System.out.println(start + " -> " + end);
}
else
{
solve(n - 1, start, end, auxiliary);
System.out.println(start + " -> " + end);
solve(n - 1, auxiliary, start, end);
}
}

b)

public void solve(int n, String start, String auxiliary, String end)


{
if (n == 1)
{
System.out.println(start + " -> " + end);
}
else
{
solve(n - 1, auxiliary, start, end);
System.out.println(start + " -> " + end);
}
}

c)

public void solve(int n, String start, String auxiliary, String end)


{
if (n == 1)
{
System.out.println(start + " -> " + end);
}
else
{
System.out.println(start + " -> " + end);
solve(n - 1, auxiliary, start, end);
}
}

d)

advertisement
public void solve(int n, String start, String auxiliary, String end)
{
if (n == 1)
{
System.out.println(start + " -> " + end);
}
else
{
solve(n - 1, start, end, auxiliary);
System.out.println(start + " -> " + end);
}
}
View Answer
Answer: a
Explanation: First transfer all the diska to the auxiliary and then to the end peg, this is
achieved by making auxiliary peg as the end peg in the first recursive call, in the second
recursive call, the auxiliary becomes the start peg from where the disks are transferred to the
end peg.

3. Which among the following is not a palindrome?


a) Madam
b) Dad
c) Malayalam
d) Maadam
View Answer

Answer: d
Explanation: A palindrome is a string that reads the same forward and backward, Madam,
Dad and Malayalam are palindromes where as Maadam is not a palindrome.
4. Which data structure can be used to test a palindrome?
a) Tree
b) Heap
c) Stack
d) Priority queue
View Answer

Answer: c
Explanation: Stack is a convenient option as it involves pushing and popping of characters.

5. Select the appropriate code which tests for a palindrome.


a)

public static void main(String[] args)


{
System.out.print("Enter any string:");
Scanner in=new Scanner(System.in);
String input = in.nextLine();
Stack<Character> stk = new Stack<Character>();
for (int i = 0; i < input.length(); i++)
{
stk.push(input.charAt(i));
}
String reverse = "";
while (!stk.isEmpty())
{
reverse = reverse + stk.pop();
}
if (input.equals(reverse))
System.out.println("palindrome");
else
System.out.println("not a palindrome");
}

b)

advertisement
public static void main(String[] args)
{
System.out.print("Enter any string:");
Scanner in=new Scanner(System.in);
String input = in.nextLine();
Stack<Character> stk = new Stack<Character>();
for (int i = 0; i < input.length(); i++)
{
stk.push(input.charAt(i));
}
String reverse = "";
while (!stk.isEmpty())
{
reverse = reverse + stk.peek();
}
if (input.equals(reverse))
System.out.println("palindrome");
else
System.out.println("not a palindrome");
}
c)

public static void main(String[] args)


{
System.out.print("Enter any string:");
Scanner in=new Scanner(System.in);
String input = in.nextLine();
Stack<Character> stk = new Stack<Character>();
for (int i = 0; i < input.length(); i++)
{
stk.push(input.charAt(i));
}
String reverse = "";
while (!stk.isEmpty())
{
reverse = reverse + stk.pop();
stk.pop();
}
if (input.equals(reverse))
System.out.println("palindrome");
else
System.out.println("not a palindrome");
}

d)

public static void main(String[] args)


{
System.out.print("Enter any string:");
Scanner in=new Scanner(System.in);
String input = in.nextLine();
Stack<Character> stk = new Stack<Character>();
for (int i = 0; i < input.length(); i++)
{
stk.push(input.charAt(i));
}
String reverse = "";
while (!stk.isEmpty())
{
reverse = reverse + stk.pop();
stk.pop();
}
if (!input.equals(reverse))
System.out.println("palindrome");
else
System.out.println("not a palindrome");
}
View Answer
Answer: a
Explanation: Push all the characters in the input string to a stack, now pop them and append
to a new string which is checked for equality with the original string.

6. What is the number of moves required to solve Tower of Hanoi problem for k disks?
a) 2k – 1
b) 2k + 1
c) 2k + 1
d) 2k – 1
View Answer

Answer: d
Explanation: Tracing of the moves in the above ToH problem will prove this result, instead
you can simply add a count for each recursive call to check the number of moves.

7. Select the appropriate code which reverses a word.


a)

public String reverse(String input)


{
for (int i = 0; i < input.length(); i++)
{
stk.push(input.charAt(i));
}
String rev = "";
while (!stk.isEmpty())
{
rev = rev + stk.peek();
}
return rev;
}

b)

advertisement
public String reverse(String input)
{
for (int i = 0; i < input.length(); i++)
{
stk.push(input.charAt(i));
}
String rev = "";
while (!stk.isEmpty())
{
rev = rev + stk.pop();
}
return rev;
}

c)

public String reverse(String input)


{
for (int i = 0; i < input.length(); i++)
{
stk.push(input.charAt(i));
}
String rev = "";
while (!stk.isEmpty())
{
rev = rev + stk.pop();
}
}

d)
public String reverse(String input)
{
for (int i = 0; i < input.length(); i++)
{
stk.push(input.charAt(i));
}
String rev = "";
while (!stk.isEmpty())
{
rev = rev + stk.pop();
stk.pop();
}
return rev;
}
View Answer
Answer: b
Explanation: Although, it is possible to reverse the string without using stack, it is done by
looping through the string from the end character by character.
In Java, it is also possible to use the StringBuilder and StringBuffer classes which have a
built-in method ‘reverse’.
Note its similarity to PalindromeTest.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Postfix to Infix Conversion Multiple Choice Questions and Answers (MCQs)
» Next - Data Structure Questions and Answers – Reverse a Word using Stack
Categories Data Structure MCQs, DS MCQs 2 - Application of Stacks Post navigation
Postfix to Infix Conversion Multiple Choice Questions and Answers (MCQs)
Data Structure Questions and Answers – Reverse a Word using Stack
advertisement
advertisement

Recommended Posts:

1. Java Programming Examples on Set & String Problems & Algorithms


2. C Programming Examples on Set & String Problems & Algorithms
3. Python Programming Examples
4. C# Programming Examples on Strings
5. Data Structures & Algorithms II – Questions and Answers
6. C Programming Examples
7. C Programming Examples on Bitwise Operations
8. C Programming Examples without using Recursion
9. Java Programming Examples on String Handling
10. C++ Programming Examples on Data-Structures
11. C Programming Examples on Linked List
12. Java Programming Examples on Data-Structures
13. Python Programming Examples on Linked Lists
14. C Programming Examples on Strings
15. C Programming Examples on Data-Structures
16. C Programming Examples using Recursion
17. Data Structure Questions and Answers
18. C# Programming Examples on Data Structures
19. C Programming Examples on Stacks & Queues
20. Python Programming Examples on Stacks & Queues

advertisement

Data Structure Questions and Answers –


Reverse a Word using Stack
« Prev
Next »

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Reverse a Word using Stack―.

1. Reversing a word using stack can be used to find if the given word is a palindrome or not.
a) True
b) False
View Answer

Answer: a
Explanation: This application of stack can also be used to find if the given word is a
palindrome because, if the reversed is same as that of the original word, the given word is a
palindrome.
advertisement

2. Which is the most appropriate data structure for reversing a word?


a) queue
b) stack
c) tree
d) graph
View Answer

Answer: b
Explanation: Stack is the most appropriate data structure for reversing a word because stack
follows LIFO principle.

3. Operations required for reversing a word or a string using stack are push() and pop().
a) True
b) False
View Answer
Answer: a
Explanation: Push operation inserts a character into the stack and pop operation pops the top
of the stack.

4. What is the time complexity of reversing a word using stack algorithm?


a) O (N log N)
b) O (N2)
c) O (N)
d) O (M log N)
View Answer

Answer: c
Explanation: The time complexity of reversing a stack is mathematically found to be O (N)
where N is the input.

5. What will be the word obtained if the word “abbcabb― is reversed using a stack?
a) bbabbca
b) abbcabb
c) bbacbba
d) bbacabb
View Answer

Answer: c
Explanation: The string “abbcabb― is pushed on to the stack. If the characters are
popped one by one, the word obtained will be bbacbba.
advertisement

6. How many stacks are required for reversing a word algorithm?


a) one
b) two
c) three
d) four
View Answer

Answer: a
Explanation: Only 1 stack is required for reversing a word using stack. In that stack, push and
pop operations are carried out.

7. What will be result if the given stack is popped?

a) pat
b) tap
c) atp
d) apt
View Answer
Answer: b
Explanation: The word ‘pat’ is pushed on to the stack. When the characters of the stack
are popped one by one, the word ‘tap’ is obtained.

8. What will be output if the following sequence of operations are executed?


Push(a,s);
Push(b,s);
Pop(b);
Push(c,s);
a) abc
b) b
c) ac
d) acb
View Answer

Answer: b
Explanation. The element ‘b’ is popped out of the stack. Hence the output of the
following sequence of operations will be ‘b’.

9. What are the set of functions that are to be executed to get the following output?
cat
a) push(c, s); push(a, s); push(t, s);
pop(s); pop(s); pop(s);
b) push(c,s); pop(s); push(a,s); pop(s);push(t,s);pop(s);
c) pop(c ); pop(a); pop(t);
d) push(c,s); push(a,s); pop(t);
View Answer

Answer: b
Explanation: During push operation, the characters ‘c’, ’a’, ’t’ are
inserted into the stack and popped immediately after push.

10. How will your stack look like if the word ‘java’ is pushed?

a)

b)
c)

d)
View Answer

Answer: a
Explanation: When a character is pushed, it stays on the top of the stack. While popping, the
word occurs in reverse order since stack follows LIFO principle.
advertisement

11. Find the error (if any) in the following code snippet for pop operation.

void pop() //removing an element from a stack


{
printf(“%s―, stack[top++]);
}

a) run time error


b) compile time error
c) pop operation is performed, but top moved in wrong direction
d) pop operation is performed properly
View Answer

Answer: c
Explanation: The statement printf(“%s―, stack[top++]) does a pop, but top gets
incremented which is not correct. The statement stack[top++] should be replaced with
stack[top–] in order to pop an operand and maintain stack properly.

12. What will be the output of the following program?

main()
{
char str[]="san foundry";
int len = strlen(str);
int i;

for(i=0;i<len;i++)
push(str[i]); // pushes an element into stack

for(i=0;i<len;i++)
pop(); //pops an element from the stack
}
a) sanfoundry
b) san foundry
c) yrdnuof nas
d) foundry nas
View Answer

Answer: c
Explanation: First, the string ‘san foundry’ is pushed one by one into the stack.
When it is popped, the output will be as ‘yrdnuof nas’.
advertisement

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Towers of Hanoi
» Next - Balanced Parenthesis Multiple Choice Questions and Answers (MCQs)
Categories Data Structure MCQs, DS MCQs 2 - Application of Stacks Post navigation
Data Structure Questions and Answers – Towers of Hanoi
Balanced Parenthesis Multiple Choice Questions and Answers (MCQs)
advertisement
advertisement

Recommended Posts:

1. C Programming Examples on Bitwise Operations


2. Data Science Questions and Answers
3. Python Programming Examples
4. Data Structures & Algorithms II – Questions and Answers
5. C Programming Examples on Arrays
6. Java Programming Examples on File Handling
7. C Programming Examples on Linked List
8. Java Programming Examples on String Handling
9. C# Programming Examples on Strings
10. C++ Programming Examples on STL
11. C Programming Examples on Strings
12. Python Programming Examples on Linked Lists
13. C Programming Examples
14. C++ Programming Examples on Data-Structures
15. Java Programming Examples on Data-Structures
16. C Programming Examples on Data-Structures
17. Python Programming Examples on Stacks & Queues
18. C Programming Examples on Stacks & Queues
19. C# Programming Examples on Data Structures
20. Data Structure Questions and Answers

advertisement

Balanced Parenthesis Multiple Choice


Questions and Answers (MCQs)
« Prev
Next »

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Balanced Parenthesis―.

1. What is the time complexity of balancing parentheses algorithm?


a) O (N)
b) O (N log N)
c) O (M log N)
d) O (N2)
View Answer

Answer: a
Explanation: The time complexity of balancing parentheses algorithm is mathematically
found to be O (N).
advertisement

2. Which application of stack is used to ensure that the pair of parentheses is properly nested?
a) Balancing symbols
b) Reversing a stack
c) Conversion of an infix to postfix expression
d) Conversion of an infix to prefix expression
View Answer

Answer: a
Explanation: Balancing symbols application ensures that the pair of parentheses are properly
nested while reversing stack reverses a stack.

3. In balancing parentheses algorithm, the string is read from?


a) right to left
b) left to right
c) center to right
d) center to left
View Answer

Answer: b
Explanation: Any string is read by the compiler from left to right and not from right to left.

4. Which is the most appropriate data structure for applying balancing of symbols algorithm?
a) stack
b) queue
c) tree
d) graph
View Answer

Answer: a
Explanation: Stack is the most appropriate data structure for balancing symbols algorithm
because stack follows LIFO principle (Last In First Out).

5. Which of the following does the balancing symbols algorithm include?


a) balancing double quotes
b) balancing single quotes
c) balancing operators and brackets
d) balancing parentheses, brackets and braces
View Answer

Answer: d
Explanation: The balancing symbols algorithm using stack only includes balancing
parentheses, brackets and braces and not any other symbols.
advertisement

6. Which of the following statement is incorrect with respect to balancing symbols algorithm?
a) {[()]}
b) ([ )]
c) {( )}
d) { [ ] }
View Answer

Answer: b
Explanation: ([ )] is incorrect because’)’ occurs before the corresponding ‘]’ is
encountered.

7. What should be done when an opening parentheses is read in a balancing symbols


algorithm?
a) push it on to the stack
b) throw an error
c) ignore the parentheses
d) pop the stack
View Answer

Answer: a
Explanation: When an opening bracket/braces/parentheses is encountered, it is pushed on to
the stack. When the corresponding end bracket/braces/parentheses is not found, throw an
error.

8. When the corresponding end bracket/braces/parentheses is not found, what happens?


a) The stack is popped
b) Ignore the parentheses
c) An error is reported
d) It is treated as an exception
View Answer

Answer: c
Explanation: When the corresponding end bracket/braces/parentheses is not found, throw an
error since they don’t match.

9. If the corresponding end bracket/braces/parentheses is encountered, which of the following


is done?
a) push it on to the stack
b) pop the stack
c) throw an error
d) treated as an exception
View Answer

Answer: b
Explanation: When the corresponding end bracket/braces/parentheses is encountered, the
stack is popped. When an opening bracket/braces/parentheses is encountered, it is pushed on
to the stack.
advertisement

10. An error is reported when the stack is not empty at the end.
a) True
b) False
View Answer

Answer: a
Explanation: When the stack contains elements at the end, it means that the given string of
parentheses is not balanced.

11. Is the given statement ((A+B) + [C-D]] valid with respect to balancing of symbols?
a) True
b) False
View Answer

Answer: b
Explanation: The given statement is invalid with respect to balancing of symbols because the
last bracket does not correspond to the opening braces.

12. How many passes does the balancing symbols algorithm makes through the input?
a) one
b) two
c) three
d) four
View Answer

Answer: a
Explanation: The balancing symbols algorithm makes only one pass through the input since it
is linear.
13. Which of the following statement is invalid with respect to balancing symbols?
a) [(A+B) + (C-D)]
b) [{A+B}-{C-[D+E]}]
c) ((A+B) + (C+D)
d) {(A+B) + [C+D]}
View Answer

Answer: c
Explanation: ((A+B) + (C+D) is invalid because the last close brace is not found in the
statement.
advertisement

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Reverse a Word using Stack
» Next - Data Structure Questions and Answers – Bit Array
Categories Data Structure MCQs, DS MCQs 2 - Application of Stacks Post navigation
Data Structure Questions and Answers – Reverse a Word using Stack
Data Structure Questions and Answers – Bit Array
advertisement
advertisement

Recommended Posts:

1. Data Structures & Algorithms II – Questions and Answers


2. C++ Programming Examples on Set & String Problems & Algorithms
3. C Programming Examples
4. Compilers Questions and Answers
5. Automata Theory Questions and Answers
6. Ruby Programming Questions and Answers
7. C Programming Examples on Linked List
8. C++ Programming Examples on Graph Problems & Algorithms
9. C Programming Examples on Graph Problems & Algorithms
10. Python Programming Examples on Linked Lists
11. C++ Programming Examples on STL
12. C++ Algorithms, Problems & Programming Examples
13. Java Algorithms, Problems & Programming Examples
14. C++ Programming Examples on Data-Structures
15. Data Structure Questions and Answers
16. Java Programming Examples on Data-Structures
17. C Programming Examples on Data-Structures
18. C# Programming Examples on Data Structures
19. Python Programming Examples on Stacks & Queues
20. C Programming Examples on Stacks & Queues

advertisement

Data Structure Questions and Answers –


Bit Array
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on “Bit
Array―.

1. What is a bit array?


a) Data structure for representing arrays of records
b) Data structure that compactly stores bits
c) An array in which most of the elements have the same value
d) Array in which elements are not present in continuous locations
View Answer

Answer: b
Explanation: It compactly stores bits and exploits bit-level parallelism.
advertisement

2. Which of the following bitwise operations will you use to set a particular bit to 1?
a) OR
b) AND
c) XOR
d) NOR
View Answer

Answer: a
Explanation: 1 OR 1 = 1, 0 OR 1 = 1, any bit OR’ed with 1 gives 1.

3. Which of the following bitwise operations will you use to set a particular bit to 0?
a) OR
b) AND
c) XOR
d) NAND
View Answer

Answer: b
Explanation: 1 AND 0 = 0, 0 AND 0 = 0, any bit AND with 0 gives 0.

4. Which of the following bitwise operations will you use to toggle a particular bit?
a) OR
b) AND
c) XOR
d) NOT
View Answer

Answer: c
Explanation: 1 XOR 1 = 0, 0 XOR 1 = 1, note that NOT inverts all the bits, while XOR
toggles only a specified bit.

5. Which of the following is not an advantage of bit array?


a) Exploit bit level parallelism
b) Maximal use of data cache
c) Can be stored and manipulated in the register set for long periods of time
d) Accessing Individual Elements is easy
View Answer

Answer: d
Explanation: Individual Elements are difficult to access and can’t be accessed in some
programming languages. If random access is more common than sequential access, they have
to be compressed to byte/word array. Exploit Bit parallelism, Maximal use of data cache and
storage and manipulation for longer time in register set are all advantages of bit array.
advertisement

6. Which of the following is not a disadvantage of bit array?


a) Without compression, they might become sparse
b) Accessing individual bits is expensive
c) Compressing bit array to byte/word array, the machine also has to support byte/word
addressing
d) Storing and Manipulating in the register set for long periods of time
View Answer

Answer: d
Explanation: Bit arrays allow small arrays of bits to be stored and manipulated in the register
set for long periods of time with no memory accesses because of their ability to exploit bit-
level parallelism, limit memory access, and maximally use the data cache, they often
outperform many other data structures on practical data sets. This is an advantage of bit array.
The rest are all disadvantages of bit array.

7. Which of the following is/are not applications of bit arrays?


a) Used by the Linux kernel
b) For the allocation of memory pages
c) Bloom filter
d) Implementation of Vectors and Matrices
View Answer

Answer: d
Explanation: Normal Arrays are used to implement vectors and matrices. Bit arrays have no
prominent role. Remaining all are applications of Bit Arrays.

8. Which class in Java can be used to represent bit array?


a) BitSet
b) BitVector
c) BitArray
d) BitStream
View Answer

Answer: a
Explanation: The BitSet class creates a special type of array that can hold bit values.

9. Which of the following bitwise operator will you use to invert all the bits in a bit array?
a) OR
b) NOT
c) XOR
d) NAND
View Answer

Answer: b
Explanation: NOT operation is used to invert all the bits stored in a bit array.
Eg: NOT (10110010) = 01001101.
advertisement

10. Run-Length encoding is used to compress data in bit arrays.


a) True
b) False
View Answer

Answer: a
Explanation: A bit array stores the combinations of bit 0 and bit 1. Each bit in the bit array is
independent. Run Length encoding is a data compression technique in which data are stored
as single value and number of times that value repeated in the data. This compression reduces
the space complexity in arrays. Bit arrays without compression require more space. Thus, we
will use Run-Length encoding in most of the cases to compress data in bit arrays.

11. What does Hamming weight/population count mean in Bit arrays?


a) Finding the number of 1 bit in a bit array
b) Finding the number of 0 bit in a bit array
c) Finding the sum of bits in a bit array
d) Finding the average number of 1’s and 0’s in bit arrays
View Answer

Answer: a
Explanation: Hamming/ population count involves finding the number of 1’s in the bit
array. Population count is used in data compression.

12. Bit fields and Bit arrays are same.


a) True
b) False
View Answer

Answer: b
Explanation: Bit field contains the number of adjacent computer locations used to store the
sequence of bits to address a bit or groups of bits. Bit array is an array that stores
combinations of bit 0 and bit 1. Thus, bit fields and Bit arrays are different.

13. Which one of the following operations returns the first occurrence of bit 1 in bit arrays?
a) Find First Zero
b) Find First One
c) Counting lead Zeroes
d) Counting lead One
View Answer

Answer: b
Explanation: Find First One operation returns the first occurrence of bit 1 in the bit array.
Find First Zero operation returns the first occurrence of bit 0 in the bit array. If the most
significant bit in bit array is 1, then count lead zeroes operation returns the number of zeroes
present before the most significant bit. If the most significant bit in bit array is 0, then the
count lead one returns the number of ones present before the most significant bit.
advertisement

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Balanced Parenthesis Multiple Choice Questions and Answers (MCQs)
» Next - Data Structure Questions and Answers – Dynamic Array
Categories Data Structure MCQs, DS MCQs 3 - Types of Arrays Post navigation
Balanced Parenthesis Multiple Choice Questions and Answers (MCQs)
Data Structure Questions and Answers – Dynamic Array
advertisement
advertisement

Recommended Posts:

1. C Programming Examples on Linked List


2. C++ Algorithms, Problems & Programming Examples
3. C Tutorials
4. C Programming Examples on Strings
5. Java Programming Examples on String Handling
6. Python Programming Examples on Trees
7. C# Programming Examples on Data Structures
8. C Programming Examples on Stacks & Queues
9. C# Programming Examples on Arrays
10. Data Structures & Algorithms II – Questions and Answers
11. Data Science Questions and Answers
12. Home
13. C Programming Examples on Arrays
14. C Programming Examples
15. Java Programming Examples on Arrays
16. C Programming Examples on Data-Structures
17. C++ Programming Examples on Data-Structures
18. Java Programming Examples on Data-Structures
19. C Programming Examples on Bitwise Operations
20. Data Structure Questions and Answers

advertisement

Data Structure Questions and Answers –


Dynamic Array
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Dynamic Array―.

1. What is a dynamic array?


a) A variable size data structure
b) An array which is created at runtime
c) The memory to the array is allocated at runtime
d) An array which is reallocated everytime whenever new elements have to be added
View Answer

Answer: a
Explanation: It is a varying-size list data structure that allows items to be added or removed,
it may use a fixed sized array at the back end.
advertisement

2. What is meant by physical size in a dynamic array?


a) The size allocated to elements
b) The size extended to add new elements
c) The size of the underlying array at the back-end
d) The size visible to users
View Answer

Answer: c
Explanation: Physical size, also called array capacity is the size of the underlying array,
which is the maximum size without relocation of data.

3. The number of items used by the dynamic array contents is its __________
a) Physical size
b) Capacity
c) Logical size
d) Random size
View Answer
Answer: c
Explanation: The number of items used by the dynamic array contents is called logical size.
Physical size is the size of the underlying array, which is the maximum size without
reallocation of data.

4. How will you implement dynamic arrays in Java?


a) Set
b) Map
c) HashMap
d) List
View Answer

Answer: d
Explanation: ArrayList is used to implement dynamic arrays in Java.

5. Which of the following is the correct syntax to declare an ArrayList in Java?


a) ArrayList al = new ArrayList();
b) ArrayList al = new ArrayList[];
c) ArrayList al() = new ArrayList();
d) ArrayList al[] = new ArrayList[];
View Answer

Answer: a
Explanation: This is a non-generic way of creating an ArrayList.
advertisement

6. Array is divided into two parts in ____________


a) Hashed Array Tree
b) Geometric Array
c) Bounded-size dynamic array
d) Sparse Array
View Answer

Answer: c
Explanation: The first part stores the items of the dynamic array and the second part is
reserved for new allocations.

7. Which of the following is a disadvantage of dynamic arrays?


a) Locality of reference
b) Data cache utilization
c) Random access
d) Memory leak
View Answer

Answer: d
Explanation: Dynamic arrays share the advantage of arrays, added to it is the dynamic
addition of elements to the array. Memory can be leaked if it is not handled properly during
allocation and deallocation. It is a disadvantage.
8. What is the time complexity for inserting/deleting at the beginning of the array?
a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn)
View Answer

Answer: b
Explanation: All the other elements will have to be moved, hence O(n).

9. Dynamic arrays overcome the limit of static arrays.


a) True
b) False
View Answer

Answer: a
Explanation: Static arrays have fixed capacity. The capacity must be specified during
memory allocation. Dynamic arrays don’t require to specify their capacity during
memory allocation. Dynamic arrays have fixed physical size at backend and its capacity
increases if required. Thus, Dynamic arrays overcome the limit of static arrays.
advertisement

10. The size of the dynamic array is deallocated if the array size is less than _________% of
the backend physical size.
a) 30
b) 40
c) 10
d) 20
View Answer

Answer: a
Explanation: The size of the dynamic array is decreased/deallocated if the actual size of the
array is less than 30% of the backend physical size. This is used to avoid memory wastage.

11. Both Dynamic array and Dynamically memory allocated array are same.
a) True
b) False
View Answer

Answer: b
Explanation: Physical size of a Dynamic array is fixed with a larger value. Dynamically
memory allocated arrays are arrays whose memory is allocated at run time rather than at
compile time. Dynamically memory allocated arrays don’t have physical size at the
backend. Thus, Dynamic arrays and Dynamically memory allocated arrays are different.

12. In which of the following cases dynamic arrays are not preferred?
a) If the size of the array is unknown
b) If the size of the array changes after few iterations
c) If the memory reallocation takes more time i.e. expensive
d) If the array holds less number of elements
View Answer

Answer: d
Explanation: Dynamic arrays are preferred when the size of the array is unknown during
memory allocation or the size changes after few iterations or the memory reallocation is
expensive. If array holds less number of elements, the physical size is reduced and reduction
takes more time. In that case, we can use normal arrays instead of dynamic arrays.

13. The growth factor of ArrayList in Java is _______


a) 1
b) 1.5
c) 2
d) 0
View Answer

Answer: b
Explanation: The growth factor of dynamic arrays (Array List) in Java is 3/2.
The new array capacity is calculated as new_array_size = (old_array_size*3)/2+1.
advertisement

14. In special case, the time complexity of inserting/deleting elements at the end of dynamic
array is __________
a) O (n)
b) O (n1/2)
c) O (log n)
d) O (1)
View Answer

Answer: a
Explanation: In general, the time complexity of inserting or deleting elements at the end of
dynamic array is O (1). Elements are added at reserved space of dynamic array. If this
reserved space is exceeded, then the physical size of the dynamic array is reallocated and
every element is copied from original array. This will take O(n) time to add new element at
the end of the array.

15. Which of the following arrays are used in the implementation of list data type in python?
a) Bit array
b) Dynamic arrays
c) Sparse arrays
d) Parallel arrays
View Answer

Answer: b
Explanation: Dynamic arrays are used in the implementation of list data type in python.
Sparse arrays are used in the implementation of sparse matrix in Numpy module. All bit array
operations are implemented in bitarray module.

Sanfoundry Global Education & Learning Series – Data Structure.


To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Bit Array
» Next - Data Structure Questions and Answers – Parallel Array
Categories Data Structure MCQs, DS MCQs 3 - Types of Arrays Post navigation
Data Structure Questions and Answers – Bit Array
Data Structure Questions and Answers – Parallel Array
advertisement
advertisement

Recommended Posts:

1. C Programming Examples on Searching and Sorting


2. C Programming Examples on Linked List
3. C Tutorials
4. Home
5. Java Programming Examples on Combinatorial Problems & Algorithms
6. Data Structures & Algorithms II – Questions and Answers
7. C Programming Examples on Arrays
8. Java Programming Examples
9. C# Programming Examples on Arrays
10. Dynamic Programming Problems and Solutions
11. Java Programming Examples on Utility Classes
12. Java Programming Examples on Arrays
13. Java Programming Examples on Collection API
14. C++ Programming Examples on Data-Structures
15. Java Programming Examples on Collections
16. C Programming Examples on Data-Structures
17. C Programming Examples on Stacks & Queues
18. C# Programming Examples on Data Structures
19. Java Programming Examples on Data-Structures
20. Data Structure Questions and Answers

advertisement

Data Structure Questions and Answers –


Parallel Array
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Parallel Array―.
1. What are parallel arrays?
a) Arrays of the same size
b) Arrays allocated one after the other
c) Arrays of the same number of elements
d) Arrays allocated dynamically
View Answer

Answer: c
Explanation: Different arrays can be of different data types but should contain same number
of elements. Elements at corresponding index belong to a record.
advertisement

2. Which of the following can be called a parallel array implementation?


a)

firstName = ['Joe','Bob','Frank','Hans']
lastName = ['Smith','Seger','Sinatra','Schultze']
heightInCM = [169,158,201,199]

for i in xrange(len(firstName)):
print "Name:",firstName[i], lastName[i]
print "Height in CM:,",heightInCM[i]

b)

firstName = ['Joe','Bob','Frank','Hans']
lastName = ['Smith','Seger']
heightInCM = [169,158]

for i in xrange(len(firstName)):
print "Name:",firstName[i], lastName[i]
print "Height in CM:,",heightInCM[i]

c)

advertisement
firstName = ['Joe','Bob']
lastName = ['Smith','Seger','Sinatra','Schultze']
heightInCM = [169,158]

for i in xrange(len(firstName)):
print "Name:",firstName[i], lastName[i]
print "Height in CM:,",heightInCM[i]

d)

firstName = ['Joe','Bob']
lastName = ['Smith','Seger' ,'Schultze']
heightInCM = [169,158]

for i in xrange(len(firstName)):
print "Name:",firstName[i], lastName[i]
print "Height in CM:,",heightInCM[i]
View Answer
Answer: a
Explanation: All the arrays must have equal length, that is, contain same number of elements.

3. Which of the following is a disadvantage of parallel array over the traditional arrays?
a) When a language does not support records, parallel arrays can be used
b) Increased locality of reference
c) Ideal cache behaviour
d) Insertion and Deletion becomes tedious
View Answer

Answer: d
Explanation: Insertion and deletion of elements require to move every element from their
initial positions. This will become tedious. For Record collection, locality of reference and
Ideal Cache behaviour we can use parallel arrays.
advertisement

4. Which of the following is an advantage of parallel arrays?


a) Poor locality of reference for non-sequential access
b) Very little direct language support
c) Expensive to shrink or grow
d) Increased Locality of Reference
View Answer

Answer: d
Explanation: Elements in the parallel array are accessed sequentially as one arrays holds the
keys whereas other holds the values. This sequential access generally improves Locality of
Reference. It is an advantage.

5. What is a sorted array?


a) Arrays sorted in numerical order
b) Arrays sorted in alphabetical order
c) Elements of the array are placed at equally spaced addresses in the memory
d) All of the mentioned
View Answer

Answer: d
Explanation: The array can be sorted in any way, numerical, alphabetical or any other way
but the elements are placed at equally spaced addresses.

6. To search for an element in a sorted array, which searching technique can be used?
a) Linear Search
b) Jump Search
c) Binary Search
d) Fibonacci Search
View Answer
Answer: c
Explanation: Since the array is sorted, binary search is preferred as its time complexity is
O(logn).
advertisement

7. Which of the following is not an application of sorted array?


a) Commercial computing
b) Priority Scheduling
c) Discrete Mathematics
d) Hash Tables
View Answer

Answer: d
Explanation: Sorted arrays have widespread applications as all commercial computing
involves large data which is very useful if it is sorted. It makes best use of locality of
reference and data cache. Linked lists are used in Hash Tables not arrays.

8. What is the worst case time complexity of inserting an element into the sorted array?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
View Answer

Answer: c
Explanation: In the worst case, an element must added to the front of the array, which means
that rest of the elements have to be shifted, hence the worst case time complexity becomes
O(n).

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Dynamic Array
» Next - Data Structure Questions and Answers – Sparse Array
Categories Data Structure MCQs, DS MCQs 3 - Types of Arrays Post navigation
Data Structure Questions and Answers – Dynamic Array
Data Structure Questions and Answers – Sparse Array
advertisement
advertisement

Recommended Posts:

1. C Programming Examples
2. C Programming Examples using Recursion
3. C# Programming Examples on Sorting
4. C Programming Examples on Stacks & Queues
5. C Programming Examples on Trees
6. Data Structures & Algorithms II – Questions and Answers
7. Python Programming Examples on Searching and Sorting
8. Python Programming Examples on Trees
9. C++ Programming Examples on Combinatorial Problems & Algorithms
10. C Programming Examples on Searching and Sorting
11. C Programming Examples on Data-Structures
12. C# Programming Examples on Data Structures
13. C Programming Examples on Combinatorial Problems & Algorithms
14. Java Programming Examples on Combinatorial Problems & Algorithms
15. C# Programming Examples on Arrays
16. Java Programming Examples on Arrays
17. Java Programming Examples on Data-Structures
18. C++ Programming Examples on Data-Structures
19. C Programming Examples on Arrays
20. Data Structure Questions and Answers

advertisement

Data Structure Questions and Answers –


Sparse Array
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Sparse Array―.

1. What is a sparse array?


a) Data structure for representing arrays of records
b) Data structure that compactly stores bits
c) An array in which most of the elements have the same value
d) An array in which memory is allocated in run time
View Answer

Answer: c
Explanation: They are set to a default value, usually 0 or null.
advertisement

2. When do you use a sparse array?


a) When there are unique elements in the array
b) When the array has more occurrence of zero elements
c) When the data type of elements differ
d) When elements are sorted
View Answer
Answer: b
Explanation: It need not necessarily be zero, it could be any default value, usually zero or
null.

3. What is the difference between a normal(naive) array and a sparse array?


a) Sparse array can hold more elements than a normal array
b) Sparse array is memory efficient
c) Sparse array is dynamic
d) A naive array is more efficient
View Answer

Answer: b
Explanation: A naive implementation allocates space for the entire size of the array, whereas
a sparse array(linked list implementation) allocates space only for the non-default values.

4. Choose the code which performs the store operation in a sparse array.(Linked list
implementation)
a)

public void store(int index, Object val)


{
List cur = this;
List prev = null;

List node = new List(index);


node.val = val;

while (cur != null && cur.index < index)


{
prev = cur;
cur = cur.next;
}

if (cur == null)
{
prev.next = node;
} else
{
if (cur.index == index)
{
System.out.println("DUPLICATE");
return;
}
prev.next = node;
node.next = cur;
}
return;
}

b)

public void store(int index, Object val)


{
List cur = this;
List prev = null;
List node = new List(index);
node.val = val;

while (prev != null && prev.index < index)


{
prev = cur;
cur = cur.next;
}

if (cur == null)
{
prev.next = node;
} else
{
if (cur.index == index)
{
System.out.println("DUPLICATE");
return;
}
prev.next = node;
node.next = cur;
}
return;
}

c)

advertisement
public void store(int index, Object val)
{
List cur = this;
List prev = null;

List node = new List(index);


node.val = val;

while (cur != null && cur.index < index)


{
cur = cur.next;
prev = cur;
}

if (cur == null)
{
prev.next = node;
} else
{
if (cur.index == index)
{
System.out.println("DUPLICATE");
return;
}
prev.next = node;
node.next = cur;
}
return;
}

d)
public void store(int index, Object val)
{
List cur = this;
List prev = null;

List node = new List(index);


node.val = val;

while (cur != null && prev.index < index)


{
cur = cur.next;
prev = cur;
}

if (cur == null)
{
prev.next = node;
}
else
{
if (cur.index == index)
{
System.out.println("DUPLICATE");
return;
}
prev.next = cur;
node.next = node;
}
return;
}
View Answer
Answer: a
Explanation: Create a new node and traverse through the list until you reach the correct
position, check for duplicate and nullity of the list and then insert the node.

5. Which of the following performs the fetch operation?


a)

public Object fetch(int index)


{
List cur = this.next;
Object val = null;
while (cur != null && cur.index != index)
{
cur = cur.next;
}
if (cur != null)
{
val = cur.val;
} else
{
val = null;
}
return val;
}
b)

advertisement
public Object fetch(int index)
{
List cur = this;
Object val = null;
while (cur != null && cur.index != index)
{
cur = cur.next;
}
if (cur != null)
{
val = cur.val;
} else
{
val = null;
}
return val;
}

c)

public Object fetch(int index)


{
List cur = this;
Object val = null;
while (cur != null && cur.index != index)
{
cur = cur.index;
}
if (cur != null)
{
val = cur.val;
} else
{
val = null;
}
return val;
}

d)

public Object fetch(int index)


{
List cur = this.next;
Object val = null;
while (cur != null && cur.index != index)
{
cur = cur.index;
}
if (cur != null)
{
val = cur.val;
}
else
{
val = null;
}
return val;
}
View Answer
Answer: b
Explanation: You travers through the array until the end is reached or the index is found and
return the element at that index, null otherwise.

6. Choose the appropriate code that counts the number of non-zero(non-null) elements in the
sparse array.
a)

public int count()


{
int count = 0;
for (List cur = this.next; (cur != null); cur = cur.next)
{
count++;
}
return count;
}

b)

advertisement
public int count()
{
int count = 0;
for (List cur = this; (cur != null); cur = cur.next)
{
count++;
}
return count;
}

c)

public int count()


{
int count = 1;
for (List cur = this.next; (cur != null); cur = cur.next)
{
count++;
}
return count;
}

d)

public int count()


{
int count = 1;
for (List cur = this.next; (cur != null); cur = cur.next.next)
{
count++;
}
return count;
}
View Answer
Answer: a
Explanation: A simple ‘for loop’ to count the non-null elements.

7. Suppose the contents of an array A are, A = {1, null, null, null, null, 10};
What would be the size of the array considering it as a normal array and a sparse array?
a) 6 and 6
b) 6 and 2
c) 2 and 6
d) 2 and 2
View Answer

Answer: b
Explanation: A normal array considers null also as an element, but in the sparse array only a
non-zero or a non-null element is considered.

8. What is sparsity of a matrix?


a) The fraction of zero elements over the total number of elements
b) The fraction of non-zero elements over the total number of elements
c) The fraction of total number of elements over the zero elements
d) The fraction of total number of elements over the non-zero elements
View Answer

Answer: a
Explanation: Sparsity of a matrix is the fraction of number of zero elements over the total
number of zero elements.

9. How would you store an element in a sparse matrix?


a)

public void store(int row_index, int col_index, Object val)


{
if (row_index < 0 || row_index > N)
{
System.out.println("row index out of bounds");
return;
}
if (col_index < 0 || col+index > N)
{
System.out.println("column index out of bounds");
return;
}
sparse_array[row_index].store(col_index, val);
}

b)

public void store(int row_index, int col_index, Object val)


{
if (row_index < 0 || row_index > N)
{
System.out.println("column index out of bounds");
return;
}
if (col_index < 0 || col+index > N)
{
System.out.println("row index out of bounds");
return;
}
sparse_array[row_index].store(col_index, val);
}

c)

public void store(int row_index, int col_index, Object val)


{
if (row_index < 0 && row_index > N)
{
System.out.println("row index out of bounds");
return;
}
if (col_index < 0 && col+index > N)
{
System.out.println("column index out of bounds");
return;
}
sparse_array[row_index].store(col_index, val);
}

d)

public void store(int row_index, int col_index, Object val)


{
if (row_index < 0 && row_index > N)
{
System.out.println("column index out of bounds");
return;
}
if (col_index < 0 && col+index > N)
{
System.out.println("row index out of bounds");
return;
}
sparse_array[row_index].store(col_index, val);
}
View Answer
Answer: a
Explanation: Each row in a sparse matrix acts as a sparse array, hence this row with the
specified col_index is the array and the specified position where the element is stored.

10. What is the functionality of the following piece of code?

public Object function(int row_index, int col_index)


{
if (row_index < 0 || col_index > N)
{
System.out.println("column index out of bounds");
return;
}
return (sparse_array[row_index].fetch(col_index));
}

a) Store the element in the specified position


b) Get the element from the specified position
c) Alter the element in the specified position
d) Removes the element from the specified position
View Answer

Answer: b
Explanation: The fetch method of SparseArray class is called , the row specified by
row_index makes it an array and the col_index denotes the specified position.

11. Which of the following is the disadvantage of sparse matrices over normal matrices?
a) Size
b) Speed
c) Easily compressible
d) Algorithm complexity
View Answer

Answer: d
Explanation: As the sparse matrix contains zeroes we will compute operations only on non
zero values. This increases the complexity of algorithm as we need to identify index of zero
elements first and during computation we should not take those index. It is a disadvantage.
Sparse matrix is easily compressible by not storing the zero/null elements, they require less
memory space, also only the non zero elements have to be computed, hence computational
speed increases.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Parallel Array
» Next - Suffix Array Multiple Choice Questions and Answers (MCQs)
Categories Data Structure MCQs, DS MCQs 3 - Types of Arrays Post navigation
Data Structure Questions and Answers – Parallel Array
Suffix Array Multiple Choice Questions and Answers (MCQs)
advertisement
advertisement

Recommended Posts:
1. Java Programming Examples on String Handling
2. C Programming Examples without using Recursion
3. Java Programming Examples on Utility Classes
4. Java Programming Examples
5. Data Science Questions and Answers
6. C Programming Examples using Recursion
7. C Programming Examples on Matrix
8. Python Programming Examples on Trees
9. C# Programming Examples on Data Structures
10. C Programming Examples on Trees
11. C Programming Examples on Linked List
12. C Programming Examples on Arrays
13. C# Programming Examples on Arrays
14. Python Programming Examples on Linked Lists
15. Java Programming Examples on Arrays
16. Java Programming Examples on Collections
17. C Programming Examples on Data-Structures
18. Java Programming Examples on Data-Structures
19. C++ Programming Examples on Data-Structures
20. Data Structure Questions and Answers

advertisement

Suffix Array Multiple Choice Questions


and Answers (MCQs)
« Prev
Next »

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Suffix Array―.

1. Which of the following is false?


a) Suffix array is always sorted
b) Suffix array is used in string matching problems
c) Suffix array is always unsorted
d) Suffix array contains all the suffixes of the given string
View Answer

Answer: c
Explanation: Suffix array is always sorted as it contains all the suffixes of a string in sorted
order. Suffix arrays are used to solve problems related to string, like string matching
problems.
advertisement

2. Suffix array of the string “statistics― is ____________


a) 2 8 7 4 9 0 5 1 6 3
b) 2 7 4 9 8 0 5 1 6 3
c) 2 4 9 0 5 7 8 1 6 3
d) 2 8 7 0 5 1 6 9 4 3
View Answer

Answer: a
Explanation: The suffix array of the string statistics will be:
2 atistics
8 cs
7 ics
4 istics
9s
0 statistics
5 stics
1 tatistics
6 tics
3 tistics
In Suffix array, we only store the indices of suffixes. So, correct option is 2 8 7 4 9 0 5 1 6 3.

3. Suffix array can be created by performing __________ traversal of a suffix tree.


a) breadth-first
b) level order
c) depth-first
d) either breadth-first or level order
View Answer

Answer: c
Explanation: A suffix tree is a trie, which contains all the suffixes of the given string as their
keys and positions in the string as their values. So, we can construct a suffix array by
performing the depth-first traversal of a suffix tree.

4. Suffix array is space efficient and faster than the suffix tree.
a) True
b) Fasle
View Answer

Answer: b
Explanation: Suffix arrays are more space efficient than the suffix trees as they just store the
original string and an array of integer. But working with suffix tree is faster than that of the
suffix array.

5. If comparison based sorting algorithm is used construct the suffix array, then what will be
time required to construct the suffix array?
a) O(nlogn)
b) O(n2)
c) O(n2logn)
d) O(n2) + O(logn)
View Answer

Answer: c
Explanation: On average comparison based sorting algorithms require O(nlogn) comparisons.
But comparing a suffix takes O(n). So, overall time to construct the suffix array will be
O(nlogn) * O(n) = O(n2logn).
advertisement

6. What will be the suffix array of the string “engineering―?


a) 2 3 8 4 9 1 7 5 0 6 10
b) 5 0 6 1 4 9 1 7 0 2 3 8
c) 5 0 6 10 2 4 9 1 7 3 8
d) 5 0 6 10 2 3 8 4 9 1 7
View Answer

Answer: d
Explanation: Correct choice is : 5 0 6 10 2 3 8 4 9 1 7.
Because the suffix array formed will be: 5 eering 0 engineering 6 ering 10 g 2 gineering 3
ineering 8 ing 4 neering 9 ng 1 ngineering 7 ring.

7. LCP array and ______ is used to construct suffix tree.


a) Hash tree
b) Hash trie
c) Suffix array
d) Balanced tree
View Answer

Answer: c
Explanation: Suffix tree can be created using an LCP array and a suffix array. If we are given
a string of length (n + 1) and its suffix array and LCP array, we can construct the suffix tree
in linear time i.e in O(n) time.

8. What is the time required to locate the occurrences of a pattern P of length m in a string of
length n using suffix array?
a) O(nm)
b) O(n2)
c) O(mnlogn)
d) O(mlogn)
View Answer

Answer: d
Explanation: Suffix arrays are used to find the occurrences of a pattern in a string. Pattern of
length m will require m characters to compare, so using suffix array we can find occurrences
of a pattern in the string of length n in O(mlogn) time.

9. Suffix array can be created in O(nlogn) time.


a) True
b) False
View Answer

Answer: a
Explanation: Suffix array can be constructed in O(n2logn) time using sorting algorithms but it
is possible to build the suffix array in O(nlogn) time using prefix doubling.
advertisement
10. Which of the following is/are advantages suffix array one suffix tree?
I. Lesser space requirement
II. Improved cache locality
III. Easy construction in linear time
a) Only I
b) All I, II and III
c) Only I and III
d) Only II and III
View Answer

Answer: b
Explanation: Advantages of the suffix array over suffix tree are : (i) Lesser space requirement
(ii) Improved cache locality and (iii) Simple algorithms to construct suffix arrays in linear
time.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Sparse Array
» Next - Data Structure Questions and Answers – Matrix
Categories Data Structure MCQs, DS MCQs 3 - Types of Arrays Post navigation
Data Structure Questions and Answers – Sparse Array
Data Structure Questions and Answers – Matrix
advertisement
advertisement

Recommended Posts:

1. Java Algorithms, Problems & Programming Examples


2. Java Programming Examples on String Handling
3. C Programming Examples using Recursion
4. C Algorithms, Problems & Programming Examples
5. C Programming Examples on Set & String Problems & Algorithms
6. C Programming Examples on Trees
7. C Programming Examples on Graph Problems & Algorithms
8. Java Programming Examples on Graph Problems & Algorithms
9. C Programming Examples on Combinatorial Problems & Algorithms
10. Java Programming Examples on Combinatorial Problems & Algorithms
11. C Programming Examples on Stacks & Queues
12. Python Programming Examples on Trees
13. C Programming Examples
14. Java Programming Examples on Data-Structures
15. C++ Programming Examples on Combinatorial Problems & Algorithms
16. C# Programming Examples on Arrays
17. C Programming Examples on Data-Structures
18. C++ Programming Examples on Data-Structures
19. C++ Algorithms, Problems & Programming Examples
20. Data Structure Questions and Answers

advertisement

Data Structure Questions and Answers –


Matrix
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Matrix―.

1. What is the order of a matrix?


a) number of rows X number of columns
b) number of columns X number of rows
c) number of rows X number of rows
d) number of columns X number of columns
View Answer

Answer: a
Explanation: The order of the matrix is the number of rows X number of columns.
advertisement

2. Which of the following property does not hold for matrix multiplication?
a) Associative
b) Distributive
c) Commutative
d) Additive Inverse
View Answer

Answer: c
Explanation: In matrix multiplication, AB != BA

3. How do you allocate a matrix using a single pointer in C?(r and c are the number of rows
and columns respectively)
a) int *arr = malloc(r * c * sizeof(int));
b) int *arr = (int *)malloc(r * c * sizeof(int));
c) int *arr = (int *)malloc(r + c * sizeof(int));
d) int *arr = (int *)malloc(r * c * sizeof(arr));
View Answer

Answer: b
Explanation: Total number of elements in the matrix will be r*c
4. Select the code snippet which performs matrix multiplication.(a and b are the two given
matrices, resultant marix is c)
a)

for (int i = 0; i < n; i++)


{
for (int j = 0; j < n; j++)
{
for (int k = 0; k < n; k++)
{
c[i][j] = c[i][j] + a[i][k] * b[k][j];
}
}
}

b)

advertisement
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
for (int k = 0; k < n; k++)
{
c[i][j] = c[i][j] * a[i][k] * b[k][j];
}
}
}

c)

for (int i = 0; i < n; i++)


{
for (int j = 0; j < n; j++)
{
for (int k = 0; k < n; k++)
{
c[i][j] = c[i][j] + a[i][k] + b[k][j];
}
}
}

d)

advertisement
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
for (int k = 0; k < n; k++)
{
c[i][j] = c[i][j] + a[i][j] + b[k][j];
}
}
}
View Answer
Answer: a
Explanation: The corresponding elements from the row and column are multiplied and a
cumulative sum is formed.

5. What does the following piece of code do?

for(int i = 0; i < row; i++)


{
for(int j = 0; j < column; j++)
{
if(i == j)
sum = sum + (array[i][j]);
}
}
System.out.println(sum);

a) Normal of a matrix
b) Trace of a matrix
c) Square of a matrix
d) Transpose of a matrix
View Answer

Answer: b
Explanation: Trace of a matrix is the sum of the principal diagonal elements.

6. If row-major order is used, how is the following matrix stored in memory?


abc
def
ghi
a) ihgfedcba
b) abcdefghi
c) cfibehadg
d) adgbehcfi
View Answer

Answer: b
Explanation: It starts with the first element and continues in the same row until the end of
row is reached and then proceeds with the next row. C follows row-major order.
advertisement

7. If column-major order is used, how is the following matrix stored in memory?


abc
def
ghi
a) ihgfedcba
b) abcdefghi
c) cfibehadg
d) adgbehcfi
View Answer
Answer: d
Explanation: It starts with the first element and continues in the same column until the end of
column is reached and then proceeds with the next column. Fortran follows column-major
order.

8. Which of the following don’t use matrices?


a) In solving linear equations
b) Image processing
c) Graph theory
d) Sorting numbers
View Answer

Answer: d
Explanation: Numbers uses arrays(1-D) for sorting not matrices(2-D arrays). Solving linear
equations is a separate field in Mathematics involving matrices, Image processing stores the
pixels in the form of matrices, and the graphs are represented with the help of matrices to
indicate the nodes and edges.

9. Which of the following is an advantage of matrices?


a) Internal complexity
b) Searching through a matrix is complex
c) Not space efficient
d) Graph Plotting
View Answer

Answer: d
Explanation: Adjacency and Incidence Matrices are used to store vertices and edges of a
graph. It is an advantage to plot graphs easily using matrices. But Time complexity of a
matrix is O(n2) and sometimes the internal organization becomes tedious. They are all
disadvantages of matrices.

10. Matrix A when multiplied with Matrix C gives the Identity matrix I, what is C?
a) Identity matrix
b) Inverse of A
c) Square of A
d) Transpose of A
View Answer

Answer: b
Explanation: Any square matrix when multiplied with its inverse gives the identity matrix.
Note that non square matrices are not invertible.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!
Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Suffix Array Multiple Choice Questions and Answers (MCQs)
» Next - Sparse Matrix Multiple Choice Questions and Answers (MCQs)
Categories Data Structure MCQs, DS MCQs 3 - Types of Arrays Post navigation
Suffix Array Multiple Choice Questions and Answers (MCQs)
Sparse Matrix Multiple Choice Questions and Answers (MCQs)
advertisement
advertisement

Recommended Posts:

1. Distillation Design Questions and Answers


2. C Programming Examples on Combinatorial Problems & Algorithms
3. Engineering Mathematics Questions and Answers
4. Structural Analysis Questions and Answers
5. C Programming Examples
6. Java Programming Examples on Numerical Problems & Algorithms
7. C# Programming Examples on Data Structures
8. C Programming Examples without using Recursion
9. Data Science Questions and Answers
10. C++ Programming Examples on Numerical Problems & Algorithms
11. Numerical Methods Questions and Answers
12. C Programming Examples on Numerical Problems & Algorithms
13. C Programming Examples on Data-Structures
14. C++ Programming Examples on Data-Structures
15. Java Programming Examples on Data-Structures
16. Data Structures & Algorithms II – Questions and Answers
17. Java Programming Examples on Arrays
18. Data Structure Questions and Answers
19. C++ Program to Find if a Matrix is Orthogonal
20. Java Program to Determine if a given Matrix is a Sparse Matrix

advertisement

Sparse Matrix Multiple Choice Questions


and Answers (MCQs)
« Prev
Next »

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Sparse Matrix―.

1. Which matrix has most of the elements (not all) as Zero?


a) Identity Matrix
b) Unit Matrix
c) Sparse Matrix
d) Zero Matrix
View Answer

Answer: c
Explanation: Sparse Matrix is a matrix in which most of the elements are Zero. Identity
Matrix is a matrix in which all principle diagonal elements are 1 and rest of the elements are
Zero. Unit Matrix is also called Identity Matrix. Zero Matrix is a matrix in which all the
elements are Zero.
advertisement

2. What is the relation between Sparsity and Density of a matrix?


a) Sparsity = 1 – Density
b) Sparsity = 1 + Density
c) Sparsity = Density*Total number of elements
d) Sparsity = Density/Total number of elements
View Answer

Answer: a
Explanation: Sparsity of a matrix is equal to 1 minus Density of the matrix. The Sparsity of
matrix is defined as the total number of Zero Valued elements divided total number of
elements.

3. Who coined the term Sparse Matrix?


a) Harry Markowitz
b) James Sylvester
c) Chris Messina
d) Arthur Cayley
View Answer

Answer: a
Explanation: Harry Markowitz coined the term Sparse Matrix. James Sylvester coined the
term Matrix. Chris Messina coined the term Hashtag and Arthur Cayley developed the
algebraic aspects of a matrix.

4. Is O(n) the Worst case Time Complexity for addition of two Sparse Matrix?
a) True
b) False
View Answer

Answer: a
Explanation: In Addition, the matrix is traversed linearly, hence it has the time complexity of
O(n) where n is the number of non-zero elements in the largest matrix amongst two.
advertisement

5. The matrix contains m rows and n columns. The matrix is called Sparse Matrix if
________
a) Total number of Zero elements > (m*n)/2
b) Total number of Zero elements = m + n
c) Total number of Zero elements = m/n
d) Total number of Zero elements = m-n
View Answer

Answer: a
Explanation: For matrix to be Sparse Matrix, it should contain Zero elements more than the
non-zero elements. Total elements of the given matrix is m*n. So if Total number of Zero
elements > (m*n)/2, then the matrix is called Sparse Matrix.

6. Which of the following is not the method to represent Sparse Matrix?


a) Dictionary of Keys
b) Linked List
c) Array
d) Heap
View Answer

Answer: d
Explanation: Heap is not used to represent Sparse Matrix while in Dictionary, rows and
column numbers are used as Keys and values as Matrix entries, Linked List is used with each
node of Four fields (Row, Column, Value, Next Node) (2D array is used to represent the
Sparse Matrix with three fields (Row, Column, Value).

7. Is Sparse Matrix also known as Dense Matrix?


a) True
b) False
View Answer

Answer: b
Explanation: Sparse Matrix is a matrix with most of the elements as Zero elements while
Dense Matrix is a matrix with most of the elements as Non-Zero element.
advertisement

8. Which one of the following is a Special Sparse Matrix?


a) Band Matrix
b) Skew Matrix
c) Null matrix
d) Unit matrix
View Answer

Answer: a
Explanation: A band matrix is a sparse matrix whose non zero elements are bounded to a
diagonal band, comprising the main diagonal and zero or more diagonals on either side.

9. In what way the Symmetry Sparse Matrix can be stored efficiently?


a) Heap
b) Binary tree
c) Hash table
d) Adjacency List
View Answer
Answer: b
Explanation: Since Symmetry Sparse Matrix arises as the adjacency matrix of the undirected
graph. Hence it can be stored efficiently as an adjacency list.

Sanfoundry Global Education & Learning Series – Data Structure.

advertisement

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Matrix
» Next - Count Inversion Multiple Choice Questions and Answers (MCQs)
Categories Data Structure MCQs, DS MCQs 3 - Types of Arrays Post navigation
Data Structure Questions and Answers – Matrix
Count Inversion Multiple Choice Questions and Answers (MCQs)
advertisement
advertisement

Recommended Posts:

1. Python Programming Examples on Trees


2. C Programming Examples on Trees
3. Java Programming Examples
4. C Programming Examples
5. Java Programming Examples on Numerical Problems & Algorithms
6. Java Algorithms, Problems & Programming Examples
7. C Programming Examples on Searching and Sorting
8. C++ Programming Examples on Numerical Problems & Algorithms
9. C Programming Examples on Numerical Problems & Algorithms
10. C++ Programming Examples on Combinatorial Problems & Algorithms
11. C# Programming Examples on Sorting
12. Java Programming Examples on Combinatorial Problems & Algorithms
13. C Programming Examples on Combinatorial Problems & Algorithms
14. Java Programming Examples on Arrays
15. C Programming Examples on Data-Structures
16. Data Structure Questions and Answers
17. C++ Programming Examples on Data-Structures
18. Java Programming Examples on Data-Structures
19. C# Programming Examples on Matrix
20. C Programming Examples on Matrix

advertisement
Count Inversion Multiple Choice Questions
and Answers (MCQs)
« Prev
Next »

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Count Inversion―.

1. What does the number of inversions in an array indicate?


a) mean value of the elements of array
b) measure of how close or far the array is from being sorted
c) the distribution of values in the array
d) median value of the elements of array
View Answer

Answer: b
Explanation: The number of inversions in an array indicates how close or far the array is from
being completely sorted. The array is sorted if the number of inversions are 0.
advertisement

2. How many inversions does a sorted array have?


a) 0
b) 1
c) 2
d) cannot be determined
View Answer

Answer: a
Explanation: When an array is sorted then there cannot be any inversion in the array. As the
necessary condition for an inversion is arr[i]>arr[j] and i<j.

3. What is the condition for two elements arr[i] and arr[j] to form an inversion?
a) arr[i]<arr[j]
b) i < j
c) arr[i] < arr[j] and i < j
d) arr[i] > arr[j] and i < j
View Answer

Answer: d
Explanation: For two elements to form an inversion the necessary condition is arr[i] > arr[j]
and i < j. The number of inversions in an array indicate how close or far the array is from
being completely sorted.

4. Under what condition the number of inversions in an array are maximum?


a) when the array is sorted
b) when the array is reverse sorted
c) when the array is half sorted
d) depends on the given array
View Answer

Answer: b
Explanation: Number of inversions in an array are maximum when the given array is reverse
sorted. As the necessary condition for an inversion is arr[i]>arr[j] and i<j.

5. Under what condition the number of inversions in an array are minimum?


a) when the array is sorted
b) when the array is reverse sorted
c) when the array is half sorted
d) depends on the given array
View Answer

Answer: a
Explanation: Number of inversions in an array are minimum when the given array is sorted.
As the necessary condition for an inversion is arr[i]>arr[j] and i<j.
advertisement

6. How many inversions are there in the array arr = {1,5,4,2,3}?


a) 0
b) 3
c) 4
d) 5
View Answer

Answer: d
Explanation: The necessary condition for an inversion is arr[i]>arr[j] and i<j. So there are 5
inversions in the array.

7. Which of the following form inversion in the array arr = {1,5,4,2}?


a) (5,4), (5,2)
b) (5,4), (5,2), (4,2)
c) (1,5), (1,4), (1,2)
d) (1,5)
View Answer

Answer: b
Explanation: The necessary condition for an inversion is arr[i]>arr[j] and i<j. So there are 3
inversions in the array. These are (5,4), (5,2), (4,2).

8. Choose the correct function from the following which determines the number of inversions
in an array?
a)

int InvCount(int arr[], int n)


{
int count = 0;
for (int i = 0; i < n - 1; i++)
for (int j = i ; j < n; j++)
if (arr[i] >= arr[j])
count++;

return count;
}

b)

advertisement
int InvCount(int arr[], int n)
{
int count = 0;
for (int i = 0; i < n - 1; i++)
for (int j = i + 1; j < n; j++)
if (arr[i] > arr[j])
count++;

return count;
}

c)

int InvCount(int arr[], int n)


{
int count = 0;
for (int i = 0; i < n - 1; i++)
for (int j = i + 1; j < n; j++)
if (arr[i] > arr[j])
count++;

return count + 1;
}

d)

int InvCount(int arr[], int n)


{
int count = 0;
for (int i = 0; i < n - 1; i++)
for (int j = i + 1; j < n; j++)
if (arr[i] < arr[j])
count++;

return count + 1;
}
View Answer
Answer: b
Explanation: To determine the number of inversions we apply a nested loop and compare the
value of each element with all the elements present after it. Then the count of number of
inversions is counted and returned to the main function.

9. What is the time complexity of the following code that determines the number of
inversions in an array?

advertisement
int InvCount(int arr[], int n)
{
int count = 0;
for (int i = 0; i < n - 1; i++)
for (int j = i + 1; j < n; j++)
if (arr[i] > arr[j])
count++;

return count;
}

a) O(n)
b) O(n log n)
c) O(n2)
d) O(log n)
View Answer

Answer: c
Explanation: The time complexity of the given code is O(n2). It is due to the presence of
nested loop.

10. The time complexity of the code that determines the number of inversions in an array
using merge sort is lesser than that of the code that uses loops for the same purpose.
a) true
b) false
View Answer

Answer: a
Explanation: The time complexity of the code that determines the number of inversions in an
array using merge sort is O(n log n) which is lesser than the time complexity taken by the
code that uses loops.

11. What is the time complexity of the code that uses merge sort for determining the number
of inversions in an array?
a) O(n2)
b) O(n)
c) O(log n)
d) O(n log n)
View Answer

Answer: d
Explanation: The code of merge sort is slightly modified in order to calculate the number of
inversions in an array. So the time complexity of merge sort remains unaffected and hence
the time complexity is O(n log n).

12. What is the time complexity of the code that uses self balancing BST for determining the
number of inversions in an array?
a) O(n2)
b) O(n)
c) O(log n)
d) O(n log n)
View Answer
Answer: d
Explanation: When a self balancing BST like an AVL tree is used to calculate the number of
inversions in an array then the time complexity is O(n log n) as AVL insert takes O(log n)
time.

13. The time complexity of the code that determines the number of inversions in an array
using self balancing BST is lesser than that of the code that uses loops for the same purpose.
a) true
b) false
View Answer

Answer: a
Explanation: The time complexity of the code that determines the number of inversions in an
array using self balancing BST is O(n log n) which is lesser than the time complexity taken
by the code that uses loops.

14. What is the space complexity of the code that uses merge sort for determining the number
of inversions in an array?
a) O(n)
b) O(log n)
c) O(1)
d) O(n log n)
View Answer

Answer: a
Explanation: The space complexity required by the code will be O(n). It is the same as the
space complexity of the code of standard merge sort.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Sparse Matrix Multiple Choice Questions and Answers (MCQs)
» Next - Rotation Array Operation Multiple Choice Questions and Answers (MCQs)
Categories Data Structure MCQs, DS MCQs 3 - Types of Arrays Post navigation
Sparse Matrix Multiple Choice Questions and Answers (MCQs)
Rotation Array Operation Multiple Choice Questions and Answers (MCQs)
advertisement
advertisement

Recommended Posts:

1. C Programming Examples on Strings


2. Python Programming Examples on Trees
3. C Programming Examples on Bitwise Operations
4. C Programming Examples on Trees
5. C++ Programming Examples on Data-Structures
6. Java Programming Examples on Collections
7. Data Structures & Algorithms II – Questions and Answers
8. Java Programming Examples on Data-Structures
9. C# Programming Examples on LINQ
10. C Programming Examples
11. C# Programming Examples on Arrays
12. C Programming Examples on Combinatorial Problems & Algorithms
13. Java Programming Examples on Combinatorial Problems & Algorithms
14. C Programming Examples using Recursion
15. C++ Programming Examples on Combinatorial Problems & Algorithms
16. Java Programming Examples on Arrays
17. C Programming Examples on Searching and Sorting
18. Python Programming Examples on Searching and Sorting
19. C Programming Examples on Arrays
20. C# Programming Examples on Sorting

advertisement

Rotation Array Operation Multiple Choice


Questions and Answers (MCQs)
« Prev
Next »

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Rotation Array Operation―.

1. What will be the resulting array after rotating arr[]={1, 2, 3, 4, 5} by 2?


a) 2, 1, 3, 4, 5
b) 3, 4, 5, 1, 2
c) 4, 5, 1, 2, 3
d) 1, 2, 3, 5, 4
View Answer

Answer: b
Explanation: When the given array is rotated by 2 then the resulting array will be
Rotation 1: {2,3,4,5,1}
Rotation 2: {3,4,5,1,2}.
Thus, the final array is {3,4,5,1,2}.
advertisement

2. What will be the output of the following code?

#include <iostream>
using namespace std;
int main()
{
int arr[] = {1,2,3,4,5,6};
int n = sizeof(arr)/sizeof(arr[0]);
int d=4;
int temp[10];

for(int i=0;i<d;i++)
temp[i]=arr[i];

int j=0;
for(int i=d;i<n;i++,j++)
arr[j]=arr[i];

int k=0;
for(int i=n-d;i<n;i++,k++)
arr[i]=temp[k];

for(int i=0;i<n;i++)
cout<<arr[i]<<" ";
return 0;
}

a) 5 6 1 2 3 4
b) 6 5 4 3 1 2
c) 3 4 5 6 1 2
d) error
View Answer

Answer: a
Explanation: The given code rotates the given array by 4. It does so by using an array temp[]
which stores the first d elements and then shift them to the end of the array. So the output will
be 5 6 1 2 3 4.

3. What will be the time complexity of the following code?

#include <iostream>
using namespace std;
int main()
{
int arr[] = {1,2,3,4,5,6};
int n = sizeof(arr)/sizeof(arr[0]);
int d=4;
int temp[10];

for(int i=0;i<d;i++)
temp[i]=arr[i];

int j=0;
for(int i=d;i<n;i++,j++)
arr[j]=arr[i];

int k=0;
for(int i=n-d;i<n;i++,k++)
arr[i]=temp[k];

for(int i=0;i<n;i++)
cout<<arr[i]<<" ";
return 0;
}

a) O(d)
b) O(n)
c) O(n2)
d) O(n*d)
View Answer

Answer: b
Explanation: The given code rotates an input array by d. The longest loop in the code takes n
iterations so the time complexity will be O(n).
advertisement

4. What will be the auxiliary space complexity of the following code?

#include <iostream>
using namespace std;
int main()
{
int arr[] = {1,2,3,4,5,6};
int n = sizeof(arr)/sizeof(arr[0]);
int d=4;
int temp[10];

for(int i=0;i<d;i++)
temp[i]=arr[i];

int j=0;
for(int i=d;i<n;i++,j++)
arr[j]=arr[i];

int k=0;
for(int i=n-d;i<n;i++,k++)
arr[i]=temp[k];

for(int i=0;i<n;i++)
cout<<arr[i]<<" ";
return 0;
}

a) O(1)
b) O(n)
c) O(d)
d) O(n*d)
View Answer

Answer: c
Explanation: The given code rotates an input array by d. It does so by using an auxiliary array
temp[] which stores first d elements of the original array. So the auxiliary space complexity
will be O(d).

5. What will be the output of the following code?

#include <bits/stdc++.h>
using namespace std;
void func1(int arr[], int n)
{
int k = arr[0], i;
for (i = 0; i < n - 1; i++)
arr[i] = arr[i + 1];

arr[i] = k;
}

void func(int arr[], int d, int n)


{
for (int i = 0; i < d; i++)
func1(arr, n);
}

void printArray(int arr[], int n)


{
for (int i = 0; i < n; i++)
cout << arr[i] << " ";
}

int main()
{
int arr[] = { 1, 2, 3, 4, 5};
int n = sizeof(arr) / sizeof(arr[0]);

func(arr, 3, n);
printArray(arr, n);

return 0;
}

a) 4 5 1 2 3
b) 3 4 5 1 2
c) 5 4 3 1 2
d) error
View Answer

Answer: a
Explanation: The given code rotates the input array by 3. It does so by rotating the elements
one by one until the desired rotation is achieved. So the output will be 4 5 1 2 3.

6. What will be the time complexity of the following code?

advertisement
#include <bits/stdc++.h>
using namespace std;
void func1(int arr[], int n)
{
int k = arr[0], i;
for (i = 0; i < n - 1; i++)
arr[i] = arr[i + 1];

arr[i] = k;
}
void func(int arr[], int d, int n)
{
for (int i = 0; i < d; i++)
func1(arr, n);
}

void printArray(int arr[], int n)


{
for (int i = 0; i < n; i++)
cout << arr[i] << " ";
}

int main()
{
int arr[] = { 1, 2, 3, 4, 5};
int n = sizeof(arr) / sizeof(arr[0]);

int d = 3;
func(arr, d, n);
printArray(arr, n);

return 0;
}

a) O(n*d)
b) O(n)
c) O(d)
d) O(n2)
View Answer

Answer: a
Explanation: The given code rotates the input array by d. It does so by rotating the elements
one by one until the desired rotation is achieved. Each element takes O(n) time for rotation
and there are d such elements in the array. So the time complexity would be O(n*d).

7. What will be the auxiliary space complexity of the following code?

#include <bits/stdc++.h>
using namespace std;
void func1(int arr[], int n)
{
int k = arr[0], i;
for (i = 0; i < n - 1; i++)
arr[i] = arr[i + 1];

arr[i] = k;
}

void func(int arr[], int d, int n)


{
for (int i = 0; i < d; i++)
func1(arr, n);
}

void printArray(int arr[], int n)


{
for (int i = 0; i < n; i++)
cout << arr[i] << " ";
}

int main()
{
int arr[] = { 1, 2, 3, 4, 5};
int n = sizeof(arr) / sizeof(arr[0]);

int d = 3;
func(arr, d, n);
printArray(arr, n);

return 0;
}

a) O(1)
b) O(n)
c) O(d)
d) O(n*d)
View Answer

Answer: a
Explanation: The given code rotates the input array by d. It does so by rotating the elements
one by one until the desired rotation is achieved. It does not require any auxiliary array for
this purpose. So the auxiliary space complexity will be O(1).

8. To rotate an array by using the algorithm of rotating its elements one by one is an in place
algorithm.
a) true
b) false
View Answer

Answer: a
Explanation: The auxiliary space requirement of the mentioned algorithm is O(1). So it
qualifies to be an in place algorithm.

9. What will be the output of the following code?

#include <bits/stdc++.h>
using namespace std;
void func1(int arr[], int left, int right)
{
while (left < right)
{
int temp = arr[left];
arr[left] = arr[right];
arr[right] = temp;
left++;
right--;
}
}

void func(int arr[], int d, int n)


{
func1(arr, 0, d-1);
func1(arr, d, n-1);
func1(arr, 0, n-1);
}

void printArray(int arr[], int size)


{
for (int i = 0; i < size; i++)
cout << arr[i] << " ";
}

int main()
{
int arr[] = {1, 2, 3, 4, 5};
int n = sizeof(arr)/sizeof(arr[0]);
int d = 2;
func(arr, d, n);
printArray(arr, n);

return 0;
}

a) 3 2 1 4 5
b) 3 4 5 1 2
c) 5 4 3 2 1
d) error
View Answer

Answer: b
Explanation: The given code rotates the input array by 2. It does so by applying a reversal
algorithm to different segments of the array. First d elements and the rest of the array is
reversed individually. Then the whole array is reversed which gives us the desired rotated
array. So the output will be 3 4 5 1 2.
advertisement

10. What will be the auxiliary space complexity of the code to rotate an array by using the
reversal algorithm (d = number of rotations)?
a) O(1)
b) O(n)
c) O(d)
d) O(n*d)
View Answer

Answer: a
Explanation: The reversal algorithm for rotating an array does not require any auxiliary
space. So the auxiliary space complexity will be O(1).

11. Which of the following is the predefined function for array reversal in C++?
a) rotate()
b) arr_rotate()
c) array_rotate()
d) rot()
View Answer
Answer: a
Explanation: The predefined function for rotating an array is rotate() in C++. It is defined
under the library algorithm and requires 3 arguments.

12. How many arguments are required by the predefined function rotate() in C++?
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: c
Explanation: The predefined function for rotating an array is rotate() in C++ which comes
under the library called an algorithm. It requires 3 arguments.

13. Predefined function rotate() in C++ is available under which header file?
a) math
b) stdio
c) stdlib
d) algorithm
View Answer

Answer: d
Explanation: The predefined function for rotating an array is rotate() in C++ which comes
under the library called algorithm. It requires 3 arguments the first being the pointer to the
starting index of the array and the last being the pointer to the last index of the array. The
middle argument is the pointer to the element that becomes the first element in the rotated
array.

14. Which of the following algorithm to rotate an array has the maximum time complexity?
a) rotate elements one by one
b) juggling algorithm
c) reversal algorithm
d) using a temporary array
View Answer

Answer: a
Explanation: The maximum time complexity is required by the algorithm that rotates
elements one by one. It requires O(n*d) time.

15. What is the time complexity of the juggling algorithm to rotate an array?
a) O(1)
b) O(n)
c) O(d)
d) O(n*d)
View Answer

Answer: b
Explanation: Time complexity of juggling algorithm is O(n). Its auxiliary space complexity is
O(1).
16. Reversal algorithm and juggling algorithm for array rotation have the same time
complexity.
a) True
b) False
View Answer

Answer: a
Explanation: Time complexity of juggling algorithm is O(n) which like that of reversal
algorithm. They also have the same space complexity.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Count Inversion Multiple Choice Questions and Answers (MCQs)
» Next - Reversal Array Operation Multiple Choice Questions and Answers (MCQs)
Categories Data Structure MCQs, DS MCQs 3 - Types of Arrays Post navigation
Count Inversion Multiple Choice Questions and Answers (MCQs)
Reversal Array Operation Multiple Choice Questions and Answers (MCQs)
advertisement
advertisement

Recommended Posts:

1. C Programming Examples on Arrays


2. C# Programming Examples on Matrix
3. C Programming Examples on Searching and Sorting
4. C Programming Examples on Matrix
5. C Programming Examples on Linked List
6. Java Programming Examples on Data-Structures
7. C# Programming Examples on Arrays
8. C Questions and Answers
9. C Programming Examples on Strings
10. C# Programming Examples on LINQ
11. Java Programming Examples on Event Handling
12. C Programming Examples on Stacks & Queues
13. Simple C Programs
14. C Programming Examples
15. Java Programming Examples
16. Java Programming Examples on Arrays
17. C Programming Examples on Data-Structures
18. C# Programming Examples on Data Structures
19. Java Programming Examples on Collections
20. Home
advertisement

Reversal Array Operation Multiple Choice


Questions and Answers (MCQs)
« Prev
Next »

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Reversal Array Operation―.

1. What will be the resulting array after reversing arr[]={3,5,4,2}?


a) 2,3,5,4
b) 4,2,3,5
c) 5,4,2,3
d) 2,4,5,3
View Answer

Answer: d
Explanation: The resulting array upon reversing after reversal is arr[]={2,4,5,3}. We can
implement an algorithm for this purpose in various possible ways.
advertisement

2. How many swaps are required for reversing an array having n elements where n is an odd
number?
a) (n-1) / 2
b) n/2
c) (n/2) – 1
d) (n+1)/2
View Answer

Answer: a
Explanation: The number of swaps required for an odd element and an even element array is
different because in an odd element array the position of the middle element does not need to
be changed. So the number of swaps will be (n-1) / 2.

3. How many swaps are required for reversing an array having n elements where n is an even
number?
a) (n-1) / 2
b) n/2
c) (n/2) – 1
d) (n+1)/2
View Answer

Answer: b
Explanation: The number of swaps required for an odd element and an even element array is
different because in an odd element array the position of the middle element does not need to
be changed. So number of swaps required will be n/2.
4. What will be the output of the following code?

#include <bits/stdc++.h>
using namespace std;

void func(int arr[], int left, int right)


{
while (left < right)
{
int temp = arr[left];
arr[left] = arr[right];
arr[right] = temp;
left++;
right--;
}

void printArray(int arr[], int size)


{
for (int i = 0; i < size; i++)
cout << arr[i] << " ";
}

int main()
{
int arr[] = {1,4,3,5};
int n = sizeof(arr) / sizeof(arr[0]);
func(arr, 0, n-1);
printArray(arr, n);
return 0;
}

a) 5 1 4 3
b) 3 5 1 4
c) 5 3 4 1
d) error
View Answer

Answer: c
Explanation: The given code reverses the input array and then prints the resulting array. So
the output of the given code will be 5 3 4 1.

5. What will be the time complexity of the following code?

advertisement
#include <bits/stdc++.h>
using namespace std;
void func(int arr[], int left, int right)
{
while (left < right)
{
int temp = arr[left];
arr[left] = arr[right];
arr[right] = temp;
left++;
right--;
}
}

void printArray(int arr[], int size)


{
for (int i = 0; i < size; i++)
cout << arr[i] << " ";
}

int main()
{
int arr[] = {1,4,3,5};
int n = sizeof(arr) / sizeof(arr[0]);
func(arr, 0, n-1);
printArray(arr, n);
return 0;
}

a) O(n)
b) O(log n)
c) O(1)
d) O(n log n)
View Answer

Answer: a
Explanation: The given code reverses the input array and then prints the resulting array. So
the time complexity of the given code will linearly vary with the number of elements in the
array and thus the time complexity will be O(n).

6. What will be the auxiliary space requirement of the following code?

#include <bits/stdc++.h>
using namespace std;
void func(int arr[], int left, int right)
{
while (left < right)
{
int temp = arr[left];
arr[left] = arr[right];
arr[right] = temp;
left++;
right--;
}

void printArray(int arr[], int size)


{
for (int i = 0; i < size; i++)
cout << arr[i] << " ";
}

int main()
{
int arr[] = {1,4,3,5};
int n = sizeof(arr) / sizeof(arr[0]);
func(arr, 0, n-1);
printArray(arr, n);
return 0;
}

a) O(1)
b) O(n)
c) O(log n)
d) O(n log n)
View Answer

Answer: a
Explanation: The given code reverses the input array and then prints the resulting array. The
given code does not use any extra array to complete this task thus the auxiliary space
requirement is O(1).

7. What will be the output of the following code ?

#include <bits/stdc++.h>
using namespace std;

void func(int arr[], int left, int right)


{
if (left >= right)
return;

int temp = arr[left];


arr[left] = arr[right];
arr[right] = temp;

func(arr, left + 1, right - 1);


}

void printArray(int arr[], int size)


{
for (int i = 0; i < size; i++)
cout << arr[i] << " ";
}

int main()
{
int arr[] = {1,2,3,4};
int n = sizeof(arr) / sizeof(arr[0]);
func(arr, 0, n-1);
printArray(arr, n);
return 0;
}

a) 1 2 3 4
b) 4 3 2 1
c) 1 4 2 3
d) 4 1 2 3
View Answer

Answer: b
Explanation: The given code reverses the original array and prints the resulting array.
Recursive function is used to reverse the array.
advertisement
8. What will be the time complexity of the following code?

#include <bits/stdc++.h>
using namespace std;
void func(int arr[], int left, int right)
{
if (left >= right)
return;

int temp = arr[left];


arr[left] = arr[right];
arr[right] = temp;

func(arr, left + 1, right - 1);


}

void printArray(int arr[], int size)


{
for (int i = 0; i < size; i++)
cout << arr[i] << " ";
}

int main()
{
int arr[] = {1,2,3,4};
int n = sizeof(arr) / sizeof(arr[0]);
func(arr, 0, n-1);
printArray(arr, n);
return 0;
}

a) O(1)
b) O(n)
c) O(log n)
d) O(n log n)
View Answer

Answer: b
Explanation: The given code reverses the original array and prints the resulting array. The
number of swaps is proportional to the number of elements in the array so it requires a time
complexity of O(n).

9. What will be the output of the following code?

#include <bits/stdc++.h>
using namespace std;
void func(int a[], int n, int k)
{
if (k <= n)
{
for (int i = 0; i < k/2; i++)
swap(a[i], a[k-i-1]);
}

}
int main()
{
int a[] = {1, 2, 3, 4, 5};
int n = sizeof(a) / sizeof(int), k = 3;
func(a, n, k);
for (int i = 0; i < n; ++i)
cout << a[i]<<" ";
return 0;
}

a) 3 2 1 4 5
b) 5 4 3 2 1
c) 1 2 5 4 3
d) error
View Answer

Answer: a
Explanation: The given code reverses only a specified segment of the input array. As the
value of k is given to be 3 in the code thus only the first three elements of the array will be
reversed.

10. What will be the time complexity of the following code?

advertisement
#include <bits/stdc++.h>
using namespace std;

void func(int a[], int n, int k)


{
if (k <= n)
{
for (int i = 0; i < k/2; i++)
swap(a[i], a[k-i-1]);
}

}
int main()
{
int a[] = {1, 2, 3, 4, 5};
int n = sizeof(a) / sizeof(int), k = 3;
func(a, n, k);
for (int i = 0; i < n; ++i)
cout << a[i]<<" ";
return 0;
}

a) O(k)
b) O(n)
c) O(k log k)
d) O(n log n)
View Answer

Answer: a
Explanation: The given code reverses only a specified segment of the input array. This
segment is decided by the value of k so the time complexity of the code will be O(k).

11. When array reversal and rotation is applied to the same array then the output produced
will also be the same every time.
a) true
b) false
View Answer

Answer: b
Explanation: Array rotation and array reversal are different operations and thus they give
different outputs when applied to the same array.

12. Which of the following is the predefined function for array reversal in C++ ?
a) reverse()
b) arr_reverse()
c) array_reverse()
d) rev()
View Answer

Answer: a
Explanation: The predefined function for reversing an array is reverse() in C++. It is defined
under the library algorithm and requires 2 arguments.

13. Which of the following is the predefined function for array reversal in javascript?
a) reverse()
b) arr_reverse()
c) array_reverse()
d) rev()
View Answer

Answer: a
Explanation: The predefined function for reversing an array is reverse() in javascript. It does
not requires any argument.

14. Predefined function reverse() in C++ is available under which header file?
a) math
b) stdio
c) stdlib
d) algorithm
View Answer

Answer: d
Explanation: The predefined function for reversing an array is reverse() in C++ which comes
under the library called an algorithm. It requires 2 arguments the first being the pointer to the
starting index of the array and the second being the pointer to the last index of the array.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!
Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Rotation Array Operation Multiple Choice Questions and Answers (MCQs)
» Next - Data Structure Questions and Answers – Number of Jumps to Reach End-array
Operation
Categories Data Structure MCQs, DS MCQs 3 - Types of Arrays Post navigation
Rotation Array Operation Multiple Choice Questions and Answers (MCQs)
Data Structure Questions and Answers – Number of Jumps to Reach End-array Operation
advertisement
advertisement

Recommended Posts:

1. C Programming Examples without using Recursion


2. C++ Programming Examples on Data-Structures
3. C# Programming Examples on Matrix
4. Java Programming Examples on Combinatorial Problems & Algorithms
5. C Programming Examples on Stacks & Queues
6. C Programming Examples on Combinatorial Problems & Algorithms
7. Data Structure Questions and Answers
8. C Programming Examples
9. Java Programming Examples on Collections
10. C Programming Examples using Recursion
11. C++ Programming Examples on Combinatorial Problems & Algorithms
12. C Programming Examples on Linked List
13. Python Programming Examples on Linked Lists
14. C Programming Examples on Bitwise Operations
15. Python Programming Examples on Searching and Sorting
16. C Programming Examples on Searching and Sorting
17. C# Programming Examples on Arrays
18. C# Programming Examples on Sorting
19. Java Programming Examples on Arrays
20. C Programming Examples on Arrays

advertisement

Data Structure Questions and Answers –


Number of Jumps to Reach End-array
Operation
« Prev
Next »

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Number of Jumps to Reach End-array Operation―.

1. What will be the minimum number of jumps required to reach the end of the array arr[] =
{1,3,6,3,6,8,5}?
a) 1
b) 2
c) 3
d) not possible to reach the end
View Answer

Answer: c
Explanation: Each element of the array represents the maximum number of steps that can be
taken forward from that element. If the first element is 0 then it is not possible to reach the
end.
advertisement

2. What will be the minimum number of jumps required to reach the end of the array arr[]
={0,1,3,6,3,6,8,5}?
a) 1
b) 2
c) 3
d) not possible to reach the end
View Answer

Answer: d
Explanation: Each element of the array represents the maximum number of steps that can be
taken forward from that element. So as the first element here is 0 so we cannot move any
further from the first element. Thus, it is not possible to reach the end of the array.

3. What will be the output of the following code?

#include <bits/stdc++.h>
using namespace std;

int func(int arr[], int s, int e)


{
if (s == e)
return 0;
if (arr[s] == 0)
return INT_MAX;

int min = INT_MAX;


for (int i = s + 1; i <= e && i <= s + arr[s]; i++)
{
int jumps = func(arr, i, e);
if(jumps != INT_MAX && jumps + 1 < min)
min = jumps + 1;
}
return min;
}

int main()
{
int arr[] = {1, 3, 6, 3, 8, 5};
int n = sizeof(arr)/sizeof(arr[0]);
cout << func(arr, 0, n-1);
return 0;
}
a) 1
b) 2
c) 3
d) error
View Answer

Answer: c
Explanation: The given code finds the minimum number of steps required to reach the end of
the array by using recursion. So the output will be 3.
advertisement

4. What will be the output of the following code?

#include <bits/stdc++.h>
using namespace std;

int min(int x, int y)


{ return (x < y)? x: y; }

int func(int arr[], int n)


{

int *jump = new int[n];


int i, j;

if (n == 0 || arr[0] == 0)
return INT_MAX;

jump[0] = 0;

for (i = 1; i < n; i++)


{
jump[i] = INT_MAX;
for (j = 0; j < i; j++)
{
if (i <= j + arr[j] && jumps[j] != INT_MAX)
{
jump[i] = min(jump[i], jump[j] + 1);
break;
}
}
}
return jump[n-1];
}

int main()
{
int arr[] = {1, 3, 6, 1, 9,7};
int size = sizeof(arr)/sizeof(int);
cout<< func(arr,size);
return 0;
}

a) 1
b) 2
c) 3
d) error
View Answer

Answer: c
Explanation: The given code finds the minimum number of steps required to reach the end of
the array by using dynamic programming. So the output will be 3.

5. What will be the time complexity of the following code?

#include <bits/stdc++.h>
using namespace std;

int min(int x, int y)


{ return (x < y)? x: y; }

int func(int arr[], int n)


{

int *jump = new int[n];


int i, j;

if (n == 0 || arr[0] == 0)
return INT_MAX;

jump[0] = 0;

for (i = 1; i < n; i++)


{
jump[i] = INT_MAX;
for (j = 0; j < i; j++)
{
if (i <= j + arr[j] && jumps[j] != INT_MAX)
{
jump[i] = min(jump[i], jump[j] + 1);
break;
}
}
}
return jump[n-1];
}

int main()
{
int arr[] = {1, 3, 6, 1, 9,7};
int size = sizeof(arr)/sizeof(int);
cout<< func(arr,size);
return 0;
}

a) O(n log n)
b) O(n)
c) O(n1/2)
d) O(n2)
View Answer

Answer: d
Explanation: The given code finds the minimum number of steps required to reach the end of
an array by using dynamic programming. As there is a nested loop in the code so the time
complexity will be O(n2).
advertisement

6. What will be the minimum number of jumps required to reach the end of the array arr[] =
{1,2,0,0,3,6,8,5}?
a) 1
b) 2
c) 3
d) not possible to reach the end
View Answer

Answer: d
Explanation: Each element of the array represents the maximum number of steps that can be
taken forward from that element. So we cannot move any further after reaching the second
element hence it is impossible to reach the end of the array.

7. It is not possible to find the minimum number of steps to reach the end of an array in linear
time.
a) true
b) false
View Answer

Answer: b
Explanation: It is possible to find the minimum number of steps to reach the end of an array
in O(n) time complexity. So it is the fastest possible method of finding the minimum number
of steps to reach the end of an array.

8. In how many different ways we can reach the end of the array arr[]={1,3,5,8,9}?
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: d
Explanation: There are 4 possible ways in which we can reach the end of the array. The
possible paths are – 1->3->5->8->9, 1->3->5->9, 1->3->8->9, 1->3->9.

9. What will be the output of the following code?

advertisement
#include <bits/stdc++.h>
using namespace std;

void func(int arr[], int n)


{
int count[n];
memset(count, 0, sizeof(count));

for (int i=n-2; i>=0; i--)


{
if (arr[i] >= n - i - 1)
count[i]++;

for (int j=i+1; j < n-1 && j <= arr[i] + i; j++)

if (count[j] != -1)
count[i] += count[j];

if (count[i] == 0)
count[i] = -1;
}

for (int i=0; i<n; i++)


cout << count[i] << " ";
}

int main()
{
int arr[] = {1, 3, 5, 8, 9};
int n = sizeof(arr) / sizeof(arr[0]);
func(arr, n);
return 0;
}

a) 3
b) 4
c) 4 4 2 1 0
d) 4 2 2 0 1
View Answer

Answer: c
Explanation: The given code finds the number of possible ways to reach the end of an array
from each element. So the output will be 4 4 2 1 0.

10. What will be the worst case time complexity of the following code?

#include <bits/stdc++.h>
using namespace std;

void func(int arr[], int n)


{
int count[n];
memset(count, 0, sizeof(count));

for (int i=n-2; i>=0; i--)


{
if (arr[i] >= n - i - 1)
count[i]++;

for (int j=i+1; j < n-1 && j <= arr[i] + i; j++)

if (count[j] != -1)
count[i] += count[j];

if (count[i] == 0)
count[i] = -1;
}
for (int i=0; i<n; i++)
cout << count[i] << " ";
}

int main()
{
int arr[] = {1, 3, 5, 8, 9};
int n = sizeof(arr) / sizeof(arr[0]);
func(arr, n);
return 0;
}

a) O(n1/2)
b) O(n)
c) O(n3/2)
d) O(n2)
View Answer

Answer: d
Explanation: The given code finds the number of possible ways to reach the end of an array
from each element. By observing the nested loop in the code we can say that the worst case
time complexity will be O(n2).

11. : It is not possible to reach the end of an array if starting element of the array is 0.
a) true
b) false
View Answer

Answer: a
Explanation: If the first element of an array is 0 then it is not possible to reach the end.
However, if 0 is present at other positions then we may/may not be able to reach the end.

12. What is the minimum possible time complexity to find the number of steps to reach the
end of an array?
a) O(n)
b) O(n2)
c) O(n3/2)
d) O(1)
View Answer

Answer: a
Explanation: The minimum possible time complexity to reach the end of an array is O(n). So
a linear time complexity is possible.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!
Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Reversal Array Operation Multiple Choice Questions and Answers (MCQs)
» Next - Data Structure Questions and Answers – Skip List
Categories Data Structure MCQs, DS MCQs 3 - Types of Arrays Post navigation
Reversal Array Operation Multiple Choice Questions and Answers (MCQs)
Data Structure Questions and Answers – Skip List
advertisement
advertisement

Recommended Posts:

1. C Programming Examples on Bitwise Operations


2. Python Programming Examples on Trees
3. C Programming Examples
4. C Programming Examples without using Recursion
5. C Programming Examples on Searching and Sorting
6. C Programming Examples on Arrays
7. C Programming Examples using Recursion
8. C Programming Examples on Trees
9. Data Science Questions and Answers
10. C++ Programming Examples on Combinatorial Problems & Algorithms
11. Dynamic Programming Problems and Solutions
12. Java Programming Examples on Arrays
13. C# Programming Examples on Sorting
14. C# Programming Examples on Data Structures
15. C Programming Examples on Data-Structures
16. C# Programming Examples on Arrays
17. Java Programming Examples on Data-Structures
18. C++ Programming Examples on Data-Structures
19. Data Structures & Algorithms II – Questions and Answers
20. Data Structure Questions and Answers

advertisement

Data Structure Questions and Answers –


Skip List
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Skip List―.

1. What is a skip list?


a) a linkedlist with size value in nodes
b) a linkedlist that allows faster search within an ordered sequence
c) a linkedlist that allows slower search within an ordered sequence
d) a tree which is in the form of linked list
View Answer

Answer: b
Explanation: It is a datastructure, which can make search in sorted linked list faster in the
same way as binary search tree and sorted array (using binary search) are faster.
advertisement

2. Consider the 2-level skip list

How to access 38?


a) travel 20-30-35-38
b) travel 20-30-40-38
c) travel 20-38
d) travel 20-40-38
View Answer

Answer: a
Explanation: Let us call the nodes 20, 30, 40 as top lines and the nodes between them as
normal lines. the advantage of skip lists is we can skip all the elements between the top line
elements as required.

3. Skip lists are similar to which of the following datastructure?


a) stack
b) heap
c) binary search tree
d) balanced binary search tree
View Answer

Answer: d
Explanation: Skip lists have the same asymptotic time complexity as balanced binary search
tree. For a Balanced Binary Search Tree, we skip almost half of the nodes after one
comparison with root element. The same thing done in the skip lists. Hence skip lists are
similar to balanced Binary search trees.

4. What is the time complexity improvement of skip lists from linked lists in insertion and
deletion?
a) O(n) to O(logn) where n is number of elements
b) O(n) to O(1) where n is number of elements
c) no change
d) O(n) to O(n2) where n is number of elements
View Answer

Answer: a
Explanation: In Skip list we skip some of the elements by adding more layers. In this the skip
list resembles balanced binary search trees. Thus we can change the time complexity from O
(n) to O (logn)

5. To which datastructure are skip lists similar to in terms of time complexities in worst and
best cases?
a) balanced binary search trees
b) binary search trees
c) binary trees
d) linked lists
View Answer

Answer: a
Explanation: Skip lists are similar to any randomly built binary search tree. a BST is balanced
because to avoid skew tree formations in case of sequential input and hence achieve O(logn)
in all 3 cases. now skip lists can gurantee that O(logn) complexity for any input.
advertisement

6. The nodes in a skip list may have many forward references. their number is determined
a) probabilistically
b) randomly
c) sequentially
d) orthogonally
View Answer

Answer: a
Explanation: The number of forward references are determined probabilistically, that is why
skip list is a probabilistic algorithm.

7. Are the below statements true about skiplists?


In a sorted set of elements skip lists can implement the below operations
i.given a element find closest element to the given value in the sorted set in O(logn)
ii.find the number of elements in the set whose values fall a given range in O(logn)
a) true
b) false
View Answer

Answer: a
Explanation: To achieve above operations augment with few additional stuff like partial
counts.

8. How to maintain multi-level skip list properties when insertions and deletions are done?
a) design each level of a multi-level skip list with varied probabilities
b) that cannot be maintained
c) rebalancing of lists
d) reconstruction
View Answer

Answer: a
Explanation: For example consider a 2 level skip list. the level-2 skip list can skip one node
on a average and at some places may skip 2 nodes, depending on probabilities. this ensures
O(logn).

9. Is a skip list like balanced tree?


a) true
b) false
View Answer

Answer: a
Explanation: Skip list behaves as a balanced tree with high probability and can be commented
as such because nodes with different heights are mixed up evenly.
advertisement

10. What is indexed skip list?


a) it stores width of link in place of element
b) it stores index values
c) array based linked list
d) indexed tree
View Answer

Answer: a
Explanation: The width is defined as number of bottom layer links that are being traversed by
each of higher layer elements. e.g: for a level-2 skip lists, all level-1 nodes have 1 as width,
for level-2 width will be 2.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Number of Jumps to Reach End-array
Operation
» Next - Self Organizing List Multiple Choice Questions and Answers (MCQs)
Categories Data Structure MCQs, DS MCQs 4 - Types of Lists Post navigation
Data Structure Questions and Answers – Number of Jumps to Reach End-array Operation
Self Organizing List Multiple Choice Questions and Answers (MCQs)
advertisement
advertisement

Recommended Posts:

1. C Programming Examples on Graph Problems & Algorithms


2. Data Structures & Algorithms II – Questions and Answers
3. Java Programming Examples on Graph Problems & Algorithms
4. C++ Programming Examples on Graph Problems & Algorithms
5. C++ Programming Examples on Combinatorial Problems & Algorithms
6. Java Programming Examples on Combinatorial Problems & Algorithms
7. Python Programming Examples on Searching and Sorting
8. C Programming Examples
9. C Programming Examples using Recursion
10. C Programming Examples on Combinatorial Problems & Algorithms
11. Python Programming Examples on Trees
12. C Programming Examples without using Recursion
13. C Programming Examples on Trees
14. Python Programming Examples on Linked Lists
15. Java Programming Examples on Data-Structures
16. C++ Programming Examples on Data-Structures
17. C# Programming Examples on Data Structures
18. C Programming Examples on Data-Structures
19. Data Structure Questions and Answers – Binomial and Fibonacci Heap
20. Linux Kernel Internals Training – V – Kernel Data Structures

advertisement

Self Organizing List Multiple Choice


Questions and Answers (MCQs)
« Prev
Next »

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Self Organizing List―.

1. The self organizing list improves the efficiency of _______


a) binary search
b) jump search
c) sublist search
d) linear search
View Answer

Answer: d
Explanation: Linear search in a linked list has time complexity O(n). To improve the
efficiency of the linear search the self organizing list is used. A self-organizing list improves
the efficiency of linear search by moving more frequently accessed elements towards the
head of the list.
advertisement

2. Which of the following is true about the Move-To-Front Method for rearranging nodes?
a) node with highest access count is moved to head of the list
b) requires extra storage
c) may over-reward infrequently accessed nodes
d) requires a counter for each node
View Answer
Answer: c
Explanation: In Move-To-front Method the element which is searched is moved to the head
of the list. And if a node is searched even once, it is moved to the head of the list and given
maximum priority even if it is not going to be accessed frequently in the future. Such a
situation is referred to as over-rewarding.

3. What technique is used in Transpose method?


a) searched node is swapped with its predecessor
b) node with highest access count is moved to head of the list
c) searched node is swapped with the head of list
d) searched nodes are rearranged based on their proximity to the head node
View Answer

Answer: a
Explanation: In Transpose method, if any node is searched, it is swapped with the node in
front unless it is the head of the list. So, in Transpose method searched node is swapped with
its predecessor.

4. The worst case running time of a linear search on the self organizing list is ____
a) O(1)
b) O(logn)
c) O(n)
d) O(n2)
View Answer

Answer: c
Explanation: Worst case occurs when the element is located at the very end of list. So n
comparisons must be made to the locate element. So the worst case running time of linear
search on self organizing list is O(n).

5. Which of the following data structure is preferred to have lesser search time when the list
size is small?
a) search tree
b) sorted list
c) self organizing list
d) linked list
View Answer

Answer: c
Explanation: Self-organizing list is easy and simple to implement than search tree and it
requires no additional space. So using self organizing list is preferred when list size is small.
advertisement

6. In _____________ method, whenever a node is accessed, it might move to the head of the
list if its number of accesses becomes greater than the records preceding it.
a) least recently used
b) count
c) traspose
d) exchange
View Answer
Answer: b
Explanation: In the count method, the number of times a node was accessed is counted and is
stored in a counter variable associated with each node. Then the nodes are arranged in
descending order based on their access counts. And the node with highest access count is
head of the list.

7. Symbol tables during compilation of program is efficiently implemented using


__________
a) a singly linked list
b) a doubly linked list
c) a self organizing list
d) an array
View Answer

Answer: c
Explanation: Self organizing list allows fast sequential search and it is simple to implement
and requires no extra storage. Self-organizing list is used to implement the symbol table.

8. Which of the following method performs poorly when elements are accessed in sequential
order?
a) count method
b) move to front method
c) transpose meth
d) ordering method
View Answer

Answer: b
Explanation: Move-to-front method performs poorly when the elements are accessed in
sequential order, especially if that sequential order is then repeated multiple times.

9. The self organizing list improves _____


a) average access time
b) insertion
c) deletion
d) binary search
View Answer

Answer: a
Explanation: The self-organizing list rearranges the nodes based on the access probabilities of
the nodes. So the required elements can be located efficiently. Therefore, self-organizing list
is mainly used to improve the average access time.
advertisement

10. Which of the following is not the rearranging method used to implement self-organizing
lists?
a) count method
b) move to front method
c) ordering method
d) least frequently used
View Answer
Answer: d
Explanation: Least frequently used is a buffer replacement policy, while other three are
methods to reorder the nodes in the self-organizing lists based on their access probability.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Skip List
» Next - Data Structure Questions and Answers – Xor Linked List
Categories Data Structure MCQs, DS MCQs 4 - Types of Lists Post navigation
Data Structure Questions and Answers – Skip List
Data Structure Questions and Answers – Xor Linked List
advertisement
advertisement

Recommended Posts:

1. C Programming Examples on Data-Structures


2. C Programming Examples on Graph Problems & Algorithms
3. C++ Programming Examples on Graph Problems & Algorithms
4. Java Programming Examples on Combinatorial Problems & Algorithms
5. C++ Programming Examples on Combinatorial Problems & Algorithms
6. C Programming Examples on Computational Geometry Problems & Algorithms
7. C Programming Examples on Searching and Sorting
8. C# Programming Examples on Data Structures
9. C Programming Examples on Combinatorial Problems & Algorithms
10. Java Programming Examples on Data-Structures
11. Python Programming Examples on Graphs
12. Data Structure Questions and Answers
13. C Programming Examples using Recursion
14. Python Programming Examples on Searching and Sorting
15. C++ Programming Examples on Data-Structures
16. C Programming Examples on Trees
17. C Programming Examples without using Recursion
18. Python Programming Examples on Trees
19. Python Programming Examples on Linked Lists
20. C Programming Examples on Linked List

advertisement
Data Structure Questions and Answers –
Xor Linked List
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Xor Linked List―.

1. What is xor linked list ?


a) uses of bitwise XOR operation to decrease storage requirements for doubly linked lists
b) uses of bitwise XOR operation to decrease storage requirements for linked lists
c) uses of bitwise operations to decrease storage requirements for doubly linked lists
d) just another form of linked list
View Answer

Answer: a
Explanation: Why we use bitwise XOR operation is to decrease storage requirements for
doubly linked lists.
advertisement

2. What does a xor linked list have ?


a) every node stores the XOR of addresses of previous and next nodes
b) actuall memory address of next node
c) every node stores the XOR of addresses of previous and next two nodes
d) every node stores xor 0 and the current node address
View Answer

Answer: a
Explanation: Every node stores the XOR of addresses.

3. What does first and last nodes of a xor linked lists contain ? (let address of first and last be
A and B)
a) NULL xor A and B xor NULL
b) NULL and NULL
c) A and B
d) NULL xor A and B
View Answer

Answer: a
Explanation: NULL xor A and B xor NULL.

4. Which of the following is an advantage of XOR list?


a) Almost of debugging tools cannot follow the XOR chain, making debugging difficult
b) You need to remember the address of the previously accessed node in order to calculate
the next node’s address
c) In some contexts XOR of pointers is not defined
d) XOR list decreases the space requirement in doubly linked list
View Answer

Answer: d
Explanation: XOR linked list stores the address of previous and next nodes by performing
XOR operations. It requires single pointer to store both XOR address of next and previous
nodes. Thus it reduces space. It is an advantage. But the main disadvantages are debugging
tools cannot follow XOR chain, previous node address must be remembered to get next nodes
and pointers are not defined accurately.

5. Which of the following is not the properties of XOR lists?


a) X⊕X = 0
b) X⊕0 = X
c) (X⊕Y)⊕Z = X⊕(Y⊕Z)
d) X⊕0 = 1
View Answer

Answer: d
Explanation: The important properties of XOR lists are X⊕X=0 , X⊕0=X and
(X⊕Y)⊕Z = X⊕(Y⊕Z).
advertisement

6. Which of the following statements are true ?


i) practical application of XOR linked lists are in environments with limited space
requirements, such as embedded devices.
ii)xor lists are not suitable because most garbage collectors will fail to work properly with
classes or structures that don’t contain literal pointers
iii)in order to calculate the address of the next node you need to remember the address of the
previous node
iv)xor lists are much efficient than single, doubly linked lists and arrays
a) i, ii, iii, iv
b) i, ii, iii
c) i, ii
d) i
View Answer

Answer: b
Explanation: Xor lists requires same time for most of the operations as arrays would require.

7. What’s wrong with this code which returns xor of two nodes address ?

//struct is common userdefined datatype in c/c++ and class is it's


alternative

struct node* XOR (struct node *a, struct node *b)


{
return ((int) (a) ^ (int) (b)); //this logic is used to fill the
nodes with address of a xor linked list
}

a) nothing wrong. everything is fine


b) type casting at return is missing
c) parameters are wrong
d) total logic is wrong
View Answer

Answer: b
Explanation: It must be typecasted– return (struct node*)((int) (a) (int) (b));

8. Given 10,8,6,7,9
swap the above numbers such that finally you got 6,7,8,9,10
so now reverse 10
9,7,6,8,10
now reverse 9
8,6,7,9,10
7,6,8,9,10
6,7,8,9,10
at this point 6 is ahead so no more reversing can be done so stop.
To implement above algorithm which datastructure is better and why ?
a) linked list. because we can swap elements easily
b) arrays. because we can swap elements easily
c) xor linked list. because there is no overhead of pointers and so memory is saved
d) doubly linked list. because you can traverse back and forth
View Answer

Answer: c
Explanation: XOR linked lists are used to reduce the memory by storing the XOR values of
address instead of actual address in pointers.
advertisement

9. Consider the following pseudocode of insertion in XOR list and write the approximate
code snippet of it.

void xor-linked-list insert(struct node **head_ref, int value)


{
node *new_node = new (struct node);
new_node->value = value;
new_node->nodepointerxored = xor (*head_ref, NULL);
if (*head_pointer == NULL)
{
printf("invalid");
}
else
{
let b,c,d are nodes and a is to be inserted at beginning, a address
field must contain NULL xor b and b
address filed must be a xor c.
}
*head_pointer = new_node;
}

a)

node* next = XOR ((*head_ref)->npx, NULL);


(*head_ref)->npx = XOR (new_node, next);
b)

advertisement
node* next = XOR ((*head_ref)->npx, NULL);
(*head_ref) = XOR (new_node, next);

c)

node* next = XOR ((*head_ref)->npx, NULL);


(*head_ref)->npx->npx = XOR (new_node, next);

d)

node* next = XOR ((*head_ref), NULL);


(*head_ref)->npx = XOR (new_node, next);
View Answer
Answer: a
Explanation: They code for the english is
node* next = XOR ((*head_ref)->npx, NULL);
(*head_ref)->npx = XOR (new_node, next);

10. In the above question would using arrays and swaping of elements in place of xor linked
list would have been more efficient ?
a) no not all
b) yes arrays would have been better than xor lists
c) both would be same in efficiency
d) can’t say
View Answer

Answer: b
Explanation: The locality of a normal array is faster in memory and moreover one has to
traverse n-nodes to reach the target to reverse in case of xor linked list.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Self Organizing List Multiple Choice Questions and Answers (MCQs)
» Next - Data Structure Questions and Answers – Free List
Categories Data Structure MCQs, DS MCQs 4 - Types of Lists Post navigation
Self Organizing List Multiple Choice Questions and Answers (MCQs)
Data Structure Questions and Answers – Free List
advertisement
advertisement
Recommended Posts:

1. C++ Programming Examples on Graph Problems & Algorithms


2. Python Programming Examples
3. Data Science Questions and Answers
4. Python Programming Examples on Graphs
5. C Programming Examples on Stacks & Queues
6. C Programming Examples
7. C Programming Examples on Combinatorial Problems & Algorithms
8. Data Structures & Algorithms II – Questions and Answers
9. C Tutorials
10. Python Programming Examples on Trees
11. C Programming Examples using Recursion
12. C Programming Examples on Trees
13. C Programming Examples without using Recursion
14. C# Programming Examples on Data Structures
15. Java Programming Examples on Data-Structures
16. C Programming Examples on Data-Structures
17. C++ Programming Examples on Data-Structures
18. Data Structure Questions and Answers
19. Python Programming Examples on Linked Lists
20. C Programming Examples on Linked List

advertisement

Data Structure Questions and Answers –


Free List
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Free List―.

1. Free lists are used in


a) static memory allocation
b) dynamic memory allocation
c) contagious allocations
d) are used for speeding up linked list operations
View Answer

Answer: b
Explanation: Their property is meant for dynamic allocations.
advertisement

2. What are implicit and explicit implementations of freelists?


a) garbage collection and new or malloc operators respectively
b) new or malloc and garbage collection respectively
c) implicit implementation is not favored
d) explicit implementation is not favored
View Answer

Answer: a
Explanation: Gc and new most widely known.

3. What datastructures can be used in implementing a free list?


a) only linked list
b) linked list or sort trees
c) arrays
d) trees
View Answer

Answer: b
Explanation: Sort trees can also be used in impelementing free lists which remaincomplex.

4. What are different ways of implementing free lists and which is simple among them?
a) best fit, first fit, worst fit, simple-first fit
b) best fit, first fit, worst fit, simple-best fit
c) best fit, first fit, worst fit, simple-worst fit
d) best fit simple-best fit
View Answer

Answer: a
Explanation: The†‬simplest form of memory management system can be called as first-
fit.†‬a device or system maintains a single†‬list of free memory locations.â€
‬When request to memory is sent,†‬the list is searched and the first block that is large
enough is returned.

5. What is buddy memory management of free lists ?


a) modified version of first fit
b) buddy allocation keeps several†‬free lists,†‬each one holds blocks which are of
one particular size
c) modified version of best fit
d) a tree representation of free lists
View Answer

Answer: b
Explanation: When an allocation request is received,†‬the list that holds blocks that are
just large enough to satisfy the request are considered, and an open location is returned.â€
‬If no†‬free†‬blocks that are smaller than two times the size that are requested are
available,†‬a larger block is split in two to satisfy the requirements.
advertisement

6. How does implicit free lists(garbage collection) works in adding memory to free list ?
a) whichever comes last will be added to free list
b) whichever comes first will be added to free list
c) certain blocks cannot be used if there are no pointers to them and hence they can be freed
d) makes a probabilistic guess
View Answer

Answer: c
Explanation: When no pointers pointing a block that means it is useless to be in memory.

7. What are the disadvantages in implementing buddy system algorithm for free lists ?
a) internal fragmentation
b) it takes so much space
c) we no more have the hole lists in order of memory address, so it is difficult to detect if 2
holes remain adjacent in memory and shall be merged into one hole
d) both a and c are correct
View Answer

Answer: d
Explantion: Internal fragmentation is an issue to be dealt and it takes so much space.

8. Assume there is a free list which contains nodes and is filled with a value if it is already
assigned and the value will be the size of requested block else will be 0.

z = startpoint;
while ((z < end) && \\ didn't reach end
(*z <= len)) \\ too small to satisfy request
{
assign this block
}

The above code represents what ?


a) code for first fit
b) code for best fit
c) code for worst fit
d) none of the mentioned
View Answer

Answer: a
Explanation: As z is start point and now from beginning we are moving and checking if we
reached end and then checking size naively assigning the first block which is bigger than
required size hence it is first fit.
advertisement

9. How are free blocks linked together mostly and in what addressing order?
a) circular linked list and increasing addressing order
b) linked list and decreasing addressing order
c) linked list and in no addressing order
d) none of the mentioned
View Answer

Answer: a
Explanation: A common way is circular linked list and address are arranged in increasing
order because merging would be easier which is actually a problem in buddy memory
allocation.
10. Accessing free list very frequently for wide range of addresses can lead to
a) paging
b) segmentation fault
c) memory errors
d) cache problems
View Answer

Answer: a
Explanation: Paging in/out of disk will be caused.

Sanfoundry Global Education & Learning Series – Data Structure.

advertisement

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Xor Linked List
» Next - Data Structure Questions and Answers – Binary Trees using Array
Categories Data Structure MCQs, DS MCQs 4 - Types of Lists Post navigation
Data Structure Questions and Answers – Xor Linked List
Data Structure Questions and Answers – Binary Trees using Array
advertisement
advertisement

Recommended Posts:

1. Java Programming Examples on Multithreading


2. Data Science Questions and Answers
3. Java Programming Examples on Classes
4. Java Programming Examples on Java.Lang
5. C Programming Examples without using Recursion
6. Java Programming Examples on Collections
7. Java Programming Examples
8. VHDL Questions and Answers
9. C Programming Examples
10. Java Programming Examples on Exception Handling
11. C# Programming Examples on Files
12. Python Programming Examples on Linked Lists
13. C# Programming Examples on Data Structures
14. Operating System Questions and Answers
15. C Programming Examples on Stacks & Queues
16. C++ Programming Examples on Data-Structures
17. Java Programming Examples on Data-Structures
18. C Programming Examples on Data-Structures
19. C Programming Examples on Linked List
20. Data Structure Questions and Answers

advertisement

Data Structure Questions and Answers –


Binary Trees using Array
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Binary Trees using Array―.

1. How many children does a binary tree have?


a) 2
b) any number of children
c) 0 or 1 or 2
d) 0 or 1
View Answer

Answer: c
Explanation: Can have atmost 2 nodes.
advertisement

2. What is/are the disadvantages of implementing tree using normal arrays?


a) difficulty in knowing children nodes of a node
b) difficult in finding the parent of a node
c) have to know the maximum number of nodes possible before creation of trees
d) difficult to implement
View Answer

Answer: c
Explanation: The size of array is fixed in normal arrays. We need to know the number of
nodes in the tree before array declaration. It is the main disadvantage of using arrays to
represent binary trees.

3. What must be the ideal size of array if the height of tree is ‘l’?
a) 2l-1
b) l-1
c) l
d) 2l
View Answer

Answer: a
Explanation: Maximum elements in a tree (complete binary tree in worst case) of height
‘L’ is 2L-1. Hence size of array is taken as 2L-1.
4. What are the children for node ‘w’ of a complete-binary tree in an array
representation?
a) 2w and 2w+1
b) 2+w and 2-w
c) w+1/2 and w/2
d) w-1/2 and w+1/2
View Answer

Answer: a
Explanation: The left child is generally taken as 2*w whereas the right child will be taken as
2*w+1 because root node is present at index 0 in the array and to access every index position
in the array.

5. What is the parent for a node ‘w’ of a complete binary tree in an array representation
when w is not 0?
a) floor(w-1/2)
b) ceil(w-1/2)
c) w-1/2
d) w/2
View Answer

Answer: a
Explanation: Floor of w-1/2 because we can’t miss a node.
advertisement

6. If the tree is not a complete binary tree then what changes can be made for easy access of
children of a node in the array?
a) every node stores data saying which of its children exist in the array
b) no need of any changes continue with 2w and 2w+1, if node is at i
c) keep a seperate table telling children of a node
d) use another array parallel to the array with tree
View Answer

Answer: a
Explanation: Array cannot represent arbitrary shaped trees. It can only be used in case of
complete trees. If every node stores data saying that which of its children exists in the array
then elements can be accessed easily.

7. What must be the missing logic in place of missing lines for finding sum of nodes of
binary tree in alternate levels?

//e.g:-consider -complete binary tree:-height-3, [1,2,3,4,5,6,7]-answer


must be 23
n=power(2,height)-1; //assume input is height and a[i] contains tree
elements
for(i=1;i<=n;)
{
for(j=1;j<=pow(2,currentlevel-1);j++) //present level is
initialized to 1 and sum is initialized to 0
{
sum=sum+a[i];
i=i+1;
}
//missing logic
}

a)

i=i+pow(2,currentlevel);
currentlevel=currentlevel+2;
j=1;

b)

advertisement
i=i+pow(2,currentlevel);
currentlevel=currentlevel+2;
j=0;

c)

i=i-pow(2,currentlevel);
currentlevel=currentlevel+2;
j=1;

d)

advertisement
i=i+pow(2,currentlevel);
currentlevel=currentlevel+1;
j=1;
View Answer
Answer: a
Explanation: The i value must skip through all nodes in the next level and current level must
be one+next level.

8. Consider a situation of writing a binary tree into a file with memory storage efficiency in
mind, is array representation of tree is good?
a) yes because we are overcoming the need of pointers and so space efficiency
b) yes because array values are indexable
c) No it is not efficient in case of sparse trees and remaning cases it is fine
d) No linked list representation of tree is only fine
View Answer

Answer: c
Explanation: In case of sparse trees (where one node per level in worst cases), the array size
(2h)-1 where h is height but only h indexes will be filled and (2h)-1-h nodes will be left
unused leading to space wastage.

9. Why is heap implemented using array representations than tree(linked list) representations
though both tree representations and heaps have same complexities?

for binary heap


-insert: O(log n)
-delete min: O(log n)

for a tree
-insert: O(log n)
-delete: O(log n)

Then why go with array representation when both are having same values ?
a) arrays can store trees which are complete and heaps are not complete
b) lists representation takes more memory hence memory efficiency is less and go with arrays
and arrays have better caching
c) lists have better caching
d) In lists insertion and deletion is difficult
View Answer

Answer: b
Explanation: In memory the pointer address for next node may not be adjacent or nearer to
each other and also array have wonderful caching power from os and manipulating pointers is
a overhead. Heap data structure is always a complete binary tree.

10. Can a tree stored in an array using either one of inorder or post order or pre order
traversals be again reformed?
a) Yes just traverse through the array and form the tree
b) No we need one more traversal to form a tree
c) No in case of sparse trees
d) Yes by using both inorder and array elements
View Answer

Answer: b
Explanation: We need any two traversals for tree formation but if some additional stuff or
techniques are used while storing a tree in an array then one traversal can facilitate like also
storing null values of a node in array.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Free List
» Next - Data Structure Questions and Answers – Binary Trees using Linked Lists
Categories Data Structure MCQs, DS MCQs 5 - Binary Trees Post navigation
Data Structure Questions and Answers – Free List
Data Structure Questions and Answers – Binary Trees using Linked Lists
advertisement
advertisement
Recommended Posts:

1. Java Programming Examples on Graph Problems & Algorithms


2. Java Programming Examples on Combinatorial Problems & Algorithms
3. C++ Programming Examples on Graph Problems & Algorithms
4. C# Programming Examples on Arrays
5. C Programming Examples on Graph Problems & Algorithms
6. C Programming Examples on Combinatorial Problems & Algorithms
7. C Programming Examples on Arrays
8. Python Programming Examples on Searching and Sorting
9. C Programming Examples
10. C Programming Examples on Linked List
11. C Programming Examples using Recursion
12. Python Programming Examples on Linked Lists
13. C Programming Examples without using Recursion
14. Java Programming Examples on Data-Structures
15. C# Programming Examples on Data Structures
16. C Programming Examples on Data-Structures
17. C++ Programming Examples on Data-Structures
18. Data Structure Questions and Answers
19. Python Programming Examples on Trees
20. Data Structure Questions and Answers – Binary Heap

advertisement

Data Structure Questions and Answers –


Binary Trees using Linked Lists
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Binary Trees using Linked Lists―.

1. Advantages of linked list representation of binary trees over arrays?


a) dynamic size
b) ease of insertion/deletion
c) ease in randomly accessing a node
d) both dynamic size and ease in insertion/deletion
View Answer

Answer: d
Explanation: It has both dynamic size and ease in insertion and deletion as advantages.
advertisement

2. Disadvantages of linked list representation of binary trees over arrays?


a) Randomly accessing is not possible
b) Extra memory for a pointer is needed with every element in the list
c) Difficulty in deletion
d) Random access is not possible and extra memory with every element
View Answer

Answer: d
Explanation: Random access is not possible with linked lists.

3. Which of the following traversing algorithm is not used to traverse in a tree?


a) Post order
b) Pre order
c) Post order
d) Randomized
View Answer

Answer: d
Explanation: Generally, all nodes in a tree are visited by using preorder, inorder and
postorder traversing algorithms.

4. Level order traversal of a tree is formed with the help of


a) breadth first search
b) depth first search
c) dijkstra’s algorithm
d) prims algorithm
View Answer

Answer: a
Explanation: Level order is similar to bfs.

5. Identify the reason which doesn’t play a key role to use threaded binary trees?
a) The storage required by stack and queue is more
b) The pointers in most of nodes of a binary tree are NULL
c) It is Difficult to find a successor node
d) They occupy less size
View Answer

Answer: d
Explanation: Threaded binary trees are introduced to make the Inorder traversal faster
without using any stack or recursion. Stack and Queue require more space and pointers in the
majority of binary trees are null and difficulties are raised while finding successor nodes. Size
constraints are not taken on threaded binary trees, but they occupy less space than a
stack/queue.
advertisement

6. The following lines talks about deleting a node in a binary tree.(the tree property must not
be violated after deletion)
i) from root search for the node to be deleted
ii)
iii) delete the node at
what must be statement ii) and fill up statement iii)
a) ii)-find random node,replace with node to be deleted. iii)- delete the node
b) ii)-find node to be deleted. iii)- delete the node at found location
c) ii)-find deepest node,replace with node to be deleted. iii)- delete a node
d) ii)-find deepest node,replace with node to be deleted. iii)- delete the deepest node
View Answer

Answer: d
Explanation: We just replace a to be deleted node with last leaf node of a tree. this must not
be done in case of BST or heaps.

7. What may be the psuedo code for finding the size of a tree?
a) find_size(root_node–>left_node) + 1 + find_size(root_node–>right_node)
b) find_size(root_node–>left_node) + find_size(root_node–>right_node)
c) find_size(root_node–>right_node) – 1
d) find_size(root_node–>left_node + 1
View Answer

Answer: a
Explanation: Draw a tree and analyze the expression. we are always taking size of left subtree
and right subtree and adding root value(1) to it and finally printing size.

8. What is missing in this logic of finding a path in the tree for a given sum (i.e checking
whether there will be a path from roots to leaf nodes with given sum)?

checkSum(struct bin-treenode *root , int sum) :


if(root==null)
return sum as 0
else :
leftover_sum=sum-root_node-->value
//missing

a) code for having recursive calls to either only left tree or right trees or to both subtrees
depending on their existence
b) code for having recursive calls to either only left tree or right trees
c) code for having recursive calls to either only left tree
d) code for having recursive calls to either only right trees
View Answer

Answer: a
Explanation: if(left subtree and right subtree) then move to both subtrees
else if only left subtree then move to left subtree carrying leftover_sum parameter
else if only right subtree then move to right subtree carrying leftover_sum parameter.
advertisement
9. What must be the missing logic below so as to print mirror of a tree as below as an
example?

if(rootnode):
mirror(rootnode-->left)
mirror(rootnode-->right)

//missing

end

a) swapping of left and right nodes is missing


b) swapping of left with root nodes is missing
c) swapping of right with root nodes is missing
d) nothing is missing
View Answer

Answer: a
Explanation: Mirror is another tree with left and right children of nodes are interchanged as
shown in the figure.

10. What is the code below trying to print?

void print(tree *root,tree *node)


{
if(root ==null) return 0
if(root-->left==node || root-->right==node || print(root-
>left,node)||printf(root->right,node)
{
print(root->data)
}
}

a) just printing all nodes


b) not a valid logic to do any task
c) printing ancestors of a node passed as argument
d) printing nodes from leaf node to a node passed as argument
View Answer

Answer: c
Explanation: We are checking if left or right node is what the argument sent or else if not the
case then move to left node or right node and print all nodes while searching for the argument
node.
advertisement
Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Binary Trees using Array
» Next - Binary Tree Operations Multiple Choice Questions and Answers (MCQs)
Categories Data Structure MCQs, DS MCQs 5 - Binary Trees Post navigation
Data Structure Questions and Answers – Binary Trees using Array
Binary Tree Operations Multiple Choice Questions and Answers (MCQs)
advertisement
advertisement

Recommended Posts:

1. Data Structures & Algorithms II – Questions and Answers


2. Python Programming Examples on Stacks & Queues
3. Python Programming Examples on Searching and Sorting
4. C Programming Examples on Arrays
5. C Programming Examples
6. Java Programming Examples on Graph Problems & Algorithms
7. Python Programming Examples on Graphs
8. C++ Programming Examples on Graph Problems & Algorithms
9. C Programming Examples using Recursion
10. C# Programming Examples on Data Structures
11. C Programming Examples on Graph Problems & Algorithms
12. Java Programming Examples on Data-Structures
13. C Programming Examples on Data-Structures
14. C++ Programming Examples on Data-Structures
15. C Programming Examples without using Recursion
16. Data Structure Questions and Answers
17. C Programming Examples on Linked List
18. Python Programming Examples on Linked Lists
19. C++ Program to Perform Postorder Recursive Traversal of a Given Binary Tree
20. C++ Program to Perform Preorder Recursive Traversal of a Given Binary Tree

advertisement

Binary Tree Operations Multiple Choice


Questions and Answers (MCQs)
« Prev
Next »
This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Binary Tree Operations―.

1. What is the maximum number of children that a binary tree node can have?
a) 0
b) 1
c) 2
d) 3
View Answer

Answer: c
Explanation: In a binary tree, a node can have atmost 2 nodes (i.e.) 0,1 or 2 left and right
child.
advertisement

2. The following given tree is an example for?

a) Binary tree
b) Binary search tree
c) Fibonacci tree
d) AVL tree
View Answer

Answer: a
Explanation: The given tree is an example for binary tree since has got two children and the
left and right children do not satisfy binary search tree’s property, Fibonacci and AVL
tree.

3. A binary tree is a rooted tree but not an ordered tree.


a) true
b) false
View Answer

Answer: b
Explanation: A binary tree is a rooted tree and also an ordered tree (i.e) every node in a
binary tree has at most two children.

4. How many common operations are performed in a binary tree?


a) 1
b) 2
c) 3
d) 4
View Answer
Answer: c
Explanation: Three common operations are performed in a binary tree- they are insertion,
deletion and traversal.

5. What is the traversal strategy used in the binary tree?


a) depth-first traversal
b) breadth-first traversal
c) random traversal
d) Priority traversal
View Answer

Answer: b
Explanation: Breadth first traversal, also known as level order traversal is the traversal
strategy used in a binary tree. It involves visiting all the nodes at a given level.
advertisement

6. How many types of insertion are performed in a binary tree?


a) 1
b) 2
c) 3
d) 4
View Answer

Answer: b
Explanation: Two kinds of insertion operation is performed in a binary tree- inserting a leaf
node and inserting an internal node.

7. What operation does the following diagram depict?

a) inserting a leaf node


b) inserting an internal node
c) deleting a node with 0 or 1 child
d) deleting a node with 2 children
View Answer

Answer: c
Explanation: The above diagram is a depiction of deleting a node with 0 or 1 child since the
node D which has 1 child is deleted.
8. General ordered tree can be encoded into binary trees.
a) true
b) false
View Answer

Answer: a
Explanation: General ordered tree can be mapped into binary tree by representing them in a
left-child-right-sibling way.

9. How many bits would a succinct binary tree occupy?


a) n+O(n)
b) 2n+O(n)
c) n/2
d) n
View Answer

Answer: b
Explanation: A succinct binary tree occupies close to minimum possible space established by
lower bounds. A succinct binary tree would occupy 2n+O(n) bits.
advertisement

10. The average depth of a binary tree is given as?


a) O(N)
b) O(√N)
c) O(N2)
d) O(log N)
View Answer

Answer: d
Explanation: The average depth of a binary tree is given as O(√N). In case of a binary
search tree, it is O(log N).

11. How many orders of traversal are applicable to a binary tree (In General)?
a) 1
b) 4
c) 2
d) 3
View Answer

Answer: d
Explanation: The three orders of traversal that can be applied to a binary tree are in-order,
pre-order and post order traversal.

12. If binary trees are represented in arrays, what formula can be used to locate a left child, if
the node has an index i?
a) 2i+1
b) 2i+2
c) 2i
d) 4i
View Answer
Answer: a
Explanation: If binary trees are represented in arrays, left children are located at indices 2i+1
and right children at 2i+2.

13. Using what formula can a parent node be located in an array?


a) (i+1)/2
b) (i-1)/2
c) i/2
d) 2i/2
View Answer

Answer: b
Explanation: If a binary tree is represented in an array, parent nodes are found at indices (i-
1)/2.
advertisement

14. Which of the following properties are obeyed by all three tree – traversals?
a) Left subtrees are visited before right subtrees
b) Right subtrees are visited before left subtrees
c) Root node is visited before left subtree
d) Root node is visited before right subtree
View Answer

Answer: a
Explanation: In preorder, inorder and postorder traversal the left subtrees are visited before
the right subtrees. In Inorder traversal, the Left subtree is visited first then the Root node then
the Right subtree. In postorder traversal, the Left subtree is visited first, then Right subtree
and then the Root node is visited.

15. Construct a binary tree using the following data.


The preorder traversal of a binary tree is 1, 2, 5, 3, 4. The inorder traversal of the same binary
tree is 2, 5, 1, 4, 3.

a)
b)

c)

d)
View Answer

Answer: d
Explanation: Here,
Preorder Traversal is 1, 2, 5, 3, 4
Inorder Traversal is 2, 5, 1, 4, 3
Root node of binary tree is the first node in Preorder traversal.
The rough sketch of tree is:

Second node in preorder traversal is 2. This makes 5 as right child to node 2. The fourth node
in preorder traversal is 3. This makes 4 as right child to node 3. Thus the final tree is:

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Binary Trees using Linked Lists
» Next - Data Structure Questions and Answers – Preorder Traversal
Categories Data Structure MCQs, DS MCQs 5 - Binary Trees Post navigation
Data Structure Questions and Answers – Binary Trees using Linked Lists
Data Structure Questions and Answers – Preorder Traversal
advertisement
advertisement

Recommended Posts:

1. Java Programming Examples on Data-Structures


2. Python Programming Examples on Searching and Sorting
3. C++ Algorithms, Problems & Programming Examples
4. C++ Programming Examples on Hard Graph Problems & Algorithms
5. C Programming Examples on Bitwise Operations
6. Python Programming Examples on Graphs
7. C Programming Examples on Data-Structures
8. C Programming Examples
9. C++ Programming Examples on Data-Structures
10. C Programming Examples on Linked List
11. Java Programming Examples on Graph Problems & Algorithms
12. C++ Programming Examples on Graph Problems & Algorithms
13. Data Structure Questions and Answers
14. Python Programming Examples on Linked Lists
15. C Programming Examples on Graph Problems & Algorithms
16. C Programming Examples using Recursion
17. C# Programming Examples on Data Structures
18. C Programming Examples without using Recursion
19. Python Programming Examples on Trees
20. C Programming Examples on Trees

advertisement

Data Structure Questions and Answers –


Preorder Traversal
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Preorder Traversal―.

1. For the tree below, write the pre-order traversal.

a) 2, 7, 2, 6, 5, 11, 5, 9, 4
b) 2, 7, 5, 2, 6, 9, 5, 11, 4
c) 2, 5, 11, 6, 7, 4, 9, 5, 2
d) 2, 7, 5, 6, 11, 2, 5, 4, 9
View Answer

Answer: a
Explanation: Pre order traversal follows NLR(Node-Left-Right).
advertisement
2. For the tree below, write the post-order traversal.

a) 2, 7, 2, 6, 5, 11, 5, 9, 4
b) 2, 7, 5, 2, 6, 9, 5, 11, 4
c) 2, 5, 11, 6, 7, 4, 9, 5, 2
d) 2, 7, 5, 6, 11, 2, 5, 4, 9
View Answer

Answer: c
Explanation: Post order traversal follows LRN(Left-Right-Node).

3. Select the code snippet which performs pre-order traversal.


a)

public void preorder(Tree root)


{
System.out.println(root.data);
preorder(root.left);
preorder(root.right);
}

b)

public void preorder(Tree root)


{
preorder(root.left);
System.out.println(root.data);
preorder(root.right);
}

c)

advertisement
public void preorder(Tree root)
{
System.out.println(root.data);
preorder(root.right);
preorder(root.left);
}

d)

public void preorder(Tree root)


{
preorder(root.right);
preorder(root.left);
System.out.println(root.data);
}
View Answer
Answer: a
Explanation: Pre-order traversal follows NLR(Node-Left-Right).

4. Select the code snippet which performs post-order traversal.


a)
public void postorder(Tree root)
{
System.out.println(root.data);
postorder(root.left);
postorder(root.right);
}

b)

public void postorder(Tree root)


{
postorder(root.left);
postorder(root.right);
System.out.println(root.data);
}

c)

advertisement
public void postorder(Tree root)
{
System.out.println(root.data);
postorder(root.right);
postorder(root.left);
}

d)

public void postorder(Tree root)


{
postorder(root.right);
System.out.println(root.data);
postorder(root.left);
}
View Answer
Answer: b
Explanation: Post order traversal follows NLR(Left-Right-Node).

5. Select the code snippet that performs pre-order traversal iteratively.


a)
public void preOrder(Tree root)
{
if (root == null) return;
Stack<Tree> stk = new Stack<Tree>();
st.add(root);
while (!stk.empty())
{
Tree node = stk.pop();
System.out.print(node.data + " ");
if (node.left != null) stk.push(node.left);
if (node.right != null) stk.push(node.right);
}
}

b)

public void preOrder(Tree root)


{
if (root == null) return;
Stack<Tree> stk = new Stack<Tree>();
while (!stk.empty())
{
Tree node = stk.pop();
System.out.print(node.data + " ");
if (node.right != null) stk.push(node.right);
if (node.left != null) stk.push(node.left);
}
}

c)

public void preOrder(Tree root)


{
if (root == null) return;
Stack<Tree> stk = new Stack<Tree>();
st.add(root);
while (!stk.empty())
{
Tree node = stk.pop();
System.out.print(node.data + " ");
if (node.right != null) stk.push(node.right);
if (node.left != null) stk.push(node.left);
}
}

d)

advertisement
public void preOrder(Tree root)
{
if (root == null) return;
Stack<Tree> stk = new Stack<Tree>();
st.add(root);
while (!stk.empty())
{
Tree node = stk.pop();
System.out.print(node.data + " ");
if (node.right != null) stk.push(node.left);
if (node.left != null) stk.push(node.right);
}
}
View Answer
Answer: c
Explanation: Add the root to the stack first, then continously check for the right and left
children of the top-of-the-stack.

6. Select the code snippet that performs post-order traversal iteratively.


a)
public void postorder(Tree root)
{
if (root == null)
return;
Stack<Tree> stk = new Stack<Tree>();
Tree node = root;
while (!stk.isEmpty() || node != null)
{
while (node != null)
{
if (node.right != null)
stk.add(node.left);
stk.add(node);
node = node.right;
}
node = stk.pop();
if (node.right != null && !stk.isEmpty() && node.right ==
stk.peek())
{
Trees nodeRight = stk.pop();
stk.push(node);
node = nodeRight;
} else
{
System.out.print(node.data + " ");
node = null;
}
}
}

b)

public void postorder(Tree root)


{
if (root == null)
return;
Stack<Tree> stk = new Stack<Tree>();
Tree node = root;
while (!stk.isEmpty() || node != null)
{
while (node != null)
{
if (node.right != null)
stk.add(node.right);
stk.add(node);
node = node.left;
}
node = stk.pop();
if (node.right != null && !stk.isEmpty() && node.right ==
stk.peek())
{
Trees nodeRight = stk.pop();
stk.push(node);
node = nodeRight;
} else
{
System.out.print(node.data + " ");
node = null;
}
}
}

c)

public void postorder(Tree root)


{
if (root == null)
return;
Stack<Tree> stk = new Stack<Tree>();
Tree node = root;
while (!stk.isEmpty() || node != null)
{
while (node != null)
{
if (node.right != null)
stk.add(node.right);
stk.add(node);
node = node.left;
}
node = stk.pop();
if (node.right != null)
{
Trees nodeRight = stk.pop();
stk.push(node);
node = nodeRight;
} else
{
System.out.print(node.data + " ");
node = null;
}
}
}

d)

public void postorder(Tree root)


{
if (root == null)
return;
Stack<Tree> stk = new Stack<Tree>();
Tree node = root;
while (!stk.isEmpty() || node != null)
{
while (node != null)
{
if (node.right != null)
stk.add(node.left);
stk.add(node);
node = node.left;
}
node = stk.pop();
if (node.right != null)
{
Trees nodeRight = stk.pop();
stk.push(node);
node = nodeLeft;
} else
{
System.out.print(node.data + " ");
node = null;
}
}
}
View Answer
Answer: b
Explanation: The left and right children are added first to the stack, followed by the node,
which is then popped. Post-order follows LRN policy.

7. What is the time complexity of pre-order traversal in the iterative fashion?


a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn)
View Answer

Answer: b
Explanation: Since you have to go through all the nodes, the complexity becomes O(n).

8. What is the space complexity of the post-order traversal in the recursive fashion? (d is the
tree depth and n is the number of nodes)
a) O(1)
b) O(nlogd)
c) O(logd)
d) O(d)
View Answer

Answer: d
Explanation: In the worst case we have d stack frames in the recursive call, hence the
complexity is O(d).

9. To obtain a prefix expression, which of the tree traversals is used?


a) Level-order traversal
b) Pre-order traversal
c) Post-order traversal
d) In-order traversal
View Answer

Answer: b
Explanation: As the name itself suggests, pre-order traversal can be used.

10. Consider the following data. The pre order traversal of a binary tree is A, B, E, C, D. The
in order traversal of the same binary tree is B, E, A, D, C. The level order sequence for the
binary tree is _________
a) A, C, D, B, E
b) A, B, C, D, E
c) A, B, C, E, D
d) D, B, E, A, C
View Answer

Answer: b
Explanation: The inorder sequence is B, E, A, D, C and Preorder sequence is A, B, E, C, D.
The tree constructed with the inorder and preorder sequence is

The levelorder traversal (BFS traversal) is A, B, C, E, D.

11. Consider the following data and specify which one is Preorder Traversal Sequence,
Inorder and Postorder sequences.
S1: N, M, P, O, Q
S2: N, P, Q, O, M
S3: M, N, O, P, Q
a) S1 is preorder, S2 is inorder and S3 is postorder
b) S1 is inorder, S2 is preorder and S3 is postorder
c) S1 is inorder, S2 is postorder and S3 is preorder
d) S1 is postorder, S2 is inorder and S3 is preorder
View Answer

Answer: c
Explanation: Preorder traversal starts from the root node and postorder and inorder starts
from the left child node of the left subtree. The first node of S3 is different and for S1 and S2
it’s the same. Thus, S3 is preorder traversal and the root node is M. Postorder traversal
visits the root node at last. S2 has the root node(M) at last that implies S2 is postorder
traversal. S1 is inorder traversal as S2 is postorder traversal and S3 is preorder traversal.
Therefore, S1 is inorder traversal, S2 is postorder traversal and S3 is preorder traversal.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!
Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Binary Tree Operations Multiple Choice Questions and Answers (MCQs)
» Next - Postorder Traversal Multiple Choice Questions and Answers (MCQs)
Categories Data Structure MCQs, DS MCQs 5 - Binary Trees Post navigation
Binary Tree Operations Multiple Choice Questions and Answers (MCQs)
Postorder Traversal Multiple Choice Questions and Answers (MCQs)
advertisement
advertisement

Recommended Posts:

1. Data Science Questions and Answers


2. C Programming Examples
3. Python Programming Examples on Stacks & Queues
4. Python Programming Examples on Graphs
5. C Programming Examples on Linked List
6. Data Structures & Algorithms II – Questions and Answers
7. Python Programming Examples on Linked Lists
8. C Programming Examples on Stacks & Queues
9. Java Programming Examples on Graph Problems & Algorithms
10. C++ Programming Examples on Graph Problems & Algorithms
11. Java Programming Examples on Data-Structures
12. C Programming Examples on Graph Problems & Algorithms
13. C++ Programming Examples on Data-Structures
14. C Programming Examples using Recursion
15. C Programming Examples on Data-Structures
16. C Programming Examples without using Recursion
17. Python Programming Examples on Trees
18. C Programming Examples on Trees
19. Data Structure Questions and Answers
20. C# Programming Examples on Data Structures

advertisement

Postorder Traversal Multiple Choice


Questions and Answers (MCQs)
« Prev
Next »

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Postorder Traversal―.

1. In postorder traversal of binary tree right subtree is traversed before visiting root.
a) True
b) False
View Answer
Answer: a
Explanation: Post-order method of traversing involves – i) Traverse left subtree in post-
order, ii) Traverse right subtree in post-order, iii) visit the root.
advertisement

2. What is the possible number of binary trees that can be created with 3 nodes, giving the
sequence N, M, L when traversed in post-order.
a) 15
b) 3
c) 5
d) 8
View Answer

Answer: c
Explanation: 5 binary trees are possible and they are,

3. The post-order traversal of a binary tree is O P Q R S T. Then possible pre-order traversal


will be ________
a) T Q R S O P
b) T O Q R P S
c) T Q O P S R
d) T Q O S P R
View Answer

Answer: c
Explanation: The last, second last nodes visited in post-order traversal are root and it’s
right child respectively. Option T Q R S O P can’t be a pre-order traversal, because nodes
O, P are visited after the nodes Q, R, S. Option T O Q R P S, can’t be valid, because the
pre-order sequence given in option T O Q R P S and given post-order traversal creates a tree
with node T as root and node O as left subtree. Option T Q O P S R is valid. Option T Q O S
P R is not valid as node P is visited after visiting node S.

4. A binary search tree contains values 7, 8, 13, 26, 35, 40, 70, 75. Which one of the
following is a valid post-order sequence of the tree provided the pre-order sequence as 35, 13,
7, 8, 26, 70, 40 and 75?
a) 7, 8, 26, 13, 75, 40, 70, 35
b) 26, 13, 7, 8, 70, 75, 40, 35
c) 7, 8, 13, 26, 35, 40, 70, 75
d) 8, 7, 26, 13, 40, 75, 70, 35
View Answer
Answer: d
Explanation: The binary tree contains values 7, 8, 13, 26, 35, 40, 70, 75. The given pre-order
sequence is 35, 13, 7, 8, 26, 70, 40 and 75. So, the binary search tree formed is

Thus post-order sequence for the tree is 8, 7, 26, 13, 40, 75, 70 and 35.

5. Which of the following pair’s traversals on a binary tree can build the tree uniquely?
a) post-order and pre-order
b) post-order and in-order
c) post-order and level order
d) level order and preorder
View Answer

Answer: b
Explanation: A binary tree can uniquely be created by post-order and in-order traversals.
advertisement

6. A full binary tree can be generated using ______


a) post-order and pre-order traversal
b) pre-order traversal
c) post-order traversal
d) in-order traversal
View Answer

Answer: a
Explanation: Every node in a full binary tree has either 0 or 2 children. A binary tree can be
generated by two traversals if one of them is in-order. But, we can generate a full binary tree
using post-order and pre-order traversals.

7. The maximum number of nodes in a tree for which post-order and pre-order traversals may
be equal is ______
a) 3
b) 1
c) 2
d) any number
View Answer

Answer: b
Explanation: The tree with only one node has post-order and pre-order traversals equal.
8. The steps for finding post-order traversal are traverse the right subtree, traverse the left
subtree or visit the current node.
a) True
b) False
View Answer

Answer: b
Explanation: Left subtree is traversed first in post-order traversal, then the right subtree is
traversed and then the output current node.

9. The pre-order and in-order are traversals of a binary tree are T M L N P O Q and L M N T
O P Q. Which of following is post-order traversal of the tree?
a) L N M O Q P T
b) N M O P O L T
c) L M N O P Q T
d) O P L M N Q T
View Answer

Answer: a
Explanation: The tree generated by using given pre-order and in-order traversal is

Thus, L N M O Q P T will be the post-order traversal.


advertisement

10. For a binary tree the first node visited in in-order and post-order traversal is same.
a) True
b) False
View Answer

Answer: b
Explanation: Consider a binary tree,

Its in-order traversal – 13 14 16 19


Its post-order traversal- 14 13 19 16. Here the first node visited is not same.
11. Find the postorder traversal of the binary tree shown below.

a) P Q R S T U V W X
b) W R S Q P V T U X
c) S W T Q X U V R P
d) S T W U X V Q R P
View Answer

Answer: c
Explanation: In postorder traversal the left subtree is traversed first and then the right subtree
and then the current node. So, the posturer traversal of the tree is, S W T Q X U V R P.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

advertisement

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Data Structure Questions and Answers – Preorder Traversal
» Next - Data Structure Questions and Answers – Inorder Traversal
Categories Data Structure MCQs, DS MCQs 5 - Binary Trees Post navigation
Data Structure Questions and Answers – Preorder Traversal
Data Structure Questions and Answers – Inorder Traversal
advertisement
advertisement

Recommended Posts:

1. C Programming Examples on Data-Structures


2. C++ Programming Examples on Combinatorial Problems & Algorithms
3. Python Programming Examples on Searching and Sorting
4. C++ Programming Examples on Hard Graph Problems & Algorithms
5. Java Programming Examples on Combinatorial Problems & Algorithms
6. C++ Programming Examples on Data-Structures
7. Data Structure Questions and Answers
8. Python Programming Examples on Graphs
9. C Programming Examples on Combinatorial Problems & Algorithms
10. C Programming Examples
11. C++ Programming Examples on Graph Problems & Algorithms
12. C Programming Examples on Linked List
13. Java Programming Examples on Graph Problems & Algorithms
14. Python Programming Examples on Linked Lists
15. C Programming Examples on Graph Problems & Algorithms
16. C# Programming Examples on Data Structures
17. C Programming Examples using Recursion
18. C Programming Examples without using Recursion
19. C Programming Examples on Trees
20. Python Programming Examples on Trees

advertisement

Data Structure Questions and Answers –


Inorder Traversal
« Prev
Next »

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Inorder Traversal―.

1. For the tree below, write the in-order traversal.

a) 6, 2, 5, 7, 11, 2, 5, 9, 4
b) 6, 5, 2, 11, 7, 4, 9, 5, 2
c) 2, 7, 2, 6, 5, 11, 5, 9, 4
d) 2, 7, 6, 5, 11, 2, 9, 5, 4
View Answer

Answer: a
Explanation: In-order traversal follows LNR(Left-Node-Right).
advertisement
2. For the tree below, write the level-order traversal.

a) 2, 7, 2, 6, 5, 11, 5, 9, 4
b) 2, 7, 5, 2, 11, 9, 6, 5, 4
c) 2, 5, 11, 6, 7, 4, 9, 5, 2
d) 2, 7, 5, 6, 11, 2, 5, 4, 9
View Answer

Answer: b
Explanation: Level order traversal follows a breadth first search approach.

3. Select the code snippet which performs in-order traversal.


a)

public void inorder(Tree root)


{
System.out.println(root.data);
inorder(root.left);
inorder(root.right);
}

b)

advertisement
public void inorder(Tree root)
{
inorder(root.left);
System.out.println(root.data);
inorder(root.right);
}

c)

public void inorder(Tree root)


{
System.out.println(root.data);
inorder(root.right);
inorder(root.left);
}

d)

public void inorder(Tree root)


{
inorder(root.right);
inorder(root.left);
System.out.println(root.data);
}
View Answer
Answer: b
Explanation: In-order traversal follows LNR(Left-Node-Right).

4. Select the code snippet which performs level-order traversal.


a)

advertisement
public static void levelOrder(Tree root)
{
Queue<Node> queue=new LinkedList<Node>();
queue.add(root);
while(!queue.isEmpty())
{
Node tempNode=queue.poll();
System.out.println("%d ",tempNode.data);
if(tempNode.left!=null)
queue.add(tempNode.left);
if(tempNode.right!=null)
queue.add(tempNode.right);
}
}

b)

public static void levelOrder(Tree root)


{
Queue<Node> queue=new LinkedList<Node>();
queue.add(root);
while(!queue.isEmpty())
{
Node tempNode=queue.poll();
System.out.println("%d ",tempNode.data);
if(tempNode.left!=null)
queue.add(tempNode.right);
if(tempNode.right!=null)
queue.add(tempNode.left);
}
}

c)

advertisement
public static void levelOrder(Tree root)
{
Queue<Node> queue=new LinkedList<Node>();
queue.add(root);
while(!queue.isEmpty())
{
Node tempNode=queue.poll();
System.out.println("%d ",tempNode.data);
if(tempNode.right!=null)
queue.add(tempNode.left);
if(tempNode.left!=null)
queue.add(tempNode.right);
}
}

d)

public static void levelOrder(Tree root)


{
Queue<Node> queue=new LinkedList<Node>();
queue.add(root);
while(!queue.isEmpty())
{
Node tempNode=queue.poll();
System.out.println("%d ",tempNode.data);
if(tempNode.right!=null)
queue.add(tempNode.left.left);
if(tempNode.left!=null)
queue.add(tempNode.right.right);
}
}
View Answer
Answer: a
Explanation: Firstly add the root node to the queue. Then for all the remaining nodes, pop the
front end of the queue and print it, add the left and right children of the popped node to the
queue.

5. What is the space complexity of the in-order traversal in the recursive fashion? (d is the
tree depth and n is the number of nodes)
a) O(1)
b) O(nlogd)
c) O(logd)
d) O(d)
View Answer

Answer: d
Explanation: In the worst case we have d stack frames in the recursive call, hence the
complexity is O(d).

6. What is the time complexity of level order traversal?


a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn)
View Answer

Answer: b
Explanation: Since you have to go through all the nodes, the complexity becomes O(n).
7. Which of the following graph traversals closely imitates level order traversal of a binary
tree?
a) Depth First Search
b) Breadth First Search
c) Depth & Breadth First Search
d) Binary Search
View Answer

Answer: b
Explanation: Both level order tree traversal and breadth first graph traversal follow the
principle that visit your neighbors first and then move on to further nodes.

8. In a binary search tree, which of the following traversals would print the numbers in the
ascending order?
a) Level-order traversal
b) Pre-order traversal
c) Post-order traversal
d) In-order traversal
View Answer

Answer: d
Explanation: In a binary search tree, a node’s left child is always lesser than the node and
right child is greater than the node, hence an in-order traversal would print them in a non
decreasing fashion.

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice
Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our
social networks below and stay updated with latest contests, videos, internships and jobs!

Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest


Youtube | LinkedIn | Instagram | Facebook | Twitter | Pinterest
« Prev - Postorder Traversal Multiple Choice Questions and Answers (MCQs)
» Next - Data Structure Questions and Answers – Binary Tree Properties
Categories Data Structure MCQs, DS MCQs 5 - Binary Trees Post navigation
Postorder Traversal Multiple Choice Questions and Answers (MCQs)
Data Structure Questions and Answers – Binary Tree Properties
advertisement
advertisement

Recommended Posts:

1. C Programming Examples on Arrays


2. Data Structures & Algorithms II – Questions and Answers
3. C Programming Examples on Stacks & Queues
4. C++ Algorithms, Problems & Programming Examples
5. C Programming Examples
Q.l Following is true for understanding a problem.

a. Knowing the knowledgebase

b. Understanding the subject on which the problem is based

c. Communication with the client

d. All of the above

[Ans : d]

Q.2 ______is the first step in solving the problem.

a. Understanding the problem

b. Identifying the problem

c. Evaluating the solution

d. None of these

[Ans. : b]

Q.3 Two main measures for efficiency of algorithm are _____.

a. processor and memory

b. complexity and capacity

c. data and space

d. time and space

[An. : d]

Q.4 The space factor when determining the efficiency of algorithm is measured by _____.

a. counting the maximum amount of memory needed by the algorithm

b. counting the minimum amount of memory needed by the algorithm

c. counting the average memory needed by the algorithm

d. counting maximum disk space needed by an algorithm

[Ans. :a]

Q.5 The symbol is used to connect two sections on the same page.
a. processing

b. input output

c. off-page connectors

d. on-page connectors

{Ans. : d)

Q.6 Data structure means______.

a. separation of physical representation of data from its logical level

b. a collection of various data element on which various operations for its storage and retrieval can be
done.

c. a logical picture of data type of various data element and just the specification of operations

d. none of these

(Anc : b)

Q.7 Abstract data types means____.

a separation of physical representation of data from its logical level

b A collection of data element on which various operation can be done for its storage and retrieval

c a logical picture of data type of various data element and just the specification of the operations

d none of these

[Ans. : c)

Q.8 The Abstract Data Type(ADT) specifies____.

a the components and structural relationship

b the list of operations that are allowed to be performed

c both a and b

d none of these

(Ans. : c)

Q9 Abstract Complex Add (a , b) Here abstract indicates ?


a C function

b an ADT operator definition

c both a and b

d none of these

[Ans. : b]

Q.10 Primary ADT are_____.?

a stacks

b queues

c linked list

d all of these

[Ans :d]

Q.11 Consider following statement

1. An algorithm is a number of steps to be performed to solve a problem.

2. An algorithm is number of steps and complete implementation for solving the problem.

3. There can be more than one algorithms to solve particular problem.?

a Only 1 is correct

b 2 and 3 are correct

c 1 and 3 are correct

d Only 2 is correct

[Ans. : b]

Q12 The step by step required to solve the problem is called?

a plan

b list

c configuration

d algorithm
[Ans. : d]

Q13 A sub-algorithm is also known as_______?

a function

b module

c flowchart

d both (a) and (b)

[Ans. : d)

Q14 If there exists two functions f(n) and g(n). The constant c>0 and there exists an integer constant
N>=1. If f(n)<=c*g(n) for every integer n>=N then we say that?

a f(n)=O(g(n))

b f(n)=o(g(n))

c f(n)=Q(g(n))

d f(n)=q(g(n))

[Ans. : a]

Q.15 In practice _____ is used to define tight upper bound on growth of function (n)?

a big oh

b big omega

c big theta

d none of these

[Ans. : a]

Q.16 In practice _____ is used to define tight lower bound on growth of function (n)?

a big oh

b big omega

c big theta

d none of these

[Ans. : b]
Q17. Two main measures for the efficiency of an algorithm are_____

a. Processor and memory

b. Complexity and capacity

c. Time and space

d. Data and space

[Ans. : c]

Q18. The time factor when determining the efficiency of algorithm is measured by

a. Counting microseconds

b. Counting the number of key operations

c. Counting the number of statements

d. Counting the kilobytes of algorithm

[Ans. : b]

Q19. The space factor when determining the efficiency of algorithm is measured by

a. Counting the maximum memory needed by the algorithm

b. Counting the minimum memory needed by the algorithm

c. Counting the average memory needed by the algorithm

d. Counting the maximum disk space needed by the algorithm

[Ans. :a]

Q20. Which of the following case does not exist in complexity theory

a. Best case

b. Worst case

c. Average case

d. Null case

[Ans. :d]

Q21. Full form of ADT is _______?


a. Advanced data type

b. Array data type

c. Abstract data type

d. none of these

[Ans. :c]

Q22. The Worst case occur in linear search algorithm when


a) Item is somewhere in the middle of the array
b) Item is not in the array at all
c) Item is the last element in the array
d) Item is the last element in the array or is not there at all

[Ans. :d]

Q23. Which of the following data structure is not linear data structure?

a. Arrays

b. Linked lists

c. Both of above

d. None of above

[Ans. :d]

Q24. Which of the following data structure is linear data structure?

a. Trees

b. Graphs

c. Arrays

d. None of above

[Ans. :c]

Q25. The Average case occur in linear search algorithm


a) When Item is somewhere in the middle of the array
b) When Item is not in the array at all
c) When Item is the last element in the array
d) When Item is the last element in the array or is not there at all

[Ans. :a]
Q26. Which of the following data structure is linear type?

a. Strings

b. Lists

c. Queues

d. All of above

[Ans. :d]

Q27. _____________is a step-by-step procedure for calculation

a. Data structure

b. Abstract Data Type

c. Primitive Data Type

d. Algorithm

[Ans. :d]

Q28. A mathematical-model with a collection of operations defined on that model is called

a. Data structure

b. Abstract Data Type

c. Primitive Data Type

d. Algorithm

[Ans. :d]

Q29. The complexity of the average case of an algorithm is


a) Much more complicated to analyze than that of worst case
b) Much more simpler to analyze than that of worst case
c) Sometimes more complicated and some other times simpler than that of worst case
d) None of the mentioned

[Ans. :a]

Q30. Which of the following is considered an Abstract Data Type?

a. Array

b. reference variable
c. any of the primitive types (e.g., int, double, char)

d. all of the above

[Ans. :d]

Q31. An algorithm must be generic enough to solve all problems of a particular class.

a. Finiteness

b. Definiteness

c. Generality

d. Effectiveness

[Ans. :c]

Q32. The complexity of linear search algorithm is


a) O(n)
b) O(log n)
c) O(n2)
d) O(n log n)

[Ans. :a]

Q33. Input instance for which algorithm take minimum possible time is called

a. Worst case

b. Best case

c. Average case

d. Null case

[Ans. :b]

Q34. Input instance for which algorithm take maximum possible time is called?

a. Worst case

b. Best case

c. Average case

d. Null case

[Ans. :a]
Q35. The time complexity of the algorithm in a best case would be expressed as

a. O(1)

b. O(n)

c. O(n2)

d. O(n+1)

[Ans. :b]

You might also like