Git Product home page Git Product logo

sherxon / algods Goto Github PK

View Code? Open in Web Editor NEW
3.4K 3.4K 609.0 1.55 MB

Implementation of Algorithms and Data Structures, Problems and Solutions

Home Page: http://sherxon.com

License: MIT License

Java 100.00%
algorithms binary-search-tree bst data-structrues dfs dijkstra dynamic-programming graph-algorithms interview-questions java linked-list mergesort search-algorithm shortest-paths sort sorting-algorithms

algods's Issues

Fibonacci using matrix multiplication

Hello.
I'm not fluent in Java so I won't implement it by myself, however there is an O(log n) solution for finding nth Fibonacci number which is based on matrix exponentiation -

[[1 1] [1 0]]^n = [[F_{n+1} F_n] [F_n F_{n-1}]]

This can be done with exponentiation by squaring which is O(log n).

CycleDetection

Whether or not there is a cycle, this program always returns true after running
` for (Integer neighbor : graph.getNeighbors(start)) {

        if(visited.contains(neighbor) && !exited.contains(neighbor)) return true;

        if(!visited.contains(neighbor) && dfs(neighbor)) return true;
    }`

Another approach to Math.abs()

hi I like your code for ReverseInteger. Why do you use the Math.abs()? Here is another approach with less code:

public int reverse(int x) {
    int rev = 0;
    while(x != 0){
        rev = rev*10 + x%10;
        x = x/10;
    }
 
    return rev;
}

Bloom filter

It would be really cool to have Bloom Filter.

CycleDetection

Looks like CycleDetection will fail if Graph has multiple component.

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.