Coder Social home page Coder Social logo

kdtree-1's Introduction

Kdtree

This is the week 5 assignment of [Coursera Algorithm, part I] (https://www.coursera.org/course/algs4partI) class.

Summary

This program implements 2d-tree data type to represent a set of points in the unit square, which speeds up the range search method compared with a brute force algorithm (shown in PointSET.java).

PointSET

Use a regular binary search tree to store the point and support only brute force range search method. The API is shown below:

   public class PointSET {
      public PointSET()                               // construct an empty set of points
      public boolean isEmpty()                        // is the set empty?
      public int size()                               // number of points in the set
      public void insert(Point2D p)                   // add the point p to the set (if it is not already in the set)
      public boolean contains(Point2D p)              // does the set contain the point p?
      public void draw()                              // draw all of the points to standard draw
      public Iterable<Point2D> range(RectHV rect)     // all points in the set that are inside the rectangle
      public Point2D nearest(Point2D p)               // a nearest neighbor in the set to p; null if set is empty
   }

KdTree

KdTree uses a red-black BST that inserts 2d points alternately based on their x and y corrdinate. This 2d-tree representation allows for effienct range search method. Its API is same as pointSET above.

Details of the assignment requirements can be found here. The checklist can be found here.

kdtree-1's People

Contributors

mamie avatar

Watchers

James Cloos avatar ThinkGamer 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.