René's URL Explorer Experiment


Title: 第 63 期(数据结构-队列):队列的应用 · Issue #66 · fezaoduke/fe-practice-hard · GitHub

Open Graph Title: 第 63 期(数据结构-队列):队列的应用 · Issue #66 · fezaoduke/fe-practice-hard

X Title: 第 63 期(数据结构-队列):队列的应用 · Issue #66 · fezaoduke/fe-practice-hard

Description: 上一期介绍了 队列和队列的模拟,这一期来看看队列的应用。 这是一道经典的面试题,要求不使用递归广度遍历下面的二叉树: 要求在控制台依次输出遍历结果:1, 2, 3, 4, 5, 6, 7, 8 测试数据: { "value": 1, "left": { "value": 2, "left": { "value": 4 } }, "right": { "value": 3, "left": { "value": 5, "left": { "value": 7 }, "ri...

Open Graph Description: 上一期介绍了 队列和队列的模拟,这一期来看看队列的应用。 这是一道经典的面试题,要求不使用递归广度遍历下面的二叉树: 要求在控制台依次输出遍历结果:1, 2, 3, 4, 5, 6, 7, 8 测试数据: { "value": 1, "left": { "value": 2, "left": { "value": 4 } }, "right": { "value": 3, "left": {...

X Description: 上一期介绍了 队列和队列的模拟,这一期来看看队列的应用。 这是一道经典的面试题,要求不使用递归广度遍历下面的二叉树: 要求在控制台依次输出遍历结果:1, 2, 3, 4, 5, 6, 7, 8 测试数据: { "value": 1, "left": { "value": 2, "left": { "va...

Opengraph URL: https://github.com/fezaoduke/fe-practice-hard/issues/66

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"第 63 期(数据结构-队列):队列的应用","articleBody":"上一期介绍了 [队列和队列的模拟](https://github.com/fezaoduke/fe-practice-hard/issues/65),这一期来看看队列的应用。\r\n\r\n这是一道经典的面试题,要求不使用递归广度遍历下面的二叉树:\r\n\r\n\u003e 要求在控制台依次输出遍历结果:1, 2, 3, 4, 5, 6, 7, 8\r\n\r\n**测试数据:**\r\n```json\r\n{\r\n  \"value\": 1,\r\n  \"left\": {\r\n    \"value\": 2,\r\n    \"left\": {\r\n      \"value\": 4\r\n    }\r\n  },\r\n  \"right\": {\r\n    \"value\": 3,\r\n    \"left\": {\r\n      \"value\": 5,\r\n      \"left\": {\r\n        \"value\": 7\r\n      },\r\n      \"right\": {\r\n        \"value\": 8\r\n      }\r\n    },\r\n    \"right\": {\r\n      \"value\": 6\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n**思路:**\r\n\r\n广度遍历的特点是从根节点开始,沿着树的宽度一层一层进行遍历,直到所有节点都被遍历完为止,我们可以利用队列来实现这个算法。\r\n\r\n核心思路是用一个队列来临时保存节点。遍历开始时先将根节点加入队列,然后从队列中取出第一个元素(此时是根节点),同时将该节点的子节点(如有)加入队列,以此循环操作,直至队列为空。参照下图示意(点击可查看大图):\r\n\r\n![image](https://user-images.githubusercontent.com/9009389/61541463-47da6700-aa72-11e9-834d-7b0b3a2d2a0a.png)\r\n\r\n**上码:**\r\n\r\n```js\r\nfunction levelOrderTraversal(tree) {\r\n  var queue = [];  // 使用数组模拟队列\r\n\r\n  queue.push(tree);  // 根节点入队列\r\n  while (queue.length !== 0) {\r\n    tree = queue.shift();  // 取出队列第一个节点\r\n\r\n    console.log(tree.value);\r\n\r\n    if (tree.left) {\r\n      queue.push(tree.left);  // 左子节点入队列\r\n    }\r\n    if (tree.right) {\r\n      queue.push(tree.right);  // 右子节点入队列\r\n    }\r\n  }\r\n}\r\n```\r\n","author":{"url":"https://github.com/wingmeng","@type":"Person","name":"wingmeng"},"datePublished":"2019-07-19T14:26:24.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/66/fe-practice-hard/issues/66"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:6521503e-e138-bf55-62a4-e2ef8bbb2a3b
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCC3C:6E8AA:39A0D3C:4BB12C0:6992DFDA
html-safe-noncefd2980860e61476a70e0573dd4e5bbb5a6b9bd371564bffbc9cbfd3dde90f73d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQzNDOjZFOEFBOjM5QTBEM0M6NEJCMTJDMDo2OTkyREZEQSIsInZpc2l0b3JfaWQiOiI1NDM4MjkwNDQ4MTE5Njg1MDgyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac2334ea2f0ca95dfd18aca0cde71bcddcf648a96aeab8985b9b3f538ec391900a
hovercard-subject-tagissue:470354412
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/fezaoduke/fe-practice-hard/66/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c2efdced5e196f960f5b6c179ff187a60352cca9700d738b2ba311bab3803eea/fezaoduke/fe-practice-hard/issues/66
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c2efdced5e196f960f5b6c179ff187a60352cca9700d738b2ba311bab3803eea/fezaoduke/fe-practice-hard/issues/66
og:image:alt上一期介绍了 队列和队列的模拟,这一期来看看队列的应用。 这是一道经典的面试题,要求不使用递归广度遍历下面的二叉树: 要求在控制台依次输出遍历结果:1, 2, 3, 4, 5, 6, 7, 8 测试数据: { "value": 1, "left": { "value": 2, "left": { "value": 4 } }, "right": { "value": 3, "left": {...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamewingmeng
hostnamegithub.com
expected-hostnamegithub.com
None42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b
turbo-cache-controlno-preview
go-importgithub.com/fezaoduke/fe-practice-hard git https://github.com/fezaoduke/fe-practice-hard.git
octolytics-dimension-user_id21255532
octolytics-dimension-user_loginfezaoduke
octolytics-dimension-repository_id184997815
octolytics-dimension-repository_nwofezaoduke/fe-practice-hard
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id184997815
octolytics-dimension-repository_network_root_nwofezaoduke/fe-practice-hard
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
release84dcb133269e3cfe6e0296cc85fbacb92cae92bb
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/fezaoduke/fe-practice-hard/issues/66#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ffezaoduke%2Ffe-practice-hard%2Fissues%2F66
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%2Ffezaoduke%2Ffe-practice-hard%2Fissues%2F66
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=fezaoduke%2Ffe-practice-hard
Reloadhttps://github.com/fezaoduke/fe-practice-hard/issues/66
Reloadhttps://github.com/fezaoduke/fe-practice-hard/issues/66
Reloadhttps://github.com/fezaoduke/fe-practice-hard/issues/66
fezaoduke https://github.com/fezaoduke
fe-practice-hardhttps://github.com/fezaoduke/fe-practice-hard
Notifications https://github.com/login?return_to=%2Ffezaoduke%2Ffe-practice-hard
Fork 6 https://github.com/login?return_to=%2Ffezaoduke%2Ffe-practice-hard
Star 69 https://github.com/login?return_to=%2Ffezaoduke%2Ffe-practice-hard
Code https://github.com/fezaoduke/fe-practice-hard
Issues 131 https://github.com/fezaoduke/fe-practice-hard/issues
Pull requests 0 https://github.com/fezaoduke/fe-practice-hard/pulls
Actions https://github.com/fezaoduke/fe-practice-hard/actions
Projects 0 https://github.com/fezaoduke/fe-practice-hard/projects
Security 0 https://github.com/fezaoduke/fe-practice-hard/security
Insights https://github.com/fezaoduke/fe-practice-hard/pulse
Code https://github.com/fezaoduke/fe-practice-hard
Issues https://github.com/fezaoduke/fe-practice-hard/issues
Pull requests https://github.com/fezaoduke/fe-practice-hard/pulls
Actions https://github.com/fezaoduke/fe-practice-hard/actions
Projects https://github.com/fezaoduke/fe-practice-hard/projects
Security https://github.com/fezaoduke/fe-practice-hard/security
Insights https://github.com/fezaoduke/fe-practice-hard/pulse
New issuehttps://github.com/login?return_to=https://github.com/fezaoduke/fe-practice-hard/issues/66
New issuehttps://github.com/login?return_to=https://github.com/fezaoduke/fe-practice-hard/issues/66
第 63 期(数据结构-队列):队列的应用https://github.com/fezaoduke/fe-practice-hard/issues/66#top
https://github.com/wingmeng
https://github.com/wingmeng
wingmenghttps://github.com/wingmeng
on Jul 19, 2019https://github.com/fezaoduke/fe-practice-hard/issues/66#issue-470354412
队列和队列的模拟https://github.com/fezaoduke/fe-practice-hard/issues/65
https://user-images.githubusercontent.com/9009389/61541463-47da6700-aa72-11e9-834d-7b0b3a2d2a0a.png
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.