0% found this document useful (0 votes)
6 views6 pages

DSAreport

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)
6 views6 pages

DSAreport

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
You are on page 1/ 6

Data Structures and Algorithms

Semester Project Report

Course Instructor: MAM MARYAM ASLAM

GROUP MEMBERS
Abdullah Sajid ( 01-135231-003)

Hamza Zahoor (01-135231-030)

Haseeb Ahmed (01-135231-033)


Project : Emergency Travel Plan Optimization
Course: Data Structures and Algorithms

Introduction

In this project, we developed an algorithm to help a traveler in an emergency situation reach their
destination as quickly as possible. The traveler must navigate through a network of cities connected by
roads and aerial routes. The constraints include a maximum number of cities that can be traveled by
road per day and specific rules for using aerial routes. The objective is to determine the minimum
number of days required for the traveler to reach the destination city from the starting city.

Problem Statement
 Given a network of cities connected by roads and aerial routes:
 The traveler can travel up to 6 cities by road per day.
 The traveler can use aerial routes to travel between cities instantaneously within a day.
 The traveler cannot stop in a city that has an aerial route leading back to a previously visited
city.
 The goal is to determine the minimum number of days required to travel from the starting city
to the destination city.

Input Description
For each test case:

 An integer representing the number of cities.


 An integer representing the number of aerial routes.
 pairs of integers where each pair (source, destination) represents an aerial route between two
cities.

Output Description
For each test case, the output should be the minimum number of days required for the traveler to reach
the destination city from the starting city.

Example

Input:
Copy code

1 30 2 2 21 10 25

Output:
Copy code

Methodology
Graph Representation
Adjacency List for Roads:
The network of cities and roads is represented using an adjacency list where each city points to its
directly connected neighboring cities.

Edge List for Aerial Routes:


Aerial routes are represented as a separate list of edges, each containing a pair of source and
destination cities.

Breadth-First Search (BFS)


Exploration Strategy:
BFS is used to explore the road network while considering the constraint of traveling up to 6 cities by
road per day. A queue is used to keep track of the cities visited each day and the days taken to reach
them.

Queue Management:
Each entry in the queue includes the current city and the day count. The algorithm explores each
neighboring city, adding them to the queue if they have not been visited or if a shorter path is found.

Aerial Route Handling


Immediate Transition:
On reaching a city with an aerial route, the algorithm transitions immediately to the destination city of
the aerial route.

Avoiding Revisit Loops:


The algorithm ensures no revisits to cities through aerial routes that lead back to previously visited
cities. This is achieved by maintaining a set of visited cities for each day.

Optimization and Constraints


Avoiding Unnecessary Stops:
Implement checks to avoid unnecessary stops in cities where aerial routes can be used advantageously.

Prioritizing Aerial Routes:


When an aerial route provides a faster alternative, it is prioritized.

Tools and Technologies


Programming Language: C++

Libraries: Standard Template Library (STL) for data structures such as queues and vectors.

Data Structure Used : Graph

Traversal Implemented: Breadth First Search (BFS)

Implementation
Step-by-Step Process
Input Parsing:
Read the number of test cases.

For each test case, read the number of cities and the number of aerial routes.

Construct the adjacency list for the road network.


Store the aerial routes in a separate list.

Graph Construction:
 Create an adjacency list to represent the road connections between cities.
 Store the aerial routes as pairs of source and destination cities.

Breadth-First Search (BFS):


 Initialize a queue with the starting city and set the day count to 0.
 For each city dequeued, explore up to 6 neighboring cities by road.
 If an aerial route is available, transition immediately to the destination city of the aerial route.

Day Count Management:


 Track the number of days taken to reach each city.
 Ensure the traveler does not revisit cities via aerial routes that lead back to previously visited
cities.

Output Generation:
For each test case, output the minimum number of days required to reach the destination city.

Results and Analysis


Initial Testing:

[Include screenshot of initial test cases and their outputs]

Optimization Check:

[Include screenshot demonstrating the effectiveness of optimization strategies]

Edge Cases:
[Include screenshot of results for edge cases, such as cities with no aerial routes or only one possible
path]

Performance Evaluation:

[Include screenshot showing performance analysis for large inputs]

Conclusion
By the end of this project, we successfully developed a C++ program that computes the minimum
number of days required for a traveler to reach the destination city from the starting city under the
given constraints. The solution efficiently handles the constraints of road travel limits and aerial route
usage, providing quick travel decisions in emergency scenarios.

Acknowledgments
We would like to thank our course instructor, MAM MARYAM ASLAM, for her guidance and support
throughout this project. We also appreciate the collaborative efforts of our group members in making
this project successful.

You might also like