https://github.com/shounlak/treeset-java
Learning TreeSet in Java
https://github.com/shounlak/treeset-java
huit java treeset
Last synced: 10 months ago
JSON representation
Learning TreeSet in Java
- Host: GitHub
- URL: https://github.com/shounlak/treeset-java
- Owner: ShouNLAK
- Created: 2025-06-08T04:52:46.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-08T05:14:08.000Z (about 1 year ago)
- Last Synced: 2025-07-04T13:07:08.922Z (about 1 year ago)
- Topics: huit, java, treeset
- Language: Java
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Learning TreeSet in Java
A Java program demonstrating various operations on `TreeSet`, including sorting, searching, statistics, and manipulation using different data sources.
---
## 📌 Table of Contents
- [Features](#features)
- [Prerequisites](#prerequisites)
- [How to Run](#how-to-run)
- [Example Output](#example-output)
- [Contributors](#contributors)
- [License](#license)
---
## 🚀 Features
- **Default Ordering TreeSet**: Stores elements in ascending order.
- **Comparator-based TreeSet**: Stores elements in descending order using a custom comparator.
- **TreeSet from User Input**: Allows users to enter values via the keyboard.
- **Randomized TreeSet**: Generates random values and stores them.
- **TreeSet from an Array**: Converts an array into a `TreeSet` to remove duplicates.
- **TreeSet from a File**: Reads values from `input.txt` and stores them.
- **Search Operations**: Allows searching for elements in the TreeSet.
- **Deletion Operations**: Enables removing elements from the TreeSet.
- **Statistics on TreeSet**: Provides insights such as the smallest/largest elements and subsets.
- **Conversion to Array**: Transforms `TreeSet` into an array.
- **Clearing Elements**: Removes all elements from the TreeSet.
## 🛠Prerequisites
- Java Development Kit (JDK) installed
- An `input.txt` file (if using file-based input)
## âš¡ How to Run
1. Clone this repository:
```sh
git clone https://github.com/ShouNLAK/Learning_TreeSet.git
```
2. Compile the Java program:
```sh
javac Learning_TreeSet.java
```
3. Run the program:
```sh
java Learning_TreeSet
```
## 📸 Example Output
```sh
TreeSet [1, 3, 4, 5, 8]
TreeSet with Comparator [8, 5, 4, 3, 1]
Number of elements:
Please input value of the elements #1: 23
TreeSet from keyboard input: [23]
Elements #1 randomized: 67
TreeSet from Random: [67]
...
```
## 👥 Contributors
- [ShouNLAK](https://github.com/ShouNLAK)
- Open to contributions! Feel free to fork, submit PRs, or suggest improvements.
## 📜 License
This project is open-source. Feel free to use and modify it as needed.