Practice array Quizzes
Explore array in depth with quizzes covering fundamentals to advanced concepts. DevBrainiac's structured quiz format helps you understand theory, apply logic and master problem-solving techniques. With continuous practice, you can track progress, fix mistakes and build strong command of array.
Explore All array Quizzes
Learn array step by step with interactive quizzes designed for beginners and learners revising key concepts. Build a strong foundation with clear, structured practice in array.
Question 1
What is the time complexity to access an element in an array by index?
1
O(log n)
2
O(n log n)
3
O(1)
4
O(n)
Question 2
What is the worst-case time complexity of searching for an element in an unsorted array?
1
O(1)
2
O(n log n)
3
O(n)
4
O(log n)
Question 3
Which of the following is an advantage of using an array over a linked list?
1
Faster access time
2
Uses less memory for large datasets
3
Dynamic size
4
Easier insertion and deletion
Question 4
What is the time complexity of inserting an element at the beginning of an array?
1
O(log n)
2
O( n log n)
3
O(1)
4
O(n)
Question 5
Which of the following operations is the most efficient in a circular array?
1
Reversing the array
2
Inserting at the end
3
Searching for an element
4
Deleting from the front
Question 6
In which case is a dynamic array preferred over a static array?
1
When searching is the primary operation
2
When memory usage is fixed
3
When frequent insertions and deletions are needed
4
When the array contains only unique elements
Question 7
Which data structure is best suited for implementing a stack using an array?
1
Binary Tree
2
Circular Queue
3
Dynamic Array
4
Linked List
Question 8
What is the correct way to declare an array of 10 integers in C++?
1
int arr[10];
2
array int arr[10];
3
int arr(10);
4
int arr = new int[10];
Question 9
Which of the following correctly declares an array in C++?
1
array{10};
2
int array[10];
3
int array;
4
array array[10];
Question 10
What will be the output of the following C++ code?
#include <stdio.h>
#include<iostream>
using namespace std;
int main ()
{
int array[] = {0, 12, 4, 6, 10, 5, 3, 5};
int n, result = 0;
for (n = 0; n < 8; n++)
{
result += array[n];
}
cout << result;
return 0;
}1
27
2
45
3
40
4
43
Question 11
What will be the output of the following C++ code?
#include <stdio.h>
#include<iostream>
using namespace std;
int main ()
{
int arr[] = {0, 12, 4, 6, 10, 5, 3, 5};
int n, result = 0;
for (n = 0; n < 8; n++)
{
result += arr[n%4];
}
cout << result;
return 0;
}1
44
2
43
3
27
4
45
Question 12
What will be the output of the following C++ code?
#include <stdio.h>
#include<iostream>
using namespace std;
int main ()
{
int arr[] = {0, 12, 4, 6, 10, 5, 3, 5};
int result = 0;
for (int n = 0; n < 8; n++)
{
result += (arr[n%4] > 1);
}
cout << result;
return 0;
}1
44
2
6
3
12
4
8
Question 13
What will be the output of the following C++ code?
#include <stdio.h>
#include<iostream>
using namespace std;
int main ()
{
int arr[] = {0, 12, 4, 6, 10, 5, 3, 5};
int result = 0;
for (int n = 0; n < 8; n++)
{
result += (arr[n%4] >> 1);
}
cout << result;
return 0;
}1
8
2
12
3
6
4
22
5
44
Question 14
What will be the output of the following LINQ query?
var numbers = new List<int> { 2, 3, 4, 5 };
var result = numbers.Where(n => n % 2 == 0);
Console.WriteLine(result.Count());1
1
2
2
3
4
4
3
Question 15
What will be the output of the following code? python Copy Edit
a = [1, 2, 3, 4] print(a[-1])
1
1
2
3
3
2
4
4
Question 16
Which method is used to remove the last element from a list?
1
discard()
2
delete()
3
remove()
4
pop()
Question 17
What will be the output of the following code?
def foo(x, y=[]):
y.append(x)
return y
print(foo(1))
print(foo(2))1
[1, 2] [1, 2]
2
[1] [2]
3
[1] [1, 2]
4
[2] [2]
Question 18
What will be the output of the following code?
let a = [1, 2, 3]; let b = a; b.push(4); console.log(a);
1
ReferenceError
2
[1, 2, 3, 4]
3
TypeError
4
[1, 2, 3]
Question 19
Which of the following sorting algorithms works best on a nearly sorted array?
1
Bubble Sort
2
Quick Sort
3
Selection Sort
4
Insertion Sort
Question 20
What is the time complexity of merging two sorted arrays of sizes m and n?
1
O(log(m + n))
2
O(m * n)
3
O(m + n)
4
O(1)
Question 21
What is the space complexity of the merge sort algorithm for sorting an array?
1
O(n)
2
O(n log n)
3
O(log n)
4
O(1)
Question 22
In which case does the time complexity of Quick Sort become O(n²)?
1
When the pivot is chosen randomly
2
When the array contains duplicate values
3
When the pivot is always the median
4
When the array is already sorted and the first or last element is chosen as the pivot
Question 23
How do you find the largest element in an array efficiently?
1
Use a binary search approach
2
Sort the array and return the last element
3
Use a linear scan to find the maximum
4
Use recursion without extra space
Question 24
What is the time complexity of finding an element in a sorted array using binary search?
1
O(log n)
2
O(1)
3
O( n log n)
4
O(n)
Question 25
Which sorting algorithm works best for small datasets and is easy to implement?
1
Bubble Sort
2
Merge Sort
3
Quick Sort
4
Insertion Sort
Question 26
How can you efficiently find the missing number in an array of size n containing numbers from 1 to n+1?
1
Calculate the sum and subtract from expected sum
2
Use a hash set to store elements
3
Sort and search for the missing number
4
Use a linked list
Question 27
How do you efficiently check if an array contains a duplicate in O(n) time complexity?
1
Sort and check adjacent elements
2
Use a binary search
3
Use a hash set
4
Use a nested loop
Question 28
Which of the following is a disadvantage of linked lists over arrays?
1
More memory usage
2
Ease of insertion and deletion
3
Dynamic size
4
No memory wastage
Question 29
What is the time complexity of inserting an element at the head of a singly linked list?
1
O(n)
2
O(n log n)
3
O(1)
4
O(log n)
Question 30
In C++, which of the following correctly initializes a char array?
1
char arr[5] = "Hello";
2
char arr[] = "Hello";
3
char arr[] = {'H', 'e', 'l', 'l', 'o'};
4
Both 2 and 3
