Skip to content

djluis/JavaSandbox

Repository files navigation

JavaSandbox

Just a safe java repo for some geek experiences

Sorting Algorithms

I have created a setup to test and compare multiple Sorting Algorithms. They have been built with simplicity in mind, for the sake of readability

Standard Implementations 😫 (Boring versions, only used for elementary school to teach kids how to sort and array)

Algorithm Time complexity Space complexity Is Recursive Notes
Quick Sort O(n * log n) O(log n) ⚠️ If sorted -> O(n^2) 🐌
Merge Sort O(n * log n) O(n) Stable
Heap Sort O(n * log n) O(1) Not Stable
Buble Sort O(n^2) O(1) 🐌 Stable 🐌
  • n -> Array size

Where the fun begins 😍

WIP

Only non recursive and "stable" algorithms are welcomed here. If you can't hold big dick arrays without causing stack overflow so please leave now.

Algorithm Time complexity Space complexity Is Recursive Notes
Quick Sort Random pivot O(n * log n) O(n)
Quick Sort + Selection Sort with threshold O(n * log n) O(n)
Parallel Merge Sort O(n * log n) O(n)
Internal Java Array Sorting implementation ---- ---- ---- Uses a quickSort dual pivot, tuned to the bone , I plan to dissect this sorting algorithm later

Result

Test report

Search Algorithms

WIP

Algorithm Time complexity Space complexity Is Recursive Notes
Breadth First Search (aka BFS) O(V + E) O(V) Auxiliary structure: Queue
Depth-first traversal (aka DFS) O(V + E) O(V) Auxiliary structure: Stack
  • v -> Vertices
  • e -> Edges

Disclaimer

This is not a benchmark, for that multiple consecutive runs are mandatory to obtain a precise measure to avoid any JIT compile suprises

About

Just a sandbox Java repo to keep my algorithm skills sharp (at least I try)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages