Skip to content

Commit d8827e9

Browse files
author
computer0101
committed
prettify md files using prettier
1 parent 844e85e commit d8827e9

File tree

17 files changed

+177
-191
lines changed

17 files changed

+177
-191
lines changed

CODE_OF_CONDUCT.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
1414
Examples of behavior that contributes to creating a positive environment
1515
include:
1616

17-
* Using welcoming and inclusive language
18-
* Being respectful of differing viewpoints and experiences
19-
* Gracefully accepting constructive criticism
20-
* Focusing on what is best for the community
21-
* Showing empathy towards other community members
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
2222

2323
Examples of unacceptable behavior by participants include:
2424

25-
* The use of sexualized language or imagery and unwelcome sexual attention or
26-
advances
27-
* Trolling, insulting/derogatory comments, and personal or political attacks
28-
* Public or private harassment
29-
* Publishing others' private information, such as a physical or electronic
30-
address, without explicit permission
31-
* Other conduct which could reasonably be considered inappropriate in a
32-
professional setting
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
- Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
3333

3434
## Our Responsibilities
3535

CONTRIBUTING.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
## Contributing Guide:
22

3-
43
### Prerequisites
54

65
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.
76

8-
97
### Issues
108

119
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.
1210

1311
It would be better if you create a issue first before implementing anything, so that other people don't accidently duplicate your effort.
1412

15-
1613
### Pull Requests
1714

1815
Before submitting a pull request, please make sure the following is done:
@@ -34,4 +31,4 @@ We look forward to your contributions. :joy:
3431
```
3532
HAPPY CODING
3633
HAPPY LEARNING
37-
```
34+
```

README.md

+76-80
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
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.
44

5-
65
### Why Go/GoLang and not C, C++ or Java?
76

87
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.
98

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.
1110

1211
**Conclusion**: Go would also be a good language to get started with implementing Data Structures and Algorithms. :computer:
1312

@@ -18,8 +17,8 @@ However the reason why go would also be a good language to implement DSA is that
1817
3. Now `cd <folder-name>` into the folder where the file you want to run is located.
1918
4. Now run `go run <file-name>`.
2019

21-
2220
### Example
21+
2322
Let's assume that I want to run files located in `graphs/directed_unweighted` directory then the syntax to run it would be:
2423

2524
```
@@ -30,95 +29,92 @@ go run graph.go traversal.go
3029

