Git Product home page Git Product logo

hash-tables's Introduction

Hash Tables

Day 1

Implement a basic hash table without collision resolution.

  1. Implement a HashTable class and HashTableEntry class

  2. Implement a good hashing function.

    Recommend either of:

    • DJB2
    • FNV-1 (64-bit)
  3. Implement the hash_index() that returns an index value for a key.

  4. Implement the put(), get(), and delete() methods.

You can test this with:

python test_hashtable_no_collisions.py

The above test program is unlikely to have collisions, but it's certainly possible for various hashing functions. With DJB2 (32 bit) and FNV-1 (64 bit) hashing functions, there are no collisions.

Day 2

Implement linked-list chaining for collision resolution.

  1. Modify put(), get(), and delete() methods to handle collisions.

  2. There is no step 2.

You can test this with:

python test_hashtable.py

Day 3

Implement load factor measurements and automatic hashtable size doubling.

  1. Compute and maintain load factor.

  2. When load factor increases above 0.7, automatically rehash the table to double its previous size.

Stretch: When load factor decreases below 0.2, automatically rehash the table to half its previous size, down to a minimum of 128 slots.

Day 4:

Work on the hashtable applications directory (in any order you wish--generally arranged from easier to harder, below).

For these, you can use either the built-in dict type, or the hashtable you built. (Some of these are easier with dict since it's more full-featured.)

hash-tables's People

Contributors

br80 avatar briandoyle81 avatar beejjorgensen avatar squashgray avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.