diff --git a/docs/dsal/10.md b/docs/dsal/10.md index ffd87773ab2c023fc7f844ae64b38858b1591be3..cb1e9b5d9d28517c62246d492c398feb709a785c 100644 --- a/docs/dsal/10.md +++ b/docs/dsal/10.md @@ -61,7 +61,7 @@ FIFO 表示 -``` +```py # Queue implementation in Python class Queue: @@ -101,7 +101,7 @@ print("After removing an element") q.display() ``` -``` +```java // Queue implementation in Java public class Queue { @@ -202,7 +202,7 @@ public class Queue { } ``` -``` +```c // Queue implementation in C #include @@ -276,7 +276,7 @@ void display() { } ``` -``` +```cpp // Queue implementation in C++ #include diff --git a/docs/dsal/12.md b/docs/dsal/12.md index 9b3807f719fb7fe2b6915a91805da953880cfb40..962eb2aba1df9349365f1b7607f64dc7a46d2923 100644 --- a/docs/dsal/12.md +++ b/docs/dsal/12.md @@ -66,7 +66,7 @@ if REAR + 1 == 5 (overflow!), REAR = (REAR + 1)%5 = 0 (start of queue) -``` +```py # Circular Queue implementation in Python class MyCircularQueue(object): @@ -149,7 +149,7 @@ obj.deQueue() obj.Display() ``` -``` +```java // Circular Queue implementation in Java public class CQueue { @@ -264,7 +264,7 @@ public class CQueue { } ``` -``` +```c // Circular Queue implementation in C #include @@ -364,7 +364,7 @@ int main() { } ``` -``` +```cpp // Circular Queue implementation in C++ #include diff --git a/docs/dsal/13.md b/docs/dsal/13.md index 125c6ae47f26c9fe04262adf76329f227a40ad55..cd7e3e4f783ee9352de1f8b808888d184f1927a4 100644 --- a/docs/dsal/13.md +++ b/docs/dsal/13.md @@ -155,7 +155,7 @@ return rootNode -``` +```py # Max-Heap data structure in Python # Function to heapify the tree @@ -215,7 +215,7 @@ deleteNode(arr, 4) print("After deleting an element: " + str(arr)) ``` -``` +```java // Max-Heap data structure in Java import java.util.ArrayList; @@ -306,7 +306,7 @@ class Heap { } ``` -``` +```c // Max-Heap data structure in C #include @@ -396,7 +396,7 @@ int main() { } ``` -``` +```cpp // Max-Heap data structure in C++ #include diff --git a/docs/dsal/14.md b/docs/dsal/14.md index 447e72a7ab5b4e43d3ab04ce5ac32d011f83038a..0eba0029723b0e967a5bbbec0d58f4bf3ed86648 100644 --- a/docs/dsal/14.md +++ b/docs/dsal/14.md @@ -158,7 +158,7 @@ -``` +```py # Deque operations in python class Deque: @@ -199,7 +199,7 @@ d.addRear(45) print(d.items) ``` -``` +```java // Deque operations in Java class Deque { @@ -340,7 +340,7 @@ class Deque { } ``` -``` +```c // Deque operations in C #include @@ -529,7 +529,7 @@ int count(int *arr) } ``` -``` +```cpp // Deque operations in C++ #include diff --git a/docs/dsal/16.md b/docs/dsal/16.md index c2104f2f339d85839b659e1dadbd49d82b2577f8..6c5a8a3eb6f0a719cc8b36b9d42e1677e3386be9 100644 --- a/docs/dsal/16.md +++ b/docs/dsal/16.md @@ -106,7 +106,7 @@ head = one; -``` +```py # Linked list implementation in Python class Node: @@ -139,7 +139,7 @@ if __name__ == '__main__': linked_list.head = linked_list.head.next ``` -``` +```java // Linked list implementation in Java class LinkedList { @@ -177,7 +177,7 @@ class LinkedList { } ``` -``` +```c // Linked list implementation in C #include @@ -225,7 +225,7 @@ int main() { } ``` -``` +```cpp // Linked list implementation in C++ #include diff --git a/docs/dsal/17.md b/docs/dsal/17.md index fc65a46b9f7702e760af41a41de4110873ea09aa..0cad75f4d8f5f93bce4e2442376b7e7b2c42c241 100644 --- a/docs/dsal/17.md +++ b/docs/dsal/17.md @@ -158,7 +158,7 @@ temp->next = temp->next->next; -``` +```py # Linked list operations in Python # Create a node @@ -257,7 +257,7 @@ if __name__ == '__main__': llist.printList() ``` -``` +```java // Linked list operations in Java class LinkedList { @@ -360,7 +360,7 @@ class LinkedList { } ``` -``` +```c // Linked list operations in C #include @@ -466,7 +466,7 @@ int main() { } ``` -``` +```cpp // Linked list operations in C++ #include diff --git a/docs/dsal/19.md b/docs/dsal/19.md index 73e07b5aaf5ba846f56bb201ce4de45d8a5ea5dd..f9c8bfea42381b35ad094ab76dab74f4c410c146 100644 --- a/docs/dsal/19.md +++ b/docs/dsal/19.md @@ -95,9 +95,9 @@ chainedHashDelete(T, x) ## Python,Java,C 和 C++ 实现 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Python program to demonstrate working of HashTable hashTable = [[],] * 10 @@ -145,7 +145,7 @@ removeData(123) print(hashTable) ``` -``` +```java // Java program to demonstrate working of HashTable import java.util.*; @@ -168,7 +168,7 @@ class HashTable { } ``` -``` +```c // Implementing hash table in C #include @@ -342,7 +342,7 @@ int main() } ``` -``` +```cpp // Implementing hash table in C++ #include diff --git a/docs/dsal/20.md b/docs/dsal/20.md index 6cfb5149ee3ea5bffd8bad8b9a2516a7fd5ed406..6e886eb41540f6b3684bdc1a0ab5b19345df2b50 100644 --- a/docs/dsal/20.md +++ b/docs/dsal/20.md @@ -143,9 +143,9 @@ return rootNode ## Python,Java,C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Max-Heap data structure in Python def heapify(arr, n, i): @@ -200,7 +200,7 @@ deleteNode(arr, 4) print("After deleting an element: " + str(arr)) ``` -``` +```java // Max-Heap data structure in Java import java.util.ArrayList; @@ -287,7 +287,7 @@ class Heap { } ``` -``` +```c // Max-Heap data structure in C #include @@ -380,7 +380,7 @@ int main() } ``` -``` +```cpp // Max-Heap data structure in C++ #include diff --git a/docs/dsal/21.md b/docs/dsal/21.md index bd5be5db0c7deeb3005ab13661264fc914efbe40..0aaacbb531bafaf9497eee517411ed9f778c8e1c 100644 --- a/docs/dsal/21.md +++ b/docs/dsal/21.md @@ -208,7 +208,7 @@ insert(H, x) -``` +```py # Fibonacci Heap in python import math @@ -301,7 +301,7 @@ print('the minimum value of the fibonacci heap: {}'.format(fibonacci_heap.get_mi print('the minimum value removed: {}'.format(fibonacci_heap.extract_min())) ``` -``` +```java // Operations on Fibonacci Heap in Java // Node creation @@ -664,7 +664,7 @@ public class fibHeap { } ``` -``` +```c // Operations on a Fibonacci heap in C #include @@ -1124,7 +1124,7 @@ int main(int argc, char **argv) { } ``` -``` +```cpp // Operations on a Fibonacci heap in C++ #include diff --git a/docs/dsal/22.md b/docs/dsal/22.md index e44c82da7b34ce2f97ab5a96610853a836cadb0d..6238d024ded2ca8cd1c77a23f183a355fb6f58aa 100644 --- a/docs/dsal/22.md +++ b/docs/dsal/22.md @@ -107,7 +107,7 @@ -``` +```py # Fibonacci Heap in python import math @@ -194,7 +194,7 @@ print('Minimum value: {}'.format(fheap.get_min())) print('Minimum value removed: {}'.format(fheap.extract_min())) ``` -``` +```java // Operations on Fibonacci Heap in Java class node { @@ -551,7 +551,7 @@ public class fibHeap { } ``` -``` +```c // Operations on a Fibonacci heap in C #include @@ -1078,7 +1078,7 @@ int main(int argc, char **argv) } ``` -``` +```cpp // Operations on a Fibonacci heap in C++ #include diff --git a/docs/dsal/25.md b/docs/dsal/25.md index 9992801d0248e395015158ba6545a95800d411a5..6925ec2d23e5b50ef1b2ff42c1a6c6c621a6f27c 100644 --- a/docs/dsal/25.md +++ b/docs/dsal/25.md @@ -151,7 +151,7 @@ Left subtree -> root -> right subtree -``` +```py # Tree traversal in Python class Node: @@ -206,7 +206,7 @@ print("\nPostorder traversal ") postorder(root) ``` -``` +```java // Tree traversal in Java class Node { @@ -283,7 +283,7 @@ class BinaryTree { } ``` -``` +```c // Tree traversal in C #include @@ -360,7 +360,7 @@ int main() { } ``` -``` +```cpp // Tree traversal in C++ #include diff --git a/docs/dsal/26.md b/docs/dsal/26.md index ad04978e146daa9dfe43550b35803e13d6e8f0e0..94814044374dde04d2715dec02732236d3fd30d4 100644 --- a/docs/dsal/26.md +++ b/docs/dsal/26.md @@ -117,7 +117,7 @@ struct node -``` +```py # Binary Tree in Python class Node: @@ -165,7 +165,7 @@ print("\nPost order Traversal: ", end="") root.traversePostOrder() ``` -``` +```java // Binary Tree in Java // Node creation @@ -235,7 +235,7 @@ class BinaryTree { } ``` -``` +```c // Tree traversal in C #include @@ -310,7 +310,7 @@ int main() { } ``` -``` +```cpp // Binary Tree in C++ #include diff --git a/docs/dsal/27.md b/docs/dsal/27.md index 4d1294635648277210b92d828aa42c807fcb4527..27730bf9969a84fa04cf6168428b78eec51d0c68 100644 --- a/docs/dsal/27.md +++ b/docs/dsal/27.md @@ -41,7 +41,7 @@ Let, i = the number of internal nodes -``` +```py # Checking if a binary tree is a full binary tree in Python # Creating a node @@ -83,7 +83,7 @@ else: print("The tree is not a full binary full") ``` -``` +```java // Checking if a binary tree is a full binary tree in Java class Node { @@ -134,7 +134,7 @@ class BinaryTree { } ``` -``` +```c // Checking if a binary tree is a full binary tree in C #include @@ -187,7 +187,7 @@ int main() { } ``` -``` +```cpp // Checking if a binary tree is a full binary tree in C++ #include diff --git a/docs/dsal/28.md b/docs/dsal/28.md index 72143da3fd4f9615aa8fcbc9c4c470a31e18eafb..74b6e9049016c842d1ee17bbcc3965e05bde58f0 100644 --- a/docs/dsal/28.md +++ b/docs/dsal/28.md @@ -31,9 +31,9 @@ 以下代码用于检查树是否是完美二叉树。 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Checking if a binary tree is a perfect binary tree in Python class newNode: @@ -79,7 +79,7 @@ else: print("The tree is not a perfect binary tree") ``` -``` +```java // Checking if a binary tree is a perfect binary tree in Java class PerfectBinaryTree { @@ -147,7 +147,7 @@ class PerfectBinaryTree { } ``` -``` +```c // Checking if a binary tree is a perfect binary tree in C #include @@ -219,7 +219,7 @@ int main() { } ``` -``` +```cpp // Checking if a binary tree is a full binary tree in C++ #include diff --git a/docs/dsal/29.md b/docs/dsal/29.md index 0a991468fe21a386669acbcadf91d114ca832293..2b8e7c6ef0a05d1730274a2bc2eab238adb276a9 100644 --- a/docs/dsal/29.md +++ b/docs/dsal/29.md @@ -78,9 +78,9 @@ ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Checking if a binary tree is a complete binary tree in C class Node: @@ -125,7 +125,7 @@ else: print("The tree is not a complete binary tree") ``` -``` +```java // Checking if a binary tree is a complete binary tree in Java // Node creation @@ -184,7 +184,7 @@ class BinaryTree { } ``` -``` +```c // Checking if a binary tree is a complete binary tree in C #include @@ -242,7 +242,7 @@ int main() { } ``` -``` +```cpp // Checking if a binary tree is a complete binary tree in C++ #include diff --git a/docs/dsal/30.md b/docs/dsal/30.md index b6907315ec92f1e4f7acb01a71bbc8ec0d7b659f..cf02e4477923f0a77d245dccb9a5a3dfe9a16032 100644 --- a/docs/dsal/30.md +++ b/docs/dsal/30.md @@ -30,9 +30,9 @@ 以下代码用于检查树是否高度平衡。 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Checking if a binary tree is CalculateHeight balanced in Python # CreateNode creation @@ -81,7 +81,7 @@ else: print('The tree is not balanced') ``` -``` +```java // Checking if a binary tree is height balanced in Java // Node creation @@ -146,7 +146,7 @@ class BinaryTree { } ``` -``` +```c // Checking if a binary tree is height balanced in C #include @@ -209,7 +209,7 @@ int main() { } ``` -``` +```cpp // Checking if a binary tree is height balanced in C++ #include diff --git a/docs/dsal/31.md b/docs/dsal/31.md index 9986bc7004218ac0bb2330a210b6b8c9a77ec74d..68a0cbd85610d3f58a21ad092d982c919dd0f70f 100644 --- a/docs/dsal/31.md +++ b/docs/dsal/31.md @@ -218,9 +218,9 @@ return node; ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Binary Search Tree operations in Python # Create a node @@ -321,7 +321,7 @@ print("Inorder traversal: ", end=' ') inorder(root) ``` -``` +```java // Binary Search Tree operations in Java class BinarySearchTree { @@ -441,7 +441,7 @@ class BinarySearchTree { } ``` -``` +```c // Binary Search Tree operations in C #include @@ -556,7 +556,7 @@ int main() { } ``` -``` +```cpp // Binary Search Tree operations in C++ #include diff --git a/docs/dsal/32.md b/docs/dsal/32.md index 1eb650daa8b91557ae658ac4bbf6f4e35bd6c26e..2e5b9775e9cebc2291dd517014e02a60f8fb7fee 100644 --- a/docs/dsal/32.md +++ b/docs/dsal/32.md @@ -315,9 +315,9 @@ Avl tree ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # AVL tree implementation in Python import sys @@ -485,7 +485,7 @@ print("After Deletion: ") myTree.printHelper(root, "", True) ``` -``` +```java // AVL tree implementation in Java // Create node @@ -680,7 +680,7 @@ class AVLTree { } ``` -``` +```c // AVL tree implementation in C #include @@ -868,7 +868,7 @@ int main() { } ``` -``` +```cpp // AVL tree implementation in C++ #include diff --git a/docs/dsal/34.md b/docs/dsal/34.md index c851eeceaa36fbbb77dd8114f3991bacdbfa1322..b23f6a7fe3dbd35bc728346bbff89b098f4a15d2 100644 --- a/docs/dsal/34.md +++ b/docs/dsal/34.md @@ -129,9 +129,9 @@ else ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Searching a key on a B-tree in Python # Create node @@ -233,7 +233,7 @@ if __name__ == '__main__': main() ``` -``` +```java // Searching a key on a B-tree in Java public class BTree { @@ -404,7 +404,7 @@ public class BTree { } ``` -``` +```c // Searching a key on a B-tree in C #include @@ -572,7 +572,7 @@ int main() { } ``` -``` +```cpp // Searching a key on a B-tree in C++ #include diff --git a/docs/dsal/35.md b/docs/dsal/35.md index 9626c1b07f223ea57058bc1e064f7fbca9a24b31..670dde730e7b070166f635863f2418a4acbcf848 100644 --- a/docs/dsal/35.md +++ b/docs/dsal/35.md @@ -92,9 +92,9 @@ n[x] = n[x] + 1 ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Inserting a key on a B-tree in Python # Create a node @@ -177,7 +177,7 @@ if __name__ == '__main__': main() ``` -``` +```java // Inserting a key on a B-tree in Java public class BTree { @@ -312,7 +312,7 @@ public class BTree { } ``` -``` +```c // insertioning a key on a B-tree in C #include @@ -561,7 +561,7 @@ int main() { } ``` -``` +```cpp // Inserting a key on a B-tree in C++ #include diff --git a/docs/dsal/36.md b/docs/dsal/36.md index 27ec5d5941aa29132b31cf709fac7ff193d459b4..a68d32e59feb170c6e36525e010e1b52fc9bb0f1 100644 --- a/docs/dsal/36.md +++ b/docs/dsal/36.md @@ -105,9 +105,9 @@ B 树中的删除操作主要有三种情况。 ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Deleting a key on a B-tree in Python # Btree node @@ -316,7 +316,7 @@ def main(): B.print_tree(B.root) ``` -``` +```java // Inserting a key on a B-tree in Java import java.util.Stack; @@ -692,7 +692,7 @@ public class BTree { } ``` -``` +```c // Deleting a key from a B-tree in C #include @@ -1029,7 +1029,7 @@ int main() { } ``` -``` +```cpp // Deleting a key from a B-tree in C++ #include diff --git a/docs/dsal/37.md b/docs/dsal/37.md index 635019a235b6ac987fcc905045feaffe1e0deecf..aa8fd1734d9f8d0e8d83fa0ac3de9ed717bfebb7 100644 --- a/docs/dsal/37.md +++ b/docs/dsal/37.md @@ -110,9 +110,9 @@ B+ 树 ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # B+ tee in python import math @@ -427,7 +427,7 @@ else: print("Not found") ``` -``` +```java // Searching on a B+ tree in Java import java.util.*; @@ -1007,7 +1007,7 @@ public class BPlusTree { } ``` -``` +```c // Searching on a B+ Tree in C #include @@ -1598,7 +1598,7 @@ int main() { } ``` -``` +```cpp // Searching on a B+ tree in C++ #include diff --git a/docs/dsal/38.md b/docs/dsal/38.md index 453f3bf9b218a053d44d325e0194bba31d1cf7c3..f667e6c5b77ff26ee861ca40b326911c21301368 100644 --- a/docs/dsal/38.md +++ b/docs/dsal/38.md @@ -86,9 +86,9 @@ ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # B+ tee in python import math @@ -253,7 +253,7 @@ else: print("Not found") ``` -``` +```java // Searching on a B+ tree in Java import java.util.*; @@ -833,7 +833,7 @@ public class BPlusTree { } ``` -``` +```c // Searching on a B+ Tree in C #include @@ -1424,7 +1424,7 @@ int main() { } ``` -``` +```cpp // Searching on a B+ tree in C++ #include diff --git a/docs/dsal/39.md b/docs/dsal/39.md index ca6fa9f25deb2fdad497e076e4b2511605782c2a..6a7bf9360ee828d6a489ad588dee8b44c6711129 100644 --- a/docs/dsal/39.md +++ b/docs/dsal/39.md @@ -72,9 +72,9 @@ ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # B+ tee in python import math @@ -389,7 +389,7 @@ else: print("Not found") ``` -``` +```java // Searching on a B+ tree in Java import java.util.*; @@ -968,7 +968,7 @@ public class BPlusTree { } ``` -``` +```c // Searching on a B+ Tree in C #include @@ -1559,7 +1559,7 @@ int main() { } ``` -``` +```cpp // Searching on a B+ tree in C++ #include diff --git a/docs/dsal/40.md b/docs/dsal/40.md index c9d274a31212fbf35123c595953db88ba7b1f476..93389c50eb08edc8732d0d89773a0ec10c89ca46 100644 --- a/docs/dsal/40.md +++ b/docs/dsal/40.md @@ -318,9 +318,9 @@ ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Implementing Red-Black Tree in Python import sys @@ -662,7 +662,7 @@ if __name__ == "__main__": bst.print_tree() ``` -``` +```java // Implementing Red-Black Tree in Java class Node { @@ -1072,7 +1072,7 @@ public class RedBlackTree { } ``` -``` +```c // Implementing Red-Black Tree in C #include @@ -1425,7 +1425,7 @@ int main() { } ``` -``` +```cpp // Implementing Red-Black Tree in C++ #include diff --git a/docs/dsal/41.md b/docs/dsal/41.md index 9be14ed98048ffefb43c8f343aca0e311f7469ae..4257e8f46eff0600a9d2582140265d9c716136bb 100644 --- a/docs/dsal/41.md +++ b/docs/dsal/41.md @@ -164,9 +164,9 @@ ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Implementing Red-Black Tree in Python import sys @@ -399,7 +399,7 @@ if __name__ == "__main__": bst.print_tree() ``` -``` +```java // Implementing Red-Black Tree in Java class Node { @@ -752,7 +752,7 @@ public class RedBlackTree { } ``` -``` +```c // Implementing Red-Black Tree in C #include @@ -1105,7 +1105,7 @@ int main() { } ``` -``` +```cpp // Implementing Red-Black Tree in C++ #include diff --git a/docs/dsal/42.md b/docs/dsal/42.md index a340297404b832a15891087681f5db71bfa22cb8..957ec47dcce0532af2eb29288a748a318132e4be 100644 --- a/docs/dsal/42.md +++ b/docs/dsal/42.md @@ -191,9 +191,9 @@ ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Implementing Red-Black Tree in Python import sys @@ -535,7 +535,7 @@ if __name__ == "__main__": bst.print_tree() ``` -``` +```java // Implementing Red-Black Tree in Java class Node { @@ -945,7 +945,7 @@ public class RedBlackTree { } ``` -``` +```c // Implementing Red-Black Tree in C #include @@ -1298,7 +1298,7 @@ int main() { } ``` -``` +```cpp // Implementing Red-Black Tree in C++ #include diff --git a/docs/dsal/46.md b/docs/dsal/46.md index 0abc4fe4bec77ea788110a9c23d1d7928cf3faee..28f387d7c3e2bfe3fd7bba2813d7cc305d50dda6 100644 --- a/docs/dsal/46.md +++ b/docs/dsal/46.md @@ -112,9 +112,9 @@ Kosaraju 算法基于[两次实现的深度优先搜索算法](/dsa/graph-dfs) ## Python,Java,C++ 示例 -[Python](#python-code)[Java](#java-code)[C++](#cpp-code) -``` + +```py # Kosaraju's algorithm to find strongly connected components in Python from collections import defaultdict @@ -187,7 +187,7 @@ print("Strongly Connected Components:") g.print_scc() ``` -``` +```java // Kosaraju's algorithm to find strongly connected components in Java import java.util.*; @@ -292,7 +292,7 @@ class Graph { } ``` -``` +```cpp // Kosaraju's algorithm to find strongly connected components in C++ #include diff --git a/docs/dsal/47.md b/docs/dsal/47.md index 5e8a2a60bded41684b0136c6b284a4751fede596..e4e788a68f995035031b0d0eaca03ab06d68df6d 100644 --- a/docs/dsal/47.md +++ b/docs/dsal/47.md @@ -54,7 +54,7 @@ -``` +```py # Adjacency Matrix representation in Python class Graph(object): @@ -105,7 +105,7 @@ if __name__ == '__main__': main() ``` -``` +```java // Adjacency Matrix representation in Java public class Graph { @@ -157,7 +157,7 @@ public class Graph { } ``` -``` +```c // Adjacency Matrix representation in C #include @@ -206,7 +206,7 @@ int main() { } ``` -``` +```cpp // Adjacency Matrix representation in C++ #include diff --git a/docs/dsal/48.md b/docs/dsal/48.md index 5c9f585598576f24c3a107194ac5f72299d1193f..94b85d1989b94cc72c35654f713207f4bcc0ac2f 100644 --- a/docs/dsal/48.md +++ b/docs/dsal/48.md @@ -103,9 +103,9 @@ graph = {'A': set(['B', 'C']), ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Adjascency List representation in Python class AdjNode: @@ -151,7 +151,7 @@ if __name__ == "__main__": graph.print_agraph() ``` -``` +```java // Adjascency List representation in Java import java.util.*; @@ -195,7 +195,7 @@ class Graph { } ``` -``` +```c // Adjascency List representation in C #include @@ -274,7 +274,7 @@ int main() { } ``` -``` +```cpp // Adjascency List representation in C++ #include diff --git a/docs/dsal/49.md b/docs/dsal/49.md index 912a5a43a39efe5c696f627e49fea08a119faa38..acd71c21947f7e518ab72910dfd64a576265931a 100644 --- a/docs/dsal/49.md +++ b/docs/dsal/49.md @@ -102,7 +102,7 @@ init() { -``` +```py # DFS algorithm in Python # DFS algorithm @@ -126,7 +126,7 @@ graph = {'0': set(['1', '2']), dfs(graph, '0') ``` -``` +```java // DFS algorithm in Java import java.util.*; @@ -177,7 +177,7 @@ class Graph { } ``` -``` +```c // DFS algorithm in C #include @@ -284,7 +284,7 @@ int main() { } ``` -``` +```cpp // DFS algorithm in C++ #include diff --git a/docs/dsal/50.md b/docs/dsal/50.md index 7575175cb0c39dd18dd2d8dbd45f05fa12154d25..d1e03c1b5713d36a4c28f216fd19debc29b373d0 100644 --- a/docs/dsal/50.md +++ b/docs/dsal/50.md @@ -98,7 +98,7 @@ while Q is non-empty -``` +```py # BFS algorithm in Python import collections @@ -128,7 +128,7 @@ if __name__ == '__main__': bfs(graph, 0) ``` -``` +```java // BFS algorithm in Java import java.util.*; @@ -192,7 +192,7 @@ public class Graph { } ``` -``` +```c // BFS algorithm in C #include @@ -364,7 +364,7 @@ int main() { } ``` -``` +```cpp // BFS algorithm in C++ #include diff --git a/docs/dsal/51.md b/docs/dsal/51.md index 3fc00cdf9a9f2d44b7a88f752f2979c4536aef94..603f5638896224ba7b977dbd3e9db6142924b468 100644 --- a/docs/dsal/51.md +++ b/docs/dsal/51.md @@ -121,9 +121,9 @@ Dijkstra vs Bellman Ford 算法 ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Bellman Ford Algorithm in Python class Graph: @@ -177,7 +177,7 @@ g.add_edge(3, 2, 2) g.bellman_ford(0) ``` -``` +```java // Bellman Ford Algorithm in Java class CreateGraph { @@ -287,7 +287,7 @@ class CreateGraph { } ``` -``` +```c // Bellman Ford Algorithm in C #include @@ -432,7 +432,7 @@ void display(int arr[], int size) { } ``` -``` +```cpp // Bellman Ford Algorithm in C++ #include diff --git a/docs/dsal/53.md b/docs/dsal/53.md index 60b9b78816807e054f9410fd69a5702a17252125..5ef82502378367c65575bb8a008e04fa6698b75f 100644 --- a/docs/dsal/53.md +++ b/docs/dsal/53.md @@ -65,9 +65,9 @@ end bubbleSort ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Bubble sort in Python def bubbleSort(array): @@ -89,7 +89,7 @@ print('Sorted Array in Asc ending Order:') print(data) ``` -``` +```java // Bubble sort in Java import java.util.Arrays; @@ -124,7 +124,7 @@ class BubbleSort { } ``` -``` +```c // Bubble sort in C #include @@ -166,7 +166,7 @@ int main() { } ``` -``` +```cpp // Bubble sort in C++ #include @@ -238,7 +238,7 @@ end bubbleSort -``` +```py # Optimized bubble sort in python def bubbleSort(array): @@ -268,7 +268,7 @@ print('Sorted Array in Ascending Order:') print(data) ``` -``` +```java // Optimized bubble sort in Java import java.util.Arrays; @@ -314,7 +314,7 @@ class BubbleSort { } ``` -``` +```c // Optimized bubble sort in C #include @@ -364,7 +364,7 @@ int main() { } ``` -``` +```cpp // Optimized bubble sort in C++ #include @@ -372,9 +372,7 @@ using namespace std; void bubbleSort(int array[], int size) { for (int step = 0; step < size - 1; ++step) { -``` -``` // Run loops two times: one for walking throught the array // and the other for comparison int swapped = 0; for (int i = 0; i < size - step - 1; ++i) { diff --git a/docs/dsal/54.md b/docs/dsal/54.md index eb42a578b67bdd602897761df85b5c5883f09aeb..83362c04e62643093cd87a8920e6c997b8116a7c 100644 --- a/docs/dsal/54.md +++ b/docs/dsal/54.md @@ -85,9 +85,9 @@ end selectionSort ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Selection sort in Python def selectionSort(array, size): @@ -112,7 +112,7 @@ print('Sorted Array in Ascending Order:') print(data) ``` -``` +```java // Selection sort in Java import java.util.Arrays; @@ -151,7 +151,7 @@ class SelectionSort { } ``` -``` +```c // Selection sort in C #include @@ -197,7 +197,7 @@ int main() { } ``` -``` +```cpp // Selection sort in C++ #include diff --git a/docs/dsal/55.md b/docs/dsal/55.md index 69b1fb8845ad803aa5bc02b6d32df124f69e5495..1b15c9480958a2d52cc417a100dc2ab95ed4daea 100644 --- a/docs/dsal/55.md +++ b/docs/dsal/55.md @@ -79,9 +79,9 @@ end insertionSort ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Insertion sort in Python def insertionSort(array): @@ -105,7 +105,7 @@ print('Sorted Array in Ascending Order:') print(data) ``` -``` +```java // Insertion sort in Java import java.util.Arrays; @@ -143,7 +143,7 @@ class InsertionSort { } ``` -``` +```c // Insertion sort in C #include @@ -182,7 +182,7 @@ int main() { } ``` -``` +```cpp // Insertion sort in C++ #include diff --git a/docs/dsal/56.md b/docs/dsal/56.md index 3f06a348cdfd0ac1e5507bc306f756b8626dc264..7fff61ebff9b1870c15f80cc8e2d41b54bc4b27a 100644 --- a/docs/dsal/56.md +++ b/docs/dsal/56.md @@ -277,9 +277,9 @@ void merge(int arr[], int p, int q, int r) { ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # MergeSort in Python def mergeSort(array): @@ -335,7 +335,7 @@ if __name__ == '__main__': printList(array) ``` -``` +```java // Merge sort in Java class MergeSort { @@ -425,7 +425,7 @@ class MergeSort { } ``` -``` +```c // Merge sort in C #include @@ -512,7 +512,7 @@ int main() { } ``` -``` +```cpp // Merge sort in C++ #include diff --git a/docs/dsal/57.md b/docs/dsal/57.md index ea86f5c402d348effd6c86b7593368f497df17bd..4a57e91551ba044a82fdfd938cd6f5be94253abb 100644 --- a/docs/dsal/57.md +++ b/docs/dsal/57.md @@ -114,7 +114,7 @@ return storeIndex + 1 -``` +```py # Quick sort in Python # Function to partition the array on the basis of pivot element @@ -155,7 +155,7 @@ print('Sorted Array in Ascending Order:') print(data) ``` -``` +```java // Quick sort in Java import java.util.Arrays; @@ -212,7 +212,7 @@ class QuickSort { } ``` -``` +```c // Quick sort in C #include @@ -277,7 +277,7 @@ int main() { } ``` -``` +```cpp // Quick sort in C++ #include diff --git a/docs/dsal/58.md b/docs/dsal/58.md index d66807c96d25aa434658c3bb90443f1d2a66deb2..9484c5e2056808b9bc8d59526c2b6bc1907162aa 100644 --- a/docs/dsal/58.md +++ b/docs/dsal/58.md @@ -76,9 +76,9 @@ countingSort(array, size) ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Counting sort in Python programming def countingSort(array): @@ -114,7 +114,7 @@ print("Sorted Array in Ascending Order: ") print(data) ``` -``` +```java // Counting sort in Java programming import java.util.Arrays; @@ -171,7 +171,7 @@ class CountingSort { } ``` -``` +```c // Counting sort in C programming #include @@ -237,7 +237,7 @@ int main() { } ``` -``` +```cpp // Counting sort in C++ programming #include diff --git a/docs/dsal/59.md b/docs/dsal/59.md index 3f8a0a58d1db21f25572c06c7a1bf2503d4a7b30..ac64b865379b02dbc63434b0cb9309be2a788ff5 100644 --- a/docs/dsal/59.md +++ b/docs/dsal/59.md @@ -81,9 +81,9 @@ countingSort(array, d) ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Radix sort in Python # Using counting sort to sort the elements in the basis of significant places @@ -128,7 +128,7 @@ radixSort(data) print(data) ``` -``` +```java // Radix Sort in Java Programming import java.util.Arrays; @@ -197,7 +197,7 @@ class RadixSort { } ``` -``` +```c // Radix Sort in C Programming #include @@ -270,7 +270,7 @@ int main() { } ``` -``` +```cpp // Radix Sort in C++ Programming #include diff --git a/docs/dsal/60.md b/docs/dsal/60.md index c9e227a0c4dcfe47e90f867b19b3528fbcec9de0..2e56f6f78ca15d4fa1d571e8ecff91baacaecf76 100644 --- a/docs/dsal/60.md +++ b/docs/dsal/60.md @@ -99,9 +99,9 @@ end bucketSort ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Bucket Sort in Python def bucketSort(array): @@ -133,7 +133,7 @@ print("Sorted Array in descending order is") print(bucketSort(array)) ``` -``` +```java // Bucket sort in Java import java.util.ArrayList; @@ -183,7 +183,7 @@ public class BucketSort { } ``` -``` +```c // Bucket sort in C #include @@ -340,7 +340,7 @@ int main(void) { } ``` -``` +```cpp // Bucket sort in C++ #include diff --git a/docs/dsal/61.md b/docs/dsal/61.md index 04be6699c080e32f72f456807322cd3e575be9cf..691ab03a918a3cabd2b8ff3652e68d154942cee2 100644 --- a/docs/dsal/61.md +++ b/docs/dsal/61.md @@ -235,9 +235,9 @@ void heapify(int arr[], int n, int i) { ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Heap Sort in python def heapify(arr, n, i): @@ -279,7 +279,7 @@ void heapify(int arr[], int n, int i) { print("%d " % arr[i], end='') ``` -``` +```java // Heap Sort in Java public class HeapSort { @@ -346,7 +346,7 @@ void heapify(int arr[], int n, int i) { } ``` -``` +```c // Heap Sort in C #include @@ -411,7 +411,7 @@ void heapify(int arr[], int n, int i) { } ``` -``` +```cpp // Heap Sort in C++ #include diff --git a/docs/dsal/62.md b/docs/dsal/62.md index 1efede1d4cb3bb8e8ae9c6a374d6b455ccabe9e9..c88f48eaaba838d4ae88b4588e9d7c0a522e55dd 100644 --- a/docs/dsal/62.md +++ b/docs/dsal/62.md @@ -94,9 +94,9 @@ end shellSort ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Shell sort in python def shellSort(array, n): @@ -121,7 +121,7 @@ print('Sorted Array in Ascending Order:') print(data) ``` -``` +```java // Shell sort in Java programming import java.util.Arrays; @@ -155,7 +155,7 @@ class ShellSort { } ``` -``` +```c // Shell Sort in C programming #include @@ -193,7 +193,7 @@ int main() { } ``` -``` +```cpp // Shell Sort in C++ programming #include diff --git a/docs/dsal/63.md b/docs/dsal/63.md index bec5a5205037761b90d59a201ea6efb56366426c..6b6aefd379d56ea26df06783392d8c2555911e10 100644 --- a/docs/dsal/63.md +++ b/docs/dsal/63.md @@ -51,9 +51,9 @@ LinearSearch(array, key) ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Linear Search in Python def linearSearch(array, n, x): @@ -74,7 +74,7 @@ else: print("Element found at index: ", result) ``` -``` +```java // Linear Search in Java class LinearSearch { @@ -103,7 +103,7 @@ class LinearSearch { } ``` -``` +```c // Linear Search in C #include @@ -128,7 +128,7 @@ int main() { } ``` -``` +```cpp // Linear Search in C++ #include diff --git a/docs/dsal/64.md b/docs/dsal/64.md index 090da00e185f3764c71277514d5b45124dfc83ae..32b84fa419528aca673d14b6a7404efcd24e1be5 100644 --- a/docs/dsal/64.md +++ b/docs/dsal/64.md @@ -108,9 +108,9 @@ binarySearch(arr, x, low, high) ## Python,Java,C/C++ 示例(迭代方法) -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Binary Search in python def binarySearch(array, x, low, high): @@ -142,7 +142,7 @@ else: print("Not found") ``` -``` +```java // Binary Search in Java class BinarySearch { @@ -179,7 +179,7 @@ class BinarySearch { } ``` -``` +```c // Binary Search in C #include @@ -215,7 +215,7 @@ int main(void) { } ``` -``` +```cpp // Binary Search in C++ #include @@ -256,9 +256,9 @@ int main(void) { ## Python,Java,C/C++ 示例(递归方法) -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Binary Search in python def binarySearch(array, x, low, high): @@ -293,7 +293,7 @@ else: print("Not found") ``` -``` +```java // Binary Search in Java class BinarySearch { @@ -331,7 +331,7 @@ class BinarySearch { } ``` -``` +```c // Binary Search in C #include @@ -367,7 +367,7 @@ int main(void) { } ``` -``` +```cpp // Binary Search in C++ #include diff --git a/docs/dsal/67.md b/docs/dsal/67.md index 494700cf40f42ff27cabaacefac392a4eef47f0d..f9008b571f8f52b555d2b52d4ecb7ae2ff6ba096 100644 --- a/docs/dsal/67.md +++ b/docs/dsal/67.md @@ -115,9 +115,9 @@ Ford-Fulkerson 算法是一种[贪婪方法](http://programiz.com/dsa/greedy-alg ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Ford-Fulkerson algorith in Python from collections import defaultdict @@ -190,7 +190,7 @@ sink = 5 print("Max Flow: %d " % g.ford_fulkerson(source, sink)) ``` -``` +```java // Ford-Fulkerson algorith in Java import java.util.LinkedList; @@ -269,7 +269,7 @@ class FordFulkerson { } ``` -``` +```c / Ford - Fulkerson algorith in C #include @@ -377,7 +377,7 @@ int main() { } ``` -``` +```cpp // Ford-Fulkerson algorith in C++ #include diff --git a/docs/dsal/68.md b/docs/dsal/68.md index aaf8cfbdcb1d4f990d552c873485060345b07350..8fa73c8748d9ba6fa2ee0f87a0312a2f63a4c2ad 100644 --- a/docs/dsal/68.md +++ b/docs/dsal/68.md @@ -110,9 +110,9 @@ function dijkstra(G, S) 下面给出了 Dijkstra 算法在 C++ 中的实现。 可以提高[代码](http://www.reviewmylife.co.uk/blog/2008/07/15/dijkstras-algorithm-code-in-c/)的复杂度,但是抽象方法很容易将代码与算法相关联。 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Dijkstra's Algorithm in Python import sys @@ -176,7 +176,7 @@ for distance in visited_and_distance: i = i + 1 ``` -``` +```java // Dijkstra's Algorithm in Java public class Dijkstra { @@ -233,7 +233,7 @@ public class Dijkstra { } ``` -``` +```c // Dijkstra's Algorithm in C #include @@ -356,7 +356,7 @@ int main() { } ``` -``` +```cpp // Dijkstra's Algorithm in C++ #include diff --git a/docs/dsal/69.md b/docs/dsal/69.md index 6b5eb59569182932ba6e9503b695c6b7b5e483cb..0ad59ff19a97bbf8e27a7bc31197f8d8a9df70ab 100644 --- a/docs/dsal/69.md +++ b/docs/dsal/69.md @@ -87,9 +87,9 @@ return A ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Kruskal's algorithm in Python class Graph: @@ -159,7 +159,7 @@ g.add_edge(5, 4, 3) g.kruskal_algo() ``` -``` +```java // Kruskal's algorithm in Java import java.util.*; @@ -284,7 +284,7 @@ class Graph { } ``` -``` +```c // Kruskal's algorithm in C #include @@ -441,7 +441,7 @@ int main() { } ``` -``` +```cpp // Kruskal's algorithm in C++ #include diff --git a/docs/dsal/70.md b/docs/dsal/70.md index f0e9e0e437ece4ed459429e64e862b05a8e835bd..bb3664001360d346927a5fe20fac33ca3a417ef0 100644 --- a/docs/dsal/70.md +++ b/docs/dsal/70.md @@ -84,9 +84,9 @@ while (U ≠ V) 尽管使用图形的[邻接矩阵](/dsa/graph-adjacency-matrix)表示,但是也可以使用[邻接表](/dsa/graph-adjacency-list)来实现此算法,以提高效率。 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Prim's Algorithm in Python INF = 9999999 @@ -133,7 +133,7 @@ while (no_edge < V - 1): no_edge += 1 ``` -``` +```java // Prim's Algorithm in Java import java.util.Arrays; @@ -212,7 +212,7 @@ class PGraph { } ``` -``` +```c // Prim's Algorithm in C #include @@ -290,7 +290,7 @@ int main() { } ``` -``` +```cpp // Prim's Algorithm in C++ #include diff --git a/docs/dsal/71.md b/docs/dsal/71.md index 10f248fccbc619bde9ba6f184e015c621c1be98c..7f1858ff253810de12f561177ced58f29ecc1def 100644 --- a/docs/dsal/71.md +++ b/docs/dsal/71.md @@ -130,9 +130,9 @@ return rootNode ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Huffman Coding in python string = 'BCAADDDCCACACAC' @@ -192,7 +192,7 @@ for (char, frequency) in freq: print(' %-4r |%12s' % (char, huffmanCode[char])) ``` -``` +```java // Huffman Coding in Java import java.util.PriorityQueue; @@ -272,7 +272,7 @@ public class Huffman { } ``` -``` +```c // Huffman Coding in C #include @@ -456,7 +456,7 @@ int main() { } ``` -``` +```cpp // Huffman Coding in C++ #include diff --git a/docs/dsal/74.md b/docs/dsal/74.md index 8d6cea12be8e8b52c2e62d08c05e100a5dca2c5e..c960e9d9811cdd8981fc5bb05232c99d561ba24a 100644 --- a/docs/dsal/74.md +++ b/docs/dsal/74.md @@ -97,9 +97,9 @@ return A ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Floyd Warshall Algorithm in python # The number of vertices @@ -135,7 +135,7 @@ G = [[0, 3, INF, 5], floyd_warshall(G) ``` -``` +```java // Floyd Warshall Algorithm in Java class FloydWarshall { @@ -182,7 +182,7 @@ class FloydWarshall { } ``` -``` +```c // Floyd-Warshall Algorithm in C #include @@ -235,7 +235,7 @@ int main() { } ``` -``` +```cpp // Floyd-Warshall Algorithm in C++ #include diff --git a/docs/dsal/75.md b/docs/dsal/75.md index 17c9657c82f990c1d7fbc51b326bb260aa90fe2b..56dfcab4294e361eb4c33985d69342bab6034e6e 100644 --- a/docs/dsal/75.md +++ b/docs/dsal/75.md @@ -142,9 +142,9 @@ Compare X[i] and Y[j] ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # The longest common subsequence in Python # Function to find lcs_algo @@ -192,7 +192,7 @@ n = len(S2) lcs_algo(S1, S2, m, n) ``` -``` +```java // The longest common subsequence in Java class LCS_ALGO { @@ -250,7 +250,7 @@ class LCS_ALGO { } ``` -``` +```c // The longest common subsequence in C #include @@ -311,7 +311,7 @@ int main() { } ``` -``` +```cpp // The longest common subsequence in C++ #include diff --git a/docs/dsal/78.md b/docs/dsal/78.md index 2873cea00eae636d2d1ad89a25c4774af3363752..08821b173fb61dd0671a027c8fd6a1b2a68592ff 100644 --- a/docs/dsal/78.md +++ b/docs/dsal/78.md @@ -124,9 +124,9 @@ for s = 0 to n - m ## Python,Java 和 C/C++ 示例 -[Python](#python-code)[Java](#java-code)[C](#c-code)[C++](#cpp-code) -``` + +```py # Rabin-Karp algorithm in python d = 10 @@ -171,7 +171,7 @@ q = 13 search(pattern, text, q) ``` -``` +```java // Rabin-Karp algorithm in Java public class RabinKarp { @@ -223,7 +223,7 @@ public class RabinKarp { } ``` -``` +```c // Rabin-Karp algorithm in C #include @@ -277,7 +277,7 @@ int main() { } ``` -``` +```cpp // Rabin-Karp algorithm in C++ #include diff --git a/docs/dsal/9.md b/docs/dsal/9.md index b1f9faa9f70ed45110b562f5ea43441416960f8e..8e84634b0567adf38cbb231c23046ab175134cc1 100644 --- a/docs/dsal/9.md +++ b/docs/dsal/9.md @@ -74,7 +74,7 @@ -``` +```py # Stack implementation in python # Creating a stack @@ -107,7 +107,7 @@ print("popped item: " + pop(stack)) print("stack after popping an element: " + str(stack)) ``` -``` +```java // Stack implementation in Java class Stack { @@ -180,7 +180,7 @@ class Stack { } ``` -``` +```c // Stack implementation in C #include @@ -270,7 +270,7 @@ int main() { } ``` -``` +```cpp // Stack implementation in C++ #include