当前位置:网站首页>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;
}
边栏推荐
- About Tolerance Intervals
- Make (convert) ICO Icon
- The version control of 2021 version is missing. Handling method
- 【无标题】
- Jerry's broadcast has built-in flash prompt tone to control playback pause [chapter]
- Leetcode-02 (linked list question)
- Shell programming basics
- 【基于 RT-Thread Studio的CPK-RA6M4 开发板环境搭建】
- 1200.Minimum Absolute Difference
- 20.(arcgis api for js篇)arcgis api for js面采集(SketchViewModel)
猜你喜欢
Restcloud ETL Community Edition June featured Q & A
Basic concepts of Huffman tree
Appx code signing Guide
input_delay
Not All Points Are Equal Learning Highly Efficient Point-based Detectors for 3D LiDAR Point
R数据分析:cox模型如何做预测,高分文章复现
【基于 RT-Thread Studio的CPK-RA6M4 开发板环境搭建】
Don't you know the relationship between JSP and servlet?
Not All Points Are Equal Learning Highly Efficient Point-based Detectors for 3D LiDAR Point
「小样本深度学习图像识别」最新2022综述
随机推荐
Enumeration general interface & enumeration usage specification
华为小米互“抄作业”
【达梦数据库】备份恢复后要执行两个sql语句
Cocos2d-x box2d physical engine compilation settings
HDU ACM 4578 Transformation-&gt;段树-间隔的变化
20. (ArcGIS API for JS) ArcGIS API for JS surface collection (sketchviewmodel)
Principle of attention mechanism
体会设计细节
[swift] learning notes (I) -- familiar with basic data types, coding styles, tuples, propositions
Variables, process control and cursors (MySQL)
Cocos2d-x Box2D物理引擎编译设置
Mathematical induction and recursion
Create applet from 0
input_delay
Domcontentloaded and window onload
密码学系列之:在线证书状态协议OCSP详解
The version control of 2021 version is missing. Handling method
[C language] question set of IX
Matlab Error (Matrix dimensions must agree)
Centerx: open centernet in the way of socialism with Chinese characteristics