You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+1-4
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,15 @@
1
1
## Contributing Guide:
2
2
3
-
4
3
### Prerequisites
5
4
6
5
The only prerequisites is to have go installed on you computer in order to contribute. Follow how to install instructions from [golang download instructions](https://golang.org/doc/install) if you don't already have.
7
6
8
-
9
7
### Issues
10
8
11
9
If you find anything wrong about any data structures or algorithm not working the way they should then feel free to create a new issue, but before doing that make sure that no one else has created the same issue.
12
10
13
11
It would be better if you create a issue first before implementing anything, so that other people don't accidently duplicate your effort.
14
12
15
-
16
13
### Pull Requests
17
14
18
15
Before submitting a pull request, please make sure the following is done:
@@ -34,4 +31,4 @@ We look forward to your contributions. :joy:
Copy file name to clipboardExpand all lines: README.md
+76-80
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,11 @@
2
2
3
3
Data Structures and Algorithms (DSA) is one of the most important topic in computer science that every CS student must be proficient in and even non-CS students must have basic understanding of it. It is said that DSA is like bread and butter, necessity of CS. This repository is made for those students (like me :sunglasses:) who are eager to learn and want to implement data strucutures and algorithms.
4
4
5
-
6
5
### Why Go/GoLang and not C, C++ or Java?
7
6
8
7
I wouldn't disagree that C, C++ or Java wouldn't be a great language to implement DSA as one has to take care of lot things while writing the code like memory allocations and proper deallocations and by doing so one learns a lot.
9
8
10
-
However the reason why go would also be a good language to implement DSA is that it lacks a lot of magic. There is no operator overloading, so no way to hide extra complexity. An index operation is O(1), a loop is O(n) - always. There are no generics, so a lot of extra abstractions and helpers don't exist, which is actually pretty great. There is no laziness or other compiler-driven magic that might alter the runtime of your algorithms significantly. And Go has pointer and low-level primitives for slices, meaning it is apparent when data is packed or when data has an extra indirection. *In short*: Go make the actual algorithmic execution obvious from the code, which is a good thing to learn algorithms.
9
+
However the reason why go would also be a good language to implement DSA is that it lacks a lot of magic. There is no operator overloading, so no way to hide extra complexity. An index operation is O(1), a loop is O(n) - always. There are no generics, so a lot of extra abstractions and helpers don't exist, which is actually pretty great. There is no laziness or other compiler-driven magic that might alter the runtime of your algorithms significantly. And Go has pointer and low-level primitives for slices, meaning it is apparent when data is packed or when data has an extra indirection. _In short_: Go make the actual algorithmic execution obvious from the code, which is a good thing to learn algorithms.
11
10
12
11
**Conclusion**: Go would also be a good language to get started with implementing Data Structures and Algorithms. :computer:
13
12
@@ -18,8 +17,8 @@ However the reason why go would also be a good language to implement DSA is that
18
17
3. Now `cd <folder-name>` into the folder where the file you want to run is located.
19
18
4. Now run `go run <file-name>`.
20
19
21
-
22
20
### Example
21
+
23
22
Let's assume that I want to run files located in `graphs/directed_unweighted` directory then the syntax to run it would be:
24
23
25
24
```
@@ -30,95 +29,92 @@ go run graph.go traversal.go
30
29
31
30
**Note**: If a folder contains multiple `go` files then use `go run <file-name> [<file-name>...]`. For e.g `bst_using_arr` folder contains two files: `bst_using_arr.go` and `traversal.go`. So use the command `go run bst_using_arr.go traversal.go`.
32
31
33
-
34
32
### FOLDER NAMES
35
33
36
-
01.**algorithms** -
37
-
**01knapsack_dp* - 0-1 Knapsack Problem using Dynamic Programming
38
-
**activity_selection_gp* - Activity Selection using Greedy Programming
39
-
**articulation_point_detection* - Detecting Articulation Points in an undirected graph
40
-
**assembly_line_scheduling* - Assembly Line Scheduling algorithm using Dynamic Programming
41
-
**bellman_ford* - Bellman Ford Algorithm
42
-
**bridge_detection* - Bridge Detection/Cut Edge Detection in an undirected graph
43
-
**cd_directed_graph_traversals* - Cycle Detection in Directed Graphs using Traversals techniques :point_left:
44
-
**cd_undirected_graph_traversals* - Cycle Detection in Undirected Graphs using Traversals techniques :point_left:
-_circular_doubly_ll_ - Circular Doubly Linked List
89
+
-_circular_ll_ - Circular Linked List
90
+
-_doubly_ll_ - Doubly Linked List
91
+
-_pres_rev_single_ll_ - Preserve order during insertion on Single Linked List and Reversing Single Linked List
92
+
-_single_ll_ - Single Linked List
93
+
5.**queues** -
94
+
-_cdqueue_ - Circular Double ended Queue
95
+
-_cqueue_ - Circular Queue
96
+
-_dqueue_ - Double ended Queue
97
+
-_priority_queue_ - Priority Queue with the use of Min Heap
98
+
-_simple_queue_ - Simple Queue
99
+
6.**stack** - stack
100
+
7.**trees** -
101
+
-_avl_tree_using_ll_ - AVL Tree using linked list with BFS and DFS (Pre, In, Post) order traversals.
102
+
-_bst_using_arr_ - Binary Search Tree using array with BFS and DFS (Pre, In, Post) order traversals.
103
+
-_bst_using_ll_ - Binary Search Tree using linked list with BFS and DFS (Pre, In, Post) order traversals.
104
+
-_simple_bt_using_arr_ - Simple Binary Tree using array with BFS and DFS (Pre, In, Post) order traversals.
105
+
-_simple_bt_using_ll_ - Simple Binary Tree using linked list with BFS and DFS (Pre, In, Post) order traversals.
109
106
110
107
**Note**: The pointer " :point_left: " indicates incomplete implementation and is in todo list.
111
108
112
-
113
109
### Contribution
114
110
115
111
Read the [contributing guide](CONTRIBUTING.md) to see how to contribute.
116
112
117
-
118
113
### License
114
+
119
115
This repository is released under the [MIT license](https://opensource.org/licenses/MIT). In short, this means you are free to use this software in any personal, open-source or commercial projects. Attribution is optional but appreciated.
Copy file name to clipboardExpand all lines: graphs/notes.md
+19-19
Original file line number
Diff line number
Diff line change
@@ -4,24 +4,23 @@ In computer science, a graph is an abstract data type that is meant to implement
4
4
5
5
A graph `( G = <V, E> )` data structure consists of a finite (and possibly mutable) set of vertices (`V`) or nodes or points, together with a set of unordered pairs of these vertices for an undirected graph or a set of ordered pairs for a directed graph. These pairs are known as edges (`E`), arcs, or lines for an undirected graph and as arrows, directed edges, directed arcs, or directed lines for a directed graph.
6
6
7
-
**Note**: The number of edges `|E|` possible in an undirected graph with `|V|` vertices and no loops: `0 ≤ |E| ≤ |V|(|V| − 1)/2`. We have to divide product `|V|(|V| - 1)` by `2`, however, because it includes every edge twice.
7
+
**Note**: The number of edges `|E|` possible in an undirected graph with `|V|` vertices and no loops: `0 ≤ |E| ≤ |V|(|V| − 1)/2`. We have to divide product `|V|(|V| - 1)` by `2`, however, because it includes every edge twice.
8
8
9
9
A graph with every pair of its vertices connected by an edge is called **complete**.
10
10
11
11
A graph with relatively few possible edges missing is called **dense**.
12
12
13
13
A graph with few edges relative to the number of its vertices is called **sparse**.
14
14
15
-
The vertex is attached as a child to the vertex it is being reached from with an edge called a **tree edge**.
15
+
The vertex is attached as a child to the vertex it is being reached from with an edge called a **tree edge** or in other words it is an edge which is present in tree obtained after applying DFS on the graph.
16
16
17
-
If an edge leading to a previously visited vertex other than its immediate predecessor is encountered, the edge is noted as a **cross edge**.
17
+
If an edge leading to a previously visited vertex other than its immediate predecessor is encountered, the edge is noted as a **cross edge** or in others words it is a edge which connects two node such that they do not have any ancestor and a descendant relationship between them.
18
18
19
-
Vertext connecting to its ancestor is called **back edges**.
19
+
Edges connecting to its ancestor is called **back edges** or in other words it is an edge (u, v) such that v is ancestor of edge u but not part of DFS tree.
20
20
21
21
**Graph Representation**:
22
22
Graph can be represented by using adjacency matrix, adjacency list or incidence matrix. Each implementations has their own pros and cons associated with it either it could be time complexity on operations or space complexity.
23
23
24
-
25
24
#### Types
26
25
27
26
1. Simple graph
@@ -32,25 +31,26 @@ Graph can be represented by using adjacency matrix, adjacency list or incidence
32
31
6. Infinite graphs
33
32
7. Graph having Connected or Disconnected components
34
33
35
-
36
34
#### Operations
37
35
38
-
***adjacent `(G, x, y)`**: Tests whether there is an edge from the vertex x to the vertex y.
39
-
***neighbors `(G, x, y)`**: Lists all vertices y such that there is an edge from the vertex x to the vertex y.
40
-
***add_vertex `(G, x)`**: Adds the vertex x, if it is not there.
41
-
***remove_vertex `(G, x)`**: Removes the vertex x, if it is there.
42
-
***add_edge `(G, x, y)`**: Adds the edge from the vertex x to the vertex y, if it is not there.
43
-
***remove_edge `(G, x, y)`**: Removes the edge from the vertex x to the vertex y, if it is there.
44
-
***get_vertex_value `(G, x)`**: Returns the value associated with the vertex x.
45
-
***set_vertex_value `(G, x, v)`**: Sets the value associated with the vertex x to v.
36
+
-**adjacent `(G, x, y)`**: Tests whether there is an edge from the vertex x to the vertex y.
37
+
-**neighbors `(G, x, y)`**: Lists all vertices y such that there is an edge from the vertex x to the vertex y.
38
+
-**add_vertex `(G, x)`**: Adds the vertex x, if it is not there.
39
+
-**remove_vertex `(G, x)`**: Removes the vertex x, if it is there.
40
+
-**add_edge `(G, x, y)`**: Adds the edge from the vertex x to the vertex y, if it is not there.
41
+
-**remove_edge `(G, x, y)`**: Removes the edge from the vertex x to the vertex y, if it is there.
42
+
-**get_vertex_value `(G, x)`**: Returns the value associated with the vertex x.
43
+
-**set_vertex_value `(G, x, v)`**: Sets the value associated with the vertex x to v.
46
44
47
45
Structures that associate values to the edges usually also provide:
48
-
***get_edge_value `(G, x, y)`**: Returns the value associated with the edge (x, y).
49
-
***set_edge_value `(G, x, y, v)`**: Sets the value associated with the edge (x, y) to v.
46
+
47
+
-**get_edge_value `(G, x, y)`**: Returns the value associated with the edge (x, y).
48
+
-**set_edge_value `(G, x, y, v)`**: Sets the value associated with the edge (x, y) to v.
0 commit comments