Recall & Review
beginner
What is a key limitation of trees that graphs overcome?
Trees cannot model relationships where nodes have multiple parents or cycles. Graphs allow multiple connections and cycles, representing more complex relationships.
Click to reveal answer
beginner
Why do graphs exist as a data structure?
Graphs exist to represent complex relationships between objects where connections are not strictly hierarchical, such as social networks, road maps, or web links.
Click to reveal answer
beginner
Can a tree have cycles? Why or why not?
No, a tree cannot have cycles because it is a hierarchical structure with a single path between any two nodes. Cycles would break this hierarchy.
Click to reveal answer
beginner
Give an example of a real-life situation where a graph is needed instead of a tree.
A social network where people can be friends with multiple others, including mutual friendships, requires a graph because it has cycles and multiple connections.
Click to reveal answer
beginner
What does it mean when we say graphs can model 'many-to-many' relationships?
It means nodes can connect to multiple other nodes in any direction, unlike trees where each child has only one parent.
Click to reveal answer
Which data structure can represent cycles and multiple parents for nodes?
✗ Incorrect
Graphs can represent cycles and multiple parents, while trees cannot.
Why can't trees model social networks well?
✗ Incorrect
Social networks have cycles and multiple connections, which trees cannot represent.
What kind of relationship does a tree represent?
✗ Incorrect
Trees represent hierarchical relationships where each child has exactly one parent.
Which of these is an example where graphs are necessary?
✗ Incorrect
Road maps have intersections and cycles, which require graphs to model.
What is a cycle in graph terms?
✗ Incorrect
A cycle is a path where you can start at a node and return to it by following edges.
Explain why trees cannot model many-to-many relationships and how graphs solve this problem.
Think about how connections between nodes differ in trees and graphs.
You got /4 concepts.
Describe a real-world example where using a graph is necessary instead of a tree and why.
Consider social networks, maps, or web links.
You got /3 concepts.