Data Structures MCQ | Linear Data Structures – List

Data Structures Multiple Choice Question(MCQ) with Answers

Chapter: Linear Data Structures – List

1. Elements in an array are accessed _____________

a) randomly

Contents
Data Structures Multiple Choice Question(MCQ) with AnswersChapter: Linear Data Structures – List1. Elements in an array are accessed _____________2. Assuming int is of 4bytes, what is the size of int arr[15];?3. In general, the index of the first element in an array is __________4. What are the disadvantages of arrays?5. What are the advantages of arrays?6. Which of the following concepts make extensive use of arrays?7. When does the ArrayIndexOutOfBoundsException occur?8. What is the output of the following Java code?9. What is the output of the following Java code?10. Which of the following is the correct way to declare a multidimensional array in Java?11. How do you instantiate an array in Java?12. How do you initialize an array in C?13. Which of these best describes an array?14. What would be the asymptotic time complexity to add a node at the end of singly linked list, if thepointer is initially pointing to the head of the list?15. What would be the asymptotic time complexity to insert an element at the front of the linked list(head is known)?16. What would be the asymptotic time complexity to find an element in the linked list?17. What would be the asymptotic time complexity to insert an element at the second position in thelinked list?18. The concatenation of two list can performed in O(1) time. Which of the following variation oflinked list can be used?19. Which of the following c code is used to create new node?20. Process of inserting an element in stack is called21. Process of removing an element from stack is called22. In a stack, if a user tries to remove an element from empty stack it is called23. Pushing an element into stack already having five elements and stack size of 5, then stack becomes24. Entries in a stack are “ordered”. What is the meaning of this statement?25. Which of the following is not the application of stack?26. 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?27. What is the value of the postfix expression 6 3 2 4 + – *?28. The postfix form of the expression (A+ B)*(C*D- E)*F / G is?29. The data structure required to check whether an expression contains balanced parenthesis is?30. What data structure would you mostly likely see in a non recursive implementation of a recursivealgorithm?31. The process of accessing data stored in a serial access memory is similar to manipulating data on a32. The postfix form of A*B+C/D is?33. Which data structure is needed to convert infix notation to postfix notation?34. The prefix form of A-B/ (C * D ^ E) is?35. What is the result of the following operation?Top (Push (S, X))36. The prefix form of an infix expression (p + q) – (r * t) is?37. Which data structure is used for implementing recursion?38. When an operand is read, which of the following is done?39. What would be the asymptotic time complexity to add a node at the end of singly linked list, if thepointer is initially pointing to the head of the list?40. What would be the asymptotic time complexity to insert an element at the front of the linked list(head is known)?41. What would be the asymptotic time complexity to find an element in the linked list?42. What would be the asymptotic time complexity to insert an element at the second position in thelinked list?43. The concatenation of two list can performed in O(1) time. Which of the following variation oflinked list can be used?44. Which of the following c code is used to create new node?

b) sequentially

c) exponentially

d) logarithmically

Answer: a

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

a) 15

b) 19

c) 11

d) 60

Answer: d

3. In general, the index of the first element in an array is __________

a) 0

b) -1

c) 2

d) 1

Answer: a

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

Answer: b

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

Answer: d

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

a) Binary trees

b) Scheduling of processes

c) Caching

d) Spatial locality

Answer: d

7. When does the ArrayIndexOutOfBoundsException occur?

a) Compile-time

b) Run-time

c) Not an error

d) Not an exception at all

Answer: b

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[5]);

}

}

a) 4

b) 5

c) ArrayIndexOutOfBoundsException

d) InavlidInputException

Answer: c

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[2]);

System.out.println(arr[4]);

}

}

a) 3 and 5

b) 5 and 3

c) 2 and 4

d) 4 and 2

Answer: a

10. 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;

Answer: c

11. 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

12. 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

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

Answer: b

14. What would be the asymptotic time complexity to add a node at the end of singly linked list, if thepointer is initially pointing to the head of the list?

A. O(1)

B. O(n)

C. θ(n)

D. θ(1)

Answer: C.θ(n)

15. 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)

Answer: A.O(1)

16. 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)

Answer: B.O(n)

17. What would be the asymptotic time complexity to insert an element at the second position in thelinked list?

A. O(1)

B. O(n)

C. O(n2)

D. O(n3)

Answer: A.O(1)

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

A. Singly linked list

B. Doubly linked list

C. Circular doubly linked list

D. Array implementation of list

Answer: C.Circular doubly linked 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));

Answer: A.ptr = (NODE*)malloc(sizeof(NODE));

chapter:  Linear Data Structures -Stacks and Queues

20. Process of inserting an element in stack is called

A. Create

B. Push

C. Evaluation

D. Pop

Answer: B.Push

21. Process of removing an element from stack is called

A. Create

B. Push

C. Evaluation

D. PopAnswer: D.Pop

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

Answer: A.Underflow

23. 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

Answer: A.Overflow

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

26. 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. none

D. none

Answer: B.2

27. What is the value of the postfix expression 6 3 2 4 + – *?

A. 1

B. 40

C. 74

D. -18Answer: D.-18

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 /

29. The data structure required to check whether an expression contains balanced parenthesis is?

A. Stack

B. Queue

C. Array

D. Tree

Answer: A.Stack

30. What data structure would you mostly likely see in a non recursive implementation of a recursivealgorithm?

A. Linked List

B. Stack

C. Queue

D. Tree

Answer: B.Stack

31. 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

Answer: D.Stack

32. The postfix form of A*B+C/D is?

A. *AB/CD+

B. AB*CD/+

C. A*BC+/D

D. ABCD+/*

Answer: B.AB*CD/+

33. Which data structure is needed to convert infix notation to postfix notation?

A. Branch

B. Tree

C. Queue

D. Stack

Answer: D.Stack

34. The prefix form of A-B/ (C * D ^ E) is?

A. -/*^ACBDE

B. -ABCD*^DE

C. -A/B*C^DE

D. -A/BC*^DE

Answer: C.-A/B*C^DE

35. What is the result of the following operation?Top (Push (S, X))

A. X

B. X+S

C. S

D. none

Answer: A.X

36. The prefix form of an infix expression (p + q) – (r * t) is?

A. + pq – *rt

B. – +pqr * t

C. – +pq * rt

D. – + * pqrt

Answer: C.– +pq * rt

37. Which data structure is used for implementing recursion?

A. Queue

B. Stack

C. Array

D. List

Answer: B.Stack

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

39. What would be the asymptotic time complexity to add a node at the end of singly linked list, if thepointer is initially pointing to the head of the list?

A. O(1)

B. O(n)

C. θ(n)

D. θ(1)Answer: C.θ(n

40. 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)Answer: A.O(1)

41. 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)

Answer: B.O(n)

42. What would be the asymptotic time complexity to insert an element at the second position in thelinked list?

A. O(1)

B. O(n)

C. O(n2)

D. O(n3)

Answer: A.O(1)

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

A. Singly linked list

B. Doubly linked list

C. Circular doubly linked list

D. Array implementation of list

Answer: C.Circular doubly linked 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));

Answer: A.ptr = (NODE*)malloc(sizeof(NODE));

Share This Article