A high-performance cricket leaderboard powered by Skip List data structure
Lightning-fast O(log n) operations β’ Real-time Rankings β’ IPL 2024 Data β’ Educational UI
Live Demo β’ API Docs β’ Report Bug β’ Request Feature
- Add/Update Players - Efficiently manage player scores with automatic ranking
- Remove Players - Clean deletion with skip list pointer management
- Top-N Leaderboard - Instant access to top performers
- Player Search - O(log n) lookup with rank information
- Bulk Operations - Load sample IPL 2024 data instantly
- Real-time Statistics - Total players, highest/lowest/average scores
- O(log n) Operations - Insert, search, and delete
- Skip List Powered - Probabilistic balanced tree alternative
- Memory Efficient - Minimal overhead compared to balanced trees
- Educational Modals - Learn skip list operations visually
- Complexity Display - See average/worst-case time complexities
- Live Status - Real-time backend connection indicator
- Responsive Design - Works on desktop and mobile
- IPL Theme - Cricket-themed interface with gradient colors
- Modal popups explain each skip list operation
- Visual feedback for insert, search, and delete operations
- Time complexity analysis (average & worst-case)
- Understanding of pointer manipulation in skip lists
SKIP-LIST-LEADERBOARD/
β
βββ π§ backend/
β βββ __init__.py
β βββ app.py # FastAPI application & all endpoints
β βββ leaderboard.py # Leaderboard logic wrapper
β βββ skiplist.py # Skip List core implementation
β
βββ π docs/
β βββ report.txt # Technical documentation
β
βββ π¨ frontend/
β βββ index.html # Interactive demo interface
β
βββ π» skiplist_implementation/
β βββ skip_list.py # Python implementation
β βββ skip_list.cpp # C++ implementation
β βββ skip_list.java # Java implementation
β βββ skip_list.c # C implementation
β
βββ .gitignore # Git ignore rules
βββ requirements.txt # Python dependencies
βββ README.md # You are here!
- Python 3.11 or higher
- pip package manager
- Modern web browser (Chrome, Firefox, Safari, Edge)
-
Clone the repository
git clone https://github.com/SH-Nihil-Mukkesh-25/skiplist-leaderboard.git cd skiplist-leaderboard -
Set up virtual environment (recommended)
python -m venv venv # Activate virtual environment source venv/bin/activate # macOS/Linux venv\Scripts\activate # Windows
-
Install dependencies
pip install -r requirements.txt
-
Launch the API server
uvicorn backend.app:app --reload --host 127.0.0.1 --port 8000
You should see:
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) INFO: Started reloader process INFO: Started server process INFO: Application startup complete. -
Access your application π
- Frontend UI: Open
frontend/index.htmlin your browser - API Base: http://127.0.0.1:8000
- Interactive Docs: http://127.0.0.1:8000/docs
- Alternative Docs: http://127.0.0.1:8000/redoc
- Frontend UI: Open
-
Try it out!
- Click "Load IPL 2024 Data" to populate with 15 cricket players
- Add your own players or search existing ones
- Watch the educational modals explain skip list operations
| Method | Endpoint | Description | Request Body |
|---|---|---|---|
GET |
/ |
Welcome page with endpoint list | None |
GET |
/health |
Health check & player count | None |
GET |
/stats |
Leaderboard statistics | None |
POST |
/add |
Add/update player score | {"name": "string", "score": number} |
POST |
/bulk-add |
Add multiple players | {"players": [{"name": "...", "score": ...}]} |
GET |
/top/{n} |
Get top N players (max 1000) | None |
GET |
/all |
Get all players sorted | None |
GET |
/search/{name} |
Find player's score & rank | None |
GET |
/rank/{name} |
Get player's rank details | None |
DELETE |
/remove/{name} |
Remove player from leaderboard | None |
DELETE |
/clear |
Clear entire leaderboard | None |
Click to expand API examples
curl "http://127.0.0.1:8000/health"Response:
{
"status": "healthy",
"total_players": 15
}curl -X POST "http://127.0.0.1:8000/add" \
-H "Content-Type: application/json" \
-d '{"name": "Virat Kohli", "score": 7500}'Response:
{
"message": "Added Virat Kohli with 7500",
"name": "Virat Kohli",
"score": 7500,
"rank": 1
}curl -X POST "http://127.0.0.1:8000/bulk-add" \
-H "Content-Type: application/json" \
-d '{
"players": [
{"name": "Rohit Sharma", "score": 6628},
{"name": "MS Dhoni", "score": 5243}
]
}'Response:
{
"message": "Successfully added 2 players",
"total_players": 17
}curl "http://127.0.0.1:8000/top/5"Response:
[
{"name": "Virat Kohli", "score": 7500},
{"name": "Shikhar Dhawan", "score": 6769},
{"name": "Rohit Sharma", "score": 6628},
{"name": "David Warner", "score": 6565},
{"name": "Suresh Raina", "score": 5528}
]curl "http://127.0.0.1:8000/search/Virat%20Kohli"Response:
{
"name": "Virat Kohli",
"score": 7500,
"rank": 1,
"found": true
}curl "http://127.0.0.1:8000/rank/MS%20Dhoni"Response:
{
"name": "MS Dhoni",
"rank": 7,
"score": 5243,
"total_players": 15
}curl "http://127.0.0.1:8000/stats"Response:
{
"total_players": 15,
"highest_score": 7500,
"lowest_score": 2434,
"average_score": 4982.73,
"top_player": {"name": "Virat Kohli", "score": 7500}
}curl -X DELETE "http://127.0.0.1:8000/remove/Virat%20Kohli"Response:
{
"message": "Removed Virat Kohli",
"success": true
}curl -X DELETE "http://127.0.0.1:8000/clear"Response:
{
"message": "Cleared 15 players",
"total_players": 0
}- π Python 3.11+ - Modern Python with type hints
- β‘ FastAPI - High-performance async web framework
- π Skip List - Probabilistic data structure for O(log n) operations
- π¦ Uvicorn - Lightning-fast ASGI server
- β Pydantic - Data validation and serialization
- π CORS - Cross-origin resource sharing enabled
- π¨ Vanilla JavaScript - No framework dependencies
- π Modern CSS - Gradients, hover effects, responsive design
βββββββββββββββ HTTP ββββββββββββββββ Python ββββββββββββββ
β Browser β ββββββββββββΊ β FastAPI β ββββββββββββββΊ β Skip List β
β (HTML/JS) β REST API β Backend β Operations β Leaderboardβ
βββββββββββββββ ββββββββββββββββ ββββββββββββββ
-
Player Storage: Dictionary for O(1) name lookups
self.players = {} # name β score
-
Score Ranking: Skip list maintains descending order
self.skiplist.insert(-score, name) # Negative for DESC order
-
Update Mechanism: Remove old entry, insert new one
if name in self.players: old_score = self.players[name] self.skiplist.delete(-old_score) self.skiplist.insert(-score, name)
| Operation | Average | Worst Case | Explanation |
|---|---|---|---|
| Insert | O(log n) | O(n) | Traverse levels top-down, probabilistic balancing |
| Delete | O(log n) | O(n) | Find node, update forward pointers across levels |
| Search | O(log n) | O(n) | Express lanes (higher levels) speed up traversal |
| Top-N | O(n) | O(n) | Linear scan through first n nodes |
| Get Rank | O(n) | O(n) | Count nodes until target found |
β
Simpler than balanced trees (AVL, Red-Black)
β
Lock-free concurrent access possible
β
Memory efficient - No color/balance metadata
β
Probabilistic balancing - No rotations needed
β
Cache-friendly - Sequential memory access patterns
- Status Bar: Real-time backend connection indicator (Online β / Offline β)
- Player Form: Add players with name and score validation
- Action Buttons:
- π Load Rankings - Refresh top N players
- π Search Player - Find specific player
- π Get Player Rank - View rank details
- β Remove Player - Delete from leaderboard
- Sample Data: Load IPL 2024 data (15 players) instantly
- Statistics Panel: Shows total players, highest/lowest/average runs
Each operation displays a modal explaining the skip list mechanics:
Insert Operation
- Average: O(log n), Worst: O(n)
- Explains level traversal and pointer updates
- Shows player name, score, and resulting rank
Search Operation
- Average: O(log n), Worst: O(n)
- Describes express lane traversal
- Displays found player's score and rank
Delete Operation
- Average: O(log n), Worst: O(n)
- Explains pointer rewiring across levels
- Confirms successful removal
- Modern Gradients: Blue gradient header (#1e3a8a β #3b82f6)
- Rank Badges: Gold/Silver/Bronze for top 3 players
- Hover Effects: Interactive row highlighting
- Responsive Layout: Grid-based design adapts to screen size
- Loading States: Visual feedback during API calls
- Error/Success Messages: Toast-style notifications
| Data Structure | Insert | Delete | Search | Get Min/Max | Space |
|---|---|---|---|---|---|
| Skip List | O(log n) | O(log n) | O(log n) | O(1) | O(n) |
| Sorted Array | O(n) | O(n) | O(log n) | O(1) | O(n) |
| Binary Heap | O(log n) | O(log n) | O(n) | O(1) | O(n) |
| AVL Tree | O(log n) | O(log n) | O(log n) | O(log n) | O(n) |
| Hash Table | O(1)* | O(1)* | O(1)* | O(n) | O(n) |
*Hash tables don't maintain order, so can't efficiently get top-N
Tested with IPL 2024 dataset (15 players):
- Bulk Insert: ~1ms for all 15 players
- Single Search: <0.1ms average
- Top-10 Query: <0.5ms
- Delete + Reinsert: ~0.2ms
This project features Skip List implementations in multiple programming languages:
| Language | Implementation | Contributor |
|---|---|---|
| π Python | Web API + Frontend + SkipList Implementation | SH Nihil Mukkesh |
| β Java | SkipList Implementation | P Dakshin Raj |
| β‘ C++ | SkipList Implementation + PPT | Vibin Ragav S |
| π§ C | SkipList Implementation | Shre Raam PJ |
Contributions are welcome! Here's how you can help:
- π Report bugs - Open an issue with detailed description
- π‘ Suggest features - Share your ideas for improvements
- π Improve documentation - Help others understand the code
- π¨ Enhance UI - Make the interface more beautiful
- β‘ Optimize performance - Make skip list operations faster
- π Add translations - Support multiple languages
- Fork the project
- Create your feature branch
git checkout -b feature/AmazingFeature
- Make your changes and test thoroughly
- Commit with descriptive messages
git commit -m 'Add: New player statistics endpoint' - Push to your branch
git push origin feature/AmazingFeature
- Open a Pull Request with detailed description
This project is licensed under the MIT License - see the LICENSE file for details.
- William Pugh - For inventing the skip list data structure
- FastAPI Team - For making Python APIs enjoyable
- IPL - For providing cricket statistics inspiration
- Open Source Community - For continuous inspiration and support
Made with β€οΈ and β by SH-Nihil-Mukkesh-25