Coder Social home page Coder Social logo

shortest_path_algorithm's Introduction

Shortest_path_algorithm

Data Structure that has been utilized in the program includes breadth-first search algorithm and queue. Breadth-first search algorithm is utilized to traverse through the graph. For every node that has been visited, it will be ‘colored’ which is represented by making it negative. Once a node is colored, it will not be visited again. As the program traverses through the graph, it labels the minimum number of turns it requires to get to that particular node. Basically, all nodes on the graph will be visited and it takes O(N) run-time to complete it. But now the number of turns is not minimal yet. That is why the program need to repeat the whole process for every row and it eventually takes O(NM) run-time to finish computing the minimum number of turns.

Run-time Complexity:

Construction of data structure to represent input:

A 2D string is first used to store the characters, then a matrix is deployed to convert the characters into integers. Therefore, O(NM) run-time is required for loading the input.

Computing the number of turns:

As mentioned above, it takes O(NM) run-time to compute the data.

shortest_path_algorithm's People

Contributors

jiaenchua 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.