This repository contains practical implementations of various algorithms in real-world scenarios using Java and Spring Boot.
- Location:
/friend-finder - Algorithm: Breadth-First Search
- Use Case: Social Network Friend Discovery
- Features:
- Friend network traversal
- Shortest path finding
- Distance-based friend recommendations
- Location:
/product-catalog - Algorithm: QuickSort
- Use Case: E-commerce Product Sorting
- Features:
- Single-criterion sorting (price, rating, popularity)
- Multi-criteria sorting (e.g., category and price, rating and price)
- In-memory product catalog with sample data
- RESTful API endpoints
- Initialize Sample Data:
curl -X POST http://localhost:8080/api/products/init- Single Criterion Sorting:
# Sort by price (ascending)
curl "http://localhost:8080/api/products/sort?sortBy=price"
# Sort by rating (highest first)
curl "http://localhost:8080/api/products/sort?sortBy=rating"
# Sort by popularity (highest first)
curl "http://localhost:8080/api/products/sort?sortBy=popularity"- Multi-criteria Sorting:
# Sort by category, then price
curl "http://localhost:8080/api/products/sort/multiple?criteria=category,price"
# Sort by rating, then price
curl "http://localhost:8080/api/products/sort/multiple?criteria=rating,price"- Algorithm: QuickSort
- Time Complexity: O(n log n) average case
- Space Complexity: O(log n)
- In-place sorting
- Sorting Criteria:
- Price: Ascending order
- Rating: Descending order (highest first)
- Popularity: Descending order (most popular first)
- Category: Alphabetical order
Each project is a standalone Spring Boot application. To run a project:
- Navigate to the project directory:
cd <project-directory>- Build the project:
mvn clean install- Run the application:
mvn spring-boot:runEach project includes a set of sample data and API endpoints for testing the implemented algorithms. Use the provided curl commands to test different functionalities.
- Content Search Engine (Binary Search)
- Travel Route Optimizer (Dynamic Programming)
- Network Router Simulator (Dijkstra's Algorithm)
- File System Navigator (Tree Traversal)