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

  • 57Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Pathfinding Foundations

In a road-network graph, what do the nodes and edges represent?

57 questions

  1. 1

    In a road-network graph, what do the nodes and edges represent?

    1. A

      Nodes represent cities or intersections, and edges represent roads connecting them

    2. B

      Nodes represent roads, and edges represent travel times between cities

    3. C

      Nodes represent route costs, and edges represent destinations

    4. D

      Nodes represent vehicles, and edges represent road intersections

    Correct answer
    A

    Nodes represent cities or intersections, and edges represent roads connecting them

    Explanation

    A road network can be modeled as a graph in which nodes are locations such as cities or intersections, and edges are the roads connecting them.

  2. 2

    Why can checking every possible route be impractical even for a navigation problem with a finite road network?

    1. A

      Road networks contain no repeated intersections, so every route must be calculated manually

    2. B

      The number of possible routes can grow enormously, making exhaustive checking take an infeasible amount of time

    3. C

      A computer cannot compare distances unless every road has the same length

    4. D

      Exhaustive checking requires the destination to be one of the source's immediate neighbors

    Correct answer
    B

    The number of possible routes can grow enormously, making exhaustive checking take an infeasible amount of time

    Explanation

    The number of possible routes can be so large that even testing a billion routes per second would not make exhaustive enumeration feasible.

  3. 3

    Why does breadth-first search find a path with the fewest edges in an unweighted graph?

    1. A

      It explores the graph in order of the total physical length of each route

    2. B

      It explores all nodes one edge away before exploring nodes two edges away, and continues in this order

    3. C

      It explores every possible route completely before considering another route

    4. D

      It always selects the node whose geographical coordinates are closest to the destination

    Correct answer
    B

    It explores all nodes one edge away before exploring nodes two edges away, and continues in this order

    Explanation

    Breadth-first search expands outward by number of edges, so it reaches a destination using the fewest edges before any longer-hop path can reach it.

  4. 4

    What limitation arises if breadth-first search is used on a road graph where edges have different distances?

    1. A

      It always returns a route with the greatest total edge weight

    2. B

      It cannot explore a node more than once, even if a shorter route is later found

    3. C

      It minimizes the number of roads used, which need not minimize total travel distance

    4. D

      It requires every road to connect directly to the destination

    Correct answer
    C

    It minimizes the number of roads used, which need not minimize total travel distance

    Explanation

    Breadth-first search treats each edge as one step. A route with fewer roads may still have a greater total distance than a route with more roads.

  5. 5

    What problem did Dijkstra devise as a computer demonstration that non-mathematicians could understand?

    1. A

      Estimating how many computers could be built in a year

    2. B

      Finding the shortest route between two towns

    3. C

      Finding the largest possible network of connected towns

    4. D

      Sorting a list of numbers into ascending order

    Correct answer
    B

    Finding the shortest route between two towns

    Explanation

    Dijkstra chose the understandable question of finding the shortest way to travel between two towns, which illustrates a shortest-path problem.

  6. 6

    In the described 1956 demonstration, what did the ARMAC computer produce after audience members chose two towns?

    1. A

      A complete list of every route between the towns

    2. B

      A map that assigned a new road category to every intersection

    3. C

      The total number of intersections in the Netherlands

    4. D

      The shortest route, printed town by town

    Correct answer
    D

    The shortest route, printed town by town

    Explanation

    At ARMAC's inauguration, the computer printed the shortest route from one selected town to another, listing the towns along the route.

  7. 7

    Which statement best describes how the shortest-path problem changes when roads have weights?

    1. A

      The route with the fewest edges is not necessarily the route with the least total weight

    2. B

      The shortest path must pass through the node with the most neighbors

    3. C

      Every route with the fewest edges must also have the least total weight

    4. D

      Edge weights make it impossible to represent the road system as a graph

    Correct answer
    A

    The route with the fewest edges is not necessarily the route with the least total weight

    Explanation

    When edges have different weights, the total cost of a route matters; minimizing the number of edges alone does not guarantee the minimum-weight path.

  8. 8

    Why can navigation systems need far faster queries than a single-user calculation might seem to require?

    1. A

      Many people may request routes at once, so server capacity makes per-query runtime important

    2. B

      Every user must receive a different shortest-path algorithm

    3. C

      A route cannot be calculated until every other route request is complete

    4. D

      Navigation systems must enumerate every route before answering any user

    Correct answer
    A

    Many people may request routes at once, so server capacity makes per-query runtime important

    Explanation

    Even a several-second calculation can become a bottleneck when millions of people are requesting directions concurrently.

  9. 9

    How does Dijkstra's algorithm initialize the distance costs in the described method?

    1. A

      It assigns one to the source and zero to every other node

    2. B

      It assigns infinity to the source and zero to every unexplored node

    3. C

      It assigns zero to the source and infinity to every other node

    4. D

      It assigns the direct edge weight to every node, whether or not it is adjacent

    Correct answer
    C

    It assigns zero to the source and infinity to every other node

    Explanation

    At the start, the source has cost zero, while all other nodes have cost infinity because no route to them has yet been established.

  10. 10

    When Dijkstra explores an edge from a reached node to a neighbor, what does it do?

    1. A

      It adds the edge weight to every node in the graph

    2. B

      It checks whether the route through the reached node gives the neighbor a lower cost, and updates the cost if so

    3. C

      It discards the neighbor whenever the neighbor already has a finite cost

    4. D

      It permanently sets the neighbor's cost to the edge weight alone

    Correct answer
    B

    It checks whether the route through the reached node gives the neighbor a lower cost, and updates the cost if so

    Explanation

    Dijkstra compares the cost of the newly found route with the neighbor's current best-known cost and replaces the current cost if the new one is lower.

  11. 11

    Why does Dijkstra explore the lowest-cost unexplored node next?

    1. A

      This ensures that every node is reached through the same number of edges

    2. B

      This avoids having to compare alternative routes to a neighbor

    3. C

      This guarantees that the next node is geographically closest to the source

    4. D

      This extends the search in increasing order of known path cost, allowing shortest distances to be established systematically

    Correct answer
    D

    This extends the search in increasing order of known path cost, allowing shortest distances to be established systematically

    Explanation

    Selecting the unexplored node with the lowest cost means the algorithm processes paths in increasing cost order, which supports its shortest-path guarantee.

  12. 12

    A node is first reached by a route costing seven, but a later-discovered route to it costs six. What should Dijkstra's algorithm do?

    1. A

      Update the node's best-known cost to six

    2. B

      Mark both costs as final and explore neither route

    3. C

      Average the two route costs and assign six and a half

    4. D

      Keep the cost at seven because the node has already been reached

    Correct answer
    A

    Update the node's best-known cost to six

    Explanation

    A discovered route with a lower total cost replaces the previous best-known cost. Dijkstra may update a node's cost more than once before it is finalized.

  13. 13

    Dijkstra first reaches the destination with cost 19, but an unexplored node has cost 16. Why should the search continue?

    1. A

      A node with cost 16 must itself be the destination

    2. B

      The algorithm can only stop when it has explored every node in the graph

    3. C

      The destination's cost must always be increased until all nodes have been explored

    4. D

      The unexplored node could lead to a route to the destination costing less than 19

    Correct answer
    D

    The unexplored node could lead to a route to the destination costing less than 19

    Explanation

    The unexplored node may provide a cheaper route to the destination. Dijkstra can be confident in the destination's cost when it is the lowest-cost remaining unexplored node.

  14. 14

    Under what condition does Dijkstra's algorithm have enough information to finalize the shortest distance to a target?

    1. A

      When the target's cost equals the number of edges in the route

    2. B

      When every node adjacent to the source has been explored

    3. C

      As soon as the target is first discovered by any route

    4. D

      When the target is selected as the lowest-cost unexplored node

    Correct answer
    D

    When the target is selected as the lowest-cost unexplored node

    Explanation

    The first discovery of a target may not be its cheapest route. Once it is the lowest-cost unexplored node, all lower-cost possibilities have already been considered.

  15. 15

    What is the key reason Dijkstra's algorithm guarantees a shortest path when edge weights are nonnegative?

    1. A

      It limits the search to paths with the fewest edges

    2. B

      It checks only routes that use the most important road in the network

    3. C

      It explores paths in increasing cost order, so any cheaper route would have been considered before the target is finalized

    4. D

      It always searches toward the target in a straight line

    Correct answer
    C

    It explores paths in increasing cost order, so any cheaper route would have been considered before the target is finalized

    Explanation

    By taking the lowest-cost unexplored node next, Dijkstra processes all possible lower-cost alternatives before finalizing a target's distance.

  16. 16

    What drawback can Dijkstra's algorithm have on a large road network when searching for one target?

    1. A

      It must calculate all possible paths before exploring any node

    2. B

      It may explore many nodes in directions that do not lead toward the target

    3. C

      It cannot handle roads with different weights

    4. D

      It is guaranteed to explore only nodes on the final shortest route

    Correct answer
    B

    It may explore many nodes in directions that do not lead toward the target

    Explanation

    Dijkstra expands by cost from the source without using the target's direction, so it can search broad areas that are irrelevant to the desired destination.

  17. 17

    On the North American network described, what was a typical average runtime for a well-tuned Dijkstra query?

    1. A

      Around 200 microseconds per path

    2. B

      Around seven milliseconds per path

    3. C

      Around seven seconds per path

    4. D

      Around one hour per path

    Correct answer
    C

    Around seven seconds per path

    Explanation

    The described average for a well-tuned Dijkstra search on the North American network was around seven seconds per path, with many searches exploring most of the nodes.

  18. 18

    Why were the random-pair average query times described as being dominated by long journeys?

    1. A

      Randomly selected points are unlikely to be close together

    2. B

      The algorithm ignores all pairs that are farther than one city apart

    3. C

      Only journeys between opposite coasts are included in the average

    4. D

      Short journeys cannot be represented by a weighted graph

    Correct answer
    A

    Randomly selected points are unlikely to be close together

    Explanation

    When points are selected randomly across a large network, most pairs are far apart, so the average includes many long journeys.

  19. 19

    How does A-star use information about the target to guide its search?

    1. A

      It ignores the path cost and ranks nodes by their number of neighbors

    2. B

      It explores nodes in alphabetical order by their location names

    3. C

      It ranks nodes using their path cost plus an estimate of their remaining distance to the target

    4. D

      It ranks nodes by the distance already traveled, without considering the target

    Correct answer
    C

    It ranks nodes using their path cost plus an estimate of their remaining distance to the target

    Explanation

    A-star prioritizes nodes using the cost so far plus a heuristic estimate of the remaining distance to the goal.

  20. 20

    In the road example, what was used as a heuristic estimate of a node's distance to the target?

    1. A

      The straight-line distance calculated from longitude and latitude

    2. B

      The total weight of every road leaving the node

    3. C

      The cost of the longest known route to the target

    4. D

      The number of intersections between the node and the source

    Correct answer
    A

    The straight-line distance calculated from longitude and latitude

    Explanation

    The straight-line distance from a node to the target, calculated using geographic coordinates, was used to estimate the remaining distance.

  21. 21

    What effect does adding the straight-line-distance heuristic have on A-star's search compared with Dijkstra's?

    1. A

      It forces the algorithm to explore every node at the same distance from the source

    2. B

      It removes the need to track the cost of the route so far

    3. C

      It prioritizes nodes that are closer to the target and avoids early exploration in the opposite direction

    4. D

      It guarantees that the route has the fewest roads, regardless of their weights

    Correct answer
    C

    It prioritizes nodes that are closer to the target and avoids early exploration in the opposite direction

    Explanation

    The heuristic favors nodes that appear closer to the target, so A-star tends to head toward the goal rather than spreading outward uniformly from the source.

  22. 22

    What does the heuristic's strength control in the described visualization of A-star?

    1. A

      How many edges are permitted in the final route

    2. B

      Whether the graph's nodes represent roads or intersections

    3. C

      Whether Dijkstra's algorithm uses weighted edges

    4. D

      How aggressively the search favors nodes in the target's direction

    Correct answer
    D

    How aggressively the search favors nodes in the target's direction

    Explanation

    A steeper heuristic penalty makes A-star spread out less and focus more strongly on the target's direction.

  23. 23

    What is the stated worst-case relationship between A-star and Dijkstra in terms of nodes checked?

    1. A

      A-star is guaranteed to check fewer nodes than Dijkstra

    2. B

      Both algorithms always check exactly the same nodes

    3. C

      Dijkstra can check no more than half as many nodes as A-star

    4. D

      A-star can check as many nodes as Dijkstra

    Correct answer
    D

    A-star can check as many nodes as Dijkstra

    Explanation

    The content states that at worst A-star checks as many nodes as Dijkstra, though a useful heuristic can make it check far fewer.

  24. 24

    Why might A-star be especially useful in a maze or video game even if its performance depends on the problem?

    1. A

      It requires no representation of obstacles or locations

    2. B

      It guarantees that every route has the same length, regardless of the maze

    3. C

      A target-directed heuristic can focus exploration, and game versions can add penalties for dangerous areas

    4. D

      It always chooses the safest path without any added information

    Correct answer
    C

    A target-directed heuristic can focus exploration, and game versions can add penalties for dangerous areas

    Explanation

    A-star is popular for maze solving and game characters because its heuristic can direct the search toward a goal; game versions can also add penalties for hazardous zones.

  25. 25

    How can a heuristic be adjusted to estimate minimum travel time rather than straight-line distance?

    1. A

      Divide the total route cost by the number of roads already traveled

    2. B

      Multiply the road distance by the number of intersections

    3. C

      Divide straight-line distance by the maximum speed allowed on the graph

    4. D

      Add the source's distance from the destination to every edge weight

    Correct answer
    C

    Divide straight-line distance by the maximum speed allowed on the graph

    Explanation

    The straight-line distance divided by the maximum allowed speed gives a lower-bound estimate of travel time.

  26. 26

    Why may A-star lose some of its advantage over a well-tuned Dijkstra when optimizing for travel time?

    1. A

      It cannot represent road speeds or travel times as edge weights

    2. B

      Its travel-time heuristic necessarily overestimates the minimum travel time

    3. C

      It may explore more nodes and must evaluate extra heuristics, including a costly square-root calculation

    4. D

      It must calculate every possible route before using its heuristic

    Correct answer
    C

    It may explore more nodes and must evaluate extra heuristics, including a costly square-root calculation

    Explanation

    The content notes that travel-time A-star may explore fewer nodes but not enough to offset evaluating additional heuristics, which can involve a square-root computation.

  27. 27

    What is a basic advantage of running Dijkstra's search from both the source and the target?

    1. A

      The searches guarantee that only nodes on the final route are visited

    2. B

      The two search frontiers can meet partway, reducing the area that must be explored

    3. C

      Each search can ignore all edge weights and still guarantee the shortest route

    4. D

      The two searches eliminate the need to store distances to nodes

    Correct answer
    B

    The two search frontiers can meet partway, reducing the area that must be explored

    Explanation

    A bidirectional search expands from both endpoints, so the frontiers can meet before either search has explored the full region around the route.

  28. 28

    In the geometric illustration, how does the explored area of two bidirectional searches compare with a single search?

    1. A

      The two searches cover roughly twice the area of one search

    2. B

      The two searches can meet around halfway and cover roughly half the area of one search

    3. C

      The two searches cover no area until they meet at the destination

    4. D

      The two searches cover exactly the same area because they start at different nodes

    Correct answer
    B

    The two searches can meet around halfway and cover roughly half the area of one search

    Explanation

    For points separated by distance RRR, each frontier can reach roughly R/2R/2R/2 before meeting, giving a combined area of about half the single-search area in the illustration.

  29. 29

    What does a basic bidirectional Dijkstra search still fail to exploit effectively in a road network?

    1. A

      The fact that edge weights can represent different distances

    2. B

      The possibility of searching from both endpoints

    3. C

      The hierarchy of roads, such as the distinction between local streets and highways

    4. D

      The identity of the source and target nodes

    Correct answer
    C

    The hierarchy of roads, such as the distinction between local streets and highways

    Explanation

    Even bidirectional Dijkstra may explore implausible local detours because it does not inherently understand that road networks have levels such as local roads and highways.

  30. 30

    What was one early way GPS systems used road hierarchy to narrow the search?

    1. A

      They ignored local roads and searched only highways for every trip

    2. B

      They assigned every road the same category to avoid additional processing

    3. C

      They searched only roads whose names matched the destination

    4. D

      They searched within a candidate area at one road level, then expanded to higher levels if needed

    Correct answer
    D

    They searched within a candidate area at one road level, then expanded to higher levels if needed

    Explanation

    Early systems categorized roads into levels and searched candidate areas at a level before moving upward if the target was not found.

  31. 31

    Why can a candidate area that is too small produce an incorrect route?

    1. A

      It may guarantee that the route uses too many local roads

    2. B

      It may cause every edge to be assigned an infinite weight

    3. C

      It may omit a better route using roads outside that area

    4. D

      It may force the two searches to begin at the same node

    Correct answer
    C

    It may omit a better route using roads outside that area

    Explanation

    If the candidate area excludes roads needed by the true shortest path, the search may return a worse route, such as a highway route when local roads would be better.

  32. 32

    What is the trade-off in making candidate areas larger for a hierarchical search?

    1. A

      Larger areas reduce the risk of missing a shortest path but can make the search approach the cost of Dijkstra

    2. B

      Larger areas eliminate the need to categorize roads but prevent shortest-path guarantees

    3. C

      Larger areas always make the result less accurate but require less computation

    4. D

      Larger areas reduce preprocessing while guaranteeing fewer explored nodes

    Correct answer
    A

    Larger areas reduce the risk of missing a shortest path but can make the search approach the cost of Dijkstra

    Explanation

    Expanding candidate areas can help capture the actual shortest path, but sufficiently large areas may eliminate much of the efficiency advantage over Dijkstra.

  33. 33

    What are the two competing goals of a useful preprocessed routing method?

    1. A

      Maximum query time and minimum route length in number of edges

    2. B

      Manual road classification and avoidance of all edge weights

    3. C

      Fast queries and a guarantee that the returned route is shortest

    4. D

      No preprocessing and no need to store a graph

    Correct answer
    C

    Fast queries and a guarantee that the returned route is shortest

    Explanation

    The routing method needs to reduce query work while still guaranteeing that it returns the shortest path.

  34. 34

    Why is a complete lookup table of shortest paths from every node to every other node impractical?

    1. A

      It would make route queries slower than running Dijkstra each time

    2. B

      It would remove all need to update information after a road change

    3. C

      It cannot store routes that use more than one edge

    4. D

      Building and storing it would be extremely costly, and road changes would require rebuilding affected data

    Correct answer
    D

    Building and storing it would be extremely costly, and road changes would require rebuilding affected data

    Explanation

    The example lookup table would require more than a decade of single-core computation and over eight petabytes, and would need updates when roads or traffic conditions change.

  35. 35

    What does nested dissection do when constructing a hierarchy of graph nodes?

    1. A

      It groups nodes solely by the weights of their shortest incident edges

    2. B

      It removes every node that is not directly connected to a highway

    3. C

      It repeatedly identifies small sets of nodes that divide the graph into roughly balanced parts

    4. D

      It sorts nodes by their names and assigns road levels alphabetically

    Correct answer
    C

    It repeatedly identifies small sets of nodes that divide the graph into roughly balanced parts

    Explanation

    Nested dissection repeatedly finds small cuts that divide the graph into roughly balanced subsets, then ranks the cut nodes highly.

  36. 36

    Why is a node on a bridge between two large regions considered important in the hierarchy?

    1. A

      It has no influence on routes once the graph is divided

    2. B

      Many shortest paths between the regions may pass through that node

    3. C

      It must have the highest number of adjacent roads in the entire graph

    4. D

      It is necessarily the closest node to every destination

    Correct answer
    B

    Many shortest paths between the regions may pass through that node

    Explanation

    A bridge or bottleneck connecting substantial parts of the graph may lie on many shortest paths, making it important to the hierarchy.

  37. 37

    What determines the importance of a bridge node in the two-town illustration?

    1. A

      How many shortest paths between the two sides depend on crossing it

    2. B

      Whether its road is classified as a local road or a highway

    3. C

      How close it is to the town with the smaller population

    4. D

      How many roads lead to the nearest house on its side

    Correct answer
    A

    How many shortest paths between the two sides depend on crossing it

    Explanation

    As more destinations lie across the bridge, more trips depend on it; it is especially important when it divides the graph into similarly sized parts.

  38. 38

    What was the large-scale example of a high-level cut in the North American road graph?

    1. A

      A set of 102 nodes found only within one city center

    2. B

      A set of 102 nodes used to connect all local roads to their own destinations

    3. C

      A set of 102 nodes that represents every highway exit in Canada

    4. D

      A set of 102 nodes that cross-country routes between the coasts would pass through

    Correct answer
    D

    A set of 102 nodes that cross-country routes between the coasts would pass through

    Explanation

    The described highest-ranked cut contained 102 nodes that roughly separated the eastern and western parts of the North American network, with the Mississippi region acting as a major bottleneck.

  39. 39

    After finding a major cut, how does nested dissection continue assigning ranks?

    1. A

      It assigns all remaining nodes the same rank

    2. B

      It discards the nodes in the cut and stops processing the graph

    3. C

      It orders the remaining nodes by their distance from the original source

    4. D

      It recursively finds cuts within each resulting subset and ranks those nodes next

    Correct answer
    D

    It recursively finds cuts within each resulting subset and ranks those nodes next

    Explanation

    The method repeats the cut-finding process on the separated subsets until all nodes have been ranked.

  40. 40

    What restriction is used during a hierarchy-based bidirectional search?

    1. A

      Each search moves only upward through the node hierarchy

    2. B

      Each search is limited to nodes within a manually chosen candidate area

    3. C

      Each search must visit all nodes in rank order before proceeding

    4. D

      Each search moves only through nodes of the lowest rank

    Correct answer
    A

    Each search moves only upward through the node hierarchy

    Explanation

    The query searches upward from both ends of the hierarchy, allowing the searches to meet at higher-ranked nodes while reducing the search space.

  41. 41

    Why is bidirectional search important when the query is restricted to moving upward in the hierarchy?

    1. A

      It allows the algorithm to ignore the hierarchy during preprocessing

    2. B

      Searches from both ends can meet high in the hierarchy, avoiding cases where a one-way search gets stuck

    3. C

      It ensures that every path is examined in both directions along every edge

    4. D

      It removes the need to compare edge weights

    Correct answer
    B

    Searches from both ends can meet high in the hierarchy, avoiding cases where a one-way search gets stuck

    Explanation

    A search from only one endpoint may be unable to reach the target while moving only upward; searches from both endpoints can meet in the hierarchy.

  42. 42

    What does a shortcut edge represent in a contraction hierarchy?

    1. A

      The cost of a path through lower-ranked nodes between higher-ranked nodes

    2. B

      A newly constructed physical road that replaces the original roads

    3. C

      A connection that is used only when all original edges have equal weights

    4. D

      An estimate of straight-line distance from a node to the destination

    Correct answer
    A

    The cost of a path through lower-ranked nodes between higher-ranked nodes

    Explanation

    A shortcut is an added graph edge that records the cost of a path through contracted lower-ranked nodes; it need not correspond to a real road.

  43. 43

    When should the described preprocessing add a shortcut between two higher-ranked nodes connected through a lower-ranked node?

    1. A

      Only when the route through the lower-ranked node is longer than every alternative

    2. B

      Whenever the lower-ranked node has exactly one neighbor

    3. C

      Whenever the two higher-ranked nodes are already directly connected

    4. D

      When the lower-ranked node connects to both higher-ranked nodes and that path may be needed as their shortest route

    Correct answer
    D

    When the lower-ranked node connects to both higher-ranked nodes and that path may be needed as their shortest route

    Explanation

    The lower triangle identifies a path through the lower-ranked node that an upward-only query might otherwise miss, so preprocessing records it with a shortcut when relevant.

  44. 44

    If there is already an edge between two higher-ranked nodes, how should preprocessing handle a possible shortcut between them?

    1. A

      Keep whichever connection represents the lower-cost path

    2. B

      Add the two costs together and use that sum as the new weight

    3. C

      Always keep the shortcut and discard the existing edge

    4. D

      Always keep the existing edge, regardless of its cost

    Correct answer
    A

    Keep whichever connection represents the lower-cost path

    Explanation

    When a shortcut and an existing connection compete, the represented path should have the minimum cost.

  45. 45

    How do shortcuts help an upward-only search preserve shortest-path correctness?

    1. A

      They ensure that the query explores all lower-ranked nodes directly

    2. B

      They encode useful paths through lower-ranked nodes that the query would otherwise skip

    3. C

      They replace every original road with a road of equal weight

    4. D

      They force every shortest route to pass through the highest-ranked node

    Correct answer
    B

    They encode useful paths through lower-ranked nodes that the query would otherwise skip

    Explanation

    Shortcuts preserve the cost of important lower-ranked detours, so the query can avoid exploring those lower-ranked nodes directly without missing the shortest path.

  46. 46

    Why can multiple node rankings produced by different valid cuts still return shortest paths?

    1. A

      Shortcuts can restore relevant paths through lower-ranked nodes that a particular ordering would otherwise overlook

    2. B

      The ranking does not affect which edges the query can use

    3. C

      Every valid ranking makes the query examine every node in the original graph

    4. D

      A shortest path never contains a lower-ranked node

    Correct answer
    A

    Shortcuts can restore relevant paths through lower-ranked nodes that a particular ordering would otherwise overlook

    Explanation

    Preprocessing adds shortcuts to preserve relevant paths through contracted nodes, allowing different valid orderings to retain shortest-path correctness.

  47. 47

    What is a possible consequence of choosing a poor node ranking even if the resulting method remains correct?

    1. A

      The algorithm may return a route with a lower cost than the true shortest path

    2. B

      Queries may be slow or the graph may acquire too many shortcuts

    3. C

      The preprocessing step will require no computation

    4. D

      The graph may become impossible to represent with edge weights

    Correct answer
    B

    Queries may be slow or the graph may acquire too many shortcuts

    Explanation

    A poor ordering can create inefficient searches or cause the graph to grow substantially with shortcuts, even though shortest-path correctness is preserved.

  48. 48

    What trade-off should be considered when choosing a node ordering?

    1. A

      The amount of travel time versus the number of geographical coordinates

    2. B

      The number of road names versus the number of map regions

    3. C

      The number of source nodes versus the number of destination nodes

    4. D

      The number of shortcuts added versus how much the query search is accelerated

    Correct answer
    D

    The number of shortcuts added versus how much the query search is accelerated

    Explanation

    An effective ordering balances the cost of adding shortcuts against the reduction in work during queries.

  49. 49

    Why is contracting nodes in a straight line from one end to the other a poor ordering for a line graph?

    1. A

      It changes every edge weight to infinity

    2. B

      It may require no shortcuts, but a query between the ends still has to traverse every node and edge

    3. C

      It prevents the two search directions from having any common node

    4. D

      It adds a shortcut for every pair of nodes and makes the graph exponentially large

    Correct answer
    B

    It may require no shortcuts, but a query between the ends still has to traverse every node and edge

    Explanation

    Although this ordering needs no shortcuts, an end-to-end query still explores the whole chain, so it offers no improvement over Dijkstra's search.

  50. 50

    What characterizes the customizable contraction hierarchy described in the content?

    1. A

      It preprocesses a node ordering, later assigns shortcut weights, and then performs fast hierarchy-restricted queries

    2. B

      It stores every possible route in a complete lookup table

    3. C

      It uses only A-star and does not require preprocessing

    4. D

      It manually classifies roads and searches only within fixed candidate areas

    Correct answer
    A

    It preprocesses a node ordering, later assigns shortcut weights, and then performs fast hierarchy-restricted queries

    Explanation

    The method has three stages: build the hierarchy and shortcuts, calculate shortcut weights, and perform the actual query.

  51. 51

    Which kinds of changes may require rebuilding the node ordering and shortcut structure in the described method?

    1. A

      Every individual route query, even if the graph remains unchanged

    2. B

      Changes to the graph itself, such as a new bridge or a road closure

    3. C

      A change in the target location for a single trip

    4. D

      A change in the source location for a single trip

    Correct answer
    B

    Changes to the graph itself, such as a new bridge or a road closure

    Explanation

    The expensive hierarchy-building phase changes when the graph's structure changes, for example when a bridge opens or a road closes.

  52. 52

    What kind of update requires recalculating shortcut weights in the described method?

    1. A

      A change in how nodes are displayed on a map

    2. B

      A new query with a different destination but unchanged graph costs

    3. C

      A traffic update that changes the costs associated with routes

    4. D

      A change in the spelling of a town's name

    Correct answer
    C

    A traffic update that changes the costs associated with routes

    Explanation

    The shortcut-weight phase must be rerun when traffic updates change route costs, while it is much quicker than rebuilding the hierarchy.

  53. 53

    How did the described North American contraction-hierarchy query compare with a well-tuned Dijkstra query?

    1. A

      It took around 200 microseconds rather than around seven seconds

    2. B

      It took around 100 milliseconds rather than around one second

    3. C

      It took around seven seconds rather than around 200 microseconds

    4. D

      It took around 1,450 seconds rather than around 64 million seconds

    Correct answer
    A

    It took around 200 microseconds rather than around seven seconds

    Explanation

    In the experiment, the contraction-hierarchy query took around 200 microseconds, while a long Dijkstra query took around seven seconds.

  54. 54

    What reduction in search effort was reported for the contraction-hierarchy experiment?

    1. A

      It explored about 7,000 nodes on average, roughly 10 times fewer than Dijkstra

    2. B

      It explored about 1,450 nodes on average, roughly 44,000 times fewer than Dijkstra

    3. C

      It explored about 64 million nodes on average, roughly 44 times more than Dijkstra

    4. D

      It explored every node, but completed without preprocessing

    Correct answer
    B

    It explored about 1,450 nodes on average, roughly 44,000 times fewer than Dijkstra

    Explanation

    The reported contraction-hierarchy query explored about 1,450 nodes on average, reducing the search space by a factor of around 44,000.

  55. 55

    Why do many nodes in a long contraction-hierarchy query cluster near the source and target?

    1. A

      The algorithm is prohibited from searching near the middle of the network

    2. B

      Only the source and target are assigned ranks during preprocessing

    3. C

      The query selects nodes based on their names rather than their network position

    4. D

      The search explores locally near the endpoints, then moves through higher-level cuts farther along the route

    Correct answer
    D

    The search explores locally near the endpoints, then moves through higher-level cuts farther along the route

    Explanation

    The query handles local areas near its endpoints and can traverse important high-level cuts, such as the Mississippi bottleneck, rather than exploring the whole intervening region.

  56. 56

    What relationship between modern shortest-path methods and Dijkstra's algorithm is emphasized in the content?

    1. A

      Many newer methods still use Dijkstra's algorithm or parts of its core search

    2. B

      Modern methods rely entirely on exhaustive route enumeration instead

    3. C

      Modern methods have made Dijkstra's algorithm irrelevant to shortest-path research

    4. D

      Dijkstra's algorithm is used only for unweighted graphs and never in newer methods

    Correct answer
    A

    Many newer methods still use Dijkstra's algorithm or parts of its core search

    Explanation

    The content emphasizes that contraction hierarchies and other developments retain Dijkstra's core search or incorporate parts of it.

  57. 57

    What principle about programming is expressed by the idea that simplicity is a prerequisite for reliability?

    1. A

      Avoiding unnecessary complexity can make algorithms and implementations more dependable

    2. B

      Reliable programs should always use the largest possible number of steps

    3. C

      A correct result matters only if the program is difficult to understand

    4. D

      A programmer can transfer responsibility for results to the computer

    Correct answer
    A

    Avoiding unnecessary complexity can make algorithms and implementations more dependable

    Explanation

    The closing principle connects simplicity with reliability and emphasizes that programmers remain accountable for their work.

Question 1 of 57
Question 1 of 57

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent