René's URL Explorer Experiment


Title: 腾讯:简述二分查找算法与时间复杂度,并实现一个二分查找算法 · Issue #83 · sisterAn/JavaScript-Algorithms · GitHub

Open Graph Title: 腾讯:简述二分查找算法与时间复杂度,并实现一个二分查找算法 · Issue #83 · sisterAn/JavaScript-Algorithms

X Title: 腾讯:简述二分查找算法与时间复杂度,并实现一个二分查找算法 · Issue #83 · sisterAn/JavaScript-Algorithms

Description: 二分查找也称折半查找算法,它是一种简单易懂的快速查找算法。例如我随机写0-100之间的一个数字,让你猜我写的是什么?你每猜一次,我就会告诉你猜的大了还是小了,直到猜中为止。 该算法要求待查找的数组已排序,实现步骤如下: 选择数组中的中间数 查找数与中间数对比,比中间数低,则去中间数左边的子数组中寻找;比中间数高,则去中间数右边的子数组中寻找;相等则返回查找成功 重复上一步,知道查找成功或失败 function binarySearch(items, item) { va...

Open Graph Description: 二分查找也称折半查找算法,它是一种简单易懂的快速查找算法。例如我随机写0-100之间的一个数字,让你猜我写的是什么?你每猜一次,我就会告诉你猜的大了还是小了,直到猜中为止。 该算法要求待查找的数组已排序,实现步骤如下: 选择数组中的中间数 查找数与中间数对比,比中间数低,则去中间数左边的子数组中寻找;比中间数高,则去中间数右边的子数组中寻找;相等则返回查找成功 重复上一步,知道查找成功或失败...

X Description: 二分查找也称折半查找算法,它是一种简单易懂的快速查找算法。例如我随机写0-100之间的一个数字,让你猜我写的是什么?你每猜一次,我就会告诉你猜的大了还是小了,直到猜中为止。 该算法要求待查找的数组已排序,实现步骤如下: 选择数组中的中间数 查找数与中间数对比,比中间数低,则去中间数左边的子数组中寻找;比中间数高,则去中间数右边的子数组中寻找;相等则返回查找成功 重复上一步,知道查找成功或失败...

Opengraph URL: https://github.com/sisterAn/JavaScript-Algorithms/issues/83

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"腾讯:简述二分查找算法与时间复杂度,并实现一个二分查找算法","articleBody":"二分查找也称折半查找算法,它是一种简单易懂的快速查找算法。例如我随机写0-100之间的一个数字,让你猜我写的是什么?你每猜一次,我就会告诉你猜的大了还是小了,直到猜中为止。\r\n\r\n该算法要求待查找的数组已排序,实现步骤如下:\r\n\r\n- 选择数组中的中间数\r\n- 查找数与中间数对比,比中间数低,则去中间数左边的子数组中寻找;比中间数高,则去中间数右边的子数组中寻找;相等则返回查找成功\r\n- 重复上一步,知道查找成功或失败\r\n\r\n```js\r\nfunction binarySearch(items, item) {\r\n    var low = 0,\r\n        high = items.length - 1,\r\n        mid, elem\r\n    while(low \u003c= high) {\r\n        mid = Math.floor((low+high)/2)\r\n        elem = items[mid]\r\n        if(elem \u003c item) {\r\n            low = mid + 1\r\n        } else if(elem \u003e item) {\r\n            high = mid - 1\r\n        } else {\r\n            return mid\r\n        }\r\n    }\r\n    return -1\r\n}\r\n\r\n// 测试\r\nvar arr = [2,3,1,4]\r\n// 快排\r\nquickSort(arr)\r\n\r\nbinarySearch(arr, 3)\r\n// 2\r\n\r\nbinarySearch(arr, 5)\r\n// -1\r\n```\r\n\r\n测试成功\r\n\r\n**二分查找易错点:**\r\n\r\n- 循环退出条件是`low \u003c= high` ,注意是 `\u003c=`\r\n- `mid` 的取值是 `Math.floor((low+high)/2)` \r\n- `low` `high` 每次更新的时候,`low = mid + 1` `high = mid - 1`\r\n\r\n**二分查找局限性:**\r\n\r\n- 针对的对象是数组结构,因为是通过下标来随机访问元素\r\n- 数组必须有序\r\n- 数组太小不合适,直接使用顺序查找即可\r\n- 数组太长不合适,数组要求连续的内存空间,数组太长不利于存储\r\n\r\n**时间复杂度: O(logn)** \r\n\r\n**空间复杂度:O(1)**\r\n\r\n[leetcode](https://leetcode-cn.com/problems/binary-search/solution/er-fen-cha-zhao-by-user7746o/)","author":{"url":"https://github.com/sisterAn","@type":"Person","name":"sisterAn"},"datePublished":"2020-07-15T13:33:28.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/83/JavaScript-Algorithms/issues/83"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:d8070a58-5673-c772-22d4-18f4888563f2
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAEE6:C2480:20D1A0F:2D38D11:696ABBC8
html-safe-nonce69ba46bee5f7697eab8920edf81e7357534b9aaf95435df351f68facdea154e5
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRUU2OkMyNDgwOjIwRDFBMEY6MkQzOEQxMTo2OTZBQkJDOCIsInZpc2l0b3JfaWQiOiIzNDk2MDUzMjAyNjA5NjgzNDAwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac963451c96ef36ead8194a29bcc795dff46f06bb5588f7ef8f597c8cf364198d5
hovercard-subject-tagissue:657354321
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/sisterAn/JavaScript-Algorithms/83/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7de463aafea8b8dbc038729b982a7c764810409f573f2174c81de75144b8b113/sisterAn/JavaScript-Algorithms/issues/83
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7de463aafea8b8dbc038729b982a7c764810409f573f2174c81de75144b8b113/sisterAn/JavaScript-Algorithms/issues/83
og:image:alt二分查找也称折半查找算法,它是一种简单易懂的快速查找算法。例如我随机写0-100之间的一个数字,让你猜我写的是什么?你每猜一次,我就会告诉你猜的大了还是小了,直到猜中为止。 该算法要求待查找的数组已排序,实现步骤如下: 选择数组中的中间数 查找数与中间数对比,比中间数低,则去中间数左边的子数组中寻找;比中间数高,则去中间数右边的子数组中寻找;相等则返回查找成功 重复上一步,知道查找成功或失败...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesisterAn
hostnamegithub.com
expected-hostnamegithub.com
None46ce962e0e18113ea447391b6ace8b02d4d2861e57b4fbab3658698f73d8855b
turbo-cache-controlno-preview
go-importgithub.com/sisterAn/JavaScript-Algorithms git https://github.com/sisterAn/JavaScript-Algorithms.git
octolytics-dimension-user_id19721451
octolytics-dimension-user_loginsisterAn
octolytics-dimension-repository_id252061924
octolytics-dimension-repository_nwosisterAn/JavaScript-Algorithms
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id252061924
octolytics-dimension-repository_network_root_nwosisterAn/JavaScript-Algorithms
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release30300f30bb3949de255e84a146706a3bdb5c19c9
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/sisterAn/JavaScript-Algorithms/issues/83#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FsisterAn%2FJavaScript-Algorithms%2Fissues%2F83
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FsisterAn%2FJavaScript-Algorithms%2Fissues%2F83
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=sisterAn%2FJavaScript-Algorithms
Reloadhttps://github.com/sisterAn/JavaScript-Algorithms/issues/83
Reloadhttps://github.com/sisterAn/JavaScript-Algorithms/issues/83
Reloadhttps://github.com/sisterAn/JavaScript-Algorithms/issues/83
sisterAn https://github.com/sisterAn
JavaScript-Algorithmshttps://github.com/sisterAn/JavaScript-Algorithms
Notifications https://github.com/login?return_to=%2FsisterAn%2FJavaScript-Algorithms
Fork 649 https://github.com/login?return_to=%2FsisterAn%2FJavaScript-Algorithms
Star 5.7k https://github.com/login?return_to=%2FsisterAn%2FJavaScript-Algorithms
Code https://github.com/sisterAn/JavaScript-Algorithms
Issues 158 https://github.com/sisterAn/JavaScript-Algorithms/issues
Pull requests 0 https://github.com/sisterAn/JavaScript-Algorithms/pulls
Actions https://github.com/sisterAn/JavaScript-Algorithms/actions
Projects 0 https://github.com/sisterAn/JavaScript-Algorithms/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/sisterAn/JavaScript-Algorithms/security
Please reload this pagehttps://github.com/sisterAn/JavaScript-Algorithms/issues/83
Insights https://github.com/sisterAn/JavaScript-Algorithms/pulse
Code https://github.com/sisterAn/JavaScript-Algorithms
Issues https://github.com/sisterAn/JavaScript-Algorithms/issues
Pull requests https://github.com/sisterAn/JavaScript-Algorithms/pulls
Actions https://github.com/sisterAn/JavaScript-Algorithms/actions
Projects https://github.com/sisterAn/JavaScript-Algorithms/projects
Security https://github.com/sisterAn/JavaScript-Algorithms/security
Insights https://github.com/sisterAn/JavaScript-Algorithms/pulse
New issuehttps://github.com/login?return_to=https://github.com/sisterAn/JavaScript-Algorithms/issues/83
New issuehttps://github.com/login?return_to=https://github.com/sisterAn/JavaScript-Algorithms/issues/83
腾讯:简述二分查找算法与时间复杂度,并实现一个二分查找算法https://github.com/sisterAn/JavaScript-Algorithms/issues/83#top
LeetCodehttps://github.com/sisterAn/JavaScript-Algorithms/issues?q=state%3Aopen%20label%3A%22LeetCode%22
腾讯https://github.com/sisterAn/JavaScript-Algorithms/issues?q=state%3Aopen%20label%3A%22%E8%85%BE%E8%AE%AF%22
阿里https://github.com/sisterAn/JavaScript-Algorithms/issues?q=state%3Aopen%20label%3A%22%E9%98%BF%E9%87%8C%22
https://github.com/sisterAn
https://github.com/sisterAn
sisterAnhttps://github.com/sisterAn
on Jul 15, 2020https://github.com/sisterAn/JavaScript-Algorithms/issues/83#issue-657354321
leetcodehttps://leetcode-cn.com/problems/binary-search/solution/er-fen-cha-zhao-by-user7746o/
LeetCodehttps://github.com/sisterAn/JavaScript-Algorithms/issues?q=state%3Aopen%20label%3A%22LeetCode%22
腾讯https://github.com/sisterAn/JavaScript-Algorithms/issues?q=state%3Aopen%20label%3A%22%E8%85%BE%E8%AE%AF%22
阿里https://github.com/sisterAn/JavaScript-Algorithms/issues?q=state%3Aopen%20label%3A%22%E9%98%BF%E9%87%8C%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.