Giter VIP home page Giter VIP logo

ls-data-structures-ii's Introduction

Data Structures II

Topics:

  • Tree
  • Graph
  • Binary Search Tree

Trees

  • Should have the methods: addChild, and contains
  • Each node on the tree should have a value property and a children array.
  • addChild(value) should accept a value and add it to that node's children array.
  • contains(value) should return true if the tree or its children the given value.
  • When you add nodes to the children array use new Tree(value) to create the node.
  • You can instantiate the Tree class inside of itself.

Binary Search Tree

  • Should have the methods: insert, contains, depthFirstForEach, and breadthFirstForEach.
  • insert(value) inserts the new value at the correct location in the tree.
  • contains(value) searches the tree and returns true if the the tree contains the specified value.
  • depthFirstForEach(cb) should iterate over the tree using DFS and passes each node of the tree to the given callback function.
  • breadthFirstForEach(cb) should iterate over the tree using BFS and passes each node of the tree to the given callback function (hint: you'll need to either re-implement or import a queue data structure for this).

Graphs

  • Should have methods named addNode, contains, removeNode, addEdge, getEdge, and removeEdge
  • addNode(newNode, toNode) should add a new item to the graph. If toNode is given then the new node should share an edge with an existing node toNode.
  • contains(value) should return true if the graph contains the given value.
  • removeNode(value) should remove the specified value from the graph.
  • addEdge(fromNode, toNode) should add an edge between the two specified nodes.
  • getEdge(fromNode, toNode) should return true if an edge exists between the two specified graph nodes.
  • removeEdge(fromNode, toNode) should remove the edge between the two specified nodes.

Extra Credit

  • Add a method to the Graph class that searches through the graph using edges. Make this search first as a depth first search and then refactor to a breadth first search.
  • Read up on heaps here. Then implement one!
  • Read up on red-black trees here. Then implement one!

ls-data-structures-ii's People

Contributors

seanchen1991 avatar phytertek avatar sunjieming avatar hohguy avatar

Watchers

Joram Clervius 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.