Binary Search using Recursion in C#


Sajjad Arif Gul - December 3, 2015 - 4 comments

Recursive Binary Search implementations using Binary Tree in C#. This is a Divide-and-Conquer search algorithm that works on a sorted array. Demonstrate Binary search using Recursion in Binary Tree.

Source Code :

Output :

Author avatar

Sajjad Arif Gul

http://sajjadgul.com
Hi! I am Sajjad Arif Gul, Software Engineer, Web & Mobile Developer from Karachi Pakistan. I love sharing my knowledge that could possibly help someone’s life in some capacity. Happy Coding.

Related posts

4 comments

  1. jinasdoas

    It does no work with a number that is not in the array

  2. Kyle

    Process is terminated due to StackOverflowException when selecting value 15.

    to correct

    Console.WriteLine(“index no. is {0}”, b.searching(iArray, 0, iArray.Length , number));

  3. Vasanth

    The boundaries are wrong when making the recursive call. Please see the correct one below.
    else if (value < array[middle])
    {
    return searching(array, first, middle – 1, value); }
    else
    {
    return searching(array, middle + 1, last, value); }

  4. jp

    why do you need middle parameter? could you explain this?

Post a Comment

Your email address will not be published. Required fields are marked *