Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • GfG 160: Daily DSA
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • DSA
  • Interview Questions on Array
  • Practice Array
  • MCQs on Array
  • Tutorial on Array
  • Types of Arrays
  • Array Operations
  • Subarrays, Subsequences, Subsets
  • Reverse Array
  • Static Vs Arrays
  • Array Vs Linked List
  • Array | Range Queries
  • Advantages & Disadvantages
Open In App
Next Article:
Searching Elements in an Array | Array Operations
Next article icon

Searching Elements in an Array | Array Operations

Last Updated : 23 May, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

In this post, we will look into search operation in an Array, i.e., how to search an element in an Array, such as:

  1. Searching in an Unsorted Array using Linear Search
  2. Searching in a Sorted Array using Linear Search
  3. Searching in a Sorted Array using Binary Search
  4. Searching in an Sorted Array using Fibonacci Search

Searching operations in an Unsorted Array using Linear Search

In an unsorted array, the search operation can be performed by linear traversal from the first element to the last element, i.e. Linear Search

Coding implementation of the search operation:

C++
// C++ program to implement linear
// search in unsorted array
#include 
using namespace std;

// Function to implement search operation
int findElement(int arr[], int n, int key)
{
    int i;
    for (i = 0; i < n; i++)
        if (arr[i] == key)
            return i;

    // If the key is not found
    return -1;
}

// Driver's Code
int main()
{
    int arr[] = { 12, 34, 10, 6, 40 };
    int n = sizeof(arr) / sizeof(arr[0]);

    // Using a last element as search element
    int key = 40;

    // Function call
    int position = findElement(arr, n, key);

    if (position == -1)
        cout << "Element not found";
    else
        cout << "Element Found at Position: "
             << position + 1;

    return 0;
}

// This code is contributed
// by Akanksha Rai
C
// C program to implement linear
// search in unsorted array
#include 

// Function to implement search operation
int findElement(int arr[], int n, int key)
{
    int i;
    for (i = 0; i < n; i++)
        if (arr[i] == key)
            return i;

    // If the key is not found
    return -1;
}

// Driver's Code
int main()
{
    int arr[] = { 12, 34, 10, 6, 40 };
    int n = sizeof(arr) / sizeof(arr[0]);

    // Using a last element as search element
    int key = 40;

    // Function call
    int position = findElement(arr, n, key);

    if (position == -1)
        printf("Element not found");
    else
        printf("Element Found at Position: %d",
               position + 1);

    return 0;
}
Java
// Java program to implement linear
// search in unsorted arrays

class Main {

    // Function to implement
    // search operation
    static int findElement(int arr[], int n, int key)
    {
        for (int i = 0; i < n; i++)
            if (arr[i] == key)
                return i;

        // If the key is not found
        return -1;
    }

    // Driver's Code
    public static void main(String args[])
    {
        int arr[] = { 12, 34, 10, 6, 40 };
        int n = arr.length;

        // Using a last element as search element
        int key = 40;

        // Function call
        int position = findElement(arr, n, key);

        if (position == -1)
            System.out.println("Element not found");
        else
            System.out.println("Element Found at Position: "
                               + (position + 1));
    }
}
Python
# Python program for searching in
# unsorted array


def findElement(arr, n, key):
    for i in range(n):
        if (arr[i] == key):
            return i

    # If the key is not found
    return -1


# Driver's code
if __name__ == '__main__':
    arr = [12, 34, 10, 6, 40]
    key = 40
    n = len(arr)

    # search operation
    index = findElement(arr, n, key)
    if index != -1:
        print("Element Found at position: " + str(index + 1))
    else:
        print("Element not found")

    # Thanks to Aditi Sharma for contributing
    # this code
C#
// C# program to implement linear
// search in unsorted arrays
using System;

class main {
    // Function to implement
    // search operation
    static int findElement(int[] arr, int n, int key)
    {
        for (int i = 0; i < n; i++)
            if (arr[i] == key)
                return i;

        // If the key is not found
        return -1;
    }

    // Driver Code
    public static void Main()
    {
        int[] arr = { 12, 34, 10, 6, 40 };
        int n = arr.Length;

        // Using a last element as
        // search element
        int key = 40;
        int position = findElement(arr, n, key);

        if (position == -1)
            Console.WriteLine("Element not found");
        else
            Console.WriteLine("Element Found at Position: "
                              + (position + 1));
    }
}

//  This code is contributed by vt_m.
JavaScript
// Javascript program to implement linear 
// search in unsorted array


// Function to implement search operation 
function findElement( arr, n, key)
{
    let i;
    for (i = 0; i < n; i++)
        if (arr[i] == key)
            return i;

    return -1;
}


    
    // Driver program
    
    let arr = [12, 34, 10, 6, 40];
    let n = arr.length;

    // Using a last element as search element
    let key = 40;
    let position = findElement(arr, n, key);

    if (position == - 1)
        console.log("Element not found");
    else
        console.log("Element Found at Position: " 
             + (position + 1));
PHP

// PHP program to implement linear 
// search in unsorted array

// Function to implement
// search operation 
function findElement($arr, $n, $key)
{
    $i;
    for ($i = 0; $i < $n; $i++)
        if ($arr[$i] == $key)
            return $i;
    
      // If the key is not found
    return -1;
}

// Driver Code
$arr = array(12, 34, 10, 6, 40);
$n = sizeof($arr);

// Using a last element
// as search element
$key = 40;
$position = findElement($arr, $n, $key);

if ($position == - 1)
    echo("Element not found");
else
    echo("Element Found at Position: " . ($position + 1));

// This code is contributed by Ajit.
?>

Output
Element Found at Position: 5

Time Complexity: O(N) 
Auxiliary Space: O(1)

Searching in a Sorted Array using Linear Search

In a sorted array, the most trivial method for search operation is by using Linear Search.

Search Operation  in a sorted array

Below is the implementation of the above approach:

C++
// C++ program to implement linear
// search in sorted array
#include 
using namespace std;

// Function to implement search operation
int findElement(int arr[], int n, int key)
{
    int i;
    for (i = 0; i < n; i++)
        if (arr[i] == key)
            return i;

    // If the key is not found
    return -1;
}

// Driver's Code
int main()
{
    int arr[] = { 5, 6, 7, 8, 9, 10 };
    int n = sizeof(arr) / sizeof(arr[0]);

    // Using a last element as search element
    int key = 10;

    // Function call
    int position = findElement(arr, n, key);

    if (position == -1)
        cout << "Element not found";
    else
        cout << "Element Found at Position: "
             << position + 1;

    return 0;
}

// This code is contributed
// by Akanksha Rai
C
// C program to implement linear
// search in sorted array
#include 

// Function to implement search operation
int findElement(int arr[], int n, int key)
{
    int i;
    for (i = 0; i < n; i++)
        if (arr[i] == key)
            return i;

    // If the key is not found
    return -1;
}

// Driver's Code
int main()
{
    int arr[] = { 5, 6, 7, 8, 9, 10 };
    int n = sizeof(arr) / sizeof(arr[0]);

    // Using a last element as search element
    int key = 10;

    // Function call
    int position = findElement(arr, n, key);

    if (position == -1)
        printf("Element not found");
    else
        printf("Element Found at Position: %d",
               position + 1);

    return 0;
}
Java
// Java program to implement linear
// search in sorted arrays

class Main {

    // Function to implement
    // search operation
    static int findElement(int arr[], int n, int key)
    {
        for (int i = 0; i < n; i++)
            if (arr[i] == key)
                return i;

        // If the key is not found
        return -1;
    }

    // Driver's Code
    public static void main(String args[])
    {
        int arr[] = { 5, 6, 7, 8, 9, 10 };
        int n = arr.length;

        // Using a last element as search element
        int key = 10;

        // Function call
        int position = findElement(arr, n, key);

        if (position == -1)
            System.out.println("Element not found");
        else
            System.out.println("Element Found at Position: "
                               + (position + 1));
    }
}
Python
# Python program for searching in
# sorted array


def findElement(arr, n, key):
    for i in range(n):
        if (arr[i] == key):
            return i

    # If the key is not found
    return -1


# Driver's code
if __name__ == '__main__':
    arr = [5, 6, 7, 8, 9, 10]
    key = 10
    n = len(arr)

    # search operation
    index = findElement(arr, n, key)
    if index != -1:
        print("Element Found at position: " + str(index + 1))
    else:
        print("Element not found")

    # Thanks to Aditi Sharma for contributing
    # this code
C#
// C# program to implement linear
// search in sorted arrays
using System;

class main {
    // Function to implement
    // search operation
    static int findElement(int[] arr, int n, int key)
    {
        for (int i = 0; i < n; i++)
            if (arr[i] == key)
                return i;

        // If the key is not found
        return -1;
    }

    // Driver Code
    public static void Main()
    {
        int[] arr = { 5, 6, 7, 8, 9, 10 };
        int n = arr.Length;

        // Using a last element as
        // search element
        int key = 10;
        int position = findElement(arr, n, key);

        if (position == -1)
            Console.WriteLine("Element not found");
        else
            Console.WriteLine("Element Found at Position: "
                              + (position + 1));
    }
}

//  This code is contributed by vt_m.
JavaScript
// Javascript program to implement linear 
// search in sorted array


// Function to implement search operation 
function findElement( arr, n, key)
{
    let i;
    for (i = 0; i < n; i++)
        if (arr[i] == key)
            return i;

    return -1;
}


    
    // Driver program
    
    let arr = [5, 6, 7, 8, 9, 10];
    let n = arr.length;

    // Using a last element as search element
    let key = 10;
    let position = findElement(arr, n, key);

    if (position == - 1)
        console.log("Element not found");
    else
        console.log("Element Found at Position: " 
             + (position + 1));
PHP

// PHP program to implement linear 
// search in sorted array

// Function to implement
// search operation 
function findElement($arr, $n, $key)
{
    $i;
    for ($i = 0; $i < $n; $i++)
        if ($arr[$i] == $key)
            return $i;
    
      // If the key is not found
    return -1;
}

// Driver Code
$arr = array(5, 6, 7, 8, 9, 10);
$n = sizeof($arr);

// Using a last element
// as search element
$key = 10;
$position = findElement($arr, $n, $key);

if ($position == - 1)
    echo("Element not found");
else
    echo("Element Found at Position: " . ($position + 1));

// This code is contributed by Ajit.
?>

Output
Element Found at Position: 6

Time Complexity: O(N) 
Auxiliary Space: O(1)

Searching in a Sorted Array using Binary Search

In a sorted array, the search operation can be performed efficiently by using binary search.

Search Operation  in a sorted array

Below is the implementation of the above approach:

C++
// C++ program to implement binary search in sorted array
#include 
using namespace std;

int binarySearch(int arr[], int low, int high, int key)
{
    if (high < low)
        return -1;
    int mid = (low + high) / 2; /*low + (high - low)/2;*/
    if (key == arr[mid])
        return mid;
    if (key > arr[mid])
        return binarySearch(arr, (mid + 1), high, key);
    return binarySearch(arr, low, (mid - 1), key);
}

/* Driver code */
int main()
{
    // Let us search 3 in below array
    int arr[] = { 5, 6, 7, 8, 9, 10 };
    int n, key;

    n = sizeof(arr) / sizeof(arr[0]);
    key = 10;

    // Function call
    cout << "Index: " << binarySearch(arr, 0, n - 1, key)
         << endl;
    return 0;
}

// This code is contributed by NamrataSrivastava1
C
// C program to implement binary search in sorted array
#include 

int binarySearch(int arr[], int low, int high, int key)
{
    if (high < low)
        return -1;
    int mid = (low + high) / 2; /*low + (high - low)/2;*/
    if (key == arr[mid])
        return mid;
    if (key > arr[mid])
        return binarySearch(arr, (mid + 1), high, key);
    return binarySearch(arr, low, (mid - 1), key);
}

/* Driver Code */
int main()
{
    // Let us search 3 in below array
    int arr[] = { 5, 6, 7, 8, 9, 10 };
    int n, key;

    n = sizeof(arr) / sizeof(arr[0]);
    key = 10;

    // Function call
    printf("Index: %d\n", binarySearch(arr, 0, n - 1, key));
    return 0;
}
Java
// Java program to implement binary
// search in a sorted array

class Main {
    // function to implement
    // binary search
    static int binarySearch(int arr[], int low, int high,
                            int key)
    {
        if (high < low)
            return -1;

        /*low + (high - low)/2;*/
        int mid = (low + high) / 2;
        if (key == arr[mid])
            return mid;
        if (key > arr[mid])
            return binarySearch(arr, (mid + 1), high, key);
        return binarySearch(arr, low, (mid - 1), key);
    }

    /* Driver Code*/
    public static void main(String[] args)
    {
        int arr[] = { 5, 6, 7, 8, 9, 10 };
        int n, key;
        n = arr.length - 1;
        key = 10;

        // Function call
        System.out.println("Index: "
                           + binarySearch(arr, 0, n, key));
    }
}
Python
# python 3 program to implement
# binary search in sorted array
def binary_search(arr, start, end, key):
    
    # if case is evaluated when element is found else -1 is returned
    if (start < end):
        mid = (start + end) //2

        if (key == arr[mid]):
            return mid
        
        if (key < arr[mid]):
            return binary_search(arr, start, mid - 1, key)
        
        if (key > arr[mid]):
            return binary_search(arr, mid + 1, end, key)
    
    else:
        return -1

# Driver code
if __name__ == "__main__":
    
    # Let us take a sorted array to find a key
    arr = [11, 20, 39, 44, 57, 63, 72, 88, 94]
    key = 72

    index = binary_search(arr, 0, len(arr) - 1, key)
    if index != -1:
        print(f"Element found at index {index}")
    else:
        print("Element not found")

# This code is contributed by Smitha Dinesh Semwal
# and improved by Rahul Varma
C#
// C# program to implement binary
// search in a sorted array

using System;

public class GFG {

    // function to implement
    // binary search
    public static int binarySearch(int[] arr, int low,
                                   int high, int key)
    {
        if (high < low) {
            return -1;
        }

        int mid = (low + high) / 2;
        if (key == arr[mid]) {
            return mid;
        }
        if (key > arr[mid]) {
            return binarySearch(arr, (mid + 1), high, key);
        }
        return binarySearch(arr, low, (mid - 1), key);
    }

    /* Driver Code */
    public static void Main(string[] args)
    {
        int[] arr = new int[] { 5, 6, 7, 8, 9, 10 };
        int n, key;
        n = arr.Length;
        key = 10;

        // Function call
        Console.WriteLine(
            "Index: " + binarySearch(arr, 0, n - 1, key));
    }
}

// This code is contributed by Shrikant13
JavaScript
// Javascript program to implement 
// binary search in sorted array

function binarySearch( arr, low, high, key)
{
    if (high < low)
        return -1;
        /*low + (high - low)/2;*/
    let mid = Math.trunc((low + high) / 2); 
    if (key == arr[mid])
        return mid;
    if (key > arr[mid])
        return binarySearch(arr, (mid + 1), high, key);
    return binarySearch(arr, low, (mid - 1), key);
}

    
    // Driver program
    
    // Let us search 3 in below array
    let arr = [ 5, 6, 7, 8, 9, 10 ];
    let n, key;

    n = arr.length;
    key = 10;

    console.log("Index: " + binarySearch(arr, 0, n - 1, key)
    + "
"
);
PHP

// PHP program to implement
// binary search in sorted array

function binarySearch($arr, $low, 
                      $high, $key) 
{
    if ($high < $low) 
    return -1;
    
    $mid = (int)($low + $high) / 2;
    
    if ($key == $arr[(int)$mid])
        return $mid;
    
    if ($key > $arr[(int)$mid]) 
        return binarySearch($arr, ($mid + 1), 
                            $high, $key);
    
    return (binarySearch($arr, $low, 
                        ($mid -1), $key));
}

// Driver Code

// Let us search 3 in below array
$arr = array(5, 6, 7, 8, 9, 10);
$n = count($arr);
$key = 10;

// Function call
echo "Index: ", (int)binarySearch($arr, 0, 
                                  $n-1, $key);

// This code is contributed by
// Srathore
?>

Output
Index: 5

Time Complexity: O(log(n)) Using Binary Search
Auxiliary Space: O(log(n)) due to recursive calls, otherwise iterative version uses Auxiliary Space of O(1).

Searching in a Sorted Array using Fibonacci Search

Fibonacci Search is a comparison-based technique that uses Fibonacci numbers to search an element in a sorted array.

Untitled

Below is the implementation of the above approach:

C++
// C++ program of the above approach
#include 
#include 
using std::cout;

//  Utility function to find minimum of two elements
int minimum(int x, int y) { return (x < y) ? x : y; }

/* Returns index of x if present,  else returns -1 */
int fibonacciSearch(int arr[], int x, int n)
{
    /* Initialize fibonacci numbers */
    int fibMMm2 = 0; // (m-2)'th Fibonacci No.
    int fibMMm1 = 1; // (m-1)'th Fibonacci No.
    int fibM = fibMMm2 + fibMMm1; // m'th Fibonacci

    /* fibM is going to store the smallest Fibonacci
       Number greater than or equal to n */
    while (fibM < n) {
        fibMMm2 = fibMMm1;
        fibMMm1 = fibM;
        fibM = fibMMm2 + fibMMm1;
    }

    // Marks the eliminated range from front
    int offset = -1;

    /* while there are elements to be inspected. Note that
       we compare arr[fibMm2] with x. When fibM becomes 1,
       fibMm2 becomes 0 */
    while (fibM > 1) {
        // Check if fibMm2 is a valid location
        int i = minimum(offset + fibMMm2, n - 1);

        /* If x is greater than the value at index fibMm2,
           cut the subarray array from offset to i */
        if (arr[i] < x) {
            fibM = fibMMm1;
            fibMMm1 = fibMMm2;
            fibMMm2 = fibM - fibMMm1;
            offset = i;
        }

        /* If x is greater than the value at index fibMm2,
           cut the subarray after i+1  */
        else if (arr[i] > x) {
            fibM = fibMMm2;
            fibMMm1 = fibMMm1 - fibMMm2;
            fibMMm2 = fibM - fibMMm1;
        }

        /* element found. return index */
        else
            return i;
    }

    /* comparing the last element with x */
    if (fibMMm1 && arr[offset + 1] == x)
        return offset + 1;

    /*element not found. return -1 */
    return -1;
}

// Driver Code
int main()
{
    int arr[] = { 10, 22, 35, 40, 45,  50,
                  80, 82, 85, 90, 100, 235 };
    int n = sizeof(arr) / sizeof(arr[0]);
    int x = 235;
    int ind = fibonacciSearch(arr, x, n);
    if (ind >= 0)
        cout << "Found at index: " << ind;
    else
        cout << x << " isn't present in the array";

    return 0;
}

// This code is contributed by sourabh_jain.
C
// C program for Fibonacci Search
#include 

// Function to find minimum of two elements
int minimum(int x, int y) { return (x <= y) ? x : y; }

/* Returns index of x if present, else returns -1 */
int fibonacciSearch(int arr[], int x, int n)
{
    /* Initialize Fibonacci numbers */
    int fibMMm2 = 0; // (m-2)'th Fibonacci number
    int fibMMm1 = 1; // (m-1)'th Fibonacci number
    int fibM = fibMMm2 + fibMMm1; // m'th Fibonacci number

    /* fibM is going to store the smallest Fibonacci
     number greater than or equal to n */
    while (fibM < n) {
        fibMMm2 = fibMMm1;
        fibMMm1 = fibM;
        fibM = fibMMm2 + fibMMm1;
    }

    // Marks the eliminated range from front
    int offset = -1;

    /* while there are elements to be inspected. Note that
     we compare arr[fibMm2] with x. When fibM becomes 1,
     fibMm2 becomes 0 */
    while (fibM > 1) {
        // Check if fibMm2 is a valid location
        int i = minimum(offset + fibMMm2, n - 1);

        /* If x is greater than the value at index fibMm2,
         cut the subarray array from offset to i */
        if (arr[i] < x) {
            fibM = fibMMm1;
            fibMMm1 = fibMMm2;
            fibMMm2 = fibM - fibMMm1;
            offset = i;
        }

        /* If x is greater than the value at index fibMm2,
         cut the subarray after i+1 */
        else if (arr[i] > x) {
            fibM = fibMMm2;
            fibMMm1 = fibMMm1 - fibMMm2;
            fibMMm2 = fibM - fibMMm1;
        }

        /* element found. return index */
        else
            return i;
    }

    /* comparing the last element with x */
    if (fibMMm1 && arr[offset + 1] == x)
        return offset + 1;

    /* element not found. return -1 */
    return -1;
}

/* driver function */
int main(void)
{
    int arr[] = { 10, 22, 35, 40, 45,  50,
                  80, 82, 85, 90, 100, 235 };
    int n = sizeof(arr) / sizeof(arr[0]);
    int x = 235;
    int index = fibonacciSearch(arr, x, n);
    if (index >= 0)
        printf("Element found at index: %d", index);
    else
        printf("%d is not present in the array", x);
    return 0;
}
// This code is contributed by sourabh_jain.
Java
// Java program of the above approach
import java.util.*; // adding util packages

class FibonacciSearch {
    // Function to find the minimum of two elements
    public static int minimum(int x, int y)
    {
        return (x <= y) ? x : y;
    }

