Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENHANCEMENT] Include Time and Space Complexity Information #698 #742

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions graph/bellmanford.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// It is slower than Dijkstra but capable of handling negative edge weights.
// https://en.wikipedia.org/wiki/Bellman%E2%80%93Ford_algorithm
// Implementation is based on the book 'Introduction to Algorithms' (CLRS)
// Worst Case Time Complexity: O(V * E)
// Auxiliary Space: O(V)

package graph

Expand Down
4 changes: 4 additions & 0 deletions graph/cycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package graph

// Worst Case Time Complexity: O(V + E)
// Auxiliary Space: O(V)
func (g *Graph) HasCycle() bool {
//this implimetation referred as 3-color too
all := map[int]struct{}{}
Expand Down Expand Up @@ -45,6 +47,8 @@ func (g Graph) hasCycleHelper(v int, all, visiting, visited map[int]struct{}) bo
}

// this function can do HasCycle() job but it is slower
// Worst Case Time Complexity: O(V + E)
// Auxiliary Space: O(V)
func (g *Graph) FindAllCycles() []Graph {
all := map[int]struct{}{}
visiting := map[int]struct{}{}
Expand Down
3 changes: 3 additions & 0 deletions graph/depthfirstsearch.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Worst Case Time Complexity: O(V + E)
// Auxiliary Space: O(V)

package graph

func GetIdx(target int, nodes []int) int {
Expand Down