当前位置:网站首页>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;
}
边栏推荐
- [untitled]
- 25.(arcgis api for js篇)arcgis api for js线修改线编辑(SketchViewModel)
- 腾讯云原生数据库TDSQL-C入选信通院《云原生产品目录》
- HDU ACM 4578 Transformation-&gt; Segment tree - interval change
- Lost in the lock world of MySQL
- Codeforces Round #264 (Div. 2) C Gargari and Bishops 【暴力】
- VHDL实现单周期CPU设计
- Basic concepts of Huffman tree
- Jerry's FM mode mono or stereo selection setting [chapter]
- 编译常量、ClassLoader类、系统类加载器深度探析
猜你喜欢

24.(arcgis api for js篇)arcgis api for js点修改点编辑(SketchViewModel)

Flink Task退出流程与Failover机制

About Confidence Intervals

Huawei and Xiaomi "copy each other"

24. (ArcGIS API for JS) ArcGIS API for JS point modification point editing (sketchviewmodel)

Leetcode-02 (linked list question)

2022.6.28

如何自定义Latex停止运行的快捷键

Experience design details

存储过程与函数(MySQL)
随机推荐
Jerry's FM mode mono or stereo selection setting [chapter]
Do you know the five most prominent advantages of E-bidding?
Cocos2d-x Box2D物理引擎编译设置
Cryptography series: detailed explanation of online certificate status protocol OCSP
Ubuntu 20 installation des enregistrements redisjson
[untitled]
netperf 而网络性能测量
Set static IP for raspberry pie
Stored procedures and functions (MySQL)
qt-线程等01概念
Jerry's broadcast has built-in flash prompt tone to control playback pause [chapter]
Numpy中排序操作partition,argpartition,sort,argsort
Depth analysis of compilation constants, classloader classes, and system class loaders
Don't you know the relationship between JSP and servlet?
The solution of unable to create servlet file after idea restart
【达梦数据库】添加自动收集统计信息的任务
体会设计细节
应用程序启动速度的优化
Restcloud ETL Community Edition June featured Q & A
CMB's written test - quantitative relationship
