0% found this document useful (0 votes)
40 views15 pages

Understanding Computational Structures

Chapter 4 discusses computational structures, focusing on primitive structures like lists, stacks, queues, trees, and graphs. It covers their definitions, properties, basic operations, and real-world applications, emphasizing the importance of choosing suitable structures based on problem requirements. The chapter also highlights the principles of LIFO and FIFO in stacks and queues, and contrasts trees and graphs in terms of their hierarchical and network representations.

Uploaded by

Mirza Imran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views15 pages

Understanding Computational Structures

Chapter 4 discusses computational structures, focusing on primitive structures like lists, stacks, queues, trees, and graphs. It covers their definitions, properties, basic operations, and real-world applications, emphasizing the importance of choosing suitable structures based on problem requirements. The chapter also highlights the principles of LIFO and FIFO in stacks and queues, and contrasts trees and graphs in terms of their hierarchical and network representations.

Uploaded by

Mirza Imran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CHAPTER # 4: COMPUTATIONAL STRUCTURES COMPUTER PART-I

Chapter No. 4
COMPUTATIONAL STRUCTURES
STUDENT LEARNING OUTCOMES [C-11-B-01 to C-11-B-18]
 Define and explain the purpose of primitive computational structures, including lists, stacks,
queues, tress, and graphs. (Understanding)
 Identify and describe the characteristics and properties of different computational structures.
(Understanding)
 Perform basic operations such as insertion, deletion traversal, and searching on various
computational structures. (Understanding)
 Understand and implement LIFO (last in first out), FIFO (first in first out) principle in stack and
queues respectively. (Understanding)
 Compare and contrast different types of trees and graph, and apply appropriate operations to
them. (Understanding)
 Analyze and choose the most suitable computational structures based on problems requirements,
data organization, and performance consideration . (Understanding)
 Apply computational structures in real world scenario, including data organization, task scheduling
and network modeling. (Understanding)
 Combine different computational structures to solve complex problems and enhance functionality.
(Understanding)

1
CHAPTER # 4: COMPUTATIONAL STRUCTURES COMPUTER PART-I

2
CHAPTER # 4: COMPUTATIONAL STRUCTURES COMPUTER PART-I

3
CHAPTER # 4: COMPUTATIONAL STRUCTURES COMPUTER PART-I

 Index-Based Access: Every item in a list has


Computational structure a position, called an index. The first item has
an index of 0, the second item has an index
A computational structure in Python is a way to
of 1, and so on. You can use these indexes
organize and handle data or instructions so that to get specific items from the list.
the computer can solve problems or perform  Ordered Collection: The order in which you
tasks. add items to a list is preserved. This means
that if you add an item first, it will stay in
1.1 Primitive Computational that position unless you change it.
structure  Heterogeneous Elements: A list can hold
In our daily lives, we often need to organize different types of items together. For
and manage data. For instance, think about example, you can have numbers, words,
the way you store your contacts on your and even other lists all in one list.
 Mutability: Lists are changeable, meaning
phone, keep a to-do list, or even stack plates
you can update, add, or remove items from
in your kitchen. Similarly, in the world of
the list after you create it.
computers, we need to organize and manage  Supports Duplicates: A list can contain the
data. Computational structures help us do same item more than once. This means you
that. can repeat values in the list if needed.
 Lists [Link] List Operations:
In Python, lists allow us to store multiple items in a Let's explore some common operations we can
single variable. perform on a list using real-world examples and
Example, if you need to store the ages of all the Python code:
students in a class, you can do this task using a list 1. Insertion: Adding a new item to your list is
 List Creation like adding a new task to your to-do list.
In Python, Lists are created using square brackets '[]', You can insert an item at different
with each item separated by a comma (,). Here's how positions in the list. Here are several ways
to do this:
party_list = ["Buy drinks”, “Buy decorations", "Buy snacks", “Buy cold drinks "] party_list.insert (0 ’ ,
# Create a list of items
“Invite friends”) # add Invite friends at start print(party_list)
items= [ "Decorations" , "Snacks" , “cold drinks", "Plates", ”Balloon”] # Print the list
Output: ["Buy drinks, “Buy decorations", "Buy snacks", “Buy cold drinks "]
print(items)
you can create and work with a list in Python. a. Inserting at a Specific Position: You can
Example: insert an item at any position in the list
Description of above example: using the 'insertf()' function.

[Link] List Properties


2. Deletion: Removing an item from
List has following properties: your list is like crossing off a task
“Items” is the name of the list.
The items inside the list are “Decorations”, “Snacks”, “Cold drinks”, “Plates”, and “Balloons”.Each
item is enclosed in quotes (for text) and separated by a comma. The print () function is used to
display the list.
 Dynamic Size: A list in Python can change you've completed. You can remove
its size. You can add new items to the list or items in various ways
remove items without any problem. The list a. Removing by Value: Use the 'remove()'
will automatically adjust to fit the changes. function to delete the first occurrence of a
specific item.

4
CHAPTER # 4: COMPUTATIONAL STRUCTURES COMPUTER PART-I

party_list = ["Invite friends ","Buy decorations”, "Buy snacks”, "Buy cold drinks"] party_list.remove ("Buy
snacks”) # Removes ’Buy snacks ’ from the list
print(party_list)
Output: [’Invite friends’, ’Buy decorations’, ’Buy cold drinks ’]

b. Removing by Index: Use the 'popO' searching data. Algorithms like


function to remove an item at a bubble sort, selection sort, and
specific index. binary search often operate on lists

party_list = ["Invite friends ", "Buy decorations", "Buy cold drinks " ] party_list.pop (0)
# Removes the item at index 0
print(party_list)
Output: [’Buy decorations’, ’Buy cold drinks’]

3. Searching: Finding an item in a list is similar to arrange or find data efficiently.


to looking for a specific task in your to-do  Function Arguments: Lists are
list. You can search for an item using often used to pass multiple
different function. Use the 'in' keyword to arguments to functions, enabling
check if an item exists in the list. flexible and efficient handling of

party_list = ["Invite friends", "Buy decorations", "Buy cold drinks"] if "Buy cold
drinks" in party_list:
print("Buy cold drinks is on the list.") # Prints if 'Buy cold drinks' is found
else:
print("Buy cold drinks is not on the list.") Output: Buy cold drinks is on the list.
inputs in programming.
1.1.1.1Applications of Lists
 Data Storage and Manipulation:
Lists are commonly used to store
and manage collections of data,
such as records, entries, or values.
They allow for easy insertion,
deletion, and access to elements.
 Stack and Queue
Implementations: Lists can be
used to implement stack (LIFO)
and queue (FIFO) data
structures, which are
fundamental for various 1.1.2 Stacks
algorithms and tasks in A stack is a simple data structure where you
computing. can only add or remove items from one end,
 Sorting and Searching known as the “top”. Both insertion and
Algorithms: Lists are frequently
deletion of elements occur at this top end. A
used in algorithms for sorting and
stack operates on the Last-In, First-Out (LIFO)

5
CHAPTER # 4: COMPUTATIONAL STRUCTURES COMPUTER PART-I

principle, meaning that the most recently to remove the element from the top
added element is the first one to be removed. of the stack.
[Link] Properties of Stack
 LIFO Principle: A stack works
by the Last-In, First-Out rule. The Description of above code:
last item added is the first one  The code creates an empty stack to hold
removed. books
 Single Access Point: You can  It then adds three books (“Book A”, “Book B”,
only add or remove items from the and “Book C”) one by one to the top of the
top of the stack. stack.
 Order Preservation: The order in  Finally, it removes the top book “Book
which you add items is preserved, with C” from the stack, showing how the
the last item added being the first to last book added is the first one taken
leave. off.
 Size Flexibility: A stack can either
1.1.2 Queues
have a fixed size or grow as needed.
Sequential Access: You can only access A queue is like a line in front of the a bank or
items in the order they were added, a ticket counter. The first person to get in line
starting from the top. is the first person to be served. In a computer,
a queue works the same way. It keeps track of
things so that the first item added is the first
one to be taken out. Just like in a bank line,
you add things to the back and remove them
from the front, following the FIFO (First-In,
First-Out) principle, as shown in Figure.

[Link] Stack Operations:


There are two basic operations in a stack:
 Push Operation: Push means
adding an item to the top of the
stack. In Python, we use list data
structure to implement the stack.
Therefore, we use the list function
append () to add an element to the
Queue of persons in front of the bank
top of the stack.
 Pop Operation: Pop means
removing the item from the top of [Link] Queue Operations
the stack. We use list pop() function  Enqueue (Add an Item): This is like

Example:
stack = []
6
Push operation - add item to the top of the stack
[Link]('A')
[Link]('B')
print("Stack after pushes:", stack) Output: ['A', 'B']
CHAPTER # 4: COMPUTATIONAL STRUCTURES COMPUTER PART-I

adding a person to the end of the data like file systems, organizational
line. In a queue, you add items to charts, and more.
the back.
Each node can have zero or more
 Dequeue (Remove an Item): This is
children, but only one parent (except the
like serving the person at the front
of the line. In a queue, you take root, which has none).
Common types of trees include binary
trees, where each node has at most two
items out from the front. children.
operations Example:
Additional might include checking
if the queue is empty, retrieving the  A family tree is a classic example
element at the front without of a tree structure in real life.
removing it, and determining the  It shows relationships between
size of the queue. family members across
Example: generations.
 The root node could be the oldest
Example of Enqueue and Dequeue operations in Pythonknown
using ancestor.
a list to simulate
a queue:  Each person (node) can have
children (child nodes), representing
Queue using a Python list the next generation.
 Each node (person) has one parent
queue = []
(except the root) and can have
# Enqueue operation - add element at the end
multiple children.
[Link]('A')
[Link]('B')
[Link]('C') Important! The concept of tree data structur
print("Queue after enqueues:", queue) scientist
Output: ['A', 'B', 'C'] John McCarthy in 1960.

# Dequeue operation - remove element from the front


item = [Link](0)
print("Dequeued item:", item) Output: 'A'
print("Queue after dequeue:", queue) Output: ['B', 'C']

 Enqueue: append() adds elements at the end.


 Dequeue: pop(0) removes the first element.

1.1.3 Trees
A tree is a data structure that consists [Link] Properties of Trees
of nodes connected in a hierarchy.  Root Node: The root is the very
It starts from a root node and branches first or top node in a tree, like the
out to child nodes, forming a parent- main folder in a computer where all
other folders and files are
child relationship.
contained.
Trees are used to represent hierarchical

7
CHAPTER # 4: COMPUTATIONAL STRUCTURES COMPUTER PART-I

 Edges and Nodes: Nodes are the each connection is a relationship


individual elements in the tree, and between two vertices.
they are  These vertices can represent
connected by lines called edges. A anything, like cities, people, or even
node without any child nodes is called a abstract concepts, and the
leaf, similar to a file edges represent the relationships
in a folder that doesn't contain any or pathways between them.
other files.
 Height: The height of a tree is the
longest path from the root node down
to the farthest leaf. It tells us how deep
or tall the tree is. Example: : In a social network, each person
 Balanced Trees: A tree is considered can be connected to many others, forming a
balanced if the branches on the left and graph. There is no single starting point, and
right sides are nearly the same height. people (vertices) can have multiple
[Link] Applications of Trees connections (edges) that do not follow a strict
parent-child relationship like in a tree.
 File Systems: Pre-order tree traversal is Difference between Tree and Graph:
useful for creating backups of file Tree Graph
systems. By visiting the root first and A Tree is A Graph does not
then recursively backing up each hierarchical, necessarily have a
directory, it ensures that directories are meaning it has a hierarchy or a root.
backed up before their contents. single root node
 File System Deletion: In file systems, from which all other
Post-order traversal ensures that files nodes branch out. In
and directories are deleted in the contrast.
correct order—by first deleting all sub In a Tree, there is In a Graph, there
directories and files before deleting the exactly one path can be multiple
parent directory. between any two paths between
 Hierarchical Data Representation: nodes, ensuring no nodes, and cycles
Trees are used in representing data cycles (loops). are allowed.
with a clear hierarchical relationship, Trees are often used Graphs are more
such as organizational charts and to represent flexible and can
family trees. structured data like represent a
 Decision Making: Trees, such as family trees or broader range of
decision trees, are used in algorithms organizational connections, such
to make decisions based on various charts. as networks, web
conditions and outcomes. links, or transport
1.1.4 Introduction to Graphs systems.

 A Graph is a data structure that [Link] Characteristics of Graphs


consists of a set of vertices (or Graphs have several defining features that
nodes) connected by edges. help us understand and use them effectively:
 Graphs are used to represent · Vertices (Nodes): These are the individual
networks of connections, where points or entities in a graph.

8
CHAPTER # 4: COMPUTATIONAL STRUCTURES COMPUTER PART-I

Example: in a social network graph, each means they go from one vertex to another in a
user is represented by a vertex. specific way.
· Edges (Links): These are the connections Example: Consider the above graph: If you want
between vertices. to travel from city A to city B, you can only go in
Example, in a transport system graph, each the direction permitted by the city's sign. If
road connecting two cities is an edge. there's no one-way street going from city A to
[Link] Properties of Graphs city B, you cannot travel directly from city A to B.
Graphs also have specific details that describe Undirected Graphs:
their structure: In an undirected graph, edges do not have a
direction. This means that if there is a connection
Degree Weight Direction between two vertices, you can travel in both
This is the : In some Edges can directions.
number of graphs, be either
edges edges directed or
connected have undirected.
to a vertex. weights Directed
For that edges have
instance, if represent a one-way
a city is values like connection,
connected distances meaning a
to three or costs. road from
other For city A to
cities, the example, if city B does
degree of a road not
that city's between necessarily
vertex is 3. two cities have a
is 50 return road
kilometers from B to A.
long, its Undirected
edge edges
might represent a
have a two-way
weight of connection.
50.
[Link] Types of Graphs
Graphs can be classified into several types based
on their structure and properties. The main types
ofgraphs are directed, undirected, and
weighted. Each type has its own characteristics ,
which can be better understood through simple
examples.
 Directed Graphs:
In a directed graph, edges have a direction, which

9
CHAPTER # 4: COMPUTATIONAL STRUCTURES COMPUTER PART-I

Example: Consider the below graph: if Person A d) Returns the length of the list.
is friends with Person B, then Person B is also 3. Which operation removes an item from

friends with Person A. There is no restriction on the top of the stack?


the direction of the friendship, so you can move a) Push b) Pop
freely between friends. c ) Peek d)
Undirected Graph Add
4. When converting an infix expression to
Weighted Graphs: postfix notation, what does a stack help
In a weighted graph, each edge has a weight or to manage?
cost associated with it. This weight represents the a) Order of operands b) Priority of
distance, time, or cost required to travel from one operators c) Parentheses
vertex to another. d)Both b and c
Example: Imagine a map of a city where each
road has a different distance or travel time. If you
want to travel from one landmark to another, the 5. Which operation is used to add an item
map provides the distance or travel time for each to a queue?
road. This information helps you determine the a) Dequeue b) Peek
shortest or quickest route between landmarks. c) Enqueue
d) Remove
6. In the context of Breadth-First
Search (BFS) in a tree, which

