Code Monkey home page Code Monkey logo

problems's People

Stargazers

 avatar

Watchers

 avatar

problems's Issues

Number of shortest paths between two given nodes

Given a graph with edge weights, such that every cycle in the graph has a strictly positive weight, design an algorithm to compute the number of shortest paths between two given nodes u and v of the graph.

Verify minimum cost path for directed graph

Suppose you are given a directed graph G = (V, E) with costs on the edges ce for e ∈ E and a sink t (costs may be negative). Assume that you also have finite values d(v) for v ∈ V . Someone claims that, for each node v ∈ V , the quantity d(v) is the cost of the minimum-cost path from node v to the sink t.

(a) Give a linear-time algorithm (time O(m) if the graph has m edges) that verifies whether this claim is correct.

(b) Assume that a distance are correct, and d(v) is finite for all v ∈ V . Now you need to compute distances to a different sink t′. Give an O(m log m) algorithm for computing distance d′(v) for all nodes v ∈ V to the sink node t′.

Vertex cover in a tree

A vertex cover of a graph G = (V, E) is a subset of vertices S ⊆ V that includes at least one endpoint of every edge in E. Give a linear-time algorithm to find the smallest vertex cover of a given undirected tree T = (V, E).

Longest common substring

The longest common substring of two strings X and Y is the longest string which appears as a run of consecutive letters in both strings. Give an O(|X||Y|) dynamic programming algorithm, and a non dynamic programming algorithm, for the above problem.

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.