/search-comparison

An analysis between binary search anternary search on c++.

Primary LanguageC++

Number Guessing Algorithm Analysis

Overview

This project contains a C++ program and a Python script designed to analyze the performance of a number guessing algorithm. The C++ program calculates the average number of tries it takes to guess a number using a specific strategy, and outputs the results to a file. The Python script then reads these results and generates a graphical representation of the data.

Files

  • main.cpp: The C++ program that implements the number guessing algorithm and calculates the averages.
  • graph.py: The Python script that reads the averages from the output file and generates a plot.
  • averages.txt: The output file generated by the C++ program containing the averages.

Prerequisites

  • A C++ compiler (e.g., g++, clang)
  • Python 3
  • Matplotlib library for Python (Install using pip install matplotlib)

Setup and Running

Compiling and Running the C++ Program

  1. Compile the C++ program using a C++ compiler:
g++ main.cpp -o main
  1. Run the compiled program:
./main

This will generate the averages.txt file with the average number of tries for different divisors.

Running the Python Script

  1. Ensure you have Python and Matplotlib installed.
  2. Run the script:
python graph.py

This will read the averages.txt file and display a plot showing the relationship between the divisor and the average number of tries.

Contributing

Feel free to fork this project and submit pull requests or suggest improvements by opening issues.

License

[Insert your preferred license here, or state if it's unlicensed]

Contact

We hope this tool helps in understanding the behavior of the number guessing algorithm. For any questions or suggestions, please contact the contributors.