    /* Returns the index of x if present, else returns -1 */
    public static int fibonacciSearch(int arr[], int x,
                                      int n)
    {
        /* Initialize Fibonacci numbers */
        int fibMMm2 = 0; // (m-2)'th Fibonacci number
        int fibMMm1 = 1; // (m-1)'th Fibonacci number
        int fibM
            = fibMMm2 + fibMMm1; // m'th Fibonacci number

        /* fibM is going to store the smallest Fibonacci
        Number greater than or equal to n */
        while (fibM < n) {
            fibMMm2 = fibMMm1;
            fibMMm1 = fibM;
            fibM = fibMMm2 + fibMMm1;
        }

        // Marks the eliminated range from the front
        int offset = -1;

        /* While there are elements to be inspected.
        Note that we compare arr[fibMm2] with x.
        When fibM becomes 1, fibMm2 becomes 0 */
        while (fibM > 1) {
            // Check if fibMm2 is a valid location
            int i = minimum(offset + fibMMm2, n - 1);

            /* If x is greater than the value at index
            fibMm2,
            cut the subarray array from offset to i */
            if (arr[i] < x) {
                fibM = fibMMm1;
                fibMMm1 = fibMMm2;
                fibMMm2 = fibM - fibMMm1;
                offset = i;
            }

            /* If x is less than the value at index fibMm2,
            cut the subarray after i+1 */
            else if (arr[i] > x) {
                fibM = fibMMm2;
                fibMMm1 = fibMMm1 - fibMMm2;
                fibMMm2 = fibM - fibMMm1;
            }

            /* Element found. Return index */
            else
                return i;
        }

        /* Comparing the last element with x */
        if (fibMMm1 == 1 && arr[n - 1] == x)
            return n - 1;

        /* Element not found. Return -1 */
        return -1;
    }

    // Driver code
    public static void main(String[] args)
    {
        int arr[] = { 10, 22, 35, 40, 45,  50,
                      80, 82, 85, 90, 100, 235 };
        int n = 12;
        int x = 235;
        int index = fibonacciSearch(arr, x, n);
        if (index >= 0)
            System.out.print("Element found at index: "
                             + index);
        else
            System.out.print(
                x + " isn't present in the array");
    }
}

// This code is contributed by sourabh_jain.
Python
# Pythin3 program of the above approach
def fibonacci_search(arr, x, n):
    # Initialize Fibonacci numbers
    fibMMm2 = 0  # (m-2)'th Fibonacci No.
    fibMMm1 = 1  # (m-1)'th Fibonacci No.
    fibM = fibMMm2 + fibMMm1  # m'th Fibonacci

    # fibM is going to store the smallest
    # Fibonacci Number greater than or equal to n
    while fibM < n:
        fibMMm2 = fibMMm1
        fibMMm1 = fibM
        fibM = fibMMm2 + fibMMm1

    # Marks the eliminated range from the front
    offset = -1

    # while there are elements to be inspected.
    # Note that we compare arr[fibMm2] with x.
    # When fibM becomes 1, fibMm2 becomes 0
    while fibM > 1:
        # Check if fibMm2 is a valid location
        i = min(offset + fibMMm2, n - 1)

        # If x is greater than the value at
        # index fibMm2, cut the subarray array
        # from offset to i
        if arr[i] < x:
            fibM = fibMMm1
            fibMMm1 = fibMMm2
            fibMMm2 = fibM - fibMMm1
            offset = i

        # If x is less than the value at
        # index fibMm2, cut the subarray
        # after i+1
        elif arr[i] > x:
            fibM = fibMMm2
            fibMMm1 = fibMMm1 - fibMMm2
            fibMMm2 = fibM - fibMMm1

        # element found. return index
        else:
            return i

    # comparing the last element with x
    if fibMMm1 and arr[n - 1] == x:
        return n - 1

    # element not found. return -1
    return -1


# Driver Code
arr = [10, 22, 35, 40, 45, 50,
       80, 82, 85, 90, 100, 235]
n = len(arr)
x = 235
index = fibonacci_search(arr, x, n)
if index >= 0:
    print("Element found at index:", index)
else:
    print(x, "isn't present in the array")

# This code is contributed by sourabh_jain.
C#
// C# program of the above approach
using System;

class GFG {
    // Function to find the minimum of two elements
    public static int Min(int x, int y)
    {
        return (x <= y) ? x : y;
    }

    /* Returns the index of x if present, else returns -1 */
    public static int FibonacciSearch(int[] arr, int x,
                                      int n)
    {
        /* Initialize Fibonacci numbers */
        int fibMMm2 = 0; // (m-2)'th Fibonacci number
        int fibMMm1 = 1; // (m-1)'th Fibonacci number
        int fibM = fibMMm2 + fibMMm1; // m'th Fibonacci

        /* fibM is going to store the smallest Fibonacci
        Number greater than or equal to n */
        while (fibM < n) {
            fibMMm2 = fibMMm1;
            fibMMm1 = fibM;
            fibM = fibMMm2 + fibMMm1;
        }

        // Marks the eliminated range from the front
        int offset = -1;

        /* While there are elements to be inspected.
        Note that we compare arr[fibMm2] with x.
        When fibM becomes 1, fibMm2 becomes 0 */
        while (fibM > 1) {
            // Check if fibMm2 is a valid location
            int i = Min(offset + fibMMm2, n - 1);

            /* If x is greater than the value at
            index fibMm2, cut the subarray array
            from offset to i */
            if (arr[i] < x) {
                fibM = fibMMm1;
                fibMMm1 = fibMMm2;
                fibMMm2 = fibM - fibMMm1;
                offset = i;
            }

            /* If x is less than the value at
            index fibMm2, cut the subarray
            after i+1 */
            else if (arr[i] > x) {
                fibM = fibMMm2;
                fibMMm1 = fibMMm1 - fibMMm2;
                fibMMm2 = fibM - fibMMm1;
            }

            /* Element found. Return index */
            else
                return i;
        }

        /* Comparing the last element with x */
        if (fibMMm1 == 1 && arr[n - 1] == x)
            return n - 1;

        /* Element not found. Return -1 */
        return -1;
    }

    // Driver code
    public static void Main()
    {
        int[] arr = { 10, 22, 35, 40, 45,  50,
                      80, 82, 85, 90, 100, 235 };
        int n = 12;
        int x = 235;
        int index = FibonacciSearch(arr, x, n);
        if (index >= 0)
            Console.Write("Element found at index: "
                          + index);
        else
            Console.Write(x
                          + " isn't present in the array");
    }
}

