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(n)
2
O(1)
3
O(log n)
4
O(n log n)
Question 2
What is the worst-case time complexity of searching for an element in an unsorted array?
1
O(n)
2
O(n log n)
3
O(1)
4
O(log n)
Question 3
Which of the following is an advantage of using an array over a linked list?
1
Dynamic size
2
Faster access time
3
Easier insertion and deletion
4
Uses less memory for large datasets
Question 4
What is the time complexity of inserting an element at the beginning of an array?
1
O(1)
2
O(n)
3
O( n log n)
4
O(log n)
Question 5
Which of the following operations is the most efficient in a circular array?
1
Deleting from the front
2
Searching for an element
3
Reversing the array
4
Inserting at the end
Question 6
In which case is a dynamic array preferred over a static array?
1
When the array contains only unique elements
2
When memory usage is fixed
3
When searching is the primary operation
4
When frequent insertions and deletions are needed
Question 7
Which data structure is best suited for implementing a stack using an array?
1
Dynamic Array
2
Linked List
3
Circular Queue
4
Binary Tree
Question 8
What is the correct way to declare an array of 10 integers in C++?
1
int arr[10];
2
int arr(10);
3
array int arr[10];
4
int arr = new int[10];
Question 9
Which of the following correctly declares an array in C++?
1
int array[10];
2
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
40
2
43
3
45
4
27
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
45
2
43
3
27
4
44
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
12
2
6
3
8
4
44
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
22
2
44
3
6
4
12
5
8
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
2
2
4
3
3
4
1
Question 15
What will be the output of the following code? python Copy Edit
a = [1, 2, 3, 4] print(a[-1])
1
4
2
1
3
2
4
3
Question 16
Which method is used to remove the last element from a list?
1
discard()
2
delete()
3
pop()
4
remove()
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
[2] [2]
3
[1] [2]
4
[1] [1, 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
[1, 2, 3]
2
[1, 2, 3, 4]
3
TypeError
4
ReferenceError
Question 19
Which of the following sorting algorithms works best on a nearly sorted array?
1
Quick Sort
2
Insertion Sort
3
Selection Sort
4
Bubble 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(1)
4
O(m + n)
Question 21
What is the space complexity of the merge sort algorithm for sorting an array?
1
O(1)
2
O(log n)
3
O(n log n)
4
O(n)
Question 22
In which case does the time complexity of Quick Sort become O(n²)?
1
When the pivot is always the median
2
When the pivot is chosen randomly
3
When the array contains duplicate values
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
Sort the array and return the last element
2
Use recursion without extra space
3
Use a linear scan to find the maximum
4
Use a binary search approach
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
Merge Sort
2
Insertion Sort
3
Quick Sort
4
Bubble 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
Sort and search for the missing number
3
Use a linked list
4
Use a hash set to store elements
Question 27
How do you efficiently check if an array contains a duplicate in O(n) time complexity?
1
Use a hash set
2
Use a binary search
3
Sort and check adjacent elements
4
Use a nested loop
Question 28
Which of the following is a disadvantage of linked lists over arrays?
1
No memory wastage
2
Dynamic size
3
Ease of insertion and deletion
4
More memory usage
Question 29
What is the time complexity of inserting an element at the head of a singly linked list?
1
O(n)
2
O(log n)
3
O(1)
4
O(n 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
