# Data Structures MCQ | Linear Data Structures – List

## 1. Elements in an array are accessed _____________

a) randomly

b) sequentially

c) exponentially

d) logarithmically

a) 15

b) 19

c) 11

d) 60

a) 0

b) -1

c) 2

d) 1

## 4. 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

## 5. 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 the first element of an array is 1

d) Easier to store elements of the same data type

## 6. Which of the following concepts make extensive use of arrays?

a) Binary trees

b) Scheduling of processes

c) Caching

d) Spatial locality

## 7. When does the ArrayIndexOutOfBoundsException occur?

a) Compile-time

b) Run-time

c) Not an error

d) Not an exception at all

## 8. 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);

}

}

a) 4

b) 5

c) ArrayIndexOutOfBoundsException

d) InavlidInputException

## 9. 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);

System.out.println(arr);

}

}

a) 3 and 5

b) 5 and 3

c) 2 and 4

d) 4 and 2

a) int[] arr;

b) int arr[[]];

c) int[][]arr;

d) int[[]] arr;

## 11. How do you instantiate an array in Java?

a) int arr[] = new int(3);

b) int arr[];

c) int arr[] = new int;

d) int arr() = new int(3);

## 12. How do you initialize an array in C?

a) int arr = (1,2,3);

b) int arr(3) = {1,2,3};

c) int arr = {1,2,3};

d) int arr(3) = (1,2,3);

## 13. 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

A. O(1)

B. O(n)

C. θ(n)

D. θ(1)

A. O(1)

B. O(n)

C. O(n2)

D. O(n3)

A. O(1)

B. O(n)

C. O(n2)

D. O(n4)

A. O(1)

B. O(n)

C. O(n2)

D. O(n3)

## 18. The concatenation of two list can performed in O(1) time. Which of the following variation oflinked list can be used?

D. Array implementation of list

## 19. 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));

chapter:  Linear Data Structures -Stacks and Queues

A. Create

B. Push

C. Evaluation

D. Pop

A. Create

B. Push

C. Evaluation

## 22. In a stack, if a user tries to remove an element from empty stack it is called

A. Underflow

B. Empty collection

C. Overflow

D. Garbage Collection

A. Overflow

B. Crash

C. Underflow

D. User flow

## 24. 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

Answer: D.There is a Sequential entry that is one by one

## 25. 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 processAnswer: D.Data Transfer between two asynchronous process

A. 1

B. 2

C. none

D. none

A. 1

B. 40

C. 74

## 28. 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 /

Answer: C.AB + CD* E – *F *G /

A. Stack

B. Queue

C. Array

D. Tree

B. Stack

C. Queue

D. Tree

A. Heap

B. Binary Tree

C. Array

D. Stack

A. *AB/CD+

B. AB*CD/+

C. A*BC+/D

D. ABCD+/*

A. Branch

B. Tree

C. Queue

D. Stack

A. -/*^ACBDE

B. -ABCD*^DE

C. -A/B*C^DE

D. -A/BC*^DE

A. X

B. X+S

C. S

D. none

A. + pq – *rt

B. – +pqr * t

C. – +pq * rt

D. – + * pqrt

A. Queue

B. Stack

C. Array

D. List

## 38. When an operand is read, which of the following is done?

A. It is placed on to the output

B. It is placed in the operator stack

C. It is ignored

D. Operator stack is emptied

Answer: A.It is placed on to the output

A. O(1)

B. O(n)

C. θ(n)

A. O(1)

B. O(n)

C. O(n2)

A. O(1)

B. O(n)

C. O(n2)

D. O(n4)

A. O(1)

B. O(n)

C. O(n2)

D. O(n3)

## 43. The concatenation of two list can performed in O(1) time. Which of the following variation oflinked list can be used?

D. Array implementation of list

## 44. 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));