بحث

Untitled Storyboard

انسخ هذه القصة المصورة
Untitled Storyboard

نص القصة المصورة

  • الانزلاق: 1
  • Hold on, Jamie! I’ve got just the thing to get you to class on time: Dijkstra's Algorithm!
  • Ugh, I’m gonna be late for Professor Lin’s lecture again! It's 9:05 AM already!
  • Ugh, I’m gonna be late for Professor Lin’s lecture again! It's 9:05 AM already!
  • الانزلاق: 2
  • import heapqdef dijkstra(graph, start): dist = {node: float('inf') for node in graph} dist[start] = 0 pq = [(0, start)] while pq: (d, node) = heapq.heappop(pq) for neighbor, weight in graph[node]: new_dist = d + weight if new_dist dist[neighbor]: dist[neighbor] = new_dist heapq.heappush(pq, (new_dist, neighbor)) return dist
  • الانزلاق: 3
  • import heapqdef dijkstra(graph, start): dist = {node: float('inf') for node in graph} dist[start] = 0 pq = [(0, start)] while pq: (d, node) = heapq.heappop(pq) for neighbor, weight in graph[node]: new_dist = d + weight if new_dist dist[neighbor]: dist[neighbor] = new_dist heapq.heappush(pq, (new_dist, neighbor)) return dist
  • Here’s the deal. You’re at Dormitory (A) and need to get to Lecture Hall (Z). The map shows several paths and each one has a travel time in minutes. We can use Dijkstra’s Algorithm to find the quickest route!
تم إنشاء أكثر من 40 مليون لوحة قصصية
لا توجد تنزيلات ولا بطاقة ائتمان ولا حاجة إلى تسجيل الدخول للمحاولة!
Storyboard That العائلة