Giter Club home page Giter Club logo

algorithms's People

Contributors

arnauddri avatar

Stargazers

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

Watchers

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

algorithms's Issues

Yen's K-Shortest Path

Hello

I would be thankful a lot if you could add Yen's KSP to the Graphs algorithms. In general, it uses Dijkstra to find k-shortest paths and is crucial, when you need to get multiple weighted shortest paths contrary to one shortest path.

There are just a few implementations of it:
https://github.com/Pent00/YenKSP in Python
https://code.google.com/p/k-shortest-paths/ in C++/Java/C#

Having this one implemented would be a radical improvement comparing to other algorithm library implementations.

On another hand, I would be very curious to hear about other implementations, like Eppstein or Lawler

Matrix code one line fix

line 150:
result := MakeMatrix(make([]float64, A.cols*A.rows), A.cols, A.rows)

maybe change to:
result := MakeMatrix(make([]float64, A.cols*A.rows), A.rows, .cols)

the order of the params in not right ??? :)

RSelect method not working as expected

Problem

The RSelect method is not returning the correct k-smallest element.

Here is an example:

arr := []int{5, 2, 6, 8, 3, 1}
x := RSelect(arr, 6, 0)

fmt.Println("Value: ", x)

The printed value is 5, when it should be 1.

Test

The test implemented for RSelect is running successfully, showing that it was implemented incorrectly.

There is an error in the applied boolean logic. The test is using && to validate the returned values, when it should be using ||.

Here is the correct test implementation:

func TestRSelect(t *testing.T) {
	arr := []int{5, 2, 6, 8, 3, 1}

	i0 := RSelect(arr, 6, 0)
	i1 := RSelect(arr, 6, 1)
	i2 := RSelect(arr, 6, 2)
	i3 := RSelect(arr, 6, 3)
	i4 := RSelect(arr, 6, 4)
	i5 := RSelect(arr, 6, 5)
	if i0 != 1 ||
		i1 != 2 ||
		i2 != 3 ||
		i3 != 5 ||
		i4 != 6 ||
		i5 != 8 {
		fmt.Println("Error: ", i0, i1, i2, i3, i4, i5)
		t.Error()
	}
}

Matrix code make the "&&" to "||", make sure the rows and cols bve the same

}

func (A *Matrix) add(B *Matrix) error {

  • if A.cols != B.cols && A.rows != B.rows {
  • if A.cols != B.cols || A.rows != B.rows {
    return errors.New("Wrong input sizes")
    }
    for i := 0; i < A.rows; i++ {
    @@ -102,7 +102,7 @@ func (A *Matrix) add(B *Matrix) error {
    }

func (A *Matrix) substract(B *Matrix) error {

  • if A.cols != B.cols && A.rows != B.rows {
  • if A.cols != B.cols || A.rows != B.rows {
    return errors.New("Wrong input sizes")
    }
    for i := 0; i < A.rows; i++ {

PreOrder, InOrder, and PostOrder Traversal

it would be nice to have PreOrder, InOrder, and PostOrder traversal methods that return nodes in the desired order in an array or slice. I guess my friend and I can work this out.

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.