0
0
DSA Typescriptprogramming~5 mins

Why Graphs Exist and What Trees Cannot Model in DSA Typescript - Quick Recap

Choose your learning style9 modes available
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?
AGraph
BTree
CArray
DStack
Why can't trees model social networks well?
ABecause trees use too much memory
BBecause trees are too slow
CBecause trees do not allow cycles or multiple parents
DBecause trees only store numbers
What kind of relationship does a tree represent?
AHierarchical with one parent per child
BMany-to-many
CRandom connections
DCyclic connections
Which of these is an example where graphs are necessary?
ACompany organizational chart
BRoad maps with intersections
CFile directory structure
DBinary search tree
What is a cycle in graph terms?
AA disconnected node
BA node with no children
CA node with multiple parents
DA path that starts and ends at the same node
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.