Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
programiz-zh
提交
f7fbf06f
P
programiz-zh
项目概览
OpenDocCN
/
programiz-zh
9 个月 前同步成功
通知
0
Star
48
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
programiz-zh
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f7fbf06f
编写于
7月 10, 2020
作者:
W
wizardforcel
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
2020-07-10 23:39:40
上级
2238acf0
变更
54
隐藏空白更改
内联
并排
Showing
54 changed file
with
262 addition
and
264 deletion
+262
-264
docs/dsal/10.md
docs/dsal/10.md
+4
-4
docs/dsal/12.md
docs/dsal/12.md
+4
-4
docs/dsal/13.md
docs/dsal/13.md
+4
-4
docs/dsal/14.md
docs/dsal/14.md
+4
-4
docs/dsal/16.md
docs/dsal/16.md
+4
-4
docs/dsal/17.md
docs/dsal/17.md
+4
-4
docs/dsal/19.md
docs/dsal/19.md
+5
-5
docs/dsal/20.md
docs/dsal/20.md
+5
-5
docs/dsal/21.md
docs/dsal/21.md
+4
-4
docs/dsal/22.md
docs/dsal/22.md
+4
-4
docs/dsal/25.md
docs/dsal/25.md
+4
-4
docs/dsal/26.md
docs/dsal/26.md
+4
-4
docs/dsal/27.md
docs/dsal/27.md
+4
-4
docs/dsal/28.md
docs/dsal/28.md
+5
-5
docs/dsal/29.md
docs/dsal/29.md
+5
-5
docs/dsal/30.md
docs/dsal/30.md
+5
-5
docs/dsal/31.md
docs/dsal/31.md
+5
-5
docs/dsal/32.md
docs/dsal/32.md
+5
-5
docs/dsal/34.md
docs/dsal/34.md
+5
-5
docs/dsal/35.md
docs/dsal/35.md
+5
-5
docs/dsal/36.md
docs/dsal/36.md
+5
-5
docs/dsal/37.md
docs/dsal/37.md
+5
-5
docs/dsal/38.md
docs/dsal/38.md
+5
-5
docs/dsal/39.md
docs/dsal/39.md
+5
-5
docs/dsal/40.md
docs/dsal/40.md
+5
-5
docs/dsal/41.md
docs/dsal/41.md
+5
-5
docs/dsal/42.md
docs/dsal/42.md
+5
-5
docs/dsal/46.md
docs/dsal/46.md
+4
-4
docs/dsal/47.md
docs/dsal/47.md
+4
-4
docs/dsal/48.md
docs/dsal/48.md
+5
-5
docs/dsal/49.md
docs/dsal/49.md
+4
-4
docs/dsal/50.md
docs/dsal/50.md
+4
-4
docs/dsal/51.md
docs/dsal/51.md
+5
-5
docs/dsal/53.md
docs/dsal/53.md
+9
-11
docs/dsal/54.md
docs/dsal/54.md
+5
-5
docs/dsal/55.md
docs/dsal/55.md
+5
-5
docs/dsal/56.md
docs/dsal/56.md
+5
-5
docs/dsal/57.md
docs/dsal/57.md
+4
-4
docs/dsal/58.md
docs/dsal/58.md
+5
-5
docs/dsal/59.md
docs/dsal/59.md
+5
-5
docs/dsal/60.md
docs/dsal/60.md
+5
-5
docs/dsal/61.md
docs/dsal/61.md
+5
-5
docs/dsal/62.md
docs/dsal/62.md
+5
-5
docs/dsal/63.md
docs/dsal/63.md
+5
-5
docs/dsal/64.md
docs/dsal/64.md
+10
-10
docs/dsal/67.md
docs/dsal/67.md
+5
-5
docs/dsal/68.md
docs/dsal/68.md
+5
-5
docs/dsal/69.md
docs/dsal/69.md
+5
-5
docs/dsal/70.md
docs/dsal/70.md
+5
-5
docs/dsal/71.md
docs/dsal/71.md
+5
-5
docs/dsal/74.md
docs/dsal/74.md
+5
-5
docs/dsal/75.md
docs/dsal/75.md
+5
-5
docs/dsal/78.md
docs/dsal/78.md
+5
-5
docs/dsal/9.md
docs/dsal/9.md
+4
-4
未找到文件。
docs/dsal/10.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -276,7 +276,7 @@ void display() {
}
```
```
```
cpp
// Queue implementation in C++
#include <iostream>
...
...
docs/dsal/12.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -364,7 +364,7 @@ int main() {
}
```
```
```
cpp
// Circular Queue implementation in C++
#include <iostream>
...
...
docs/dsal/13.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -396,7 +396,7 @@ int main() {
}
```
```
```
cpp
// Max-Heap data structure in C++
#include <iostream>
...
...
docs/dsal/14.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -529,7 +529,7 @@ int count(int *arr)
}
```
```
```
cpp
// Deque operations in C++
#include <iostream>
...
...
docs/dsal/16.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -225,7 +225,7 @@ int main() {
}
```
```
```
cpp
// Linked list implementation in C++
#include <bits/stdc++.h>
...
...
docs/dsal/17.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -466,7 +466,7 @@ int main() {
}
```
```
```
cpp
// Linked list operations in C++
#include <stdlib.h>
...
...
docs/dsal/19.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -342,7 +342,7 @@ int main()
}
```
```
```
cpp
// Implementing hash table in C++
#include <iostream>
...
...
docs/dsal/20.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -380,7 +380,7 @@ int main()
}
```
```
```
cpp
// Max-Heap data structure in C++
#include <iostream>
...
...
docs/dsal/21.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <math.h>
...
...
@@ -1124,7 +1124,7 @@ int main(int argc, char **argv) {
}
```
```
```
cpp
// Operations on a Fibonacci heap in C++
#include <cmath>
...
...
docs/dsal/22.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -1078,7 +1078,7 @@ int main(int argc, char **argv)
}
```
```
```
cpp
// Operations on a Fibonacci heap in C++
#include <iostream>
...
...
docs/dsal/25.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -360,7 +360,7 @@ int main() {
}
```
```
```
cpp
// Tree traversal in C++
#include <iostream>
...
...
docs/dsal/26.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -310,7 +310,7 @@ int main() {
}
```
```
```
cpp
// Binary Tree in C++
#include <stdlib.h>
...
...
docs/dsal/27.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdbool.h>
...
...
@@ -187,7 +187,7 @@ int main() {
}
```
```
```
cpp
// Checking if a binary tree is a full binary tree in C++
#include <iostream>
...
...
docs/dsal/28.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdbool.h>
...
...
@@ -219,7 +219,7 @@ int main() {
}
```
```
```
cpp
// Checking if a binary tree is a full binary tree in C++
#include <iostream>
...
...
docs/dsal/29.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdbool.h>
...
...
@@ -242,7 +242,7 @@ int main() {
}
```
```
```
cpp
// Checking if a binary tree is a complete binary tree in C++
#include <iostream>
...
...
docs/dsal/30.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -209,7 +209,7 @@ int main() {
}
```
```
```
cpp
// Checking if a binary tree is height balanced in C++
#include <iostream>
...
...
docs/dsal/31.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -556,7 +556,7 @@ int main() {
}
```
```
```
cpp
// Binary Search Tree operations in C++
#include <iostream>
...
...
docs/dsal/32.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -868,7 +868,7 @@ int main() {
}
```
```
```
cpp
// AVL tree implementation in C++
#include <iostream>
...
...
docs/dsal/34.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -572,7 +572,7 @@ int main() {
}
```
```
```
cpp
// Searching a key on a B-tree in C++
#include <iostream>
...
...
docs/dsal/35.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -561,7 +561,7 @@ int main() {
}
```
```
```
cpp
// Inserting a key on a B-tree in C++
#include <iostream>
...
...
docs/dsal/36.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -1029,7 +1029,7 @@ int main() {
}
```
```
```
cpp
// Deleting a key from a B-tree in C++
#include <iostream>
...
...
docs/dsal/37.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdbool.h>
...
...
@@ -1598,7 +1598,7 @@ int main() {
}
```
```
```
cpp
// Searching on a B+ tree in C++
#include <climits>
...
...
docs/dsal/38.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdbool.h>
...
...
@@ -1424,7 +1424,7 @@ int main() {
}
```
```
```
cpp
// Searching on a B+ tree in C++
#include <climits>
...
...
docs/dsal/39.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdbool.h>
...
...
@@ -1559,7 +1559,7 @@ int main() {
}
```
```
```
cpp
// Searching on a B+ tree in C++
#include <climits>
...
...
docs/dsal/40.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -1425,7 +1425,7 @@ int main() {
}
```
```
```
cpp
// Implementing Red-Black Tree in C++
#include <iostream>
...
...
docs/dsal/41.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -1105,7 +1105,7 @@ int main() {
}
```
```
```
cpp
// Implementing Red-Black Tree in C++
#include <iostream>
...
...
docs/dsal/42.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -1298,7 +1298,7 @@ int main() {
}
```
```
```
cpp
// Implementing Red-Black Tree in C++
#include <iostream>
...
...
docs/dsal/46.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <iostream>
...
...
docs/dsal/47.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -206,7 +206,7 @@ int main() {
}
```
```
```
cpp
// Adjacency Matrix representation in C++
#include <iostream>
...
...
docs/dsal/48.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -274,7 +274,7 @@ int main() {
}
```
```
```
cpp
// Adjascency List representation in C++
#include <bits/stdc++.h>
...
...
docs/dsal/49.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -284,7 +284,7 @@ int main() {
}
```
```
```
cpp
// DFS algorithm in C++
#include <iostream>
...
...
docs/dsal/50.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -364,7 +364,7 @@ int main() {
}
```
```
```
cpp
// BFS algorithm in C++
#include <iostream>
...
...
docs/dsal/51.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -432,7 +432,7 @@ void display(int arr[], int size) {
}
```
```
```
cpp
// Bellman Ford Algorithm in C++
#include <bits/stdc++.h>
...
...
docs/dsal/53.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -166,7 +166,7 @@ int main() {
}
```
```
```
cpp
// Bubble sort in C++
#include <iostream>
...
...
@@ -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 <stdio.h>
...
...
@@ -364,7 +364,7 @@ int main() {
}
```
```
```
cpp
// Optimized bubble sort in C++
#include <iostream>
...
...
@@ -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
)
{
...
...
docs/dsal/54.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -197,7 +197,7 @@ int main() {
}
```
```
```
cpp
// Selection sort in C++
#include <iostream>
...
...
docs/dsal/55.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -182,7 +182,7 @@ int main() {
}
```
```
```
cpp
// Insertion sort in C++
#include <iostream>
...
...
docs/dsal/56.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -512,7 +512,7 @@ int main() {
}
```
```
```
cpp
// Merge sort in C++
#include <iostream>
...
...
docs/dsal/57.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -277,7 +277,7 @@ int main() {
}
```
```
```
cpp
// Quick sort in C++
#include <iostream>
...
...
docs/dsal/58.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -237,7 +237,7 @@ int main() {
}
```
```
```
cpp
// Counting sort in C++ programming
#include <iostream>
...
...
docs/dsal/59.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -270,7 +270,7 @@ int main() {
}
```
```
```
cpp
// Radix Sort in C++ Programming
#include <iostream>
...
...
docs/dsal/60.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -340,7 +340,7 @@ int main(void) {
}
```
```
```
cpp
// Bucket sort in C++
#include <iomanip>
...
...
docs/dsal/61.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -411,7 +411,7 @@ void heapify(int arr[], int n, int i) {
}
```
```
```
cpp
// Heap Sort in C++
#include <iostream>
...
...
docs/dsal/62.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -193,7 +193,7 @@ int main() {
}
```
```
```
cpp
// Shell Sort in C++ programming
#include <iostream>
...
...
docs/dsal/63.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -128,7 +128,7 @@ int main() {
}
```
```
```
cpp
// Linear Search in C++
#include <iostream>
...
...
docs/dsal/64.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -215,7 +215,7 @@ int main(void) {
}
```
```
```
cpp
// Binary Search in C++
#include <iostream>
...
...
@@ -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 <stdio.h>
...
...
@@ -367,7 +367,7 @@ int main(void) {
}
```
```
```
cpp
// Binary Search in C++
#include <iostream>
...
...
docs/dsal/67.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -377,7 +377,7 @@ int main() {
}
```
```
```
cpp
// Ford-Fulkerson algorith in C++
#include <limits.h>
...
...
docs/dsal/68.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -356,7 +356,7 @@ int main() {
}
```
```
```
cpp
// Dijkstra's Algorithm in C++
#include <iostream>
...
...
docs/dsal/69.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -441,7 +441,7 @@ int main() {
}
```
```
```
cpp
// Kruskal's algorithm in C++
#include <algorithm>
...
...
docs/dsal/70.md
浏览文件 @
f7fbf06f
...
...
@@ -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<stdio.h>
...
...
@@ -290,7 +290,7 @@ int main() {
}
```
```
```
cpp
// Prim's Algorithm in C++
#include <cstring>
...
...
docs/dsal/71.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -456,7 +456,7 @@ int main() {
}
```
```
```
cpp
// Huffman Coding in C++
#include <iostream>
...
...
docs/dsal/74.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -235,7 +235,7 @@ int main() {
}
```
```
```
cpp
// Floyd-Warshall Algorithm in C++
#include <iostream>
...
...
docs/dsal/75.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -311,7 +311,7 @@ int main() {
}
```
```
```
cpp
// The longest common subsequence in C++
#include <iostream>
...
...
docs/dsal/78.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -277,7 +277,7 @@ int main() {
}
```
```
```
cpp
// Rabin-Karp algorithm in C++
#include <string.h>
...
...
docs/dsal/9.md
浏览文件 @
f7fbf06f
...
...
@@ -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 <stdio.h>
...
...
@@ -270,7 +270,7 @@ int main() {
}
```
```
```
cpp
// Stack implementation in C++
#include <stdlib.h>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录