![](https://img-blog.csdnimg.cn/20190927151043371.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
Dive Deep in Data Structures
文章平均质量分 50
some deep thoughts and summary of commonly used data strutures.
Tech In Pieces
这个作者很懒,什么都没留下…
展开
-
String: new和直接创建的区别
String s = “abc”;String s = new String(“abc”);第一种,交String literal.像其他primitive 一样,这个东西会被储存在公共常量池里面。之所以叫公共,是因为如果其他String也被这样创建,并且值一样,那么两者就会指向常量值中的同一值(也是同一地址)。第二种,叫String object.这种对象会被保存在堆中。每个字符串对象都有自己的储存(有地址 而且不同)。但是String值之间的比较 最好只用equals().因为equal.原创 2021-08-26 04:12:46 · 836 阅读 · 0 评论 -
Bloom Filter(布隆过滤器)
some thoughts原创 2020-10-24 00:27:47 · 136 阅读 · 0 评论 -
[Dive in Data Structure] Trie
What is Trie?It has another name: prefix tree, which is commonly used for search if a given word is on the words sets in O(logn), makes it much better than common search which at least took O(n).The best way to understand how it works is by implement it.原创 2021-06-21 04:48:49 · 45 阅读 · 0 评论 -
数组和链表到底有什么区别?What is the difference between linkedlist and arraylist?
different implementationarraylist uses dynamic array and linkedlist uses doubly linkedlistdifferent storage ways:arraylist stores its elements in memory consecutively, but linkedlist don’t have to because of the pointers.different interface it implem.原创 2020-10-28 07:28:02 · 176 阅读 · 0 评论 -
[Dive in Data Structure] TreeMap and TreeSet
What is TreeMap?TreeMap extends AbstractMap and implement NavigableMaptreeMap is a k-v pair set with order based on red-black tree’s navigableMap to implement. we can custom of sort principle or just use the default with based on the key.Red-Black Tree原创 2021-06-19 04:44:00 · 165 阅读 · 0 评论 -
[Dive in Data Structure] Queue/Priority Queue/Heap
Those are few commonly used and powerful data structures, so in here we are not gonna rephrase the defination of them again. This article will focus on the difference and relationship between them.The Difference between Queue and Priority Queue:They are原创 2021-06-19 04:32:34 · 173 阅读 · 0 评论 -
与查找有关的数据结构
哈希表跳跃表排序二叉树AVL 树B 树 / B+ 树 / B* 树AA 树红黑树排序二叉堆Splay 树双链树Trie 树R 树原创 2021-01-02 06:14:50 · 112 阅读 · 0 评论 -
数据结构--树的分类(以结构树的方式)
原创 2020-12-13 00:57:34 · 496 阅读 · 0 评论 -
TreeMap和TreeSet的构造器以及常用方法
简而言之 treemap就是按照key排序的hashmap.所以treeset就是按照key排序的hashsetTreeMap<Integer, Integer> treemap = new TreeMap<>();TreeSet< Integer > treeset = new TreeSet<>()TreeMap的常用方法:增:1. put( Key,Value ) 2. Clone( )克隆; 3 putAll(Map map) //就像has原创 2020-12-10 09:59:25 · 384 阅读 · 0 评论 -
Java 容器和对象有什么区别?
从字面上理解的话 容器就是装对象的东西 就像是那些数据结构:链表 列表 hashmap, hashset等等 这些里面只能承装对象。但是数组算是什么呢?它像一个容器 但是里面却承装了原始类型的数据 不是对象。还有一个问题:容器算不算也是对象呢?下面逐个解决:我们要明白 Java创建之初 是不完美的 而且当初的设计者是想让我们有一个能够便捷访问的数据结构–直接通过[i]这样非常直观的方式来访问。所以这才有了数组。而容器 其实就是Collection,他是用来存方其他类的对象的一个container。原创 2020-12-10 01:08:57 · 796 阅读 · 0 评论 -
Java容器型数据结构常用的获得放入删除方法汇总
最近被add()和put()都该用在哪里搞得很烦躁,现在就来总结一下boolean add(Object obj):向容器中添加指定的元素Iterator iterator():返回能够遍历当前集合中所有元素的迭代器Object[] toArray():返回包含此容器中所有元素的数组。Object get(int index):获取下标为index的那个元素Object remove(int index):删除下标为index的那个元素Object set(int index,Object el原创 2020-12-10 00:58:52 · 171 阅读 · 0 评论 -
什么是Union Find(并查集)?
并查集是一种属性数据结构 用于处理一些不交集disjoint sets的合并以及查询问题。但是光这么说也太他妈抽象了。不如看两个应用场景:网络连接判断:如果每个pair中的两个整数分别代表一个网络节点,那么该pair就是用来表示这两个节点是需要连通的。那么为所有的pairs建立了动态连通图后,就能够尽可能少的减少布线的需要,因为已经连通的两个节点会被直接忽略掉。变量名等同性(类似于指针的概念):在程序中,可以声明多个引用来指向同一对象,这个时候就可以通过为程序中声明的引用和实际对象建立动态连通原创 2020-12-06 08:08:45 · 225 阅读 · 0 评论 -
Java自动装箱和自动拆箱(int, Integer的使用注意事项)
自动装箱:int->Integer自动拆箱:Integer -> int自动装箱和拆箱是根据什么原理实现的?自动装箱时编译器调用valueOf将原始类型值转换成对象,自动拆箱时,编译器通过调用类似intValue(),doubleValue()这类的方法将对象转换成原始类型值。这种方式在Java中很常见 比如说当我们要把一个只接受对象的Collection类型的容器内填满我们所需要的元素的时候。我们需要格外注意int和Integer之间转换的处理吗?(也就是说 需要我们自己处理吗?原创 2020-12-05 13:12:05 · 354 阅读 · 1 评论 -
Java 打印常用数据结构(完全版本)
我们为啥要打印这些?主要是debug的时候用。 而且打印和遍历还不完全一样 打印是不管怎么样 输出值就行了 遍历则是按顺序一个一个取元素使用。有哪些常用的数据结构?无非是各种字符 字符串 Array, List, HashMap, HashSet等等抛开数据结构不谈,有哪些常常被用来打印的方法?System.out.println() //可以直接打印Arrays.toString()/.toString() //转化成String再打印出来常用的数据结构的常用的打印方法?Array: Ar原创 2020-12-05 03:31:24 · 918 阅读 · 0 评论 -
Union Find代码块
如果我们要利用Index比如说我们想把uf[]数组变成下面这样:{0, 0, 2, 3, 2, 0} 这个意味着node0, node1, node5属于同一个图 node2 node 4 属于另一个图 node3属于单独一个图//首先 对uf进行初始化 每个的parent都设为自己for (int i = 0; i < uf.length; i++) { uf[i] = i; }//然后我们把题目给的输入转换成一个一个图(就是union起来)加黑色输原创 2020-12-03 02:39:47 · 333 阅读 · 0 评论 -
PriorityQueue(优先队列)和Heap(堆)到底有什么区别?
首先来看名字:优先队列:说到底还是一种队列 不过是一种特殊的队列他的工作就是poll()/peek()出队列中最大/最小的那个元素堆:首先我们要明确:堆是一个很大的概念 他并不一定是完全二叉树 我们之前用完全二叉树是因为这个很容易被数组储存(index: index * 2是右子节点 index*2+1是左子节点)正因为这样 所以大部分时间我们用完全二叉树(数组)来储存堆,但是除了这种二叉堆之外 我们还有二项堆 斐波那契堆 这种堆就不属于二叉树优先对列和堆有什么区别呢?这里面说的堆默认我们最常原创 2020-12-03 01:59:21 · 8992 阅读 · 2 评论 -
Queue and PriorityQueue
even though those two things are pretty similar by the names, they are implement is totally differentqueue can be implemented using array/arrayList or doublely Linked List. (and it can also be implement by stack…although stack is also based on array or li原创 2020-05-17 13:51:49 · 142 阅读 · 0 评论 -
Trie, Segment Tree,树状数组-----Other Kinds of Tree
some thoughts原创 2020-05-02 04:46:22 · 184 阅读 · 0 评论 -
TreeMap and TreeSet (English Version)
what is TreeMap:TreeMap extends AbstractMap and implement NavigableMaptreeMap is a k-v pair set with order, it’s based on red-black tree’s navigableMap to implement. we can custom of sort principle...原创 2020-04-29 04:59:38 · 78 阅读 · 0 评论 -
Union Find---Some Thoughts
some thoughts原创 2020-04-27 04:06:29 · 151 阅读 · 0 评论 -
Segment Tree and Binary Index Tree
http://pages.cs.wisc.edu/~dieter/ICPC/18-19/advanced-topics/seg-tree-bin-indexed-tree.htmlthese two data structures are used in LC307/308 which is range sum query 1D and 2D problem. segment tree can ...原创 2020-04-26 23:13:04 · 152 阅读 · 0 评论 -
SkipList---Some Thoughts
some thoughts原创 2020-04-26 12:50:09 · 166 阅读 · 0 评论 -
Tree Classification
//slim treebinary tree:heap: all leap have to be as left as possible, like complete treebst: just remeber that every node in left subtree < current node < every node in right subtreeavl: th...原创 2020-04-24 20:03:41 · 207 阅读 · 0 评论