Giter VIP home page Giter VIP logo

hash-table-exercise's Introduction

Hash Table Exercise

Setup

  1. Clone a copy of this exercise. This command makes a new folder called hash-table-exercise, and then puts the exercise into this new folder. You do not need to fork the repository.
git clone ...

Use ls to confirm there's a new project folder

  1. Move your location into this project folder
cd hash-table-exercise
  1. Create a virtual environment named venv for this project:
python3 -m venv venv
  1. Activate this environment:
source venv/bin/activate

Verify that you're in a python3 virtual environment by running:

  • $ python --version should output a Python 3 version
  • $ pip --version should output that it is working with Python 3
  1. Install dependencies once at the beginning of this exercise with
# Must be in activated virtual environment
pip install -r requirements.txt
  1. Exit and re-enter the virtual enviornment with the following command. This is needed to ensure the correct version of pytest is used in the terminal.
deactivate && source venv/bin/activate

Activity

For this activity you will write the insert method for the two different hash tables (SeparateChainingTable and LinearProbingTable) within the hashtables directory.

Start withSeperateChainingTable, then complete LinearProbingTable

All this needs to do is insert the key into the table in the correct location. It does not need to handle the case where the key already exists (that is optional). Assume that the user will never insert the same key twice.

You should use the built in function hash as your hash function (though you will need to mod by the size of the table each time you insert).

The only other method needed to pass the tests is already there (get).

Optional Challenges

If you have extra time or are just super pumped about hash tables and want to do more after class you can do the following:

  • Stop assuming the user will never try to insert the same key twice.
  • Grow the table (double its size) when it is more than 75% full (self.size >= len(table) * 0.75).
  • Implement delete to remove an item from the table.

hash-table-exercise's People

Contributors

alope107 avatar beccaelenzil avatar cheezitman avatar kaidamasaki avatar

Watchers

 avatar  avatar  avatar  avatar  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.