1. Home
  2. Explore
  3. Computer Science
  4. Shortest-Path Algorithms

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Shortest-Path Algorithms

  • 87Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Pathfinding Basics
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

Why is brute-force route checking impractical on a large road network?

Tap to flipClick to flipspace

A simplified estimate gives about 1022010^{220}10220 possible routes. Even checking a billion routes per second would take more than 1020010^{200}10200 years.

Or swipe the card

87 cards

  1. Why is brute-force route checking impractical on a large road network?

    A simplified estimate gives about 1022010^{220}10220 possible routes. Even checking a billion routes per second would take more than 1020010^{200}10200 years.

  2. How can a road network be represented as a graph?

    Intersections or cities are nodes, and roads connecting them are edges.

  3. What does a road edge weight represent in a shortest-path problem?

    A cost associated with traveling that edge, such as distance or travel time.

  4. What is the goal of a shortest-path algorithm?

    To find a path from a source to a target whose total edge cost is as small as possible.

  5. What is Breadth-First Search (BFS)?

    A graph-search algorithm that explores all nodes one edge away, then two edges away, and so on.

  6. When does BFS find a shortest path?

    When all edges have equal cost, because BFS finds a path with the fewest edges.

  7. Why can BFS give the wrong route when road lengths differ?

    BFS treats every edge as having the same cost, so the fewest-edge route may not have the least total distance.

  8. How does BFS expand its search from a starting node?

    It explores the starting node’s neighbors, then their unexplored neighbors, continuing outward in layers.

  9. How many steps away was the Rotterdam-to-Groningen route in the BFS example?

    Five steps; the search did not reach Groningen in four iterations.

  10. What information does Dijkstra’s algorithm maintain for each node?

    A tentative cost: the lowest total path cost from the source found so far.

  11. How are tentative costs initialized in Dijkstra’s algorithm?

    The source is assigned cost 000, and every other node is initially assigned infinity.

  12. What is a relaxation in Dijkstra’s algorithm?

    Checking whether reaching a neighbor through the current node gives it a lower cost, and updating its tentative cost if it does.

  13. How does Dijkstra choose the next node to explore?

    It selects the unexplored node with the lowest tentative cost.

  14. Why can Dijkstra ignore a newly found route to a node if its tentative cost is already lower?

    The new route is not an improvement, so it cannot replace the best cost found so far for that node.

  15. Can Dijkstra’s algorithm update a node’s cost more than once?

    Yes. A later-discovered route may be cheaper than the route that first reached the node.

  16. Why does Dijkstra explore nodes in increasing cost order?

    This ensures that lower-cost possibilities are examined before higher-cost ones, allowing the algorithm to establish shortest distances.

  17. Why shouldn’t Dijkstra stop the first time it discovers the target?

    The target may have a tentative cost that can still be improved by a path through an unexplored node.

  18. When can Dijkstra safely stop once the target has been reached?

    When the target is the lowest-cost unexplored node and is selected for exploration; no unexplored route can then produce a cheaper path to it.

  19. How does Dijkstra’s algorithm guarantee a shortest path to a target?

    It explores nodes in increasing path cost, so before finalizing the target it has considered all possible routes with lower cost.

  20. What is a limitation of Dijkstra’s algorithm for a specific destination?

    It has no built-in sense of the target’s direction, so it may explore many nodes far from the destination.

  21. What extra information does A-star use compared with Dijkstra’s algorithm?

    A heuristic estimate of the remaining cost from a node to the target.

  22. How does A-star prioritize nodes in the described method?

    It orders nodes by their known cost from the source plus a heuristic estimate of their remaining distance to the target.

  23. What heuristic is used in the geographic-distance example of A-star?

    The straight-line distance from a node to the target, calculated using its geographic coordinates.

  24. How does a straight-line-distance heuristic change A-star’s search pattern?

    It favors nodes closer to the target, so the search tends to head toward the destination rather than spreading evenly in all directions.

  25. What is the effect of making A-star’s heuristic penalty steeper?

    A-star spreads out less and targets the destination more aggressively.

  26. What is a heuristic in A-star search?

    An estimate of the remaining cost to the target that helps guide which nodes to explore first.

  27. What is a useful lower-bound heuristic for minimum travel time?

    Straight-line distance to the target divided by the maximum allowed speed on the graph.

  28. Why can A-star be less advantageous for optimizing travel time than for optimizing geographic distance?

    The travel-time heuristic may be a weak underestimate, and evaluating heuristics adds computation, including costly square-root calculations.

  29. How does A-star perform in the described New York City shortest-distance example compared with Dijkstra?

    Dijkstra explored about 9.59.59.5 times as many nodes as A-star.

  30. Why is A-star popular for video-game characters and maze solving?

    Its target-directed heuristic can reduce the search space, and game versions can add penalties for hazards such as dangerous zones.

  31. What is bidirectional Dijkstra’s search strategy?

    It searches forward from the source and backward from the target until the two search frontiers meet.

  32. Why can bidirectional search explore fewer nodes than a one-directional search?

    The two searches meet partway between the endpoints, reducing how far each frontier must expand.

  33. In the circular-area illustration, how does the area covered by two Dijkstra searches compare with one search?

    For endpoints about distance RRR apart, a single search covers roughly rac{1}{2} imes 2 ext{?} No: the stated comparison is that the two searches together cover about rac{1}{2} imes rac{1}{2} ext{?}

  34. How did bidirectional Dijkstra compare with ordinary Dijkstra in the Carnegie Hall-to-Wall Street example?

    Ordinary Dijkstra explored over 7,2007{,}2007,200 nodes; bidirectional Dijkstra explored a little over 2,6002{,}6002,600, nearly a threefold reduction.

  35. Why does bidirectional search alone not fully exploit road networks?

    It still lacks an understanding of road-network hierarchy and may explore implausible routes, such as detours through a parking lot or drive-through.

  36. What does bidirectional Dijkstra require to take advantage of hierarchical searches from both ends?

    Both searches must be able to move upward through the hierarchy so they can meet near its top.

  37. What is the key limitation of plain Dijkstra and A-star on hierarchical road networks?

    They may treat a local road and a highway similarly when their edge costs are similar, despite the different roles those roads play in a route.

  38. What is a road-network hierarchy?

    A classification of roads by their role or importance, such as narrow roads, local major roads, and express highways.

  39. How were road hierarchies created for early in-car GPS routing systems?

    Surveyors recorded road characteristics, and mapping companies manually categorized roads into levels.

  40. How did early hierarchical GPS routing use road levels?

    It searched local roads within a candidate area first, then expanded to major local roads and highways if necessary.

  41. What is a candidate area in hierarchical routing?

    The region within which a search is conducted at a particular stage or road level.

  42. What can happen if a hierarchical routing candidate area is too small?

    The search may miss the true shortest route and return a less optimal route, such as a highway route when local roads are better.

  43. What is the trade-off in choosing candidate-area size for early hierarchical routing?

    A larger area is less likely to miss the shortest path but requires more searching and can approach Dijkstra’s cost.

  44. Why is manually assigning road hierarchies challenging?

    The levels must be chosen correctly; otherwise, restricting the search can cause shortest paths to be missed.

  45. What is the goal of contraction hierarchies’ preprocessing?

    To rank nodes by importance and add shortcuts so queries can search efficiently while still finding shortest paths.

  46. How does a contraction hierarchy differ from manually assigning road classes?

    It automatically preprocesses the graph to order nodes by importance rather than relying on hand-assigned road categories.

  47. What makes a node important in a road network?

    It lies on many shortest paths or acts as a bottleneck connecting large parts of the network.

  48. Why can a bridge intersection become highly important in a graph?

    Trips between the areas it connects may all have to pass through that intersection.

  49. When is a bridge node especially important between two areas?

    When the areas on either side are roughly the same size, so the node separates the graph into near halves.

  50. What does it mean for a small cut of nodes to be important?

    Removing or crossing that small set separates large portions of the graph, making those nodes bottlenecks for many routes.

  51. What method is used to find nested, important cuts in a graph?

    Nested dissection: find a small separator that divides the graph, then recursively find separators within the resulting parts.

  52. What was the example of a major separator in the North American road network?

    A set of 102102102 nodes roughly separating the East Coast from the West Coast, associated with crossings of the Mississippi River.

  53. How are node ranks assigned using nested dissection?

    Nodes in high-level separators receive high ranks, and the process recursively ranks nodes in the smaller subgraphs.

  54. Does the ordering within one separator have to be unique for correctness?

    No. Different valid orderings can still find shortest paths when the needed shortcuts are added.

  55. What is node contraction in a contraction hierarchy?

    Processing nodes from lower to higher rank and representing necessary routes through lower-ranked nodes with shortcuts between higher-ranked nodes.

  56. Why does a contraction-hierarchy query search upward from both endpoints?

    Limiting the search to higher-ranked nodes shrinks the search space, while bidirectional search allows the frontiers to meet near the top of the hierarchy.

  57. Why can an upward-only search miss the true shortest path without additional preprocessing?

    The shortest path may pass through a lower-ranked node that the query is not allowed to visit.

  58. What is a shortcut in a contraction hierarchy?

    A non-original edge that represents a route through one or more contracted, lower-ranked nodes.

  59. When is a shortcut added while contracting a node?

    When the node connects at least two higher-ranked neighbors and a route through it may be needed as the shortest connection between them.

  60. How is the weight of a shortcut determined?

    It is the total cost of the represented path through the contracted node or nodes.

  61. What should preprocessing do if a shortcut candidate is not the cheapest connection between its endpoints?

    Keep the lower-cost alternative; the shortcut should represent the minimum-cost route available between those higher-ranked nodes.

  62. How do shortcuts preserve shortest paths while allowing queries to avoid lower-ranked nodes?

    They encode necessary paths through lower-ranked nodes as direct edges between higher-ranked nodes.

  63. Why can shortcuts make an imperfect node ranking correct?

    If the ranking would otherwise hide a shortest path, preprocessing can add a shortcut that restores that path for the query.

  64. Does every possible route through a contracted node require a shortcut?

    No. A shortcut is needed only when the route may provide the minimum-cost connection between its higher-ranked endpoints.

  65. What is the trade-off involved in choosing a node ranking?

    A ranking that creates too many shortcuts increases preprocessing and graph size; one that creates weak shortcuts can leave queries slow.

  66. Why is contracting a straight-line graph from left to right a poor ordering?

    It may require no shortcuts, but an end-to-end query still has to traverse every node and edge.

  67. What is the drawback of an ordering that allows an end-to-end query to use only a few edges but creates many shortcuts?

    It can make queries fast, but the large number of shortcuts increases preprocessing and storage costs.

  68. What is the main goal of selecting a good hierarchy and shortcut set?

    Balance a small query search space against a manageable number of shortcuts and preprocessing cost.

  69. What are the three phases of a customizable contraction hierarchy?

    First order the nodes and build shortcuts; second calculate shortcut weights; third run the shortest-path query.

  70. When does the node ordering and shortcut structure need to be rebuilt?

    When the graph’s structure changes, such as when a road closes or a new bridge opens.

  71. When do shortcut weights need to be recalculated?

    When edge costs change, such as after traffic updates.

  72. How long did the described North American node-ordering preprocessing take?

    About one hour and forty minutes in the reported experiment, with more time potentially producing better results.

  73. How long did the described shortcut-weighting phase take?

    About seven to eight seconds without parallelization, or around one second when parallelized.

  74. How fast was the described contraction-hierarchy query on the North American network?

    About 200200200 microseconds, with configurations capable of roughly 100100100 microseconds.

  75. How did the contraction-hierarchy query compare with a well-tuned Dijkstra search in the experiment?

    It was about 35,00035{,}00035,000 times faster and explored about 1,4501{,}4501,450 nodes on average, versus Dijkstra exploring most of the 646464 million-node network for long trips.

  76. By what factor did the contraction hierarchy reduce the search space in the reported experiment?

    By about 44,00044{,}00044,000 on average.

  77. Why is a full lookup table of shortest paths impractical for a road network?

    Computing and storing all pairwise routes is enormous; even running Dijkstra from every one of 646464 million intersections would take more than a decade on one core, and the table would exceed eight petabytes.

  78. What maintenance problem would a complete shortest-path lookup table face?

    Road closures, new bridges, and traffic changes would require rebuilding affected portions of the table.

  79. Why is preprocessing useful for routing services that handle many queries?

    It shifts computation to an offline stage so each route query can be answered much faster, easing demand on servers serving many users.

  80. What was Dijkstra’s original shortest-path demonstration intended to show?

    That a computer could solve an understandable, practical problem: finding the shortest route between two towns.

  81. What simple graph-search idea preceded Dijkstra’s weighted method in the explanation?

    Breadth-First Search, which works for equal-length edges but does not account for differing road distances.

  82. When and where did Dijkstra conceive his shortest-path algorithm?

    In 1956, while shopping in Amsterdam and later thinking about the problem over coffee with his fiancée.

  83. How was Dijkstra’s shortest-path algorithm first demonstrated publicly?

    At ARMAC’s 1956 inauguration, audience members named two towns and the computer printed the shortest route town by town.

  84. When and where was Dijkstra’s algorithm published?

    In 1959 in the new German journal Numerische Mathematik (Numerical Mathematics).

  85. Why did Dijkstra say designing the algorithm without pencil and paper helped?

    It forced him to avoid complexities that were not necessary.

  86. What principle did Dijkstra express with the statement “Simplicity is prerequisite for reliability”?

    Simple, carefully designed solutions are important for producing reliable work.

  87. What enduring role does Dijkstra’s algorithm play in modern shortest-path methods?

    Many later routing methods, including contraction-hierarchy variations, still use Dijkstra’s algorithm or parts of its approach as their core search.

Card 1 of 87
Card 1 of 87

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent