Skip to content

LinkisLethe/COMP2003_AVLRecords

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AVL Student Record System

中文说明

Build Java Maven License

A Java 11 command-line application for managing student records in an AVL tree. It supports CRUD operations, UTF-8 CSV persistence, legacy course-file import, a corrected Quickselect implementation, and a reproducible comparison with an unbalanced binary search tree.

Features

  • AVL-backed lookup, insertion, update, deletion, and sorted listing
  • CSV load and atomic save, including quoted fields and the original headerless field order
  • Interactive CLI with input validation and explicit error messages
  • Quickselect for finding the k-th largest integer without changing the input array
  • Deterministic AVL/BST benchmark using a fixed data size and random seed
  • JUnit coverage for rotations, root deletion, duplicate IDs, CSV errors, persistence, CLI flow, and Quickselect edge cases

Requirements

  • JDK 11 or newer
  • No global Maven installation is required; the Maven Wrapper is included

Build and run

On Windows:

./mvnw.cmd test
./mvnw.cmd package
java -jar target/avl-student-record-system-1.0.0.jar src/main/resources/students.csv

On macOS or Linux:

./mvnw test
./mvnw package
java -jar target/avl-student-record-system-1.0.0.jar src/main/resources/students.csv

The bundled CSV contains synthetic example records only. Starting without a file creates an empty in-memory store:

java -jar target/avl-student-record-system-1.0.0.jar

CLI commands

Command Purpose
load <csv-path> Replace the in-memory records after validating the complete file
save <csv-path> Write sorted records through a temporary file and atomic replacement
find <id> Find one student by ID
add <id> <first> <last> <gender> <age> Add a record and reject duplicate IDs
update <id> <first> <last> <gender> <age> Replace an existing record
remove <id> Delete a record
list [limit] List records in ascending ID order
stats Show record count, tree height, and balance state
kth <k> <value> [value ...] Find the k-th largest integer
exit Close the CLI

CLI names are whitespace-delimited. Names containing spaces or commas should be edited through CSV, where quoted fields are supported.

Benchmark

Run the deterministic comparison after compiling:

java -cp target/classes io.github.linkislethe.studentrecords.benchmark.TreeBenchmark 20000 20241215

The recorded run and its limits are documented in docs/BENCHMARKS.md. The implementation details and tree invariants are in docs/ARCHITECTURE.md.

Project structure

src/main/java/.../algorithm/    Quickselect
src/main/java/.../benchmark/    AVL/BST comparison
src/main/java/.../cli/          Interactive command interface
src/main/java/.../model/        Student record
src/main/java/.../persistence/  CSV reader and atomic writer
src/main/java/.../service/      Record operations
src/main/java/.../tree/         BST and AVL implementations
src/test/java/                  JUnit tests
docs/                           Architecture and benchmark notes

Limitations

  • Records are held in memory and persisted only when save is called.
  • The CLI is designed for one local process, without authentication or concurrent writes.
  • The benchmark uses System.nanoTime() rather than JMH; timing values are illustrative, while final tree height is deterministic for the supplied size and seed.

License

This repository is licensed under the MIT License.

About

A Java 11 CLI for persistent student records backed by an AVL tree, with Quickselect, tests, and reproducible BST comparisons.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages