mirror of
https://github.com/mfocko/blog.git
synced 2024-11-14 01:59:42 +01:00
1 line
24 KiB
JavaScript
1 line
24 KiB
JavaScript
|
"use strict";(self.webpackChunkfi=self.webpackChunkfi||[]).push([[3713],{38961:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>h,contentTitle:()=>r,default:()=>c,frontMatter:()=>i,metadata:()=>o,toc:()=>l});var n=s(85893),a=s(11151);const i={id:"dijkstra",slug:"/paths/bf-to-astar/dijkstra",title:"Dijkstra's algorithm",description:"Moving from Bellman-Ford into the Dijsktra's algorithm.\n",tags:["cpp","dynamic programming","greedy","dijkstra"],last_update:{date:new Date("2024-01-03T00:00:00.000Z")}},r=void 0,o={id:"paths/2024-01-01-bf-to-astar/dijkstra",title:"Dijkstra's algorithm",description:"Moving from Bellman-Ford into the Dijsktra's algorithm.\n",source:"@site/algorithms/11-paths/2024-01-01-bf-to-astar/02-dijkstra.md",sourceDirName:"11-paths/2024-01-01-bf-to-astar",slug:"/paths/bf-to-astar/dijkstra",permalink:"/algorithms/paths/bf-to-astar/dijkstra",draft:!1,unlisted:!1,editUrl:"https://github.com/mfocko/blog/tree/main/algorithms/11-paths/2024-01-01-bf-to-astar/02-dijkstra.md",tags:[{label:"cpp",permalink:"/algorithms/tags/cpp"},{label:"dynamic programming",permalink:"/algorithms/tags/dynamic-programming"},{label:"greedy",permalink:"/algorithms/tags/greedy"},{label:"dijkstra",permalink:"/algorithms/tags/dijkstra"}],version:"current",lastUpdatedAt:170424e4,formattedLastUpdatedAt:"Jan 3, 2024",sidebarPosition:2,frontMatter:{id:"dijkstra",slug:"/paths/bf-to-astar/dijkstra",title:"Dijkstra's algorithm",description:"Moving from Bellman-Ford into the Dijsktra's algorithm.\n",tags:["cpp","dynamic programming","greedy","dijkstra"],last_update:{date:"2024-01-03T00:00:00.000Z"}},sidebar:"autogeneratedBar",previous:{title:"BF",permalink:"/algorithms/paths/bf-to-astar/bf"},next:{title:"A* algorithm",permalink:"/algorithms/paths/bf-to-astar/astar"}},h={},l=[{value:"Intro",id:"intro",level:2},{value:"Dijkstra's algorithm",id:"dijkstras-algorithm",level:2},{value:"Short description",id:"short-description",level:2},{value:"Used techniques",id:"used-techniques",level:2},{value:"Implementation",id:"implementation",level:2},{value:"Time complexity",id:"time-complexity",level:2},{value:"Running the Dijkstra",id:"running-the-dijkstra",level:2},{value:"Busting the myth about looping Dijkstra",id:"busting-the-myth-about-looping-dijkstra",level:2},{value:"Summary",id:"summary",level:2}];function m(e){const t={admonition:"admonition",annotation:"annotation",blockquote:"blockquote",code:"code",em:"em",h2:"h2",img:"img",math:"math",mi:"mi",mn:"mn",mo:"mo",mrow:"mrow",msup:"msup",p:"p",pre:"pre",semantics:"semantics",span:"span",strong:"strong",...(0,a.a)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(t.h2,{id:"intro",children:"Intro"}),"\n",(0,n.jsx)(t.p,{children:"Let's rewind back to the small argument in the previous post about the fact that\nwe can safely bound the amount of iterations with relaxations being done."}),"\n",(0,n.jsxs)(t.p,{children:["We have said that assuming the worst-case scenario (bad order of relaxations) we\n",(0,n.jsx)(t.strong,{children:"need"})," at most ",(0,n.jsxs)(t.span,{className:"katex",children:[(0,n.jsx)(t.span,{className:"katex-mathml",children:(0,n.jsx)(t.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,n.jsxs)(t.semantics,{children:[(0,n.jsxs)(t.mrow,{children:[(0,n.jsx)(t.mi,{mathvariant:"normal",children:"\u2223"}),(0,n.jsx)(t.mi,{children:"V"}),(0,n.jsx)(t.mi,{mathvariant:"normal",children:"\u2223"}),(0,n.jsx)(t.mo,{children:"\u2212"}),(0,n.jsx)(t.mn,{children:"1"})]}),(0,n.jsx)(t.annotation,{encoding:"application/x-tex",children:"\\vert V \\vert - 1"})]})})}),(0,n.jsxs)(t.span,{className:"katex-html","aria-hidden":"true",children:[(0,n.jsxs)(t.span,{className:"base",children:[(0,n.jsx)(t.span,{className:"strut",style:{height:"1em",verticalAlign:"-0.25em"}}),(0,n.jsx)(t.span,{className:"mord",children:"\u2223"}),(0,n.jsx)(t.span,{className:"mord mathnormal",style:{marginRight:"0.22222em"},children:"V"}),(0,n.jsx)(t.span,{className:"mord",children:"\u2223"}),(0,n.jsx)(t.span,{className:"mspace",style:{marginRight:"0.2222em"}}),(0,n.jsx)(t.span,{className:"mbin",children:"\u2212
|