Giter Club home page Giter Club logo

dan-on / php-interval-tree Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 2.0 160 KB

Implementation of self balancing binary search tree data structure called Red-Black Tree. Based on interval tree described in "Introduction to Algorithms 3rd Edition", published by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein.

License: MIT License

PHP 100.00%
interval-tree overlap intersections range-tree red-black-tree data-structures php

php-interval-tree's People

Contributors

dan-on avatar transistive avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

php-interval-tree's Issues

Interval Merge

Hi, I have a question about the Interval->merge() function.

public function merge(Interval $otherInterval) { return new Interval( $this->low === null ? $otherInterval->low : min($this->low, $otherInterval->low), $this->high === null ? $otherInterval->high : max($this->high, $otherInterval->high) ); }

Consider an existing interval [1,5] and a new interval [7,9]... merging will result in a new interval [1,9]. Is this the intended behaviour? I assumed merging implied an overlap, say: [1,5] with [4,9] will result in [1,9] because 4<=5.

The reason that I ask, is because I'm looking for a specific interval tree functionality and I'm not sure if I can do this with your code. I have an interval X -> [1,10] that I need to check against an interval tree Y -> [1,4],[4,8],[7,9],[8,11].

What I want to do is Y->findCompleteOverlap(X). In the example above, this function would return 'true', because all nodes overlap the given interval X. On the other hand, if Y didn't contain interval [4,8], then it would return 'false' because there is a gap between all intervals in the tree: the intervals in Y don't completely overlap X.

Is it possible to do something like that with the existing code? I thought I could use "merge" to create one big interval and then compare it with X but that seems it won't work as intended (it will merge even when there is a gap).

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.