Exercise operation of queue is used to visit


nodes level by level?
a) Adding notes to the end of a stack
Multiple Choice Questions: Choose the correct b) Removing nodes from the end
option. of a list
1. The function used to add an item at the c) Enqueueing nodes to a queue
end of a list in Python: d) Dequeueing nodes from a
a) insert( ) b) append( ) stack
c) remove( ) d) pop( ) 7. Which of the following tree traversals
2. What does the 'in' keyword do when visits the root node before its children?
used with python list? a) In-order b) pre-order
a) Adds an item to the list. c) post-order
b) Removes an item from the list. d) level order
c) Checks if an item exists in the 8. Which of the following is true about the
list. height of a tree?
a) The height is the number of

10
CHAPTER # 4: COMPUTATIONAL STRUCTURES COMPUTER PART-I

edges from the root to the Answer: When two variables reference
deepest node the same list in Python, they both point
b) The height is the number of nodes to the same object in memory. This
from the root to the deepest node means that changes made through one
c) The height is the number of variable will affect the other, which can
children of the root node lead to unexpected behavior or bugs,
d) The height is always equal to the especially if you're not intentionally
number of nodes in the tree sharing data.
9. Which graph traversal explores all
immediate neighbors of a vertex
before moving to the next level?
a) Depth-First Search (DFS)
b) Breadth-First Search (BFS)
Example: list1 = [1, 2, 3]
c) Depth-Limited Search (DLS)
list2 = list1 #Both variables refer to
d) Iterative Deepening Search (IDS)
10. For which scenario would a graph data the same list
structure be most appropriate? [Link](4)
a) Managing a to-do list print(list1) Output: [1, 2, 3, 4]
b) Modeling a line of customers in a print(list2) Output: [1, 2, 3, 4]
store 3. Define a stack and explain the Last-In,
c) Representing connections in a First-Out (LIFO) principle.
social network Answer: A stack is a simple data structure
d) None of these where you can only add or remove items
from one end, known as the “top”. Both
Short Questions: insertion and deletion of elements occur at
1. Explain how the ' extend() ' function this top end. A stack operates on the Last-In,
works in python lists. Provide an First-Out (LIFO) principle, meaning that the
example. most recently added element is the first one
Answer: In Python, extend() method is used to be removed.
to add items from one list to the end of 4. How does the stack help in
another list. This method modifies the balancing parentheses in an
original list by appending all items from the expression? Describe the process.
given iterable. Answer: The stack helps balance
Let’s look at a simple example of parentheses by keeping track of
the extend() method. opening parentheses encountered.
a = [1, 2, 3] When a closing parenthesis is met, it
b = [4, 5] checks if the top of the stack contains a
Using extend() to add elements of b to a
matching opening parenthesis. If it
[Link](b)
does, they cancel out (pop the stack). If
print(a)
Output: [1,2,3,4,5]
not, or if the stack is empty, the
2. Explain the potential issues which parentheses are unbalanced. If the stack
could arise when two variables is empty at the end, the parentheses are
reference the same list in a balanced.
program? Provide an example. 5. Differentiate between the Enqueue and

