0% found this document useful (0 votes)
27 views6 pages

Arrays MCQ

The document contains multiple-choice questions (MCQs) related to arrays, covering topics such as time complexity, array characteristics, and data structures. Key concepts include accessing elements, insertion complexities, and characteristics of arrays in C and Java. The document serves as a study guide for understanding arrays in programming.

Uploaded by

sindhuu7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views6 pages

Arrays MCQ

The document contains multiple-choice questions (MCQs) related to arrays, covering topics such as time complexity, array characteristics, and data structures. Key concepts include accessing elements, insertion complexities, and characteristics of arrays in C and Java. The document serves as a study guide for understanding arrays in programming.

Uploaded by

sindhuu7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

GATE Level MCQs - Arrays

1. What is the time complexity of accessing an element in an array using the index?

A. O(1)

B. O(n)

C. O(log n)

D. O(n log n)

Answer: A. O(1)

2. Which of the following is true about arrays in C?

A. Array size can be changed during runtime

B. Arrays are dynamic structures

C. Array elements are stored in contiguous memory locations

D. Arrays can grow automatically

Answer: C. Array elements are stored in contiguous memory locations

3. What will be the index of the 5th element in a 0-indexed array?

A. 4

B. 5

C. 6

D. 3

Answer: A. 4

4. Which of the following is not a valid array declaration in C?

A. int arr[5];

B. int arr[] = {1,2,3};

C. int[] arr = new int[5];

D. int arr[3] = {1,2,3};


Answer: C. int[] arr = new int[5];

5. Which data structure is most suitable to implement an array with variable size?

A. Stack

B. Queue

C. Linked List

D. Tree

Answer: C. Linked List

6. What is the time complexity to insert an element at the beginning of an array?

A. O(1)

B. O(n)

C. O(log n)

D. O(n log n)

Answer: B. O(n)

7. What is the time complexity to append an element to the end of an array, assuming enough

space is available?

A. O(1)

B. O(n)

C. O(log n)

D. O(n log n)

Answer: A. O(1)

8. Which of the following is used to traverse an array?

A. Loops

B. Recursion

C. Iterators
D. All of the above

Answer: D. All of the above

9. Which of the following is not a characteristic of an array?

A. Fixed size

B. Sequential storage

C. Fast insertion at beginning

D. Random access

Answer: C. Fast insertion at beginning

10. What happens if you try to access an array index out of bounds in C?

A. Compile time error

B. Runtime error

C. Segmentation fault

D. Logical error

Answer: C. Segmentation fault

11. What is the base address of an array?

A. Address of the last element

B. Address of the first element

C. Address after the last element

D. None of the above

Answer: B. Address of the first element

12. What is the result of the expression *(arr + i) in C?

A. Value at arr[i]

B. Address of arr[i]

C. Garbage value
D. Compiler error

Answer: A. Value at arr[i]

13. Which of the following sorting algorithms works best for nearly sorted arrays?

A. Quick Sort

B. Merge Sort

C. Insertion Sort

D. Selection Sort

Answer: C. Insertion Sort

14. Which of these is used to reverse an array efficiently?

A. Stack

B. Queue

C. Two-pointer method

D. Recursion only

Answer: C. Two-pointer method

15. What is the auxiliary space complexity of the merge sort algorithm on arrays?

A. O(1)

B. O(n)

C. O(log n)

D. O(n^2)

Answer: B. O(n)

16. Which of the following best describes a sparse array?

A. An array with many elements

B. An array with mostly zero or empty values

C. An array with unique elements


D. A dynamic array

Answer: B. An array with mostly zero or empty values

17. Which method can be used to search an element in a sorted array efficiently?

A. Linear Search

B. Binary Search

C. Jump Search

D. All of the above

Answer: D. All of the above

18. What is the default value of elements in an integer array in Java?

A. 1

B. 0

C. -1

D. Garbage

Answer: B. 0

19. What is the best case time complexity of linear search?

A. O(n)

B. O(log n)

C. O(1)

D. O(n^2)

Answer: C. O(1)

20. Which data structure is used internally in multidimensional arrays?

A. Single linked list

B. Array of arrays

C. Graph
D. Matrix

Answer: B. Array of arrays

You might also like