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

  • 59Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Pathfinding Basics
In a graph model of a road network, cities or intersections are represented by
, while roads are represented by edges.

59 questions

  1. 1
    In a graph model of a road network, cities or intersections are represented by
    _____
    , while roads are represented by edges.
    Hint

    These are the points that connections link together.

    Answer

    nodes

    Explanation

    A road network can be represented as a graph in which nodes are locations and edges are the roads connecting them.

  2. 2
    When every edge is treated as having the same length, the shortest route is the one with the fewest
    _____
    .
    Hint

    Count how many connections a route uses.

    Answer

    steps

    Explanation

    If all edges have equal length, minimizing the number of edges also minimizes the total route length.

  3. 3
    The algorithm that explores all nodes one step away, then two steps away, and so on is
    _____
    .
    Hint

    Its name describes exploring broadly across each layer before moving farther away.

    Answer

    Breadth-First Search

    Explanation

    Breadth-First Search expands a graph in layers of increasing number of edges from the source.

  4. 4
    Breadth-First Search guarantees the fewest-edge route because it explores nodes in order of increasing
    _____
    from the source.
    Hint

    Think about the layer or distance measured by counting edges.

    Answer

    number of steps

    Explanation

    The algorithm checks every node one step away before checking nodes two steps away, so it finds a target at the smallest step count first.

  5. 5
    Breadth-First Search is unsuitable for finding the shortest physical route when roads have different
    _____
    , because it treats them as equal.
    Hint

    A short street and a long highway do not necessarily cover the same distance.

    Answer

    lengths

    Explanation

    Breadth-First Search counts edges rather than accounting for the different distances represented by weighted roads.

  6. 6
    With over 64 million intersections, the number of possible routes can be so enormous that checking every route is
    _____
    .
    Hint

    Consider whether exhaustive testing could finish in a useful amount of time.

    Answer

    impractical

    Explanation

    The content estimates about 10 to the 220 possible routes, making brute-force testing infeasible even at a billion routes per second.

  7. 7
    Because many people may request routes at once, a practical mapping service needs its search to finish in less than a
    _____
    .
    Hint

    This is one thousandth of a second.

    Answer

    millisecond

    Explanation

    Fast individual searches help a service handle many simultaneous requests within its limited computing capacity.

  8. 8
    A pathfinding algorithm can be used not only for maps but also by robots and video game characters navigating a
    _____
    .
    Hint

    It is a space with routes and obstacles that an agent must navigate.

    Answer

    maze

    Explanation

    Robots and game characters face the same general problem of finding routes through connected spaces with obstacles.

  9. 9
    In Dijkstra's algorithm, the best known distance from the source to a node is called its
    _____
    .
    Hint

    It records the total route weight accumulated so far.

    Answer

    cost

    Explanation

    Dijkstra's algorithm tracks a cost for each node, representing the shortest source-to-node distance found so far.

  10. 10
    At initialization, the source node has a cost of
    _____
    , because no travel is needed to reach it from itself.
    Hint

    The starting location has not yet required any movement.

    Answer

    zero

    Explanation

    The source's distance to itself is zero, so its initial cost is zero.

  11. 11
    Before other nodes have been reached, Dijkstra's algorithm assigns them a cost of
    _____
    .
    Hint

    This represents that no route to the node has been found yet.

    Answer

    infinity

    Explanation

    Infinity is used as an initial value larger than any known route cost, allowing discovered routes to replace it.

  12. 12
    After exploring a node, Dijkstra's algorithm next selects the unexplored node with the
    _____
    cost.
    Hint

    The algorithm advances by choosing the most promising known distance.

    Answer

    lowest

    Explanation

    Choosing the unexplored node with the lowest cost ensures the search progresses in increasing order of distance.

  13. 13
    When considering an edge to a neighbor, Dijkstra's algorithm updates that neighbor's cost only if the newly found route is
    _____
    than its current cost.
    Hint

    Compare the proposed route with the best one already recorded.

    Answer

    shorter

    Explanation

    The algorithm replaces a node's cost when the route through the current node improves on the previously known route.

  14. 14
    If a node already has a cost of three and a newly considered route costs five, Dijkstra's algorithm does not update the node because the existing route is
    _____
    .
    Hint

    Compare the two route costs.

    Answer

    shorter

    Explanation

    A route costing five cannot improve on the already known route costing three.

  15. 15
    If a node is first reached by a route costing seven and later a route costing six is found, its cost must be
    _____
    .
    Hint

    The algorithm should keep the best route discovered so far.

    Answer

    updated

    Explanation

    Dijkstra's algorithm can revise a node's cost whenever a lower-cost route is found.

  16. 16
    Finding the target for the first time does not always prove the route is shortest; the target is confirmed when it has the lowest cost among the
    _____
    nodes.
    Hint

    A not-yet-processed node might still lead to a better route.

    Answer

    unexplored

    Explanation

    The algorithm continues after first reaching the target if another unexplored node has a lower cost and could lead to a shorter path.

  17. 17
    Dijkstra's algorithm guarantees a shortest path by exploring routes from the source in order of increasing
    _____
    .
    Hint

    This is the weighted counterpart of exploring breadth-first by step count.

    Answer

    cost

    Explanation

    Exploring in cost order means every lower-cost possibility is considered before a higher-cost route is finalized.

  18. 18
    When the target is finalized at cost 18, Dijkstra's algorithm has already examined all possible routes with cost less than
    _____
    .
    Hint

    The finalized cost is the boundary below which all alternatives have been explored.

    Answer

    18

    Explanation

    If the lowest-cost unexplored node has cost 18 and is the target, all routes with lower cost have already been explored.

  19. 19
    A-star uses the known cost to a node plus an estimate of its remaining distance to the target; that estimate is called a
    _____
    .
    Hint

    It guides the search toward promising locations without being the actual route cost.

    Answer

    heuristic

    Explanation

    A heuristic estimates how far a node is from the goal and is combined with the known cost to prioritize the search.

  20. 20
    A-star can estimate how close a node is to a destination by calculating the
    _____
    distance between their coordinates.
    Hint

    This is the direct geometric distance, not necessarily a route along roads.

    Answer

    straight line

    Explanation

    Using latitude and longitude, A-star can estimate the direct distance from a node to the target.

  21. 21
    In the three-dimensional visualization of A-star, nodes farther from the target are represented at a greater
    _____
    .
    Hint

    The visualization turns the heuristic value into a vertical dimension.

    Answer

    height

    Explanation

    The height represents straight-line distance to the target, making distant nodes appear higher in the visualization.

  22. 22
    The penalty in A-star discourages exploring nodes that move
    _____
    from the target.
    Hint

    Think about the direction opposite to making progress toward the goal.

    Answer

    farther

    Explanation

    A-star prioritizes nodes with lower estimated remaining distance, so it tends not to explore routes that head away from the target early.

  23. 23
    Increasing the steepness of A-star's heuristic makes the search spread out
    _____
    , because it focuses more aggressively toward the target.
    Hint

    A stronger directional preference narrows the exploration.

    Answer

    less

    Explanation

    A steeper heuristic penalizes moving away from the target more strongly, reducing how broadly the search expands.

  24. 24
    On the described Newark-to-zoo example, A-star explored about 7,000 nodes, compared with more than 65,000 for ordinary
    _____
    .
    Hint

    This search expands in increasing route-cost order without a target-directed heuristic.

    Answer

    Dijkstra's algorithm

    Explanation

    The heuristic guided A-star toward the zoo and greatly reduced the number of nodes explored in that example.

  25. 25
    In the worst case, A-star may explore as many nodes as
    _____
    .
    Hint

    This is the underlying shortest-path search against which A-star is compared.

    Answer

    Dijkstra

    Explanation

    A-star's guidance may fail to reduce exploration, and in that case it can check as many nodes as Dijkstra.

  26. 26
    For travel-time routing, dividing straight-line distance by the maximum allowed speed gives a heuristic estimate of the minimum
    _____
    .
    Hint

    It estimates how long a trip could take under an ideal speed assumption.

    Answer

    travel time

    Explanation

    The direct distance divided by the maximum speed provides a lower-bound estimate of how quickly the destination could be reached.

  27. 27
    The travel-time heuristic can be costly to evaluate because it involves a square root
    _____
    , which may make A-star less effective.
    Hint

    This refers to the mathematical operation's demand on processing.

    Answer

    computation

    Explanation

    The content notes that evaluating the heuristic involves a costly square root computation, reducing A-star's advantage for travel-time searches.

  28. 28
    A bidirectional Dijkstra search runs one search from the source and another from the
    _____
    .
    Hint

    The second search starts at the destination and proceeds backward.

    Answer

    target

    Explanation

    The two searches advance toward each other, one from each endpoint of the route.

  29. 29
    The advantage of bidirectional search is that its two search frontiers can
    _____
    before either search explores the whole region.
    Hint

    They advance toward each other until they share part of the searched area.

    Answer

    overlap

    Explanation

    When the frontiers meet, the route can be assembled without expanding as far as a single search would.

  30. 30
    For a route spanning distance R, the content explains that two searches can cover roughly half the area of one search by meeting around distance
    _____
    from each endpoint.
    Hint

    The two searches divide the approximate source-to-target distance into equal portions.

    Answer

    R over two

    Explanation

    Each search advances about half the distance before the frontiers meet, reducing the approximate explored area.

  31. 31
    In the Carnegie Hall to Wall Street example, bidirectional Dijkstra explored about 2,600 nodes instead of more than
    _____
    nodes for a one-way search.
    Hint

    This is the larger node count reported for the basic search.

    Answer

    7,200

    Explanation

    The two-frontier search substantially reduced node exploration in this example.

  32. 32
    Human route planning often follows a road hierarchy by traveling on local roads, then a highway, and finally
    _____
    roads near the destination.
    Hint

    These are the smaller-scale roads used near the beginning and end of a journey.

    Answer

    local

    Explanation

    A typical route moves from local roads to major roads and highways, then returns to local roads near the destination.

  33. 33
    Early in-car GPS systems used survey information to classify roads into categories such as express highways, major local roads, and
    _____
    roads.
    Hint

    This category describes small roads, such as those in residential areas.

    Answer

    narrow

    Explanation

    Road attributes collected by surveyors were used to assign roads to different hierarchy levels.

  34. 34
    Searching road hierarchies within candidate areas risks returning a non-shortest route if the candidate area is too
    _____
    .
    Hint

    A limited search region may exclude a better route.

    Answer

    small

    Explanation

    If the candidate area excludes the best local-road route, the search might return a longer highway route instead.

  35. 35
    Nested dissection assigns high importance to small sets of nodes that roughly split a graph into two
    _____
    .
    Hint

    A good separator divides the graph into similarly sized parts.

    Answer

    halves

    Explanation

    The method recursively finds small cuts that divide the graph into roughly equal subsets and ranks their nodes highly.

  36. 36
    A bridge intersection connecting two similarly sized towns can be important because many shortest paths between the towns must pass through that
    _____
    .
    Hint

    It is the bottleneck location that connects the two sides.

    Answer

    intersection

    Explanation

    When trips between two regions depend on a shared connection, that connection lies on many shortest paths.

  37. 37
    In the North American network example, the highest-ranked small cut contained
    _____
    nodes linking east-west travel across a major bottleneck region.
    Hint

    This is the number of nodes identified in the example.

    Answer

    102

    Explanation

    Those 102 nodes roughly split the network and serve as important connections for east-to-west routes.

  38. 38
    The recursive process of finding small graph cuts and ranking their nodes is called
    _____
    .
    Hint

    Its name describes repeatedly dividing a graph into nested parts.

    Answer

    nested dissection

    Explanation

    Nested dissection recursively finds separators and assigns node ranks to build a hierarchy.

  39. 39
    In a contraction hierarchy, the node with a higher rank is positioned higher in the search
    _____
    .
    Hint

    The ranking establishes which direction searches are allowed to move.

    Answer

    hierarchy

    Explanation

    The ranks form levels, and upward searches move from lower-ranked nodes toward higher-ranked ones.

  40. 40
    To limit the search space in a contraction hierarchy, each direction of a bidirectional search is restricted to moving
    _____
    in rank.
    Hint

    Searches progress toward the higher levels of the ordering.

    Answer

    up

    Explanation

    Restricting each search to higher-ranked nodes reduces the number of nodes considered.

  41. 41
    If a search could only proceed upward from the source and not also from the target, it could get stuck; this is why contraction hierarchies use
    _____
    search.
    Hint

    Both endpoints need their own upward search.

    Answer

    bi-directional

    Explanation

    Searching upward from both endpoints lets the searches meet near the top of the hierarchy.

  42. 42
    A lower triangle occurs when a low-ranked node connects to at least two
    _____
    nodes.
    Hint

    These are the nodes above it in the ordering.

    Answer

    higher-ranked

    Explanation

    The lower-ranked node may be part of the shortest route between the higher-ranked neighbors.

  43. 43
    When contracting a lower-ranked node that connects two higher-ranked nodes, preprocessing may add a
    _____
    between those higher nodes.
    Hint

    It preserves a route that would otherwise pass through a contracted node.

    Answer

    shortcut

    Explanation

    A shortcut records the route through the lower-ranked node so that an upward search can still account for it.

  44. 44
    If a shortcut could represent several possible routes, its weight should reflect the route with the
    _____
    cost.
    Hint

    The shortcut must preserve the best option among the alternatives.

    Answer

    minimum

    Explanation

    When multiple paths are represented, the shortcut keeps the least-cost path so that shortest routes remain available.

  45. 45
    A shortcut is not necessarily a physical road; it is a bookkeeping edge used to preserve
    _____
    paths.
    Hint

    It ensures the search can still account for optimal routes through contracted nodes.

    Answer

    shortest

    Explanation

    Shortcuts represent the cost of paths in the original graph even when there is no direct road between their endpoints.

  46. 46
    Adding shortcuts from the bottom of the hierarchy upward prevents shortest paths through lower-ranked nodes from being
    _____
    .
    Hint

    The preprocessing step preserves paths that an upward-only search would not otherwise see.

    Answer

    missed

    Explanation

    Shortcuts are added when needed so that restricting the query search to higher-ranked nodes does not eliminate optimal routes.

  47. 47
    Different node rankings can still produce correct shortest paths when the necessary
    _____
    are added.
    Hint

    These preserve routes that a particular ranking might otherwise hide.

    Answer

    shortcuts

    Explanation

    The shortcut preprocessing can compensate for different valid orderings, although the efficiency may vary.

  48. 48
    A poor node ranking may make queries slow or cause the graph to grow rapidly because it requires too many
    _____
    .
    Hint

    These extra edges increase the size of the preprocessed graph.

    Answer

    shortcuts

    Explanation

    Although many rankings can preserve correctness, a bad ordering can create an inefficient number of shortcuts or leave queries with extensive searches.

  49. 49
    Choosing a useful node ordering involves a trade-off between the number of shortcuts and how much faster the
    _____
    becomes.
    Hint

    This is the actual route search performed after preprocessing.

    Answer

    query

    Explanation

    A good hierarchy balances preprocessing and graph size against the speed of later route queries.

  50. 50
    The customizable contraction hierarchy separates preprocessing into node ordering and shortcut creation, shortcut weight calculation, and the final
    _____
    .
    Hint

    This is the phase that finds a route for a particular request.

    Answer

    search

    Explanation

    Its three phases are building the hierarchy, assigning shortcut weights, and running the route query.

  51. 51
    The expensive first phase of a customizable contraction hierarchy needs to be repeated mainly when the
    _____
    itself changes, such as when a bridge is added or a road closes.
    Hint

    This is the network structure that the hierarchy represents.

    Answer

    graph

    Explanation

    Node ordering and shortcut creation depend on the graph's structure, so structural road-network changes can require this phase again.

  52. 52
    When traffic conditions change but the road network structure stays the same, the customizable contraction hierarchy must recalculate shortcut
    _____
    .
    Hint

    These encode the costs used when comparing routes.

    Answer

    weights

    Explanation

    Traffic updates change route costs, so the weights assigned to shortcuts need to be recalculated.

  53. 53
    On the North American network, the reported customizable contraction hierarchy query took about 200
    _____
    .
    Hint

    A microsecond is one millionth of a second.

    Answer

    microseconds

    Explanation

    The experiment reported a query runtime of around 200 microseconds, much faster than the several seconds taken by a well-tuned Dijkstra search.

  54. 54
    In the reported experiment, the customizable contraction hierarchy was about 35,000 times
    _____
    than Dijkstra's algorithm.
    Hint

    The query took far less time than the comparison search.

    Answer

    faster

    Explanation

    A query runtime around 200 microseconds was reported as roughly 35,000 times faster than Dijkstra's in that experiment.

  55. 55
    The customizable contraction hierarchy explored an average of about
    _____
    nodes per query in the reported North American experiment.
    Hint

    This is a small fraction of the network's more than 64 million nodes.

    Answer

    1,450

    Explanation

    By using the hierarchy and shortcuts, the search only needed to explore about 1,450 nodes on average.

  56. 56
    Compared with Dijkstra's search space, the reported contraction hierarchy reduced the number of explored nodes by a factor of about
    _____
    .
    Hint

    The reduction was tens of thousands to one.

    Answer

    44,000

    Explanation

    The experiment reported a search-space reduction of approximately 44,000 times.

  57. 57
    In a long route query, contraction hierarchy searches concentrate near the source and target, then examine important
    _____
    farther along the route.
    Hint

    These are high-ranking separators that divide the graph.

    Answer

    cuts

    Explanation

    Once the searches reach higher levels, they need to consider only important cuts such as major bottlenecks across the network.

  58. 58
    The core search used by contraction hierarchies remains based on
    _____
    's algorithm.
    Hint

    This classic algorithm explores nodes in increasing order of path cost.

    Answer

    Dijkstra

    Explanation

    Contraction hierarchies accelerate queries through preprocessing and restricted bidirectional searches, while retaining Dijkstra-style search as their core.

  59. 59
    Dijkstra argued that simplicity is a prerequisite for
    _____
    , which is why avoiding unnecessary complexity matters in software design.
    Hint

    This quality means a system can be depended on to work correctly.

    Answer

    reliability

    Explanation

    The content connects Dijkstra's preference for simple designs with the goal of making software dependable.

1 of 59
Question 1 of 59

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent