Question : What is an array?
Solution :
Correct Answer : Collection of elements of the same data type stored in contiguous memory locations
Description -
Question : The index of the first element in most programming language arrays is:
Solution :
Correct Answer : 0
Description -
Question : What is the size of the array int arr[10]?
Solution :
Correct Answer : 10
Description -
Question : Which operation takes O(1) time in an array?
Solution :
Correct Answer : Accessing an element by index
Description -
Question : Which memory allocation is used for arrays?
Solution :
Correct Answer : Contiguous
Description -
Question : In an array of size 15, the last valid index is:
Solution :
Correct Answer : 14
Description -
Question : Which data structure is best represented using arrays?
Solution :
Correct Answer : Matrix
Description -
Question : What happens if you access an invalid array index?
Solution :
Correct Answer : Runtime error or undefined behavior
Description -
Question : Which traversal method visits every element exactly once?
Solution :
Correct Answer : Linear Traversal
Description -
Question : What is the time complexity of traversing an array of n elements?
Solution :
Correct Answer : O(n)
Description -
Question : A 2D array is also known as:
Solution :
Correct Answer : Matrix
Description -
Question : How many elements are in a 4 × 5 matrix?
Solution :
Correct Answer : 20
Description -
Question : In a matrix A[3][4], how many rows exist?
Solution :
Correct Answer : 3
Description -
Question : Address calculation in row-major order depends on:
Solution :
Correct Answer : Number of columns
Description -
Question : Which representation is used by C language for multidimensional arrays?
Solution :
Correct Answer : Row-major
Description -
Question : What is the total number of elements in a 3D array A[2][3][4]?
Solution :
Correct Answer : 24
Description -
Question : Which searching algorithm requires a sorted array?
Solution :
Correct Answer : Binary Search
Description -
Question : Worst-case complexity of binary search is:
Solution :
Correct Answer : O(log n)
Description -
Question : Inserting an element at the beginning of an array requires:
Solution :
Correct Answer : Shifting all elements right
Description -
Question : What is the time complexity of insertion at the beginning?
Solution :
Correct Answer : O(n)
Description -
Question : A sparse matrix is a matrix:
Solution :
Correct Answer : Having mostly zero elements
Description -
Question : A matrix of size 100 × 100 contains only 50 non-zero elements. It is:
Solution :
Correct Answer : Sparse Matrix
Description -
Question : Which representation saves memory for sparse matrices?
Solution :
Correct Answer : Both B and C
Description -
Question : In triplet representation, each non-zero element is stored as:
Solution :
Correct Answer : Row, Column, Value
Description -
Question : The first row in triplet representation generally contains:
Solution :
Correct Answer : Matrix dimensions and number of non-zero elements
Description -
Question : A 5 × 5 identity matrix has how many non-zero elements?
Solution :
Correct Answer : 5
Description -
Question : Memory complexity of storing a sparse matrix in normal form is:
Solution :
Correct Answer : Depends on total matrix size
Description -
Question : Which matrix is always sparse when its size becomes very large?
Solution :
Correct Answer : Identity Matrix
Description -
Question : For a sparse matrix with 1000 rows, 1000 columns, and 20 non-zero elements, triplet representation stores:
Solution :
Correct Answer : 21 rows of triplets (including header)
Description -