当前位置:网站首页>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;
}
边栏推荐
猜你喜欢

U.S. Air Force Research Laboratory, "exploring the vulnerability and robustness of deep learning systems", the latest 85 page technical report in 2022

图形化工具打包YOLOv5,生成可执行文件EXE

Code quality management

枚举通用接口&枚举使用规范

Can the applet run in its own app and realize live broadcast and connection?

Don't you know the relationship between JSP and servlet?

编译常量、ClassLoader类、系统类加载器深度探析

「小样本深度学习图像识别」最新2022综述

亚像素级角点检测Opencv-cornerSubPix

体会设计细节
随机推荐
腾讯云原生数据库TDSQL-C入选信通院《云原生产品目录》
Jerry's ble exiting Bluetooth mode card machine [chapter]
About Confidence Intervals
RestClould ETL 社区版六月精选问答
“去虚向实”大潮下,百度智能云向实而生
Open3D 网格滤波
ubuntu20安裝redisjson記錄
Matlab Error (Matrix dimensions must agree)
Don't you know the relationship between JSP and servlet?
华为小米互“抄作业”
20.(arcgis api for js篇)arcgis api for js面采集(SketchViewModel)
The version control of 2021 version is missing. Handling method
Jerry's RTC clock development [chapter]
【安全的办公和生产力应用程序】上海道宁为您提供ONLYOFFICE下载、试用、教程
SQL Tuning Advisor一个错误ORA-00600: internal error code, arguments: [kesqsMakeBindValue:obj]
Enumeration general interface & enumeration usage specification
Cryptography series: detailed explanation of online certificate status protocol OCSP
Set WiFi automatic connection for raspberry pie
Cocos2d-x box2d physical engine compilation settings
[colmap] 3D reconstruction with known camera pose
