Skip to content

final exam project for the Algorythms and Data Structures course

Notifications You must be signed in to change notification settings

omgbarde/PFAPI23

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

50 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Highway Stations Shortest Path Calculator

Welcome to the Highway Stations Shortest Path Calculator repository!

πŸš—πŸ’¨ This C program computes the shortest paths between highway service stations, following the specifications provided in the reference file.

πŸš€ Project Overview

This program efficiently calculates the shortest paths between service stations on a highway using different algorithms depending on the travel direction (left or right). It ensures optimal performance while adhering to the constraints required by the verification server.

See reference file

πŸ› οΈ Data Structure Choice

To store the service stations efficiently, I needed a data structure that supports fast insertions, deletions, and lookups. Therefore, I opted for a Red-Black Tree, which balances these operations efficiently.

πŸ”’ Path Planning Algorithms

Different strategies were used based on the direction of travel:

  • Rightward Paths (β†’): A greedy approach is used. Starting from the destination and moving backward, the algorithm always selects the farthest reachable station. If the starting station is reached, the path is guaranteed to be optimal.
  • Leftward Paths (←): A BFS-style algorithm is implemented. The search starts from the final station and ensures that the first valid path found is both the shortest and the most optimal in terms of distance from the start of the highway.

⚑ Performance

  • Red-Black Tree Operations: Provide efficient insertions, deletions, and lookups in O(log n) time.

  • Rightward Path Calculation: Runs in approximately O(n) due to the greedy approach scanning reachable stations.

  • Leftward Path Calculation: The BFS traversal ensures an O(n) complexity for finding the shortest path.

max runtime memory execution time
40,2 mB ~ 5,7s

performance based on non-public tests made by a verifier server

πŸ”§ Possible Optimizations

An additional optimization in the vehicle addition/removal mechanism could improve performance further, as this operation represents the main bottleneck. Implementing a max-heap or a tree structure with a pointer to the maximum element would have significantly enhanced efficiency.


Feel free to explore, contribute, or provide feedback! πŸš€

About

final exam project for the Algorythms and Data Structures course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages