Skip to content

Rumm1/Assignment2selection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

assignment2-selectionsort (Student B)

Selection Sort implementation with early-termination/suffix-check optimization.

Project structure

  • src/main/java/algorithms/SelectionSort.java - main implementation
  • src/main/java/metrics/PerformanceTracker.java - counts comparisons/swaps/accesses
  • src/main/java/cli/BenchmarkRunner.java - simple CLI benchmark
  • src/test/java/algorithms/SelectionSortTest.java - JUnit5 tests
  • pom.xml - Maven build

Build & Run

Requirements: JDK 17+, Maven.

Build:

mvn -q -DskipTests=false test package

Run CLI (example):

mvn -q exec:java -Dexec.mainClass=cli.BenchmarkRunner

or build jar and run.

Notes on optimization

The implementation is standard selection sort with an additional suffix-sorted check when no swap is needed for a pass. This gives early termination on already-sorted or nearly-sorted arrays, while preserving selection sort stability of operation counts in general.

Metrics

PerformanceTracker records:

  • comparisons
  • swaps
  • arrayAccesses (approximate)

Use BenchmarkRunner to experiment with different input sizes and distributions (random, sorted, reverse, nearly).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages