Skip to content

SemionVlad/Java-sorting-searching-templates

Repository files navigation

Java Sorting & Searching Templates (Copy‑Paste)

Language: Java Domain: Algorithms Focus: Sorting Focus: Searching Arrays: int[] License: MIT

Minimal, static Java templates for classic sorting/searching on int[]: binary search + lower/upper bound, bubble/insertion/merge/heap/quick (3-way), counting, radix (LSD).

Files

  • BinarySearch.java – binary search + lower/upper bound.
  • BubbleSort.java – stable, adaptive bubble with last‑swap boundary.
  • InsertionSort.java – stable insertion; includes [lo..hi] overload.
  • MergeSort.java – stable top‑down merge with early‑exit.
  • HeapSort.java – in‑place heap (max‑heap), not stable.
  • QuickSort3Way.java – Dijkstra 3‑way with median‑of‑three + smaller‑side‑first.
  • RadixSort.java – LSD base‑256 for full signed int (negatives OK), plus a simple base‑10 non‑negative demo.
  • CountingSort.java – stable counting sort with [min..max] and auto‑detect overload.

How to use as templates

  • Copy the class (or just the static method) into your project.
  • Rename the class/methods.
  • If needed, adapt comparisons (e.g., reverse order), or change ranges like [lo..hi].
  • For objects, consider writing a comparator‑based variant in your project.

These are deliberately minimal and self‑contained so they’re quick to reuse.

About

Copy-pasteable Java templates for classic sorting and searching on int[]. Minimal, no packages, static APIs.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages