Coder Social home page Coder Social logo

ads-heaps's Introduction

Heaps Lab

Ada Developers Academy / Lovelace Learning Labs

Advanced Data Structures 1 - Trees

Week 4

Instructions

Download

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

Install

$ npm install

Run tests in watch mode

$ npm test

Assignment

Core

  1. Read through the existing code in heap.js and skim the tests in heap.test.js
  2. Implement insert and _float to make the appropriate tests pass
  3. Implement removeMax and _sink to make the appropriate tests pass
  4. Implement _buildheap to make the appropriate tests pass
  5. Implement heapsort to make the appropriate tests pass

Optional

Submit your assignment in Learn before starting to work on these, then do them on a branch

  1. Test and implement a function to remove an element from the heap. What does the interface for this look like?
  2. Modify your heap to use a 0-indexed array.
  3. Make your heap accept arbitrary data:
    • Modify the constructor to take an optional callback isHigherPriority, and use it to compare records in float and sink
      • What should the default value of isHigherPriority be?
      • Test your capabilities by creating a min-heap
    • Modify insert to take an opaque record object instead of a priority and element. Fix all the tests that break!
    • Modify removeMax to return an opaque record object. Fix all the tests that break!
    • Test your implementation by heapsorting an array of integers, an array of strings, and an array of complex objects

ads-heaps's People

Watchers

 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.