当前位置:网站首页>Deng Junhui's notes on data structure and algorithm learning - Chapter 9
Deng Junhui's notes on data structure and algorithm learning - Chapter 9
2020-11-09 08:20:00 【osc_0m0d4mbq】
List of articles
day58
Chapter nine The dictionary
9. The dictionary
9.b Hash principle
Hashing- hash
The data comes from a fairly large space , But the actual data to be stored and organized is a very small subset of it , Space efficiency is extremely low
Compress space
The pigeon nest problem , take x From a larger definition domain , Mapping to a smaller range of values , There are ways to reduce conflict ( Design better hash function or increase hash table length M), But it can't be avoided ( How to solve ?)
9.c Hash function
gcd: The greatest common factor is 1
Take the middle bit , It can make the influence of each digit of the original key code closer to each other , Here's the picture , Square operations can be decomposed into addition operations
The more random the hash function is , The more irregular , The better .
key It may not be an integer , You need to convert it to hashcode, Do it again. , Here's the picture
It is necessary to , If you use a simple calculation method , It's easy to have hash conflicts
9.d Conflict
9.d1 Hash resolves conflicts 1
Skip when searching , Insert directly when inserting .
9.d2 Hash resolves conflicts 2
Closed addressing vs Open addressing
The linear heuristics described above , It's too close to each other , There will be a lot of unnecessary conflicts . You can open the space properly
Suppose the size of a cache is 1KB, Only the pointer is stored in the bucket (4 byte ), Well, unless 16 Secondary hash conflict , To make the cache invalid , Need extra I/O.
b+a≥2, yes M The nontrivial factor of , This is related to M Contradict prime numbers .
For some primes ( for example 7,11) The long table , The two-way search chain works , Some primes ( for example 5,13) The effect of the surface length is not good .
9.e bucket / Count sorting
among n Is the number of elements ,[0,M) Is the element range
Where the red line is the integral of the blue line
Linear scan over and over again count[], Scan again count[] obtain accum[], You can sort in linear time .
版权声明
本文为[osc_0m0d4mbq]所创,转载请带上原文链接,感谢
边栏推荐
- Operation 2020.11.7-8
- Web上的分享(Share)API
- For the first time open CSDN, this article is for the past self and what is happening to you
- 商品管理系统——SPU检索功能
- Dark网站的后端为什么选择F#? - darklang
- APP 莫名崩溃,开始以为是 Header 中 name 大小写的锅,最后发现原来是容器的错!
- File queue in Bifrost (1)
- OpenGL ES 框架详细解析(八) —— OpenGL ES 设计指南
- 写时复制集合 —— CopyOnWriteArrayList
- Android 解决setRequestedOrientation之后手机屏幕的旋转不触发onConfigurationChanged方法
猜你喜欢
LTM理解及配置笔记记录
Bifrost 之 文件队列(一)
你有没有想过为什么交易和退款要拆开不同的表
Factory pattern pattern pattern (simple factory, factory method, abstract factory pattern)
The file size uploaded by WordPress import exceeds php.ini Upload defined in_ max_ Filesize value -- & gt; solution.
STS安装
1.操作系统是干什么的?
RabbitMQ快速入门详解
14.Kubenetes简介
Concurrent linked queue: a non blocking unbounded thread safe queue
随机推荐
RabbitMQ脑裂问题解决方案调查
Platform in architecture
Have you ever thought about why the transaction and refund have to be split into different tables
A bunch of code forgot to indent? Shortcut teach you carefree!
Bifrost 之 文件队列(一)
Introduction to nmon
第五章编程
当我们聊数据质量的时候,我们在聊些什么?
How to reduce the resource consumption of istio agent through sidecar custom resource
20201108 programming exercise exercise 3
The file size uploaded by WordPress import exceeds php.ini Upload defined in_ max_ Filesize value -- & gt; solution.
OpenGL ES 框架详细解析(八) —— OpenGL ES 设计指南
梁老师小课堂|谈谈模板方法模式
Commodity management system -- the search function of SPU
Application of cloud gateway equipment on easynts in Xueliang project
Common feature pyramid network FPN and its variants
自然语言处理(NLP)路线图 - kdnuggets
失业日志 11月5日
14. Introduction to kubenetes
14.Kubenetes简介