This is a Java program that calculates the most frequent element in an array of integers using both serial and parallel algorithms.
Created by Stanislav Kinash / neprostostas
To run the program, open a command prompt or terminal window and navigate to the directory containing the Main.java
and WorkerThread.java
files. Then, compile the source code using the following command:
javac Main.java
Once the code is compiled, you can run the program using the following command:
java Main
When you run the program, you will be presented with the following options:
- Generate random input data
- Read input data from file (
input.txt
)
If you choose option 1, you will be prompted to enter the size of the array you wish to generate. The array will then be written to a file called input.txt
.
If you choose option 2, the program will attempt to read an array from a file called input.txt
. If the file does not exist, option 2 will be unavailable.
After the input data has been generated or read, the program will calculate the most frequent element using both a serial algorithm and a parallel algorithm. The results will be displayed on the screen along with the time taken to perform each calculation.
Finally, you will be prompted to run the program again or exit.
- Generates random input data or reads input data from a file
- Calculates the most frequent element using a serial algorithm
- Calculates the most frequent element using a parallel algorithm
- Displays the time taken to calculate the most frequent element for both algorithms
- Allows the user to run the program multiple times or exit after each run
- Supports Windows and Unix-based operating systems
Contributions, issues, and feature requests are welcome!
This program is licensed under the terms of the MIT License. See the LICENSE
file for more information.
If you have any questions or concerns, please contact the author at [email protected]