Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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

  • 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:
    git clone https://github.com/ShouNLAK/Learning_TreeSet.git
  2. Compile the Java program:
    javac Learning_TreeSet.java
  3. Run the program:
    java Learning_TreeSet

πŸ“Έ Example Output

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
  • 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.

About

Learning TreeSet in Java

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages