GithubHelp home page GithubHelp logo

jocegonz / ads-binary-search-trees Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lovelace-learning-labs/ads-binary-search-trees

0.0 1.0 0.0 169 KB

JavaScript 97.85% Dockerfile 2.07% Shell 0.08%

ads-binary-search-trees's Introduction

Red-Black Trees

Ada Developers Academy / Lovelace Learning Labs

Advanced Data Structures 1 - Trees

Week 3

Instructions

Since red-black trees are a special type of binary search tree, we'll reuse the binary search tree tests from last week's lab. That means that this week's lab has a bit of a weird setup process.

Option 1: start over with a new repo

This option is simpler, but involves juggling multiple repos with similar file structures. Recommended if you're less comfortable with git.

Download

$ git clone <paste-url>
$ cd <created-directory>

Install

$ npm install

Run tests in watch mode

$ npm test

Option 2: merge stubs into your existing binary search tree repo

The advantage here is that it's easier to build on your existing binary search tree code, and you don't need to juggle multiple directories. The disadvantage is that the git setup is a fair bit more complex.

# cd into your lab repo from last week
$ cd <path>/ads-binary-search-trees

# Check out a new branch for this week's work
$ git checkout -b red-black-trees

# Add this week's lab as a second remote
$ git remote add rbt https://github.com/Lovelace-Learning-Labs/ads-red-black-trees.git

# Merge this week's lab's code into your branch
$ git fetch rbt
$ git merge rbt/master

# Install additional packages (should be a no-op)
$ npm install

# Run tests as usual
$ npm test

Assignment - Week 3

Core

  1. Read through the existing code in src/data_structures/red_black_tree.js and ensure you understand how it works
  2. Make sure that both the binary search tree tests and the red-black tree tests are running (and failing) against RedBlackTree
  3. Implement RedBlackTree._insertInternal() and RedBlackTree._insertRebalance() to pass the tests

Optional

  1. Implement RedBlackTree.delete() to pass the tests

  2. Implement a visualization of a user list that relies on a red-black tree

  3. Write a command-line program to profile the performance of an ordered dictionary. It should...

    • Build a tree of a certain size and then measure the time it takes to do various operations
    • Measure the time it takes to build the tree, to do a set number of lookups, and to delete every record in the tree
    • Build trees of size 1,000 to 25,000 nodes, at 1,000 node increments
    • Use both random and pathological input orderings to generate trees

    Run your profiler against both your red-black tree implementation and your binary search tree implementation. You should get 4 sets of performance data, one for each combination of algorithm and input ordering. Plug these data into your favorite spreadsheet and make a graph. Can you see the difference between linear and logarithmic peformance?

    Note: because JS is JIT-compiled, you may see significantly lower performance on the first few runs of any given operation for your program. To avoid this, you can "warm up" the JIT by creating a dummy tree and doing a few hundred inserts, lookups and deletes before starting the profile run.

ads-binary-search-trees's People

Contributors

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