Skip to content

Instantly share code, notes, and snippets.

@jbubriski
Last active February 7, 2017 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbubriski/16194b94eb3a5ff69ce21e7b2bec8ddc to your computer and use it in GitHub Desktop.
Save jbubriski/16194b94eb3a5ff69ce21e7b2bec8ddc to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoAlgorithms
{
class BinarySearch
{
public BinarySearch()
{
}
public int Search(int[] values, int valueToSearchFor)
{
for (int i = 0; i < values.Length; i++)
{
}
return 1;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoAlgorithms
{
class Program
{
static void Main(string[] args)
{
// var name = "Chiemeka";
var valueToSearchFor = 3;
var values = new int[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
var searcher = new BinarySearch();
var index = searcher.Search(values, valueToSearchFor);
if (index >= 0)
{
Console.WriteLine("Value found at index " + index);
}
else
{
Console.WriteLine("Value not found");
}
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment