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