This project is a Node.js-based application developed to analyze and compare the performance of three sorting algorithms: Bubble Sort, Insertion Sort, and Quick Sort. The application evaluates execution time using multiple datasets with varying sizes to understand the efficiency of each algorithm.
- Implementation of three sorting algorithms:
- Bubble Sort
- Insertion Sort
- Quick Sort
- Automatic dataset generation (1000 – 10000 elements)
- Performance measurement using high-resolution timer
- Comparison of runtime results in tabular format (console.table)
- Modular code structure (each algorithm separated)
- Generate datasets with different sizes (1000–10000 elements).
- Store datasets in JSON format inside the Data/ folder.
- Load datasets into the main program.
- Execute each sorting algorithm using the same dataset.
- Measure execution time for each algorithm.
- Display results in a comparison table.
- Dataset Generation: Creates random data for testing algorithm performance.
- Sorting Execution: Runs three sorting algorithms independently.
- Runtime Measurement: Uses high-resolution timing (process.hrtime.bigint()).
- Data Comparison: Displays results in structured table format.
- Programming Language : JavaScript
- Runtime Environment : Node.js
- File System Module : Built-in fs module
- Data Format : JSON
This performance test was conducted on the following system:
- Operating System : Arch Linux
- Processor : 12th Gen Intel(R) Core(TM) i5-1235U
- RAM : 8 GB
- Storage : SSD 512 GB
- Runtime : Node.js v25.9.0
- Node.js v14 or higher
- Operating System: Windows / Linux / macOS
- No external libraries required
Algorithms-Strategy/
│
├── Bubble-Sort/
│ └── bubble.js
│
├── Insertion-Sort/
│ └── insertion.js
│
├── Quick-Sort/
│ └── quick.js
│
├── Data/
│ ├── data_1000.json
│ ├── data_2000.json
│ ├── ...
│ ├── data_10000.json
│ └── generate.js
│
└── main.js
- Generate Dataset
node Data/generate.js
- Run Performance Test
node main.js
| Index | Data Size | Bubble Sort | Insertion Sort | Quick Sort |
|---|---|---|---|---|
| 0 | 1000 | 5.123 ms | 2.456 ms | 0.789 ms |
| 1 | 2000 | 20.456 ms | 9.321 ms | 1.234 ms |
| ... | ... | ... | ... | ... |
- Bubble Sort → Time Complexity: O(n²)
- Insertion Sort → Time Complexity: O(n²)
- Quick Sort → Average Time Complexity: O(n log n)
From the experiment results:
- Bubble and Insertion Sort show significant increase in runtime as data size grows.
- Quick Sort performs much faster and more efficiently for large datasets.
- Analyze and compare sorting algorithm performance
- Understand time complexity through real implementation
- Practice modular programming in Node.js
- Visualize runtime differences using structured output
Institution : Universitas Ahmad Dahlan
Course : Strategi Algoritma
| Contributors | GitHub |
|---|---|
| Lutfan Alaudin Naja | Nekonepan |
If you find this project useful:
⭐ Star the repository
🛠️ Fork and experiment with other algorithms
📬 Use it as reference for algorithm analysis