Skip to content

Instantly share code, notes, and snippets.

@rogerwschmidt
Created September 6, 2017 17:14
Show Gist options
  • Select an option

  • Save rogerwschmidt/2661af79aa067de6e444c188bd852392 to your computer and use it in GitHub Desktop.

Select an option

Save rogerwschmidt/2661af79aa067de6e444c188bd852392 to your computer and use it in GitHub Desktop.

Hash tables instructor notes

Objectives

  • Define a hash function
  • Explain how a hash table can be used to increase the performance of an algorithm

Define a hash function

Turn to your neighbot and define what a hash function is

Explain how a hash table can be used to increase the performance of an algorithm

Turn to your neighbor and discuss how a hash table can increase the performance of to following problem.

function hasDuplicates(str){
  for(let i = 0; i < str.length; i++){
    for(let j = 0; j < str.length; j++){
      if(i !== j && str[i] === str[j]) return true;
    }
  }
  return false;
}

hasDuplicates('123456') // false
hasDuplicates('123416') // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment