LogIn
I don't have account.

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(log n)
3
O(n log n)
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(log n)
3
O(n log n)
4
O(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
Easier insertion and deletion
4
Dynamic size
Question 4
What is the time complexity of inserting an element at the beginning of an array?
1
O(1)
2
O( n log n)
3
O(log n)
4
O(n)
Question 5
Which of the following operations is the most efficient in a circular array?
1
Inserting at the end
2
Reversing the array
3
Deleting from the front
4
Searching for an element
Question 6
In which case is a dynamic array preferred over a static array?
1
When frequent insertions and deletions are needed
2
When memory usage is fixed
3
When searching is the primary operation
4
When the array contains only unique elements
Question 7
Which data structure is best suited for implementing a stack using an array?
1
Linked List
2
Circular Queue
3
Binary Tree
4
Dynamic Array
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
int arr = new int[10];
4
array int arr[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
27
3
43
4
45
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
27
3
45
4
43
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
44
2
6
3
22
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
3
3
1
4
4
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
2
3
1
4
3
Question 16
Which method is used to remove the last element from a list?
1
pop()
2
delete()
3
discard()
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] [1, 2]
2
[2] [2]
3
[1] [2]
4
[1, 2] [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
TypeError
3
ReferenceError
4
[1, 2, 3, 4]
Question 19
Which of the following sorting algorithms works best on a nearly sorted array?
1
Bubble Sort
2
Insertion Sort
3
Selection Sort
4
Quick 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(1)
3
O(m + n)
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(n log n)
3
O(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 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 recursion without extra space
2
Sort the array and return the last element
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(1)
2
O(n)
3
O( n log n)
4
O(log n)
Question 25
Which sorting algorithm works best for small datasets and is easy to implement?
1
Insertion Sort
2
Merge 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
Use a nested loop
4
Sort and check adjacent elements
Question 28
Which of the following is a disadvantage of linked lists over arrays?
1
Dynamic size
2
No memory wastage
3
More memory usage
4
Ease of insertion and deletion
Question 29
What is the time complexity of inserting an element at the head of a singly linked list?
1
O(1)
2
O(n log n)
3
O(log n)
4
O(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