随笔分类 -  数据结构

摘要:object IntervalTree1 extends App{ val score = Array(1, 2, 3, 4, 5) val commands = Array( "Q 1 5", "U 3 6", "Q 3 4", "Q 4 5", "U 2 ... 阅读全文
posted @ 2014-09-18 16:46 rilley 阅读(241) 评论(0) 推荐(0)
摘要:import scala.collection.mutable.{ArrayBuffer, Map}class TrieTree{ private var root: TrieNode = new TrieNode() def insert(word: String) { ... 阅读全文
posted @ 2014-05-07 10:57 rilley 阅读(209) 评论(0) 推荐(0)
摘要:package org.riley.tree;import java.util.Random;/** * 保存int的集合 集合中的元素存放在B-树中 * * @author dou * */public class IntBalancedSet implements Cloneable { private static final int MINIMUM = 2;// 非根节点中最少存放的元素个数 private static final int MAXIMUM = 2 * MINIMUM;// 节点中最多存放的元素个数 int dataCount;// 存放节点中元素... 阅读全文
posted @ 2012-12-09 16:03 rilley 阅读(348) 评论(0) 推荐(0)
摘要:索引结构一个数据文件可以用来存储一个关系。一个数据文件可能拥有一个或多个索引文件,每个索引文件建立查找键和数据记录之间的关联,查找键的指针指向于查找键相同属相值得记录。索引可以是稠密的,以数据文件中每个记录在索引文件中都设有一个索引项。也可以是稀疏的,即数据文件中只有一些记录在索引文件中表示出来,通常为每个数据块在索引文件中设一个索引项。索引还可以是主索引或者辅助索引。顺序文件顺序文件是对关系中的元祖按主键进行排序而生成的文件。关系中的元祖按照这个次序分布在多个数据块中。稠密索引如果记录是排好序的,我们就可以在记录上建立稠密索引。块中只存放记录的键以及只想记录本身的指针。稠密索引文件中的索引块 阅读全文
posted @ 2012-12-02 11:32 rilley 阅读(246) 评论(0) 推荐(0)
摘要:1 import java.util.Random; 2 3 4 public class RBTree 5 { 6 7 private Node root; 8 9 10 public RBTree(int[] array) 11 { 12 for (int i : array) insert(i); 13 } 14 15 private Node search(int key, Node node) 16 { 17 if (node == nul... 阅读全文
posted @ 2012-07-11 18:47 rilley 阅读(259) 评论(1) 推荐(0)
摘要:原帖地址 http://www.iteye.com/topic/561590 1 import java.util.Collection; 2 import java.util.Iterator; 3 import java.util.NoSuchElementException; 4 5 public class BinarySearchTree<E extends Comparable<E>> 6 { 7 8 public static void main(String[] args) 9 { 10 BinarySearchT... 阅读全文
posted @ 2012-07-11 15:39 rilley 阅读(254) 评论(0) 推荐(0)
摘要:1 public class FibHeap 2 { 3 private FibNode min; 4 5 private int count; 6 7 private FibNode root; 8 9 10 public FibHeap() 11 { 12 root = new FibNode(); 13 root.left = root; 14 root.right = root; 15 } 16 17 /* 18 ... 阅读全文
posted @ 2012-07-11 15:36 rilley 阅读(656) 评论(1) 推荐(0)
摘要:1 public class BinaryHeap<E extends Comparable<? super E>> 2 { 3 4 public static void main(String[] args) 5 { 6 Integer[] array = {0, 12, 90, 1, 85, 12, 3, 13, 49, 7 55, 10, 3, 31, 97, 19, 93, 41, 55, 56, 82, 2}; 8 9 BinaryHeap<Integer> he... 阅读全文
posted @ 2012-07-10 15:55 rilley 阅读(309) 评论(0) 推荐(0)
摘要:1 public class DisjoinSet 2 { 3 4 public static void main(String[] args) 5 { 6 DisjoinSet disjoin = new DisjoinSet(8); 7 8 disjoin.union(4, 3); 9 disjoin.union(5, 4);10 disjoin.union(6, 5);11 disjoin.union(7, 6);12 disjoin.union(8, 7);13 ... 阅读全文
posted @ 2012-07-10 15:54 rilley 阅读(259) 评论(0) 推荐(0)
摘要:1 public class ArrayDeque<E> 2 { 3 4 private static final int MIN_INITIAL_CAPACITY = 16; 5 6 private E[] elements; 7 8 private int head; 9 10 private int tail; 11 12 13 public ArrayDeque() 14 { 15 elements = (E[]) new Object[MIN_IN... 阅读全文
posted @ 2012-03-21 15:59 rilley 阅读(323) 评论(0) 推荐(0)
摘要:1 package queue; 2 3 import java.lang.reflect.Array; 4 import java.util.Arrays; 5 import java.util.Comparator; 6 7 8 public class PriorityQueue<T> 9 { 10 11 private static final int DEFAULT_SIZE = 32; 12 private int size = 0; 13 private Object[] queue; 14 private final... 阅读全文
posted @ 2012-03-21 10:53 rilley 阅读(239) 评论(0) 推荐(0)
摘要:package java.util.concurrent;import java.util.concurrent.locks.*;import java.util.*;public class ThreadPoolExecutor extends AbstractExecutorService { /** * runState provides the main lifecyle control, taking on values: * * RUNNING: Accept new tasks and process queued tasks * ... 阅读全文
posted @ 2012-02-07 17:47 rilley 阅读(2461) 评论(2) 推荐(1)