Skip to content
New issue

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

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

Already on GitHub? # to your account

Codebase improvements #336

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -141,28 +141,3 @@ func (ll *DoubleLinkedList) DisplayReverse() {

fmt.Print("\n")
}

/*
func main() {
ll := DoubleLinkedList{}

ll.addAtBeg(10)
ll.addAtEnd(20)
ll.display()
ll.addAtBeg(30)
ll.display()

ll.reverse()
ll.display()
ll.displayReverse()

fmt.Print(ll.delAtBeg(), "\n")
fmt.Print(ll.delAtEnd(), "\n")
fmt.Print("Display")
ll.display()
fmt.Print(ll.delAtBeg(), "\n")
ll.display()
fmt.Print(ll.delAtBeg(), "\n")
ll.display()
}
*/
104 changes: 0 additions & 104 deletions data_structures/linkedlist/singly_linkedlist/singly_linkedlist2.go

This file was deleted.

15 changes: 0 additions & 15 deletions dynamic_programming/binomialcoefficient.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
package dynamic_programming

// func main() {
// myArrayOfK := [4]int{5, 6, 7, 8}
// var x int

// fmt.Println("\nBinomial Coefficient Using Dynamic Programming:", bin2(50, 5))
// for _, element := range myArrayOfK {
// start := time.Now()
// x = bin2(50, element)
// elapsed := time.Since(start)
// fmt.Println("bin2 (50,", element, ") = ", x, " took ", elapsed)

// }

// }

// Bin2 function
func Bin2(n int, k int) int {
var i, j int
Expand Down
14 changes: 0 additions & 14 deletions dynamic_programming/knapsack.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,3 @@ func Solve(maxWeight int, weights, values []int) int {
}
return dp[n][m]
}

/*
func main() {
maxWeight := 50
values := []int{
60, 100, 120,
}
weights := []int{
10, 20, 30,
}
maxProfit := solve(maxWeight, weights, values)
fmt.Println(maxProfit)
}
*/
9 changes: 0 additions & 9 deletions dynamic_programming/longestcommonsubsequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,3 @@ func LongestCommonSubsequence(a string, b string, m int, n int) int {
// returning the length of longest common subsequence
return lcs[m][n]
}

// func main(){
// // declaring two strings and asking for input

// var a,b string
// fmt.Scan(&a, &b)
// // calling the LCS function
// fmt.Println("The length of longest common subsequence is:", longestCommonSubsequence(a,b, len(a), len(b)))
// }
9 changes: 0 additions & 9 deletions dynamic_programming/longestpalindromicsubsequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,3 @@ func LpsDp(word string) int {

return dp[1][N-1]
}

/*
func main() {
// word := "aaabbbbababbabbabbabf"
word := "aaaabbbba"
fmt.Printf("%d\n", lpsRec(word, 0, len(word)-1))
fmt.Printf("%d\n", lpsDp(word))
}
*/
8 changes: 0 additions & 8 deletions dynamic_programming/matrixmultiplication.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,3 @@ func MatrixChainDp(D []int) int {

return dp[1][N-1]
}

/*
func main() {
D := []int{2, 2, 2, 2, 2} // 4 matrices
fmt.Print(matrixChainRec(D, 1, 4), "\n")
fmt.Print(matrixChainDp(D), "\n")
}
*/
13 changes: 0 additions & 13 deletions dynamic_programming/rodcutting.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,3 @@ func CutRodDp(price []int, length int) int {

return r[length]
}

/*
func main() {
length := 10
price := []int{0, 1, 5, 8, 9, 17, 17, 17, 20, 24, 30}
// price := []int{0, 10, 5, 8, 9, 17, 17, 17, 20, 24, 30}

// fmt.Print(price[5]+price[length-5], "\n")

fmt.Print(cutRodRec(price, length), "\n")
fmt.Print(cutRodDp(price, length), "\n")
}
*/
24 changes: 0 additions & 24 deletions graphs/depth_first_search/depthfirstsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,3 @@ func Dfs(start, end int, nodes []int, edges [][]bool) ([]int, bool) {
}
return nil, false
}

// func main() {
// nodes := []int{
// 1, 2, 3, 4, 5, 6,
// }
// /*
// sample graph
// ①-②
// | |
// ③-④-⑤-⑥
// */
// edges := [][]bool{
// {false, true, true, false, false, false},
// {true, false, false, true, false, false},
// {true, false, false, true, false, false},
// {false, true, true, false, true, false},
// {false, false, false, true, false, true},
// {false, false, false, false, true, false},
// }
// start := 1
// end := 6
// route, _ := dfs(start, end, nodes, edges)
// fmt.Println(route)
// }
15 changes: 0 additions & 15 deletions graphs/floyd_warshall/floydwarshall.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,3 @@ func FloydWarshall(graph Matrix) Matrix {

return result
}

// func main() {
// var graph Matrix
// graph = Matrix{{0, maxValue, -2, maxValue},
// {4, 0, 3, maxValue},
// {maxValue, maxValue, 0, 2},
// {maxValue, -1, maxValue, 0}}

// result := FloydWarshall(graph)

// //Print result
// for i := 0; i < len(result); i++ {
// fmt.Printf("%4g\n", result[i])
// }
// }
5 changes: 0 additions & 5 deletions other/max_subarray_sum/maxsubarraysum.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,3 @@ func MaxSubarraySum(array []int) int {
}
return maxTillNow
}

// func main() {
// array := []int{-2, -5, 6, 0, -2, 0, -3, 1, 0, 5, -6}
// fmt.Println("Maximum contiguous sum: ", maxSubarraySum(array))
// }
14 changes: 0 additions & 14 deletions other/password_generator/passwordgenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,3 @@ func GeneratePassword(minLength int, maxLength int) string {
}
}
}

// func main() {
// rand.Seed(time.Now().Unix())

// fmt.Print("Please specify a minimum length: ")
// var minLength int
// fmt.Scanf("%d", &minLength)

// fmt.Print("Please specify a maximum length: ")
// var maxLength int
// fmt.Scanf("%d", &maxLength)

// fmt.Printf("Your generated password is %v\n", generatePassword(minLength, maxLength))
// }
8 changes: 0 additions & 8 deletions sort/heapsort.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func (h maxHeap) MaxHeapify(i int) {
if r < h.size() && h.slice[r] > h.slice[max] {
max = r
}
//log.Printf("MaxHeapify(%v): l,r=%v,%v; max=%v\t%v\n", i, l, r, max, h.slice)
if max != i {
h.slice[i], h.slice[max] = h.slice[max], h.slice[i]
h.MaxHeapify(max)
Expand All @@ -34,17 +33,10 @@ func (h maxHeap) size() int { return h.heapSize } // ???

func HeapSort(slice []int) []int {
h := buildMaxHeap(slice)
//log.Println(slice)
for i := len(h.slice) - 1; i >= 1; i-- {
h.slice[0], h.slice[i] = h.slice[i], h.slice[0]
h.heapSize--
h.MaxHeapify(0)
/*if i == len(h.slice)-1 || i == len(h.slice)-3 || i == len(h.slice)-5 {
element := (i - len(h.slice)) * -1
fmt.Println("Heap after removing ", element, " elements")
fmt.Println(h.slice)

}*/
}
return h.slice
}
Loading