Skip to content

Instantly share code, notes, and snippets.

View IdrissDimson's full-sized avatar
👋
Working on open source projects

Idriss IdrissDimson

👋
Working on open source projects
View GitHub Profile
@IdrissDimson
IdrissDimson / liri-sites-colors-db.json
Last active October 10, 2015 00:20 — forked from pierremtb/liri-sites-colors-db.json
Liri Browser SitesColors database
[
{'domain':'facebook.com', 'color': '#3b5998'} ,
{'domain':'linkedin.com', 'color': '#646464'} ,
{'domain':'twitter.com', 'color': '#00aced'} ,
{'domain':'github.com', 'color': '#f5f5f5'} ,
{'domain':'khanacademy.org', 'color': '#66CD00'}
]
function selectionSort(arr){
for (var i = 0; i < arr.length; i++) {
let min = i;
// if the array index is less than the min, the min is equal to j.
// this finds the smallest number in the iteration.
for(let j = i + 1; j < arr.length; j++){
if(arr[j] < arr[min]){
min = j;
}
}
/* Returns either the index of the location in the array,
or -1 if the array did not contain the targetValue */
function doSearch(array, targetValue) {
let min = 0;
let max = array.length - 1;
let guess;
while(min < max + 1){
guess = Math.floor((max + min) / 2);
if(array[guess] === targetValue){
class BinarySearch {
int doSearch(int arr[], int targetValue)
{
int min = 0;
int max = arr.length - 1;
int guess;
while (min <= max)
{
// split the array in half