Unit 4 - Practice Quiz
CSE101
1 Which of the following correctly declares an array of 10 integers in C?
2
If an array is declared as int arr[5] = {1, 2, 3};, what are the values of arr[3] and arr[4]?
3
What is the index range for an array declared as int arr[N];?
4 How is the memory allocated for elements of an array in C?
5
Which operator is used to determine the total size in bytes occupied by an array named arr?
6
Given int arr[] = {10, 20, 30, 40, 50};, what does the expression *(arr + 2) evaluate to?
7 Which of the following statements about array initialization is FALSE?
int a[5] = {0}; sets all elements to 0.
int a[] = {1, 2}; sets size automatically to 2.
int a[2] = {1, 2, 3}; is a valid statement.
int a[5]; (local) contains garbage values.
8
In the expression arr[i], arr is equivalent to:
9
Is the expression 3[arr] valid in C, assuming arr is an integer array?
arr[3].
arr[0].
10
What happens if you access arr[10] in an array declared as int arr[10];?
11 Which is the correct syntax to declare a 2D array with 3 rows and 4 columns?
12
In a 2D array int A[R][C], how is the address of element A[i][j] calculated in row-major order (assuming base address and element size )?
13 Which declaration allows omitting the first dimension size during initialization?
int arr[3][] = {{1,2}, {3,4}};
int arr[][2] = {{1,2}, {3,4}};
int arr[][] = {{1,2}, {3,4}};
int arr[][] = {1, 2, 3, 4};
14
What is the maximum number of elements in int data[5][4];?
15
When passing a 1D array to a function void func(int a[]), what is actually passed?
16
Consider the function prototype void fun(int arr[10]);. Inside the function, what does sizeof(arr) return on a 32-bit system?
17
To pass a 2D array int grid[3][3] to a function, which prototype is valid?
void f(int grid[][]);
void f(int **grid);
void f(int grid[][3]);
void f(int grid[3][]);
18 What is the time complexity to insert an element at the beginning of an array of size ?
19 When deleting an element from index in an array of size , what is the standard procedure?
20 Which search algorithm requires the array to be sorted beforehand?
21 What is the worst-case time complexity of Linear Search?
22 In Binary Search, if the target is greater than the middle element, which part of the array is processed next?
23
What is the formula to calculate the middle index mid in Binary Search given low and high?
mid = low + high
mid = (low + high) / 2
mid = low + (high - low) / 2
mid = (low - high) / 2
24 What is the maximum number of comparisons required for a Binary Search on an array of 32 elements?
25 How does Bubble Sort sort an array?
26 What is the worst-case time complexity of Bubble Sort?
27 How many passes are required to sort an array of size using Bubble Sort (worst case)?
28 Which optimization can be applied to Bubble Sort?
29
Consider int a[3][3] = {{1}, {2}, {3}};. What is the value of a[1][1]?
30 In C, strings are essentially:
31 Which library function is used to copy one string array to another?
32 To transpose a square matrix of size , which operation is performed?
A[i][j] with A[j][i].
A[i][j] = 0.
33 Which of the following is a valid application of a 2D array?
34
If int a[] = {1, 2, 3};, what is the result of printf("%d", a[a[1]]);?
35 Why is it inefficient to use an array for a dataset where frequent insertions and deletions occur in the middle?
36
What is the output of int a[5]; printf("%d", a);?
37
Can array size be a variable in Standard C89 (e.g., int n=5; int a[n];)?
38 In the context of Binary Search, what does 'Linear' vs 'Logarithmic' time complexity imply?
39
What happens if you try to assign one array to another directly: int a[5], b[5]; a = b;?
40 What is a 'Sparse Matrix'?
41
Given int arr[5] = {10, 20, 30, 40, 50};, what is the result of arr[1] + 2?
42 If you pass an array to a function and modify its elements inside the function, do the changes persist in the calling function?
43 Which of the following sorting algorithms is 'Stable' (maintains relative order of equal elements)?
44
In a 2D array, what does arr (the name) represent conceptually?
45
Which header file is usually required for standard input/output operations on arrays (like printf)?
46 What logic allows Linear Search to work on unsorted arrays?
47
If we want to sort an array in Descending order using Bubble Sort, the condition for swapping a[j] and a[j+1] should be:
if (a[j] > a[j+1])
if (a[j] < a[j+1])
if (a[j] == a[j+1])
if (a[j] != a[j+1])
48 What is the space complexity of the Bubble Sort algorithm?
49
Accessing an array using a negative index (e.g., arr[-1]) inside a function where arr is a pointer pointing to the middle of an allocated block:
50 Which initialization is valid for a string (char array)?
char s[] = 'Hello';
char s[] = "Hello";
char s[5] = "Hello";
char s = "Hello";