随笔分类 -  数据结构与算法

摘要:package c; class ListNode { int val; ListNode next; ListNode(int x) { val = x; } // 链表结点的构造函数 // 使用arr为参数, 创建一个链表, 当前的ListNode为链表头结点 ListNode(int [] arr) { if(arr == null || arr.le... 阅读全文
posted @ 2019-05-22 13:05 青衫客36 阅读(346) 评论(0) 推荐(0)
摘要:import java.util.ArrayList; public class AVLTree, V> { private class Node{ public K key; public V value; public Node left, right; public int height; pub... 阅读全文
posted @ 2019-05-21 20:29 青衫客36 阅读(127) 评论(0) 推荐(0)
摘要:import java.util.TreeMap; public class Trie { private class Node { public boolean isWord; public TreeMap next; public Node(boolean isWord) { this.isWord = isWord; next = new Tree... 阅读全文
posted @ 2019-05-17 20:31 青衫客36 阅读(165) 评论(0) 推荐(0)
摘要:public class SegmentTree { private E[] tree; private E[] data; private Merger merger; public SegmentTree(E[] arr, Merger merger) { this.merger = merger; data = (E[]) new Object[arr.... 阅读全文
posted @ 2019-05-17 18:01 青衫客36 阅读(109) 评论(0) 推荐(0)
摘要:// Binary Heap #include #include #include #include #include #include #include using namespace std; template class MaxHeap { private : Item * data; int count; int capacity; void ... 阅读全文
posted @ 2019-03-25 20:32 青衫客36 阅读(174) 评论(0) 推荐(0)
摘要:#include #include #include #include #include using namespace std; template class BST { public : BST() { root = NULL; count = 0; } ~BST() { // TODO : ~BST() destroy(root... 阅读全文
posted @ 2019-03-25 19:20 青衫客36 阅读(118) 评论(0) 推荐(0)
摘要:#include #include using namespace std; // 非递归 template int binarySearch(T arr[], int n, T target) { int l = 0, r = n - 1; while(l int _binarySearch2(T arr[], int l, int r, T target) { if(l >... 阅读全文
posted @ 2019-03-25 16:16 青衫客36 阅读(102) 评论(0) 推荐(0)