![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
文章平均质量分 61
easyjsf
do it....
展开
-
哈夫曼编码
哈夫曼(Huffman)树与哈夫曼编码文章分类:综合技术哈夫曼树又称最优二叉树,是一种带权路径长最短的树。树的路径长度是从树根到每一个叶子之间的路径长度之和。节点的带树路径长度为从该节点到树根之间的路径长度与该节点权(比如字符在某串中的使用频率)的乘积。比如有一串字符串如:3334444555556666667777777,它是由3、4、5、6、7这五个数字组成的,现要使用一种编码方式,让它编码存储最短,如何做?如果五个数使用3位的定长的二进制就可表示,如:(3:000) (4:原创 2011-05-09 12:46:00 · 795 阅读 · 0 评论 -
列表
<br />ListADT<T><br />列表接口<br /> <br />import java.util.Iterator;public interface ListADT<T>{ /** * Removes and returns the first element from this list. * * @return the first element from this list */ public T removeFi原创 2011-04-24 18:38:00 · 376 阅读 · 0 评论 -
二叉树 计算后缀表达式
表达式树:public class ExpressionTree extends LinkedBinaryTree{ /** * Creates an empty expression tree. */ public ExpressionTree() { super(); } /** * Constructs a expression tree from the two specified expression原创 2011-04-23 10:25:00 · 2134 阅读 · 0 评论 -
递归
<br />使用递归穿越迷宫:<br /> <br /> /** * Attempts to recursively traverse the maze. Inserts special * characters indicating locations that have been tried and that * eventually become part of the solution. * * @param row the intege原创 2011-04-23 10:14:00 · 362 阅读 · 0 评论 -
BinaryTree 书中的实现。
<br />BinaryTreeADT<T>:<br />/** * BinaryTreeADT defines the interface to a binary tree data structure. * * @author Dr. Lewis * @author Dr. Chase * @version 1.0, 8/19/08 */package jss2;import java.util.Iterator;public interface BinaryTree原创 2011-04-24 18:58:00 · 530 阅读 · 0 评论 -
二叉树的实现
树节点定义:class TreeNode { public TreeNode left; public TreeNode right; public int value; public TreeNode(TreeNode left, TreeNode right, int value) { this.left = left; this.right = right; this.value = value;转载 2011-04-23 10:44:00 · 313 阅读 · 0 评论 -
队列
队列应用:代码密钥 public static void main ( String[] args) { int[] key = {5, 12, -3, 8, -9, 4, 10}; Integer keyValue; String encoded = "", decoded = ""; String message = "All programmers are playwrights and all " + "co原创 2011-04-23 10:02:00 · 411 阅读 · 0 评论 -
栈
栈:数组实现TOP指向下一个位置栈 计算后缀表达式从左到右扫描表达式,依次标识出每个符号(操作符或操作数)如果是操作数压入栈中。如果是操作符则从栈中弹出两个元素并把该操作符应用在这连个元素上,然后操作结果压入栈中。/** * Evaluates the specified postfix expression. If an operand is * encountered, it is pushed onto the stack. If an operator is * encoun原创 2011-04-21 22:32:00 · 445 阅读 · 0 评论 -
最小生成树,最短路径
prim最小生成树算法 1.任意选取一个起始顶点,并将它添加到最小生成树中。2.将所有含起始顶点的边按照权重次序添加到minheap(最小堆)中。3.从最小堆中取出最小边,并将这条边和那个新顶点添加到最小生成树中。4.我们往minheap中添加所有含新顶点且另一顶点不在最小生成树中的边。5.重复这一过程直到最小生成树含有原始图中的所有顶点时结束。 pub原创 2011-06-13 09:08:00 · 1404 阅读 · 0 评论 -
快速排序 两种实现
<br /> <br /> <br />第一种: 首 为 轴<br /> <br />public static void sort1(int[] a,int left,int right){if(left<right){int i = left;int j = right;int axis = a[i];while(i<j){while(i<j&&a[j]>axis)j--;if(i<j)a[i++]=a[j];while(i<j&&a[i]>axis)i++;原创 2011-04-21 14:16:00 · 368 阅读 · 0 评论 -
简单 的 排序
public static void selectionSort(int[] number) { for(int i = 0; i int m = i; for(int j = i + 1; j if(number[j] m = j; if(i != m) swap(number, i, m); }原创 2011-04-21 12:24:00 · 330 阅读 · 0 评论 -
图的深度优先,广度优先
深度优先遍历public Iterator iteratorDFS(int startIndex) { Integer x; boolean found; LinkedStack traversalStack = new LinkedStack(); ArrayUnorderedList resultList = new Arra原创 2011-06-07 22:32:00 · 312 阅读 · 0 评论 -
堆的书中实现
public HeapNode lastNode; public class LinkedHeap extends LinkedBinaryTree implements HeapADT public void addElement (T obj) { HeapNode node = new HeapNode(obj);原创 2011-06-04 14:20:00 · 351 阅读 · 0 评论 -
二叉查找树书中实现
<br /> <br />在二叉排序树插入结点的算法<br />向一个二叉排序树b中插入一个结点s的算法,过程为:<br />1. 若b是空树,则将s所指结点作为根结点插入,否则:<br />2. 若s->data小于b的根结点的数据域之值,则把s所指结点插入到左子树中,否则:<br />3. 把s所指结点插入到右子树中。<br /> <br />publicvoid addElement (T element) <br /> {<br /> BinaryTreeN原创 2011-06-02 16:16:00 · 336 阅读 · 0 评论 -
堆排序与归并排序
、 //每次将堆顶元素与最后的元素交换public class HeapSort{ public static void heapSort(DataWrap[] data) { System.out.println("开始排序"); int arrayLength = data.length; //循环建堆原创 2011-06-24 11:46:00 · 375 阅读 · 0 评论