| title | DAA Algorithm Visualizer |
|---|---|
| emoji | π |
| colorFrom | blue |
| colorTo | green |
| sdk | docker |
| app_port | 7860 |
| pinned | false |
A comprehensive collection of divide-and-conquer algorithm implementations with professional web-based visualizations for the Design and Analysis of Algorithms course.
Try the deployed application here:
| Name | Roll Number |
|---|---|
| Huzaifa Abdul Rehman | 23k-0782 |
| Abdul Moiz Hossain | 23k-0553 |
| Ajay Kumar | 23K-0514 |
- Live Demo
- About the Project
- Features
- Technologies Used
- Project Structure
- Problem Implementations
- How to Run
- Screenshots
- Time Complexity Analysis
- Contributing
This project showcases 13 algorithmic implementations focusing on the Divide and Conquer paradigm, featuring:
- π Interactive Web Visualizations - Step-by-step algorithm execution
- π¨ Modern UI/UX - Dark mode, glassmorphism, smooth animations
- β‘ High Performance - Optimized C++ backend with Next.js frontend
- π Comprehensive Testing - 40+ test cases with benchmark dashboard
- π Educational Value - Clear explanations and visual learning
- Beautiful Landing Page with animated gradient backgrounds
- Interactive Visualizations:
- Closest Pair: Step-by-step divide-and-conquer animation
- Integer Multiplication: Recursive tree visualization
- Dark/Light Mode with system preference detection
- Multiple Input Methods: Predefined files, custom upload, manual entry
- Real-time Performance Metrics with benchmark dashboard
- Responsive Design - works on all screen sizes
- Professional UI Components using shadcn/ui and Radix UI
- 13 C++ Implementations covering classic divide-and-conquer problems
- Optimized Code with
-O2compilation flags - Detailed Output including execution time and complexity analysis
- Test Data Generation for comprehensive testing
C++11/14 - Algorithm implementation
- STL - Data structures and algorithms
- Chrono - High-precision time measurement
Next.js 14.1 - React framework with App Router
React 18.2 - UI library
TypeScript 5.3 - Type safety
Tailwind CSS 3.4 - Utility-first styling
- Framer Motion - Smooth animations
- Recharts - Performance charts
- shadcn/ui - Modern UI components
Daa-Project/
β
βββ README.md # Main documentation
βββ GIT_CHEAT_SHEET.md # Git collaboration guide
βββ INSTRUCTIONS.md # Quick setup guide
βββ .gitignore # Git ignore rules
β
βββ q1/ # Question 1: Basic Algorithms
β βββ a.cpp # Algorithm A
β βββ b.cpp # Binary Exponentiation
β βββ c.cpp # Counting Inversions
β βββ e.cpp # Algorithm E
β βββ f.cpp # Peak Element Finder
β βββ g.cpp # Maximum Stock Profit
β βββ h_1.cpp # Median of Two Arrays (Method 1)
β βββ h_2.cpp # Median of Two Arrays (Method 2)
β βββ h_3.cpp # Median of Two Arrays (Method 3)
β
βββ q2/ # Question 2: Advanced Visualization
βββ closest_pair.cpp # Closest Pair Algorithm (247 lines)
βββ integer_multiplication.cpp # Karatsuba Multiplication (214 lines)
β
βββ test_data/ # Test Files (40+ files)
β βββ closest_pair/ # 10 point datasets (100-1000 points)
β βββ integer_multiplication/ # 10 digit datasets (100-1000 digits)
β
βββ ui/ # Next.js Web Application
βββ app/ # Pages & API Routes
β βββ page.tsx # Landing page
β βββ closest-pair/ # Closest pair visualization page
β βββ integer-multiplication/ # Karatsuba visualization page
β βββ benchmark/ # Performance dashboard
β βββ api/ # API endpoints (5 routes)
β
βββ components/ # React Components (22 components)
β βββ closest-pair-step-visualization.tsx
β βββ recursive-tree.tsx
β βββ static-points-canvas.tsx
β βββ navigation.tsx
β βββ theme-provider.tsx
β βββ ui/ # shadcn/ui components
β
βββ lib/ # Utilities
βββ public/ # Static assets
βββ styles/ # Global styles
Problem: Compute a^b efficiently using divide and conquer.
- Time Complexity: O(log b)
- Space Complexity: O(log b) - recursion stack
- Approach: Exponentiation by squaring
// If b is even: a^b = (a^(b/2))^2
// If b is odd: a^b = (a^(b/2))^2 Γ aProblem: Count pairs (i, j) where i < j but arr[i] > arr[j].
- Time Complexity: O(n log n)
- Space Complexity: O(n)
- Approach: Modified merge sort
Problem: Find an element greater than or equal to its neighbors.
- Time Complexity: O(log n)
- Space Complexity: O(log n) - recursion stack
- Approach: Binary search on array
Problem: Find maximum profit from buying and selling stocks.
- Time Complexity: O(n log n)
- Space Complexity: O(n)
- Approach: Divide and conquer on difference array
Problem: Find n-th smallest element from two sorted arrays.
- Time Complexity: O(log n)
- Space Complexity: O(1)
- Approach: Binary search on partitions
File: q2/closest_pair.cpp (247 lines)
Problem: Find the two closest points among n points in 2D space.
Algorithm: Divide and Conquer
- Time Complexity: O(n log n)
- Space Complexity: O(n)
Implementation Features:
- β Sorts points by x and y coordinates
- β Recursively divides plane into halves
- β Checks strip area for cross-boundary pairs
- β Generates JSON trace for visualization (n β€ 50)
- β Handles 100-1000 point datasets
Visualization Features:
- π¨ Step-by-step animation with playback controls
- π Divide line visualization (red dashed)
- π― Active region highlighting (teal)
- π£ Strip area visualization (purple)
- β Closest pair highlighting (green)
- β―οΈ Play, pause, step forward/backward controls
- π Progress tracking with step descriptions
File: q2/integer_multiplication.cpp (214 lines)
Problem: Multiply arbitrarily large integers efficiently.
Algorithm: Karatsuba's Fast Multiplication
- Time Complexity: O(n^1.585) where n = number of digits
- Space Complexity: O(n)
Implementation Features:
- β String-based arithmetic for large numbers
- β Recursive three-way split (z2, z0, z1)
- β Generates tree visualization (β€50 digits)
- β Handles 100-1000+ digit multiplication
- β Falls back to naive method for small numbers
Visualization Features:
- π³ Interactive recursive tree display
- π¨ Color-coded node types:
- π£ Purple - Root (original multiplication)
- π΅ Blue - zβ (high digits: a Γ c)
- π’ Green - zβ (low digits: b Γ d)
- π Orange - zβ (middle term)
- π Zoom controls (30%-150%)
- π±οΈ Pan with left-click drag
- π Smart number truncation for readability
- π Depth and digit count tracking
- Node.js v18 or higher
- npm or yarn package manager
- C++ Compiler (g++/MinGW/MSVC)
- Git (optional)
git clone https://github.com/amh1k/Daa-Project.git
cd Daa-Projectcd q2
g++ -O2 closest_pair.cpp -o closest_pair.exe
g++ -O2 integer_multiplication.cpp -o integer_multiplication.execd ui
npm installnpm run devNavigate to: http://localhost:3000
# Navigate to q1 directory
cd q1
# Compile and run any algorithm
g++ b.cpp -o b.exe
./b.exe
# Example: Binary Exponentiation
echo "2 10" | ./b.exe
# Output: 1024
# Example: Counting Inversions
./c.exe
# Output: The number of inversions are: 22
Beautiful gradient animations with glassmorphism effects, featuring three main algorithm sections
Professional light theme with optimal contrast and accessibility
Step-by-step divide-and-conquer animation with playback controls, divide line visualization, and active region highlighting
Features:
- Interactive canvas visualization
- Play, pause, step forward/backward controls
- Real-time algorithm step descriptions
- Multiple input methods (predefined, custom, manual)
- Compact footer legend with color coding
Large number multiplication with result display and performance metrics
Features:
- Support for 100-1000+ digit numbers
- Instant calculation results
- Execution time tracking
- Clean result presentation
Interactive tree showing Karatsuba's recursive breakdown with color-coded node types (zβ, zβ, zβ)
Features:
- Expand view with zoom controls (30%-150%)
- Pan with left-click drag
- Shrink button for compact view
- Color-coded nodes: Purple (Root), Blue (zβ), Green (zβ), Orange (zβ)
- Horizontal scrollbar for wide trees
- Smart number truncation for readability
Comprehensive performance testing with real-time progress tracking for all 20 test cases
Features:
- Batch execution of all test files
- Real-time progress indicators
- Side-by-side performance comparison
- Success/failure status for each test
- Execution time metrics
- Dataset size information
| Algorithm | Problem | Time Complexity | Space Complexity | Lines of Code |
|---|---|---|---|---|
| Binary Exponentiation | Compute a^b | O(log b) | O(log b) | ~30 |
| Counting Inversions | Count inversions | O(n log n) | O(n) | ~50 |
| Peak Element | Find peak | O(log n) | O(log n) | ~40 |
| Max Stock Profit | Maximum profit | O(n log n) | O(n) | ~60 |
| Median of Arrays | Find median | O(log n) | O(1) | ~70 |
| Closest Pair | 2D point distance | O(n log n) | O(n) | 247 |
| Karatsuba Multiply | Large integer multiplication | O(n^1.585) | O(n) | 214 |
- β Divide and Conquer - Breaking problems into smaller subproblems
- β Binary Search - Efficient searching in sorted/partially sorted data
- β Merge Sort - Efficient sorting with additional applications
- β Dynamic Problem Solving - Converting problems to known formats
- β Optimization - Achieving logarithmic and linearithmic complexities
- β Full-Stack Development - C++ backend + React frontend
- β API Design - RESTful endpoints with error handling
- β Component Architecture - Reusable React components
- β Type Safety - TypeScript for robust code
- β Performance Optimization - Lazy loading, caching, GPU acceleration
- β Responsive Design - Mobile-first approach
- β Accessibility - WCAG-compliant UI
- β Modern Design Patterns - Glassmorphism, gradients
- β Smooth Animations - Framer Motion for professional feel
- β Dark Mode - System preference detection
- β Interactive Visualizations - Canvas & SVG rendering
- β User Feedback - Loading states, progress bars, error messages
- π Step-by-step algorithm execution - Visual learning
- π‘ Clear complexity explanations - Understand time/space trade-offs
- π§ͺ Multiple test cases - Edge case handling
- π Performance comparison - Benchmark different inputs
- β Production-ready code - Demonstrates best practices
- β Comprehensive documentation - Easy to understand and grade
- β Interactive demos - Use in lectures
- β Extensible architecture - Students can add more algorithms
- C++ Backend:
-O2optimization flags - React Frontend: Code splitting, lazy loading
- Canvas Rendering: GPU-accelerated drawing
- Smart Caching: Webpack build optimization
- β Executable validation
- β Input file validation
- β Parse error detection
- β Timeout handling (30s limit)
- β User-friendly error messages
- 40+ predefined test files
- Custom file upload support
- Manual input validation
- Edge case coverage
- Performance benchmarking
This is an academic project. For improvements:
- Fork the repository
- Create feature branch:
git checkout -b feature/improvement - Commit changes:
git commit -m 'Add improvement' - Push to branch:
git push origin feature/improvement - Open Pull Request
For questions or discussions:
- Huzaifa Abdul Rehman - 23k-0782
- Abdul Moiz Hossain - 23k-0553
- Ajay Kumar - 23K-0514
This project is created for educational purposes as part of the Design and Analysis of Algorithms course (CS302 - 5th Semester).
- Introduction to Algorithms (CLRS) - Algorithm theory
- GeeksforGeeks & LeetCode - Problem-solving inspiration
- Next.js Documentation - Web framework guidance
- shadcn/ui - Component library
- Framer Motion - Animation library
- Algorithm visualization tools (VisuAlgo, Algorithm Visualizer)
- Professional web applications (Figma, VS Code)
- Academic research papers on divide-and-conquer
- Total Files: 2,800+ (including dependencies)
- Custom Code:
- 13 C++ algorithm implementations
- 22 React components
- 5 API routes
- 40+ test data files
- Lines of Code:
- C++: 600+ lines
- TypeScript/TSX: 3,000+ lines
- Test Coverage: 20 comprehensive test cases
- Supported Input Sizes:
- Closest Pair: 10-1000 points
- Integer Multiplication: 12-1000+ digits
β Complete implementation of 13 divide-and-conquer algorithms β Professional web application with modern tech stack β Interactive visualizations demonstrating algorithm internals β Comprehensive test suite with 40+ test cases β Beautiful UI design with dark mode support β Performance benchmarking capabilities β Educational documentation for learning β Multiple input methods for flexibility β Robust error handling and validation β Production-ready deployment capability
- Add more algorithms (Quick Sort, Heap Sort, etc.)
- Export visualization as GIF/Video
- Mobile app version
- Algorithm complexity calculator
- User accounts and saved visualizations
- Collaborative features
- Multi-language support
β If you find this repository helpful, please consider giving it a star!
Repository: https://github.com/amh1k/Daa-Project