This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:math'; | |
void main() { | |
List<int> array = [1, 9, 5, 7, 2, 8, 4, 6, 3, 0]; | |
print('${array.join(',')}\n'); | |
// bubbleSort(array); | |
// selectionSort(array); | |
// insertSort(array); | |
// array = mergeSort(array); | |
// quickSort(array, 0, array.length - 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
//创建测试节点 | |
HeroNode heroNode1 = HeroNode(1, "宋江", "及时雨"); | |
HeroNode heroNode2 = HeroNode(2, "卢俊义", "玉麒麟"); | |
HeroNode heroNode3 = HeroNode(3, "吴用", "智多星"); | |
HeroNode heroNode4 = HeroNode(4, "林冲", "豹子头"); | |
//创建链表 | |
DoubleLinkedList doubleLinkedList = DoubleLinkedList(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
//创建测试节点 | |
HeroNode heroNode1 = HeroNode(1, "宋江", "及时雨"); | |
HeroNode heroNode2 = HeroNode(2, "卢俊义", "玉麒麟"); | |
HeroNode heroNode3 = HeroNode(3, "吴用", "智多星"); | |
HeroNode heroNode4 = HeroNode(4, "林冲", "豹子头"); | |
//创建链表 | |
SingleLinkedList singleLinkedList = SingleLinkedList(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
//创建测试节点 | |
HeroNode heroNode1 = HeroNode(1, "宋江", "及时雨"); | |
HeroNode heroNode2 = HeroNode(2, "卢俊义", "玉麒麟"); | |
HeroNode heroNode3 = HeroNode(3, "吴用", "智多星"); | |
HeroNode heroNode4 = HeroNode(4, "林冲", "豹子头"); | |
//创建链表 | |
SingleLinkedList singleLinkedList = SingleLinkedList(); | |
//添加数据 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 思路如下: | |
// 1. front变量的含义做一个调整:front指向队列的第一个元素front初始值=0 | |
// 2. rear变量的含义做一个调整:rear指向队列的最后一个元素的后一个位置,因为 | |
// 希望空出一个空间作为约定.rear的初始值=0 | |
// 3. 当队列满时,条件是(rear + 1) % maxSize == front[满] | |
// 4. 队列为空的条件,rear == front [空] | |
// 5. 队列中有效的数据个数 [rear - front + maxSize] % maxSize | |
void main() { | |
// 创建一个队列 | |
CircleArrayQueue queue = CircleArrayQueue(4); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
// 创建一个队列 | |
ArrayQueue queue = ArrayQueue(3); | |
// 显示队列所有数据 | |
queue.showQueue(); | |
// 添加一个数 | |
queue.addQueue(5); | |
// 添加一个数 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
// 创建一个原始的二维数组 11*11 | |
List<List<int>> chessArr1 = []; | |
for (int i = 0; i < 11; i++) { | |
List<int> list = []; | |
for (int j = 0; j < 11; j++) { | |
list.add(0); | |
} | |
chessArr1.add(list); | |
} |