Skip to content

Educational Java implementations of core data structures and algorithms (sorting, hashing, hash tables) with step-by-step console visualizations.

Notifications You must be signed in to change notification settings

RasHOSub5/DataForJava

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo

🧠 Data Search and Organization

This project provides a comprehensive collection of Data Structures and Algorithms implemented in Java, designed for learning, experimentation, and educational visualization. It includes step-by-step implementations of sorting methods, hashing techniques, and data organization structures.

📦 What's inside?

Sorting Algorithms Core sorting algorithms with detailed console visualizations for each step:

  • Bubble Sort → Basic iterative swap-based sort.
  • Insertion Sort → Builds sorted list incrementally.
  • Selection Sort → Finds and places the smallest element.
  • Shell Sort → Gap-based optimization of insertion sort.
  • Merge Sort → Recursive divide-and-conquer sorting.
  • Quick Sort → Partition-based recursive sorting.
  • Heap Sort → Uses max-heap structure for in-place sorting.
  • Radix Sort → Stable sorting based on digit place values. Each algorithm prints intermediate array states to help students understand how data is progressively organized.

Hashing Functions

Custom implementations of hash functions and collision resolution strategies:

  • Modulo Function → Uses nearest prime for optimized distribution.
  • Square (Quadratic) Function → Extracts central digits from key².
  • Folding Function → Splits key and combines halves (additive or multiplicative).
  • Truncation Function → Selects specific digits from the key.

Collision Handling Techniques

Three classical hash reassignment strategies for resolving collisions:

  • Linear Probing → Sequential search for next empty slot.
  • Quadratic Probing → Probes positions using quadratic offsets.
  • Double Hashing → Uses a secondary hash function dynamically. Also includes Nested Arrays for separate chaining visualization, showing collisions as vertical chains, or showing collisions as a dynamic matrix.

Hash Table Implementation

A custom-built HashTable class with modular structure:

  • Supports multiple hash functions and collision strategies.
  • Displays hash mapping, collisions, and final table states.
  • Compatible with any integer dataset.
  • Designed for experimentation and educational demos.

🚀 Features

  • Fully implemented in pure Java, no external dependencies.
  • Detailed console-based step visualizations for every algorithm.
  • Educationally oriented — suitable for students studying data structures.
  • Implements hashing, sorting, and search organization principles from scratch.
  • Includes modular classes for HashTables, Reassignments, and Sorting Utilities.

💻 Code Examples

  • Example - Merge Sort Visualization
int[] V8 = {54, 26, 93, 17, 77, 31, 44, 55, 20};
        Sorting.mergeSort(V8);

Console output:

[ 54 26 93 17 77 31 44 55 20 ]
[ 54 26 93 17 ] [ 77 31 44 55 20 ]
[ 54 26 93 17 ]
[ 54 26 ] [ 93 17 ]
[ 54 26 ]
[ 54 ] [ 26 ]
[ 54 ] [ 26 ]
[ 26 54 ]
[ 93 17 ]
[ 93 ] [ 17 ]
[ 93 ] [ 17 ]
[ 17 93 ]
[ 26 54 ] [ 17 93 ]
[ 17 26 54 93 ]
[ 77 31 44 55 20 ]
[ 77 31 ] [ 44 55 20 ]
[ 77 31 ]
[ 77 ] [ 31 ]
[ 77 ] [ 31 ]
[ 31 77 ]
[ 44 55 20 ]
[ 44 ] [ 55 20 ]
[ 55 20 ]
[ 55 ] [ 20 ]
[ 55 ] [ 20 ]
[ 20 55 ]
[ 44 ] [ 20 55 ]
[ 20 44 55 ]
[ 31 77 ] [ 20 44 55 ]
[ 20 31 44 55 77 ]
[ 17 26 54 93 ] [ 20 31 44 55 77 ]
[ 17 20 26 31 44 54 55 77 93 ]
  • Example – Hash Table with Linear Probing
HashTable table = new HashTable(8);
int[] keys = {125, 47, 35, 141, 112};
table.addKeys(keys, 1, 1);

Console output:

dir = 125 % 7 = 6.
Current element at 6: null
FINAL POS: 6.
[ [  ][  ][  ][  ][  ][  ][ 125 ][  ] ]

dir = 47 % 7 = 5.
Current element at 5: null
FINAL POS: 5.
[ [  ][  ][  ][  ][  ][ 47 ][ 125 ][  ] ]

dir = 35 % 7 = 0.
Current element at 0: null
FINAL POS: 0.
[ [ 35 ][  ][  ][  ][  ][ 47 ][ 125 ][  ] ]

dir = 141 % 7 = 1.
Current element at 1: null
FINAL POS: 1.
[ [ 35 ][ 141 ][  ][  ][  ][ 47 ][ 125 ][  ] ]

dir = 112 % 7 = 0.
Current element at 0: 35
Performing Linear Test
FINAL POS: 2.
[ [ 35 ][ 141 ][ 112 ][  ][  ][ 47 ][ 125 ][  ] ]
  • Nested Array Visualization
NestedArray array = new NestedArray(8);
int[] keys = {125, 47, 35, 141, 112};
array.addKeys(keys, 1);
System.out.println(array);

Console output:

dir = 125 % 7 = 6.
dir = 47 % 7 = 5.
dir = 35 % 7 = 0.
dir = 141 % 7 = 1.
dir = 112 % 7 = 0.
[ 0 ][ 35 ][ 112 ]
[ 1 ][ 141 ][ ]
[ 2 ][ ][ ]
[ 3 ][ ][ ]
[ 4 ][ ][ ]
[ 5 ][ 47 ][ ]
[ 6 ][ 125 ][ ]
[ 7 ][ ][ ]

📚 Concepts Covered

This project reinforces fundamental concepts of:

  • Sorting complexity and algorithmic design.
  • Hash function behavior and collision handling.
  • Prime optimization in modular hashing.
  • Static vs dynamic data organization.
  • Visualization-driven understanding of algorithm flow.

🧩 Lessons Learned

Building this project strengthened my understanding of:

  • Algorithm visualization as a learning tool.
  • Hash function design and optimization.
  • Trade-offs between collision-handling strategies.
  • Implementation of sorting algorithms from scratch.
  • Structuring reusable and modular Java utilities.

Feedback

I’d love to hear your thoughts or suggestions to improve this project. Feel free to reach out at rashosubs@gmail.com or open an issue in the repository.

Author

About

Educational Java implementations of core data structures and algorithms (sorting, hashing, hash tables) with step-by-step console visualizations.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages