Skip to content

Commit 4cd17f4

Browse files
committed
Fix formatting and tables
1 parent d19bf6e commit 4cd17f4

File tree

19 files changed

+85
-116
lines changed

19 files changed

+85
-116
lines changed

en/Data Structures/Linked Lists/Doubly Linked List.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ In singly linked list, to delete a node, pointer to the previous node is needed.
1717
### Time Complexity
1818

1919
| Operation | Average | Worst |
20-
|:---------:|:-------:|:-----:|
20+
|-----------|---------|-------|
2121
| Access | Θ(n) | O(n) |
2222
| Search | Θ(n) | O(n) |
2323
| Insertion | Θ(1) | O(1) |

en/Data Structures/Linked Lists/Singly Linked List.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Singly Linked List is a linear and connected data structure made of Nodes. Each
1515
### Time Complexity
1616

1717
| Operation | Average | Worst |
18-
|:---------:|:-------:|:-----:|
18+
|-----------|---------|-------|
1919
| Access | O(n) | O(n) |
2020
| Search | O(n) | O(n) |
2121
| Insertion | O(1) | O(1) |

en/Dynamic Programming/Longest Common Subseqence.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#### Problem Statement
44

5-
Given two strings `S` and `T`, find the length of the longest common subsequence (<b>LCS</b>).
5+
Given two strings `S` and `T`, find the length of the longest common subsequence (<b>LCS</b>).
66

77
#### Approach
88

@@ -19,14 +19,14 @@ We could see that we can fill our `dp` table row by row, column by column. So ou
1919
- Let's say that we have strings `S` of the length N and `T` of the length M (numbered from 1). Let's create the table `dp` of size `(N + 1) x (M + 1)` numbered from 0.
2020
- Let's fill the 0th row and the 0th column of `dp` with 0.
2121
- Then, we follow the algorithm:
22-
```
23-
for i in range(1..N):
24-
for j in range(1..M):
25-
if(S[i] == T[j])
26-
dp[i][j] = dp[i - 1][j - 1] + 1
27-
else
28-
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
29-
```
22+
```
23+
for i in range(1..N):
24+
for j in range(1..M):
25+
if(S[i] == T[j])
26+
dp[i][j] = dp[i - 1][j - 1] + 1
27+
else
28+
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
29+
```
3030

3131

3232
#### Time Complexity
@@ -35,8 +35,8 @@ We could see that we can fill our `dp` table row by row, column by column. So ou
3535

3636
#### Space Complexity
3737

38-
`O(N * M)` - simple implementation
39-
`O(min {N, M})` - two-layers implementation (as `dp[i][j]` depends on only i-th and i-th layers, we coudld store only two layers).
38+
`O(N * M)` - simple implementation
39+
`O(min {N, M})` - two-layers implementation (as `dp[i][j]` depends on only i-th and i-th layers, we coudld store only two layers).
4040

4141
#### Example
4242

en/Search Algorithms/Binary Search.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ O(1) Best Case (If middle element of initial array is the target element)
2222
#### Space Complexity
2323

2424
O(1) For iterative approach
25-
O(log n) For recursive approach due to recursion call stack
25+
O(log n) For recursive approach due to recursion call stack
2626

2727
#### Example
2828

@@ -36,7 +36,7 @@ Here we find the middle element equal to target element so we return its index i
3636
3737
target = 9
3838
Binary Search should return -1 as 9 is not present in the array
39-
```
39+
```
4040

4141
#### Code Implementation Links
4242

en/Search Algorithms/Linear Search.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Linear Search should return index 3 as 5 is on index 3
3131
3232
target = 6
3333
Linear Search should return -1 as 6 is not present in the array
34-
```
34+
```
3535

3636
#### Code Implementation Links
3737

en/Sorting Algorithms/Bubble Sort.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ Given an unsorted array of n elements, write a function to sort the array
1515

1616
#### Time Complexity
1717

18-
O(n^2) Worst case performance
18+
`O(n^2)` Worst case performance
1919

20-
O(n) Best-case performance
20+
`O(n)` Best-case performance
2121

22-
O(n^2) Average performance
22+
`O(n^2)` Average performance
2323

2424
#### Space Complexity
2525

26-
O(1) Worst case
26+
`O(1)` Worst case
2727

2828
#### Founder's Name
2929

@@ -46,7 +46,7 @@ Indexes: 0 1 2 3
4646
7. 80 > 30, swap 80 and 30
4747
8. The array now is {10, 40, 30, 80}
4848
49-
Repeat the Above Steps again
49+
Repeat the Above Steps again
5050
5151
arr[] = {10, 40, 30, 80}
5252
Indexes: 0 1 2 3
@@ -62,7 +62,7 @@ Indexes: 0 1 2 3
6262
7. 40 < 80, do nothing
6363
8. The array now is {10, 30, 40, 80}
6464
65-
Repeat the Above Steps again
65+
Repeat the Above Steps again
6666
6767
arr[] = {10, 30, 40, 80}
6868
Indexes: 0 1 2 3
@@ -76,11 +76,8 @@ Indexes: 0 1 2 3
7676
5. Index = 2, Number = 40
7777
6. 40 < 80, do nothing
7878
79-
Since there are no swaps in above steps, it means the array is sorted and we can stop here.
80-
81-
82-
```
83-
79+
Since there are no swaps in above steps, it means the array is sorted and we can stop here.
80+
```
8481

8582
#### Code Implementation Links
8683

@@ -94,7 +91,6 @@ Indexes: 0 1 2 3
9491
- [Scala](https://github.com/TheAlgorithms/Scala/blob/master/src/main/scala/Sort/BubbleSort.scala)
9592
- [Javascript](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/BubbleSort.js)
9693

97-
9894
#### Video Explanation
9995

10096
[A video explaining the Bubble Sort Algorithm](https://www.youtube.com/watch?v=Jdtq5uKz-w4)
@@ -106,4 +102,3 @@ Bubble sort is also known as Sinking sort.
106102
#### Animation Explanation
107103

108104
- [Tute Board](https://boardhub.github.io/tute/?wd=bubbleSortAlgo2)
109-

en/Sorting Algorithms/Heap Sort.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ Given an unsorted array of n elements, write a function to sort the array
1212

1313
#### Time Complexity
1414

15-
O(n log n) Worst case performance
15+
`O(n log n)` Worst case performance
1616

17-
O(n log n) (distinct keys)
18-
or O(n) (equal keys) Best-case performance
17+
`O(n log n)` (distinct keys)
18+
or O(n) (equal keys) Best-case performance
1919

20-
O(n log n) Average performance
20+
`O(n log n)` Average performance
2121

2222
#### Space Complexity
2323

24-
O(1) Worst case auxiliary
24+
`O(1)` Worst case auxiliary
2525

2626

2727
#### Example
@@ -33,7 +33,7 @@ Input data: 4, 10, 3, 5, 1
3333
/ \
3434
5(3) 1(4)
3535
36-
The numbers in bracket represent the indices in the array
36+
The numbers in bracket represent the indices in the array
3737
representation of data.
3838
3939
Applying heapify procedure to index 1:
@@ -52,7 +52,7 @@ Applying heapify procedure to index 0:
5252
The heapify procedure calls itself recursively to build heap
5353
in top down manner.
5454
```
55-
55+
5656
![heap-image](https://upload.wikimedia.org/wikipedia/commons/1/1b/Sorting_heapsort_anim.gif "Heap Sort")
5757

5858
#### Code Implementation Links
@@ -66,7 +66,6 @@ The heapify procedure calls itself recursively to build heap
6666
- [C](https://github.com/TheAlgorithms/C/blob/master/sorting/heap_sort.c)
6767
- [Javascript](https://github.com/TheAlgorithms/Javascript/blob/master/Sorts/HeapSort.js)
6868

69-
7069
#### Video Explanation
7170

7271
[A video explaining the Selection Sort Algorithm](https://www.youtube.com/watch?v=MtQL_ll5KhQ)

en/Sorting Algorithms/Insertion Sort.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,18 @@ Given an array of n elements, write a function to sort the array in increasing o
88

99
- Define a "key" index, the subarray to the left of which is sorted.
1010
- Initiate "key" as 1, ie. the second element of array(as there is only one element to left of the second element, which can be considered as sorted array with one element).
11-
1211
- If value of element at (key - 1) position is less than value of element at (key) position; increment "key".
1312
- Else move elements of sorted subarray that are greater than value of element at "key" to one position ahead of their current position. Put the value of element at "key" in the newly created void.
1413

1514
#### Time Complexity
1615

17-
О(n^2) comparisons, О(n^2) swaps -- Worst Case
16+
- `О(n^2)` comparisons, `О(n^2)` swaps -- Worst Case
1817

19-
O(n) comparisons, O(1) swaps -- Best Case
18+
- `O(n)` comparisons, `O(1)` swaps -- Best Case
2019

2120
#### Space Complexity
2221

23-
O(1) -- (No extra space needed, sorting done in place)
22+
`O(1)` -- (No extra space needed, sorting done in place)
2423

2524
#### Example
2625

@@ -47,7 +46,7 @@ i = 4.
4746
6 will move to position after 5,
4847
and elements from 11 to 13 will move one position ahead of their current position.
4948
5, 6, 11, 12, 13 -- sorted array
50-
```
49+
```
5150

5251
#### Code Implementation Links
5352

en/Sorting Algorithms/Merge Sort.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ Given an array of n elements, write a function to sort the array
1212

1313
#### Time Complexity
1414

15-
O(nLogn)
15+
`O(n log n)`
1616

1717
#### Space Complexity
1818

19-
O(n)
19+
`O(n)`
2020

2121
#### Example
2222

@@ -29,7 +29,7 @@ Recursively call merge sort function for both these halves which will provide so
2929
=> [1, 3, 9] & [0, 2, 5]
3030
3131
Now merge both these halves to get the sorted array [0, 1, 2, 3, 5, 9]
32-
```
32+
```
3333

3434
#### Code Implementation Links
3535

en/Sorting Algorithms/Quick Sort.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ Given an unsorted array of n elements, write a function to sort the array
99
- partition the array using pivot value
1010
- quicksort left partition recursively
1111
- quicksort right partition recursively
12-
#### Time Complexity
1312

14-
O(n^2) Worst case performance
13+
#### Time Complexity
1514

16-
O(n log n) Best-case performance
15+
- `O(n^2)` Worst case performance
16+
- `O(n log n)` Best-case performance
17+
- `O(n log n)` Average performance
1718

18-
O(n log n) Average performance
1919
#### Space Complexity
2020

21-
O(log(n)) Worst case
21+
`O(log n)` Worst case
2222

2323
#### Founder's Name
2424

@@ -64,7 +64,7 @@ arr[] = {10, 30, 40, 50, 70, 90, 80} // 80 and 70 Swapped
6464
Now 70 is at its correct place. All elements smaller than
6565
70 are before it and all elements greater than 70 are after
6666
it.
67-
```
67+
```
6868

6969
#### Code Implementation Links
7070

0 commit comments

Comments
 (0)