matlab 字典最快查找算法_二分查找 事半功倍

本文介绍了二分查找算法,通过字典查找的例子揭示其原理。二分查找通过比较目标值与数组中间元素,在有序数组中高效定位目标。文章对比了二分查找与顺序遍历、哈希表的区别,并提供了实现二分查找的思路和代码示例,强调了算法在解决问题中的重要性。
摘要由CSDN通过智能技术生成

前言:

“Simplicity is the soul of efficiency.”

简洁是效率的灵魂。

-- Enda Kenny, Taoiseach

You clicked on the third article written by ADOSCIE.

你激动的点开了ADOSCIE的第三篇文章。

But you realized that you aren’t familiar with the term “binary”.

 可是你发现你对“二分”这个概念不太熟悉。

Since you have WeChat opened, 

you decided to check the dictionary.

由于你的手机开着微信,你决定查一下被遗忘在角落的字典。

But then you discovered that, the only way to find the word “binary” is to repeat the process of guess and check.

 字典在你面前,可是你突然发现你不是能背字典的大佬,你只能慢慢去翻来找到字典里“二分”在什么位置。 

So you flipped to a page in the middle, then flipped to the middle of the left region or the right region depending on whether you passed the word alphabetically.

你慢慢的翻开中间的一页,决定通过看自己是翻过了还是翻少了来决定下次翻的是前面的中间还是后面的中间。

When you found the word “binary”,  you realised that you already know something about binary search.

 当你找到“二分”的时候,你对二分搜索已经有了一定的了解。

1. 二分查找的定义

Wiki: “Binary search is a search algorithm that finds the position of a target value within a sorted array.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值