11
CHAPTER # 4: COMPUTATIONAL STRUCTURES COMPUTER PART-I

Dequeue operations of queue. Example: queue = [] queue = [10, 20,


Enqueue Dequeue [Link](10) 30]
operations operations Enqueue 10 item =
When a new task As soon as the [Link](20) [Link](0)
arrives (for example, computer is ready Enqueue 20 Dequeue
when you press to process a task, it print(queue) operation
"Print" on your removes the first Output: [10, 20] removes 10
computer), it is task from the front print(item)
added to the end of of the queue, just Output: 10
the queue, similar like the doctor print(queue)
to how a new calling in the next Output: [20, 30]
patient is added to patient from the
the end of the waiting list. This Long Questions
waiting list. This process of 1. Discuss the dynamic size
process of adding a removing a task property of lists in Python.
task to the queue is from the queue for How does this property make
called enqueue. processing is called
lists more flexible?
dequeue.
Answer: Dynamic Size Property of
Lists in Python and Its Flexibility
6. Name two basic operations performed
Python lists have a dynamic size, which
on stack. means that unlike arrays in some other
Answer: Two basic operations performed programming languages, you don’t need
on a stack are: to define the size of a list at the time of
 Push: Adds an element to the top of the its creation. You can add or remove
stack. elements freely during the execution of
the program, and the list will
 Pop: Removes the top element from the