3130
**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`.
3231

33-
3432
### FOLDER NAMES
3533

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 &nbsp;&nbsp;:point_left:
44-
* *cd_undirected_graph_traversals* - Cycle Detection in Undirected Graphs using Traversals techniques &nbsp;&nbsp;:point_left:
45-
* *dijkstra* - Dijkstra's Algorithm
46-
* *expression_conversions* -
47-
* *infix_postfix* - Infix to Postfix Conversion
48-
* *infix_prefix* - Infix to Prefix Conversion
49-
* *postfix_infix* - Postfix to Infix Conversion
50-
* *postfix_prefix* - Postfix to Prefix Conversion
51-
* *prefix_infix* - Prefix to Infix Conversion
52-
* *prefix_postfix* - Prefix to Postfix Conversion
53-
* *floyd_warshall* - Floyd Warshall Algorithm (All points shortest path)
54-
* *huffman_codes* - Huffman Codes (Generating Huffman Codes)
55-
* *job_scheduling_gp* - Job Scheduling Algorithm using Greedy Programming
56-
* *knuth_morris_pratt* - Knuth Morris Pratt Algorithm for Pattern Matching
57-
* *kruskals* - Kruskal's Algorithm (Finding Minimum Spanning Tree MST using Greedy Approach)
58-
* *lcs* - Longest Common Subsequence
59-
* *iterative_dp* - Longest Common Subsequence using Dynamic Programming (Iterative Version)
60-
* *making_change_dp* - Making Change Problem using Dynamic Programming
61-
* *naive_pattern_matching* - Naive Pattern/String Matching
62-
* *prims* - Prim's Algorithm (Finding Minimum Spanning Tree MST using Greedy Approach)
63-
* *searching* -
64-
* *binary_search* - Binary Search - O(log n)
65-
* *linear_search* - Linear Search - O(n)
66-
* *sorting* -
67-
* *binary_insertion_sort* - Binary Insertion Sort - O(n<sup>2</sup>)
68-
* *bubble_sort* - Bubble Sort - O(n<sup>2</sup>)
69-
* *bucket_sort* - Bucket Sort - O(n<sup>2</sup>)
70-
* *counting_sort* - Counting Sort - O(n + k)
71-
* *heap_sort* - Heap Sort - O(nlog(n)
72-
* *insertion_sort* - Insertion Sort - O(n<sup>2</sup>)
73-
* *merge_sort* - Merge Sort - O(nlog(n))
74-
* *quick_sort* - Quick Sort - Θ(nlog(n))
75-
* *radix_sort* - Radix Sort - O(n+k)
76-
* *selection_sort* - Selection Sort - (O(n<sup>2</sup>))
77-
* *shell_sort* - Shell Sort - О(n)
78-
* *toh* - Tower of Hanoi
79-
* *topological_sort* - Topological Sort
80-
* *union_find* - Union Find / Disjoint Sets (Detecting cycles in an undirected graph)
81-
02. **graphs** -
82-
* *directed_unweighted* - Directed Unweighted graph
83-
* *directed_weighted* - Directed Weighted graph
84-
* *undirected_unweighted* - Undirected Unweighted graph
85-
* *undirected_weighted* - Undirected Weighted graph
86-
03. **heaps** -
87-
* *max_binary_heap* - Max Binary Heap
88-
* *min_binary_heap* - Min Binary Heap
89-
04. **linked_lists** -
90-
* *circular_doubly_ll* - Circular Doubly Linked List
91-
* *circular_ll* - Circular Linked List
92-
* *doubly_ll* - Doubly Linked List
93-
* *pres_rev_single_ll* - Preserve order during insertion on Single Linked List and Reversing Single Linked List
94-
* *single_ll* - Single Linked List
95-
05. **queues** -
96-
* *cdqueue* - Circular Double ended Queue
97-
* *cqueue* - Circular Queue
98-
* *dqueue* - Double ended Queue
99-
* *priority_queue* - Priority Queue with the use of Min Heap
100-
* *simple_queue* - Simple Queue
101-
06. **stack** - stack
102-
07. **trees** -
103-
* *avl_tree_using_ll* - AVL Tree using linked list with BFS and DFS (Pre, In, Post) order traversals.
104-
* *bst_using_arr* - Binary Search Tree using array with BFS and DFS (Pre, In, Post) order traversals.
105-
* *bst_using_ll* - Binary Search Tree using linked list with BFS and DFS (Pre, In, Post) order traversals.
106-
* *simple_bt_using_arr* - Simple Binary Tree using array with BFS and DFS (Pre, In, Post) order traversals.
107-
* *simple_bt_using_ll* - Simple Binary Tree using linked list with BFS and DFS (Pre, In, Post) order traversals.
108-
34+
1. **algorithms** -
35+
- _01knapsack_dp_ - 0-1 Knapsack Problem using Dynamic Programming
36+
- _activity_selection_gp_ - Activity Selection using Greedy Programming
37+
- _articulation_point_detection_ - Detecting Articulation Points in an undirected graph
38+
- _assembly_line_scheduling_ - Assembly Line Scheduling algorithm using Dynamic Programming
39+
- _bellman_ford_ - Bellman Ford Algorithm
40+
- _bridge_detection_ - Bridge Detection/Cut Edge Detection in an undirected graph
41+
- _cd_directed_graph_traversals_ - Cycle Detection in Directed Graphs using Traversals techniques &nbsp;&nbsp;:point_left:
42+
- _cd_undirected_graph_traversals_ - Cycle Detection in Undirected Graphs using Traversals techniques &nbsp;&nbsp;:point_left:
43+
- _dijkstra_ - Dijkstra's Algorithm
44+
- _expression_conversions_ -
45+
- _infix_postfix_ - Infix to Postfix Conversion
46+
- _infix_prefix_ - Infix to Prefix Conversion
47+
- _postfix_infix_ - Postfix to Infix Conversion
48+
- _postfix_prefix_ - Postfix to Prefix Conversion
49+
- _prefix_infix_ - Prefix to Infix Conversion
50+
- _prefix_postfix_ - Prefix to Postfix Conversion
51+
- _floyd_warshall_ - Floyd Warshall Algorithm (All points shortest path)
52+
- _huffman_codes_ - Huffman Codes (Generating Huffman Codes)
53+
- _job_scheduling_gp_ - Job Scheduling Algorithm using Greedy Programming
54+
- _knuth_morris_pratt_ - Knuth Morris Pratt Algorithm for Pattern Matching
55+
- _kruskals_ - Kruskal's Algorithm (Finding Minimum Spanning Tree MST using Greedy Approach)
56+
- _lcs_ - Longest Common Subsequence
57+
- _iterative_dp_ - Longest Common Subsequence using Dynamic Programming (Iterative Version)
58+
- _making_change_dp_ - Making Change Problem using Dynamic Programming
59+
- _naive_pattern_matching_ - Naive Pattern/String Matching
60+
- _prims_ - Prim's Algorithm (Finding Minimum Spanning Tree MST using Greedy Approach)
61+
- _searching_ -
62+
- _binary_search_ - Binary Search - O(log n)
63+
- _linear_search_ - Linear Search - O(n)
64+
- _sorting_ -
65+
- _binary_insertion_sort_ - Binary Insertion Sort - O(n<sup>2</sup>)
66+
- _bubble_sort_ - Bubble Sort - O(n<sup>2</sup>)
67+
- _bucket_sort_ - Bucket Sort - O(n<sup>2</sup>)
68+
- _counting_sort_ - Counting Sort - O(n + k)
69+
- _heap_sort_ - Heap Sort - O(nlog(n)
70+
- _insertion_sort_ - Insertion Sort - O(n<sup>2</sup>)
71+
- _merge_sort_ - Merge Sort - O(nlog(n))
72+
- _quick_sort_ - Quick Sort - Θ(nlog(n))
73+
- _radix_sort_ - Radix Sort - O(n+k)
74+
- _selection_sort_ - Selection Sort - (O(n<sup>2</sup>))
75+
- _shell_sort_ - Shell Sort - О(n)
76+
- _toh_ - Tower of Hanoi
77+
- _topological_sort_ - Topological Sort
78+
- _union_find_ - Union Find / Disjoint Sets (Detecting cycles in an undirected graph)
79+
2. **graphs** -
80+
- _directed_unweighted_ - Directed Unweighted graph
81+
- _directed_weighted_ - Directed Weighted graph
82+
- _undirected_unweighted_ - Undirected Unweighted graph
83+
- _undirected_weighted_ - Undirected Weighted graph
84+
3. **heaps** -
85+
- _max_binary_heap_ - Max Binary Heap
86+
- _min_binary_heap_ - Min Binary Heap
87+
4. **linked_lists** -
88+
- _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.
109106

110107
**Note**: The pointer &nbsp;"&nbsp;:point_left:&nbsp;"&nbsp; indicates incomplete implementation and is in todo list.
111108

112-
113109
### Contribution
114110

115111
Read the [contributing guide](CONTRIBUTING.md) to see how to contribute.
116112

117-
118113
### License
114+
119115
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.
120116

121117
```
122118
HAPPY CODING
123119
HAPPY LEARNING
124-
```
120+
```

graphs/notes.md

+19-19
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,23 @@ In computer science, a graph is an abstract data type that is meant to implement
44

55
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.
66

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.
88

99
A graph with every pair of its vertices connected by an edge is called **complete**.
1010

1111
A graph with relatively few possible edges missing is called **dense**.
1212

1313
A graph with few edges relative to the number of its vertices is called **sparse**.
1414

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.
1616

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.
1818

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.
2020

2121
**Graph Representation**:
2222
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.
2323

24-
2524
#### Types
2625

2726
1. Simple graph
@@ -32,25 +31,26 @@ Graph can be represented by using adjacency matrix, adjacency list or incidence
3231
6. Infinite graphs
3332
7. Graph having Connected or Disconnected components
3433

35-
3634
#### Operations
3735

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.
4644

4745
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.
5049

5150
Traversals:
52-
* BFS - Breadth First Search
53-
* DFS - Depth First Search
51+
52+
- BFS - Breadth First Search
53+
- DFS - Depth First Search
5454

5555
#### Applications
5656

@@ -64,4 +64,4 @@ Traversals:
6464

6565
<br>
6666
*References*:
67-
* [https://en.wikipedia.org/wiki/Graph_(abstract_data_type)](https://en.wikipedia.org/wiki/Graph_(abstract_data_type))
67+
* [https://en.wikipedia.org/wiki/Graph_(abstract_data_type)](https://en.wikipedia.org/wiki/Graph_(abstract_data_type))

linked_lists/circular_doubly_ll/notes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ It is the combine version of circular and doubly linked list where each node poi
1313

1414
<br>
1515
*References*:
16-
[https://en.wikipedia.org/wiki/Linked_list#Singly_linked_list](https://en.wikipedia.org/wiki/Linked_list#Singly_linked_list)
16+
[https://en.wikipedia.org/wiki/Linked_list#Singly_linked_list](https://en.wikipedia.org/wiki/Linked_list#Singly_linked_list)

0 commit comments

Comments
 (0)