当前位置:网站首页>Search of linear table
Search of linear table
2022-07-07 03:26:00 【ScarboroughFair#】
Catalog
1. Sequential table lookup algorithm
Implementation of sequential search
( Take a sentry ) Sequential search time efficiency analysis
2. Two points search ( See the column for details :Acwing Basic courses )
The implementation of binary search
Performance analysis of binary search —— Decision tree
Implementation of block search
Block search performance analysis
4. The interpolation to find ( understand )
1. Sequential table lookup algorithm
Implementation of sequential search
improvement : Application &,for Add a semicolon after the loop
improvement : Put the key words to be checked key Save to header ( sentry ), Compare one by one from the back to the front , It can eliminate the need to check whether the search is completed at every step of the search process , Speed up
When ST.length large , This improvement can reduce the average time required for a search by almost half
( Take a sentry ) Sequential search time efficiency analysis
Features of sequential search
2. Two points search ( See the column for details :Acwing Basic courses )
The implementation of binary search
Normal half search
Recursive algorithm for binary search
Performance analysis of binary search —— Decision tree
Time complexity O(logn)
Binary search features
The reason why the linear linked list is invalid is that it cannot be found mid
3. Search in blocks
Implementation of block search
Conditions :1. Divide the watch into several pieces , And the table or order , Or block by block ; if i<j, Is the first j The keywords of all records in the block are greater than the first i The largest keyword in the block
2. establish “ Index table ”( Each node contains the largest keyword and a pointer to the first node of this block , And ordered by keywords )
Block search performance analysis
Block search feature
4. The interpolation to find ( understand )
5. Fibonacci looks for
int Fibonacci_Search(int* a, int n, int key)
{
int low, high, mid, i, k;
low = 1; // Define the lowest subscript as the record first
high = n; // Define the highest subscript as the record end
k = 0;
while (n > F[k] - 1) // Calculation n The position of the Fibonacci series
k++;
for (i = n; i < F[k] - 1; i++) // Fill in the dissatisfied figures
a[i] = a[n];
while (low <= high)
{
mid = low + F[k - 1] - 1; // Calculate the subscript of the current partition
if (key < a[mid]) // If the search record is smaller than the current delimited record
{
high = mid - 1; // Adjust the highest subscript to the split subscript mid-1 It's about
k = k - 1; // The Fibonacci sequence is reduced by one place
}
else if (key > a[mid]) // If the search record is larger than the current delimited record
{
low = mid + 1; // Adjust the lowest subscript to the separated subscript mid+1 It's about
k = k - 2; // Fibonacci sequence subscript minus two digits
}
else
{
if (mid <= n)
return mid; // If it is equal, it means mid That's where we found it
else
return n; // if mid>n, The description is to complete the value , return n
}
}
return 0;
}
边栏推荐
- cocos3——8. Implementation Guide for beginners
- 腾讯云原生数据库TDSQL-C入选信通院《云原生产品目录》
- [tools] basic concept of database and MySQL installation
- Intelligent static presence detection scheme, 5.8G radar sensing technology, human presence inductive radar application
- Opencv environment, and open a local PC camera.
- 装饰设计企业网站管理系统源码(含手机版源码)
- Centerx: open centernet in the way of socialism with Chinese characteristics
- 美国空军研究实验室《探索深度学习系统的脆弱性和稳健性》2022年最新85页技术报告
- 源代码保密的意义和措施
- Jerry's question about DAC output power [chapter]
猜你喜欢
华为小米互“抄作业”
Do you know the five most prominent advantages of E-bidding?
Centerx: open centernet in the way of socialism with Chinese characteristics
The solution of unable to create servlet file after idea restart
input_delay
1200.Minimum Absolute Difference
1200.Minimum Absolute Difference
Don't you know the relationship between JSP and servlet?
2022.6.28
Depth analysis of compilation constants, classloader classes, and system class loaders
随机推荐
Principle of attention mechanism
Make (convert) ICO Icon
Create applet from 0
Not All Points Are Equal Learning Highly Efficient Point-based Detectors for 3D LiDAR Point
[Dameng database] after backup and recovery, two SQL statements should be executed
2022 information security engineer examination outline
Development of wireless communication technology, cv5200 long-distance WiFi module, UAV WiFi image transmission application
【达梦数据库】添加自动收集统计信息的任务
密码学系列之:在线证书状态协议OCSP详解
What about SSL certificate errors? Solutions to common SSL certificate errors in browsers
Can the applet run in its own app and realize live broadcast and connection?
Flink task exit process and failover mechanism
Set static IP for raspberry pie
19.(arcgis api for js篇)arcgis api for js线采集(SketchViewModel)
Function reentry, function overloading and function rewriting are understood by yourself
Decoration design enterprise website management system source code (including mobile source code)
Huawei and Xiaomi "copy each other"
哈夫曼树基本概念
HDU ACM 4578 Transformation-&gt; Segment tree - interval change
Stored procedures and functions (MySQL)