0
0
Data Structures Theoryknowledge~10 mins

Why shortest path algorithms power navigation in Data Structures Theory - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to find the shortest path distance from the start node.

Data Structures Theory
distance = graph.get([1], float('inf'))
Drag options to blanks, or click blank then click option'
Aneighbor
Bend_node
Cstart_node
Dpath
Attempts:
3 left
💡 Hint
Common Mistakes
Using the end node instead of the start node for initial distance.
Using a neighbor node which is not the starting point.
2fill in blank
medium

Complete the code to update the shortest distance if a better path is found.

Data Structures Theory
if new_distance [1] distances[neighbor]:
Drag options to blanks, or click blank then click option'
A<
B>
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' which would update for longer paths.
Using '==' which does not help find shorter paths.
3fill in blank
hard

Fix the error in the code that selects the next node with the smallest distance.

Data Structures Theory
current_node = min(unvisited_nodes, key=lambda node: [1][node])
Drag options to blanks, or click blank then click option'
Adistances
Bgraph
Cneighbors
Dpaths
Attempts:
3 left
💡 Hint
Common Mistakes
Using the graph structure instead of distances.
Using neighbors or paths which do not hold distance values.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps nodes to their distances if the distance is less than 10.

Data Structures Theory
{node: [1] for node, dist in distances.items() if dist [2] 10}
Drag options to blanks, or click blank then click option'
Adist
B>
C<
Dnode
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' instead of '<' to filter distances.
Mapping nodes to themselves instead of their distances.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase node names to their distances if the distance is greater than 5.

Data Structures Theory
{ [1]: [2] for [3], dist in distances.items() if dist > 5 }
Drag options to blanks, or click blank then click option'
Anode.upper()
Bdist
Cnode
Ddistance
Attempts:
3 left
💡 Hint
Common Mistakes
Using the original node name instead of uppercase for keys.
Using incorrect variable names in the loop.