diff --git a/linked-list-1-introduction/README.md b/linked-list-1-introduction/README.md new file mode 100644 index 0000000..12278ed --- /dev/null +++ b/linked-list-1-introduction/README.md @@ -0,0 +1,6 @@ +

Linked List | SET 1 (INTRODUCTION) Source

+ +[What It Is](#what-it-is) + +## What It Is + diff --git a/linked-list-1-introduction/linked-list-1-introduction.go b/linked-list-1-introduction/linked-list-1-introduction.go new file mode 100644 index 0000000..99c480b --- /dev/null +++ b/linked-list-1-introduction/linked-list-1-introduction.go @@ -0,0 +1,54 @@ +// ==================================================== +// 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" + +type Node struct { + data int + next *Node +} + +//Returns an initialized list +func (n *Node) Init() *Node { + n.data = -1 + return n +} + +//Returns an new list +func New() *Node { + return new(Node).Init() +} + +func printList(n *Node){ + for n != nil { + fmt.Println(n.data) + n = n.next + } +} + +func main() { + + //To allocate dynamically a new Node in C language : head = (struct Node*) malloc(sizeof(struct Node)); + head := New() + second := New() + third := New() + + //Assign data in first node + head.data = 1 + //Link first node with second node + head.next = second + + second.data = 2 + second.next = third + + third.data = 3 + third.next = nil + + printList(head) +} \ No newline at end of file diff --git a/linked-list-2-inserting-a-node/README.md b/linked-list-2-inserting-a-node/README.md new file mode 100644 index 0000000..e69de29 diff --git a/linked-list-2-inserting-a-node/linked-list-2-inserting-a-node.go b/linked-list-2-inserting-a-node/linked-list-2-inserting-a-node.go new file mode 100644 index 0000000..e69de29 diff --git a/linked-list-3-deleting-a-node/README.md b/linked-list-3-deleting-a-node/README.md new file mode 100644 index 0000000..e69de29 diff --git a/linked-list-3-deleting-a-node/linked-list-3-deleting-a-node.go b/linked-list-3-deleting-a-node/linked-list-3-deleting-a-node.go new file mode 100644 index 0000000..e69de29 diff --git a/linked-list-circular-1-introduction/README.md b/linked-list-circular-1-introduction/README.md new file mode 100644 index 0000000..e69de29 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 new file mode 100644 index 0000000..e69de29 diff --git a/linked-list-circular-2-insertion-singly/README.md b/linked-list-circular-2-insertion-singly/README.md new file mode 100644 index 0000000..e69de29 diff --git a/linked-list-circular-2-insertion-singly/linked-list-circular-2-insertion-singly.go b/linked-list-circular-2-insertion-singly/linked-list-circular-2-insertion-singly.go new file mode 100644 index 0000000..e69de29 diff --git a/linked-list-find-length/README.md b/linked-list-find-length/README.md new file mode 100644 index 0000000..e69de29 diff --git a/linked-list-find-length/linked-list-find-length.go b/linked-list-find-length/linked-list-find-length.go new file mode 100644 index 0000000..e69de29 diff --git a/linked-list-merge-two-sorted/README.md b/linked-list-merge-two-sorted/README.md new file mode 100644 index 0000000..e69de29 diff --git a/linked-list-merge-two-sorted/linked-list-merge-two-sorted.go b/linked-list-merge-two-sorted/linked-list-merge-two-sorted.go new file mode 100644 index 0000000..e69de29 diff --git a/linked-list-reverse/README.md b/linked-list-reverse/README.md new file mode 100644 index 0000000..e69de29 diff --git a/linked-list-reverse/linked-list-reverse.go b/linked-list-reverse/linked-list-reverse.go new file mode 100644 index 0000000..e69de29