automatically adjust its size to
stack. accommodate these changes.
 These operations follow the Last In, First How Python Implements Dynamic Size:
Out (LIFO) principle.
 When you add elements using
7. What is difference between enqueue ()
methods like append() or insert(), Python
and dequeue.
internally allocates more memory to
Enqueue Dequeue hold the new elements.
Enqueue is the Dequeue is the  If the current allocated memory is full,
operation of adding operation of Python creates a larger space and
an element to the removing an copies the existing elements to this
end (rear) of a element from the new space. This process is mostly
queue data structure. front (beginning) transparent to the programmer.
In Python, you can of a queue data  When elements are removed using
perform enqueue on structure. In remove() or pop(), the list size reduces,
a list using the Python, you can
and Python may free some memory as
append() method. perform dequeue
needed.
on a list using the
pop(0) method.

12
CHAPTER # 4: COMPUTATIONAL STRUCTURES COMPUTER PART-I

Why Is This Property Important?  When you need a plate, you take the
topmost plate first (pop).
 Flexibility in Usage: You don’t have to
know the number of elements beforehand.  You cannot remove a plate from the
This makes lists very useful when working middle or bottom without taking off the
with data that can change size plates above it.
dynamically, such as user input, data
processing, or results of computations.
 Efficient Memory Management: Python
