摘要:首先dijkstra是一个人,一位计算机上古时期的先驱;而dijkstra是他用来向观众解释什么计算机想到的一个算法,如何计算两个地点的最短距离;当然这个最短距离,是有一个前提的,首先你要有一个已知各个点之间距离的路网; 比如这个图,我们如何去寻找A点到E点的最短距离?显然,正常人的直觉就是“这不是
阅读全文
摘要:Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a
阅读全文
摘要:A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Specification: Each inp
阅读全文
摘要:原题目: As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by so
阅读全文
摘要:#include "DFS.h" #include <list> #include <stack> using namespace std; DFS::DFS(int vertexCount) { this->v = vertexCount; this->adj = new list<int>[v]
阅读全文
摘要:#include <queue> #include <list> #include "BFS.h" using namespace std; BFS::BFS(int vertexCount){ this->v = vertexCount; this->adj = new list<int>[v];
阅读全文
摘要:class ShellSort { public: void sort(int * arr, int size); }; #include "ShellSort.h" #include <iostream> void ShellSort::sort(int *arr, int size) { int
阅读全文
摘要:class QuickSort { public: void sort(int * arr, int size); private: int partition(int * arr, int start, int end); void quickSort(int *arr, int start, i
阅读全文
摘要:class MergeSort { public: void sort(int * arr, int size); private: void arrCopy(int *sourceArr, int *targetArr, int size); void divideSort(int *arr, i
阅读全文
摘要:class InsertionSort { public: void sort(int * arr, int size); }; #include "InsertionSort.h" /** * 本质上是遍历每个元素,和数组前部的有序部分进行一一比较,找到合适的位置,进行插入 * 所以这里有两部分逻
阅读全文
摘要:class BubbleSort { public: void sort(int * arr, int size); }; #include "BubbleSort.h" /** * 冒泡排序,意思是从头开始,拿 j 和 j+1 元素 进行比较,如果前面的元素大于后面的元素,那么就进行交换,就像冒泡
阅读全文