数据结构全部复习

Linear Structure

    Array: the length cannot changed

    ArrayList:

            当到达max length时候需要进行resize:1.5x new ArrayList & copy the old one

            Add Last: Armortized O(1)

            Add First: O(n)

            Remove First: O(n)

            Remove Last: O(1)

 

    ArrayDeque:

            当到达max的时候resize是2x原来的length

            Add Last: O(1)

            Add First: O(1)

            Remove First: O(1)

            Remove Last: O(1)

 

    LinkedList

            Dynamic data structure

            Add First O(1)

            Add Last O(1)

            Access(随机访问) O(n)

            Set O(n)

            Space也是其中一个缺点

    Deque

        Deque<Integer> stack = new ArrayDeque<>();

        Deque<Integer> queue = new ArrayDeque<>();

 

Hash

    build index

HashCode

    Many to One (多对一的情况) 完美情况 一对一

    设计原则: 1. same code repeating called same application

                    2. equal => Same hash code

                    3. Same hash code != Equals, but good to have

HashTable

    Use hashcode to find the index of array

    Collision:

        Linear Probing & Seperate Chain

    Rehashing after 2/3 size of HashTable

 

HashMap

    Hard to traver the hashmap

    Seperate Chain HahTable implementation

    在Java8中,List特别长的时候就会变成Tree

 

LinkedHashMap

    LinkedList+HashMap

    维护当前的HashMap顺序 

 

HashSet

    Wrapper class of the HashMap.

    Value is a constant dummy object

 

TreeMap

    永远是一个平衡树

    Red-Black Tree Implementation

    O(logn): put, containsKey, remove

    Iteration in Order, sorted key

Heap

    Complete Tree

    Largest/Smallest in the root

    Children always small or higher than root

    Java没有Heap这个概念但是有一个数据结构PriorityQueue

 

转载于:https://my.oschina.net/u/3457852/blog/1546940

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值