diff --git a/array-minimum-distance/array-minimum-distance b/array-minimum-distance/array-minimum-distance new file mode 100755 index 0000000..5206f73 Binary files /dev/null and b/array-minimum-distance/array-minimum-distance differ diff --git a/binary-search-tree-1-insertion/binary-search-tree-1-insertion.go b/binary-search-tree-1-insertion/binary-search-tree-1-insertion.go index 34f1070..c3b9968 100644 --- a/binary-search-tree-1-insertion/binary-search-tree-1-insertion.go +++ b/binary-search-tree-1-insertion/binary-search-tree-1-insertion.go @@ -32,7 +32,7 @@ func New(data int) *Node { func Search(root *Node, key int) *Node { //1. Base Cases: root is null or key is present at root if root == nil || root.data == key { - fmt.Println("The given previous node cannot be NULL") + //fmt.Println("The given previous node cannot be NULL") return root } diff --git a/binary-tree-1-introduction/binary-tree-1-introduction.go b/binary-tree-1-introduction/binary-tree-1-introduction.go index d09fd22..83f8bd5 100644 --- a/binary-tree-1-introduction/binary-tree-1-introduction.go +++ b/binary-tree-1-introduction/binary-tree-1-introduction.go @@ -29,7 +29,6 @@ func New(data int) *Node { } func main() { - //To allocate dynamically a new Node in C language : root = (struct Node*) malloc(sizeof(struct Node)); root := New(1) /* diff --git a/linked-list-circular-1-introduction/linked-list-circular-1-introduction.go b/linked-list-circular-1-introduction/linked-list-circular-1-introduction.go index e69de29..06ab7d0 100644 --- a/linked-list-circular-1-introduction/linked-list-circular-1-introduction.go +++ b/linked-list-circular-1-introduction/linked-list-circular-1-introduction.go @@ -0,0 +1 @@ +package main diff --git a/stack-reverse/stack-reverse.go b/stack-reverse/stack-reverse.go deleted file mode 100644 index 60abd03..0000000 --- a/stack-reverse/stack-reverse.go +++ /dev/null @@ -1,56 +0,0 @@ -// ==================================================== -// Data-Structures-with-Go Copyright(C) 2017 Furkan Türkal -// This program comes with ABSOLUTELY NO WARRANTY; This is free software, -// and you are welcome to redistribute it under certain conditions; See -// file LICENSE, which is part of this source code package, for details. -// ==================================================== - -package main - -import "fmt" - -const MaxUint = ^uint(0) -const MinUint = 0 -const MaxInt = int(MaxUint >> 1) -const MinInt = -MaxInt - 1 - -type Stack struct { - top int - capacity uint - array []int -} - -//Returns an initialized list -func (s *Stack) Init(capacity uint) *Stack { - s.top = -1 - s.capacity = capacity - s.array = make([]int, capacity) - return s -} - -//Returns an new list -func New(capacity uint) *Stack { - return new(Stack).Init(capacity) -} - -// Stack is full when top is equal to the last index -func IsFull(stack *Stack) bool { - return stack.top == int(stack.capacity)-1 -} - -// Stack is empty when top is equal to -1 -func IsEmpty(stack *Stack) bool { - return stack.top == -1 -} - -func main() { - - stack := New(100) - - //Push(stack, 10) - //Push(stack, 20) - //Push(stack, 30) - - fmt.Println("Popped from stack : %d", Pop(stack)) - -} diff --git a/stack-1-introduction/stack-1-introduction.go b/stack/stack.go similarity index 99% rename from stack-1-introduction/stack-1-introduction.go rename to stack/stack.go index 9ca058a..426f3b4 100644 --- a/stack-1-introduction/stack-1-introduction.go +++ b/stack/stack.go @@ -61,7 +61,6 @@ func Pop(stack *Stack) int { } func main() { - stack := New(100) Push(stack, 10) @@ -72,5 +71,4 @@ func main() { fmt.Println("Pushed to stack : 30") fmt.Printf("Popped from stack : %d", Pop(stack)) - } diff --git a/stack-1-introduction/stack-1-introduction_test.go b/stack/stack_test.go similarity index 100% rename from stack-1-introduction/stack-1-introduction_test.go rename to stack/stack_test.go