Array Manipulation and Searching Quiz Quiz

  1. Finding a Specific Element in an Array

    Given the array arr = [3, 7, 2, 9, 5], what is the index of the element 9?

    1. 2
    2. 3
    3. 4
    4. 1
    5. 5
  2. Detecting Duplicates in an Array

    In the array nums = [1, 4, 2, 4, 6], which number is duplicated?

    1. 1
    2. 2
    3. 4
    4. 6
    5. 0
  3. Rotating an Array to the Right

    After rotating the array [11, 22, 33, 44, 55] by two positions to the right, what is the resulting array?

    1. [44, 55, 11, 22, 33]
    2. [33, 44, 55, 11, 22]
    3. [22, 33, 44, 55, 11]
    4. [55, 11, 22, 33, 44]
    5. [33, 22, 11, 55, 44]
  4. Checking Inclusion in an Array

    Which function in JavaScript checks if an array contains a given value?

    1. includes()
    2. hasMember()
    3. contain()
    4. hasElement()
    5. findIn()
  5. Finding the Maximum Value in an Array

    What is the output of Math.max(...[2, 5, 1, 9, 8]) in JavaScript?

    1. 2
    2. 5
    3. 9
    4. 8
    5. 1
  6. Linear Search

    In a linear search, how many elements are checked in the worst case scenario in an array of length N?

    1. N-1
    2. N
    3. N+1
    4. Half of N
    5. Always 1
  7. Sorting an Array

    What is the result of sorting the array [10, 5, 40] using JavaScript's default sort() method?

    1. [10, 5, 40]
    2. [5, 10, 40]
    3. [10, 40, 5]
    4. [40, 10, 5]
    5. [10, 5, 40]
  8. Finding All Indices of a Value

    If arr = [1, 3, 7, 3, 5], which indices contain the value 3?

    1. [1, 3]
    2. [3, 4]
    3. [0, 2]
    4. [2, 3]
    5. [1, 2]
  9. Binary Search Prerequisite

    Before using binary search on an array, what must always be true?

    1. The array must be sorted
    2. The array must have no duplicates
    3. The array must have only integers
    4. The array length must be even
    5. The array must be reversed
  10. Merging Two Arrays

    What is the correct result of merging [1,2,3] and [4,5] in JavaScript using the concat method?

    1. [1,2,3,4,5]
    2. [1,2,3][4,5]
    3. [4,5,1,2,3]
    4. [1,2,3,5,4]
    5. [1,2,3,5]