Problem Set 8: Searching

Write a C program that declares an integer array length of one hundred (100) and initializes the array with ten (10) values. Then do the following operations. [NB: Use Function] [Write each program in a different file. The file name will be the problem number]

  1. The function will return 1 if the key element is found in the array otherwise return 0, find X (take input X from the user), and print "Found" if X is found in the array otherwise print "Not Found".

    1. Implement iterative linear search.

    2. Implement recursive linear search.

    3. Implement iterative binary search.

    4. Implement recursive binary search.

  2. The function will return the array index if the key element is found in the array otherwise return -1, find X (take input X from the user), and print "Found" if X is found in the array otherwise print "Not Found".

    1. Implement iterative linear search.

    2. Implement recursive linear search.

    3. Implement iterative binary search.

    4. Implement recursive binary search.

  3. The function will return the array index if the key element is found in the array otherwise return -1, find X (take input X from the user), and print the array index if X is found in the array otherwise print -1.

    1. Implement iterative linear search.

    2. Implement recursive linear search.

    3. Implement iterative binary search.

    4. Implement recursive binary search.

Last updated