This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{'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'} | |
] |