Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
159 views16 pages

Data Structures & Algorithms: Summative

The document is a lab assignment on data structures and algorithms topics including trees, binary trees, graphs, and sorting algorithms. It contains source code implementations of an adjacency list and adjacency matrix to represent graphs, along with sample outputs. It also includes questions about generating an adjacency list for a sample graph, comparing adjacency lists and matrices, and giving examples of when breadth-first search and depth-first search are used.

Uploaded by

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

Data Structures & Algorithms: Summative

The document is a lab assignment on data structures and algorithms topics including trees, binary trees, graphs, and sorting algorithms. It contains source code implementations of an adjacency list and adjacency matrix to represent graphs, along with sample outputs. It also includes questions about generating an adjacency list for a sample graph, comparing adjacency lists and matrices, and giving examples of when breadth-first search and depth-first search are used.

Uploaded by

Bella Choi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

DATA STRUCTURES &

ALGORITHMS

SUMMATIVE

3
[M7_M8_M9-SUMMATIVE3] - ANSWER SHEET
TREE & BINARY TREE / GRAPH / SORTING
ALGORITHMS

Group Name:
Ekey
Name Role
Ascaño, Leigh Reign Project Leader -
Members: Coding
Marqueses, Katrina Member 1 - Coding
Cyndee

Data Structures & Algorithms (LAB) Page 1 of 16


Velasco, Antonius Member 2 - Coding
Charlemagne

Section:

I. PROGRAM SOLUTION (60 POINTS)

• REQUIREMENTS:
o You are required to use Codio. Teacher will check actual C++ project in Codio.
Each member must ensure that his Codio Project is updated and the same as
what the group submits so that the teacher may check any of the member’s work.
o In snipping images of your answers, make sure that the names of the files are
visible. Properly label the images as follows and should be pasted in the order
stated below:
 Header File (.h file)
 Implementation File (.cpp)
 Main Program (.cpp) o Show sample output for each
operation. Show adequate outputs to demonstrate how your program
works.

Snip and paste your source codes and outputs below. Snip it directly from Codio
IDE so that colors of the codes are preserved for readability. Include additional
pages if necessary.

Data Structures & Algorithms (LAB) Page 2 of 16


DATA.H

Data Structures & Algorithms (LAB) Page 3 of 16


Data Structures & Algorithms (LAB) Page 4 of 16
MAIN

Data Structures & Algorithms (LAB) Page 5 of 16


Data Structures & Algorithms (LAB) Page 6 of 16
IMPLEMENTATION:

Data Structures & Algorithms (LAB) Page 7 of 16


Data Structures & Algorithms (LAB) Page 8 of 16
Data Structures & Algorithms (LAB) Page 9 of 16
Data Structures & Algorithms (LAB) Page 10 of 16
Data Structures & Algorithms (LAB) Page 11 of 16
OUTPUT:

Data Structures & Algorithms (LAB) Page 12 of 16


1 – Adjacency List

Data Structures & Algorithms (LAB) Page 13 of 16


2 – Adjacency Matrix

Data Structures & Algorithms (LAB) Page 14 of 16


II. QUESTION AND ANSWER (10 POINTS)

Briefly answer the questions below. Avoid erasures. Do not forget to include
the sources for all NONORIGINAL IDEAS. Indicate the name of the member
that contributed the answer.

a. Generate the Adjacency List of the Graph below:

b. Which do you think is a more efficient way of representing a graph, using


Adjacency Matrix or Adjacency List? Support your choice.

Adjacency lists are more economical in terms of both space and


memory. It enables algorithms to obtain a list of neighboring vertices in
O(1) time, which is a major benefit. Furthermore, adjacency lists are
often regarded as the most appropriate data structure for most
applications of graphs.

Data Structures & Algorithms (LAB) Page 15 of 16


c. Give real-life examples on when BFS and DFS are
used. BFS examples:

• Navigation Systems - Find all the neighboring locations from the


source location. Like waze, google map etc.
• Social Networks - Find people within a given distance from a
person using BFS Like facebook and tinder.

DFS examples:

• Topological Sorting - For data serialization and primarily scheduling


jobs from dependencies among a group of jobs.
• Path Finding - To search a path between two vertices. A great
example would be exploring hard to reach locations like NASA’s
recent robot sending to mars.

Data Structures & Algorithms (LAB) Page 16 of 16

You might also like