随笔分类 - Data Structure & Algorithm
摘要:public class BST<E extends Comparable<E>>{ private class Node{ public E e; public Node left, right; public Node(E e){ this.e = e; this.left = null; th
阅读全文
摘要:一、树结构本身是一种天然的组织结构 将数据使用树结构后,出奇的高效。 二、二叉树 和链表一样,动态数据结构 class Node{ E e; Node left; Node right; } 二叉树(多叉树) 二叉树具有唯一根节点 class Node{ E e; Node left; <-- 左孩
阅读全文
摘要:递归 本质上,将原来的问题,转化为更小的同一问题 举例:数组求和 1 /* 2 3 Sum(arr[0...n-1]) = arr[0] + Sum(arr[1...n-1]) <-- 更小的同一问题 4 Sum(arr[1...n-1]) = arr[1] + Sum(arr[2...n-1])
阅读全文
摘要:interface Queue01<E> 1 interface Queue01<E>{ 2 3 int getSize(); 4 boolean isEmpty(); 5 void enqueue(E e); 6 E dequeue(); 7 E getFront(); 8 } class Arr
阅读全文
摘要:Array.java 1 public class Array<E> { 2 3 private E[] data; 4 private int size; 5 6 // 构造函数,传入数组的容量capacity构造Array 7 public Array(int capacity){ 8 data
阅读全文
摘要:1 public class Array01{ 2 3 private int[] data; 4 private int size; // 记录数组中实际存在的元素个数 5 6 // 构造函数,传入数组的容量capacity构造Array01 7 public Array01(int capaci
阅读全文
摘要:1 public class SparseArray{ 2 public static void main(String[] args) { 3 // 一、二维数组 --> 稀疏数组 4 // 1.创建一个二维数组 size:11 * 11 5 // 0 表示棋盘 1 表示黑子 2 表示蓝子 6 7
阅读全文