optimizes memory allocation behind the Python code:
scenes, so the list grows and shrinks as
required without wasting too much stack = []
memory.
 Ease of Programming: Programmers can # Push operation
focus more on the logic rather than [Link]('Plate 1')
managing memory or resizing arrays
[Link]('Plate 2')
manually, which reduces complexity and
print("Stack after pushes:", stack)
chances of errors.
 Supports Various Operations:
Operations like insertion, deletion, and # Pop operation
appending become simpler and more top_item = [Link]()
natural, which is not always possible in print("Popped item:", top_item)
fixed-size data structures. print("Stack after pop:", stack)
2. Explain the operations on stack
with real life example and
3. Write, a simple program to
python code.
implement a queue (insertion and
Answer: A stack is a data structure that follows deletion).
the Last In, First Out (LIFO) principle. The two
main operations on a stack are: from collections import deque

1. Push: Add an element to the top of the


# Create a queue using deque
stack.
queue = deque()
2. Pop: Remove the element from the top of
the stack. # Enqueue operation (insertion)
[Link]('A')
Other common operations include peek (view the
[Link]('B')
top element without removing it) and isEmpty [Link]('C')
(check if the stack is empty). print("Queue after enqueues:", list(queue)) # Outp
Real-Life Example: Stack of Plates
 Imagine a stack of plates in your kitchen. # Dequeue operation (deletion)
item = [Link]()
 You add a plate on top of the stack (push). print("Dequeued item:", item) Outpu
print("Queue after dequeue:", list(queue)) Outpu

deque provides O(1) time complexity for both enqu


13 implementation.
CHAPTER # 4: COMPUTATIONAL STRUCTURES COMPUTER PART-I

4. Define Tree and explain its properties


Answer: A tree is a data structure that
consists of nodes connected in a
hierarchy.
It starts from a root node and branches
out to child nodes, forming a parent-
child relationship.
Trees are used to represent hierarchical Properties of Trees
data like file systems, organizational  Root Node: The root is the very
charts, and more. first or top node in a tree, like
Each node can have zero or more the main folder in a computer
children, but only one parent (except the where all other folders and files
root, which has none). are contained.
 Edges and Nodes: Nodes are the
Common types of trees include binary
individual elements in the tree, and
trees, where each node has at most two they are connected by lines called
children. edges. A node without any child
Example: nodes is called a leaf, similar to a file
 A family tree is a classic example in a folder that doesn't contain any
of a tree structure in real life. other files.
 It shows relationships between  Height: The height of a tree is the
longest path from the root node
family members across
down to the farthest leaf. It tells us
generations. how deep or tall the tree is.
 The root node could be the oldest  Balanced Trees: A tree is considered
known ancestor. balanced if the branches on the left
 Each person (node) can have and right sides are nearly the same
children (child nodes), representing height.
the next generation. 5. What is graph? Explain differences
 Each node (person) has one parent between directed and undirected
(except the root) and can have
graph.
multiple children.
 Answer: A Graph is a data structure
that consists of a set of vertices (or
nodes) connected by edges.
 Graphs are used to represent
networks of connections, where
each connection is a relationship
between two vertices.
 These vertices can represent

14
CHAPTER # 4: COMPUTATIONAL STRUCTURES COMPUTER PART-I

anything, like cities, people, or even to travel from city A to city B, you can only go in
abstract concepts, and the edges the direction permitted by the city's sign. If
represent the relationships or there's no one-way street going from city A to
pathways between them. city B, you cannot travel directly from city A to B.
 Example: : In a social network, each Undirected Graphs:
person can be connected to many In an undirected graph, edges do not have a
others, forming a graph. direction. This means that if there is a connection
 There is no single starting point, between two vertices, you can travel in both
and people (vertices) can have directions.
multiple connections (edges) that do Example: Consider the below graph: if Person A
not follow a strict parent-child is friends with Person B, then Person B is also
relationship like in a tree. friends with Person A. There is no restriction on
the direction of the friendship, so you can move
freely between friends.
Undirected Graph
 Directed Graphs:
In a directed graph, edges have a direction, which

means they go from one vertex to another in a


specific way.

Directed Graph
Example: Consider the above graph: If you want

15

You might also like