// This code is contributed by sourabh_jain.
JavaScript
// JavaScript program of the above approach

/* Returns the index of x if present, else returns -1 */
function fibonacciSearch(arr, x, n) {
    /* Initialize Fibonacci numbers */
    let fibMMm2 = 0; // (m-2)'th Fibonacci No.
    let fibMMm1 = 1; // (m-1)'th Fibonacci No.
    let fibM = fibMMm2 + fibMMm1; // m'th Fibonacci

    /* fibM is going to store the smallest Fibonacci
    Number greater than or equal to n */
    while (fibM < n) {
        fibMMm2 = fibMMm1;
        fibMMm1 = fibM;
        fibM = fibMMm2 + fibMMm1;
    }

    // Marks the eliminated range from the front
    let offset = -1;

    /* While there are elements to be inspected.
    Note that we compare arr[fibMm2] with x.
    When fibM becomes 1, fibMm2 becomes 0 */
    while (fibM > 1) {
        // Check if fibMm2 is a valid location
        let i = Math.min(offset + fibMMm2, n - 1);

        /* If x is greater than the value at
        index fibMm2, cut the subarray array
        from offset to i */
        if (arr[i] < x) {
            fibM = fibMMm1;
            fibMMm1 = fibMMm2;
            fibMMm2 = fibM - fibMMm1;
            offset = i;
        }

        /* If x is less than the value at index fibMm2,
        cut the subarray after i+1 */
        else if (arr[i] > x) {
            fibM = fibMMm2;
            fibMMm1 = fibMMm1 - fibMMm2;
            fibMMm2 = fibM - fibMMm1;
        }

        /* Element found. Return index */
        else return i;
    }

    /* Comparing the last element with x */
    if (fibMMm1 && arr[n - 1] == x) {
        return n - 1;
    }

    /* Element not found. Return -1 */
    return -1;
}

/* Driver code */
let arr = [10, 22, 35, 40, 45, 50, 80, 82, 85, 90, 100, 235];
let n = arr.length;
let x = 235;
let index = fibonacciSearch(arr, x, n);
if (index >= 0) {
    console.log("Element found at index: " + index);
} else {
    console.log(x + " isn't present in the array");
}

// This code is contributed by sourabh_jain.
PHP

// PHP program of the above approach

/* Returns the index of x if present, else returns -1 */
function fibonacciSearch($arr, $x, $n)
{
    /* Initialize Fibonacci numbers */
    $fibMMm2 = 0; // (m-2)'th Fibonacci No.
    $fibMMm1 = 1; // (m-1)'th Fibonacci No.
    $fibM = $fibMMm2 + $fibMMm1; // m'th Fibonacci

    /* fibM is going to store the smallest Fibonacci
    Number greater than or equal to n */
    while ($fibM < $n)
    {
        $fibMMm2 = $fibMMm1;
        $fibMMm1 = $fibM;
        $fibM = $fibMMm2 + $fibMMm1;
    }

    // Marks the eliminated range from the front
    $offset = -1;

    /* While there are elements to be inspected.
    Note that we compare arr[fibMm2] with x.
    When fibM becomes 1, fibMm2 becomes 0 */
    while ($fibM > 1)
    {
        // Check if fibMm2 is a valid location
        $i = min($offset + $fibMMm2, $n - 1);

        /* If x is greater than the value at
        index fibMm2, cut the subarray array
        from offset to i */
        if ($arr[$i] < $x)
        {
            $fibM = $fibMMm1;
            $fibMMm1 = $fibMMm2;
            $fibMMm2 = $fibM - $fibMMm1;
            $offset = $i;
        }

        /* If x is less than the value at
        index fibMm2, cut the subarray
        after i+1 */
        elseif ($arr[$i] > $x)
        {
            $fibM = $fibMMm2;
            $fibMMm1 = $fibMMm1 - $fibMMm2;
            $fibMMm2 = $fibM - $fibMMm1;
        }

        /* Element found. Return index */
        else
            return $i;
    }

    /* Comparing the last element with x */
    if ($fibMMm1 == 1 && $arr[$n - 1] == $x)
        return $n - 1;

    /* Element not found. Return -1 */
    return -1;
}

/* Driver code */
$arr = array(10, 22, 35, 40, 45, 50, 80, 82, 85, 90, 100, 235);
$n = count($arr);
$x = 235;
$index = fibonacciSearch($arr, $x, $n);
if ($index >= 0)
    printf("Element found at index: " . $index);
else
    printf($x . " isn't present in the array");
?>

// This code is contributed by sourabh_jain.

Output
Found at index: 11

Time Complexity: O(log(n)) Using Fibonacci Search
Auxiliary Space: O(1) Using Fibonacci Search


Next Article
Searching Elements in an Array | Array Operations

C

code_r
Improve
Article Tags :
  • DSA
  • Arrays
Practice Tags :
  • Arrays

Similar Reads

    Deleting Elements in an Array - Array Operations
    In this post, we will look into deletion operation in an Array, i.e., how to delete an element from an Array, such as:Delete an Element from the Beginning of an ArrayDelete an Element from a Given Position in an ArrayDelete First Occurrence of Given Element from an ArrayRemove All Occurrences of an
    4 min read
    Search, Insert, and Delete in an Unsorted Array | Array Operations
    In this post, a program to search, insert, and delete operations in an unsorted array is discussed.Search Operation:In an unsorted array, the search operation can be performed by linear traversal from the first element to the last element. Coding implementation of the search operation:C++// C++ prog
    15+ min read
    Search, Insert, and Delete in an Sorted Array | Array Operations
    How to Search in a Sorted Array?In a sorted array, the search operation can be performed by using binary search.Below is the implementation of the above approach:C++// C++ program to implement binary search in sorted array #include using namespace std; int binarySearch(int arr[
    15+ min read
    Array range queries for searching an element
    Given an array of N elements and Q queries of the form L R X. For each query, you have to output if the element X exists in the array between the indices L and R(included). Prerequisite : Mo's Algorithms Examples : Input : N = 5 arr = [1, 1, 5, 4, 5] Q = 3 1 3 2 2 5 1 3 5 5 Output : No Yes Yes Expla
    15+ min read
    Search an element in a reverse sorted array
    Given an array arr[] sorted in decreasing order, and an integer X, the task is to check if X is present in the given array or not. If X is present in the array, print its index ( 0-based indexing). Otherwise, print -1. Examples: Input: arr[] = {5, 4, 3, 2, 1}, X = 4Output: 1Explanation: Element X (=
    8 min read
    Searching in Array for a given element in Julia
    Given an array (1D, 2D or 3D), and an element to look for in the array. If the element is present in the array, then print the position of the element in the array, else print "Element not found". In the recent updates to Julia, the developers have unified the search() and find() functions into a si
    6 min read
    Binary search in an object Array for the field of an element
    What is Binary Searching?Binary searching is a type of algorithm that can quickly search through a sorted array of elements. The algorithm works by comparing the search key to the middle element of the array. If the key is larger than the middle element, the algorithm will search the right side of t
    8 min read
    How to find the index of an element in an array using PHP ?
    In this article, we will discuss how to find the index of an element in an array in PHP. Array indexing starts from 0 to n-1. Here we have some common approachesTable of ContentUsing array_search() FunctionUsing array_flip()Using a custom functionUsing a foreach LoopUsing array_keys FunctionUsing ar
    6 min read
    Find a String in given Array of Strings using Binary Search
    Given a sorted array of Strings arr and a string x, The task is to find the index of x in the array using the Binary Search algorithm. If x is not present, return -1.Examples:Input: arr[] = {"contribute", "geeks", "ide", "practice"}, x = "ide"Output: 2Explanation: The String x is present at index 2.
    6 min read
    Javascript Program for Search an element in a sorted and rotated array
    An element in a sorted array can be found in O(log n) time via binary search. But suppose we rotate an ascending order sorted array at some pivot unknown to you beforehand. So for instance, 1 2 3 4 5 might become 3 4 5 1 2. Devise a way to find an element in the rotated array in O(log n) time.  Exam
    7 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

'); // $('.spinner-loading-overlay').show(); let script = document.createElement('script'); script.src = 'https://assets.geeksforgeeks.org/v2/editor-prod/static/js/bundle.min.js'; script.defer = true document.head.appendChild(script); script.onload = function() { suggestionModalEditor() //to add editor in suggestion modal if(loginData && loginData.premiumConsent){ personalNoteEditor() //to load editor in personal note } } script.onerror = function() { if($('.editorError').length){ $('.editorError').remove(); } var messageDiv = $('
').text('Editor not loaded due to some issues'); $('#suggestion-section-textarea').append(messageDiv); $('.suggest-bottom-btn').hide(); $('.suggestion-section').hide(); editorLoaded = false; } }); //suggestion modal editor function suggestionModalEditor(){ // editor params const params = { data: undefined, plugins: ["BOLD", "ITALIC", "UNDERLINE", "PREBLOCK"], } // loading editor try { suggestEditorInstance = new GFGEditorWrapper("suggestion-section-textarea", params, { appNode: true }) suggestEditorInstance._createEditor("") $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = true; } catch (error) { $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = false; } } //personal note editor function personalNoteEditor(){ // editor params const params = { data: undefined, plugins: ["UNDO", "REDO", "BOLD", "ITALIC", "NUMBERED_LIST", "BULLET_LIST", "TEXTALIGNMENTDROPDOWN"], placeholderText: "Description to be......", } // loading editor try { let notesEditorInstance = new GFGEditorWrapper("pn-editor", params, { appNode: true }) notesEditorInstance._createEditor(loginData&&loginData.user_personal_note?loginData.user_personal_note:"") $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = true; } catch (error) { $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = false; } } var lockedCasesHtml = `You can suggest the changes for now and it will be under 'My Suggestions' Tab on Write.

You will be notified via email once the article is available for improvement. Thank you for your valuable feedback!`; var badgesRequiredHtml = `It seems that you do not meet the eligibility criteria to create improvements for this article, as only users who have earned specific badges are permitted to do so.

However, you can still create improvements through the Pick for Improvement section.`; jQuery('.improve-header-sec-child').on('click', function(){ jQuery('.improve-modal--overlay').hide(); $('.improve-modal--suggestion').hide(); jQuery('#suggestion-modal-alert').hide(); }); $('.suggest-change_wrapper, .locked-status--impove-modal .improve-bottom-btn').on('click',function(){ // when suggest changes option is clicked $('.ContentEditable__root').text(""); $('.suggest-bottom-btn').html("Suggest changes"); $('.thank-you-message').css("display","none"); $('.improve-modal--improvement').hide(); $('.improve-modal--suggestion').show(); $('#suggestion-section-textarea').show(); jQuery('#suggestion-modal-alert').hide(); if(suggestEditorInstance !== null){ suggestEditorInstance.setEditorValue(""); } $('.suggestion-section').css('display', 'block'); jQuery('.suggest-bottom-btn').css("display","block"); }); $('.create-improvement_wrapper').on('click',function(){ // when create improvement option clicked then improvement reason will be shown if(loginData && loginData.isLoggedIn) { $('body').append('
'); $('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.unlocked-status--improve-modal-content').css("display","none"); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { showErrorMessage(e.responseJSON,e.status) }, }); } else { if(loginData && !loginData.isLoggedIn) { $('.improve-modal--overlay').hide(); if ($('.header-main__wrapper').find('.header-main__signup.login-modal-btn').length) { $('.header-main__wrapper').find('.header-main__signup.login-modal-btn').click(); } return; } } }); $('.left-arrow-icon_wrapper').on('click',function(){ if($('.improve-modal--suggestion').is(":visible")) $('.improve-modal--suggestion').hide(); else{ } $('.improve-modal--improvement').show(); }); const showErrorMessage = (result,statusCode) => { if(!result) return; $('.spinner-loading-overlay:eq(0)').remove(); if(statusCode == 403) { $('.improve-modal--improve-content.error-message').html(result.message); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); return; } } function suggestionCall() { var editorValue = suggestEditorInstance.getValue(); var suggest_val = $(".ContentEditable__root").find("[data-lexical-text='true']").map(function() { return $(this).text().trim(); }).get().join(' '); suggest_val = suggest_val.replace(/\s+/g, ' ').trim(); var array_String= suggest_val.split(" ") //array of words var gCaptchaToken = $("#g-recaptcha-response-suggestion-form").val(); var error_msg = false; if(suggest_val != "" && array_String.length >=4){ if(editorValue.length <= 2000){ var payload = { "gfg_post_id" : `${post_id}`, "suggestion" : `${editorValue}`, } if(!loginData || !loginData.isLoggedIn) // User is not logged in payload["g-recaptcha-token"] = gCaptchaToken jQuery.ajax({ type:'post', url: "https://apiwrite.geeksforgeeks.org/suggestions/auth/create/", xhrFields: { withCredentials: true }, crossDomain: true, contentType:'application/json', data: JSON.stringify(payload), success:function(data) { if(!loginData || !loginData.isLoggedIn) { grecaptcha.reset(); } jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('.suggest-bottom-btn').css("display","none"); $('#suggestion-section-textarea').hide() $('.thank-you-message').css('display', 'flex'); $('.suggestion-section').css('display', 'none'); jQuery('#suggestion-modal-alert').hide(); }, error:function(data) { if(!loginData || !loginData.isLoggedIn) { grecaptcha.reset(); } jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Something went wrong."); jQuery('#suggestion-modal-alert').show(); error_msg = true; } }); } else{ jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Minimum 4 Words and Maximum Words limit is 1000."); jQuery('#suggestion-modal-alert').show(); jQuery('.ContentEditable__root').focus(); error_msg = true; } } else{ jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Enter atleast four words !"); jQuery('#suggestion-modal-alert').show(); jQuery('.ContentEditable__root').focus(); error_msg = true; } if(error_msg){ setTimeout(() => { jQuery('.ContentEditable__root').focus(); jQuery('#suggestion-modal-alert').hide(); }, 3000); } } document.querySelector('.suggest-bottom-btn').addEventListener('click', function(){ jQuery('body').append('
'); jQuery('.spinner-loading-overlay').show(); if(loginData && loginData.isLoggedIn) { suggestionCall(); return; } // script for grecaptcha loaded in loginmodal.html and call function to set the token setGoogleRecaptcha(); }); $('.improvement-bottom-btn.create-improvement-btn').click(function() { //create improvement button is clicked $('body').append('
'); $('.spinner-loading-overlay').show(); // send this option via create-improvement-post api jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { showErrorMessage(e.responseJSON,e.status); }, }); });
"For an ad-free experience and exclusive features, subscribe to our Premium Plan!"
Continue without supporting
`; $('body').append(adBlockerModal); $('body').addClass('body-for-ad-blocker'); const modal = document.getElementById("adBlockerModal"); modal.style.display = "block"; } function handleAdBlockerClick(type){ if(type == 'disabled'){ window.location.reload(); } else if(type == 'info'){ document.getElementById("ad-blocker-div").style.display = "none"; document.getElementById("ad-blocker-info-div").style.display = "flex"; handleAdBlockerIconClick(0); } } var lastSelected= null; //Mapping of name and video URL with the index. const adBlockerVideoMap = [ ['Ad Block Plus','https://media.geeksforgeeks.org/auth-dashboard-uploads/abp-blocker-min.mp4'], ['Ad Block','https://media.geeksforgeeks.org/auth-dashboard-uploads/Ad-block-min.mp4'], ['uBlock Origin','https://media.geeksforgeeks.org/auth-dashboard-uploads/ub-blocke-min.mp4'], ['uBlock','https://media.geeksforgeeks.org/auth-dashboard-uploads/U-blocker-min.mp4'], ] function handleAdBlockerIconClick(currSelected){ const videocontainer = document.getElementById('ad-blocker-info-div-gif'); const videosource = document.getElementById('ad-blocker-info-div-gif-src'); if(lastSelected != null){ document.getElementById("ad-blocker-info-div-icons-"+lastSelected).style.backgroundColor = "white"; document.getElementById("ad-blocker-info-div-icons-"+lastSelected).style.borderColor = "#D6D6D6"; } document.getElementById("ad-blocker-info-div-icons-"+currSelected).style.backgroundColor = "#D9D9D9"; document.getElementById("ad-blocker-info-div-icons-"+currSelected).style.borderColor = "#848484"; document.getElementById('ad-blocker-info-div-name-span').innerHTML = adBlockerVideoMap[currSelected][0] videocontainer.pause(); videosource.setAttribute('src', adBlockerVideoMap[currSelected][1]); videocontainer.load(); videocontainer.play(); lastSelected = currSelected; }

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences