算法导论
shifan86
互相交流
展开
-
HeapSort and PriorityQueue(堆排序算法和优先队列Java代码实现)
HeapSortpackage Search;//堆排序算法实现public class HeapSort {public static void main(String[] args) { int arr[] = { 4, 1, 3, 2, 16, 9, 10, 14, 8, 7 }; HeapSort hs = new HeapSort(); System.out.prin...原创 2019-03-22 11:40:15 · 166 阅读 · 0 评论 -
算法导论---堆排序Java代码实现
package Search;//堆排序算法实现public class HeapSort1 {public static void main(String[] args) { int arr[] = { 4, 1, 3, 2, 16, 9, 10, 14, 8, 7 }; HeapSort1 hs1 = new HeapSort1(); hs1.HeapSort(arr,ar...原创 2019-03-19 14:19:13 · 164 阅读 · 0 评论 -
通过深度优先算法来找出有向图的树边,后向边,前向边,横跨边
**通过深度优先算法来找出有向图的树边,后向边,前向边,横跨边(Java实现)**package graph;import java.io.IOException;import java.util.Scanner;public class ListCycle { private class ENode { int ivex; // 该边所指向的顶点的位...原创 2019-05-28 22:01:16 · 1607 阅读 · 0 评论 -
通过深度优先算法进行拓扑排序(算法导论)
通过深度优先算法进行拓扑排序(Java)package graph;//拓扑排序用深度优先算法实现import java.io.IOException;import java.util.Scanner;import java.util.Stack;public class Topological { private class ENode { int ivex; // 该...原创 2019-05-28 22:06:41 · 4818 阅读 · 1 评论 -
判断两个集合是否相交(判定问题)
package test;//判断两个集合是否相交,是否有交集import Search.QuickSort;public class Disjoint_Set extends QuickSort {public int Disjoint_Set(int a[], int b[]){ int count = 0; int i = 0, j = 0; Quicksort(a, 0, ...原创 2019-06-01 14:49:50 · 4410 阅读 · 0 评论 -
判断一个整数表,是否按非降序排列
package test;//判断是否是非降序public class Nojiangxu {public static void main(String[] args) { int A[] = { 1, 2, 4, 3, 0 }; int n = A.length; int i = 0; int count = 0; while (i < n - 1) { if (A[...原创 2019-06-01 14:53:24 · 827 阅读 · 0 评论 -
单源最短路径问题Java代码实现
**The Bellman-Ford algorithm solves the single-source shortest-paths problem in the general case in which edge weights may be negative.**import java.io.IOException;import java.util.Scanner;public...原创 2019-06-19 22:12:53 · 1055 阅读 · 0 评论