Dev-016 / Data-Structures-with-Algorithm-Design-Analysis

University project to learn Java, OOP, and data structures. Achieved 100% mark for this project.

Repository from Github https://github.comDev-016/Data-Structures-with-Algorithm-Design-AnalysisRepository from Github https://github.comDev-016/Data-Structures-with-Algorithm-Design-Analysis

CSC1035: Assessment 2

Synopsis

This program allows the user to manipulate a staff telephone directory - entries can be inserted, deleted and looked up.
Staff entries consist of a surname, initials and extension.

Performance and Correctness Testing

See the [Performance and Correctness Testing Report](performance Testing.pdf) for my discussion about the difference in
performance of data structures and some testing conducted to ensure the validity of certain methods.

How To Use - Entry Point

To run this program simply run the "Main" class. Upon running the program you will be prompted with:
    Please choose a valid data structure to use!
    1 - Array
    2 - ArrayList
    3 - HashMap
    Input 1 or 2 or 3: 

This is where you must select which data structure to use to store and manipulate entries.
Only type "1", "2", or "3" and press enter to select a data structure of your choice. After selecting a valid choice
You should be prompted with 9 choices as follows:

    Please choose a valid choice
    1 - Input Entry
    2 - Delete Entry By Surname
    3 - Delete Entry By Extension
    4 - Lookup Extension By Surname
    5 - Update Extension By Surname
    6 - Extract From CSV File
    7 - Display Contents As Table
    8 - Output Contents To CSV File @ 'csv files/Output.csv'
    9 - Output Performance Analysis
    Enter choice: 

To select a valid choice please enter the preceding number to the corresponding choice and then press enter.

By typing "1" and pressing enter, you will be prompted to input a surname, initials and extension. Only the extension
will be validated to meet the specified format in the specification - as in the specification the surname and initials were not stated
with any formatting rules. Attempting to enter an entry that has a surname already assigned to another entry in the
directory will not have any affect on the directory. If you wish to test this - attempt to input a duplicate entry
and then type "7" and press enter to view the contents of the directory.

By typing "2" and pressing enter, you will be prompted to enter a surname to delete the corresponding entry
entering a valid surname will delete an entry whereas not entering a valid surname will not have any affect on the
directory.

By typing "3" and pressing enter, this will have the exact same behaviour or effect as option 2 but instead an entry's
extension will be required to delete the corresponding entry.

By typing "4" and pressing enter, you will be prompted to enter a surname - if an entry exists with the surname
passed then the entry's extension will be printed otherwise null will be printed.

By typing "5" and pressing enter, you will be prompted to enter a surname then extension. If an entry with the specified
surname exists and extension is valid then the existing entry's extension will be set to the new extension inputted.
Otherwise the directory will not be affected.

By typing "6" and pressing enter, you will prompted to enter a directory and filename to specify where this program
should extract entry data from to combine with your selected directory data structure. Important to note that all
CSV data has been moved to a directory in this directory named "csv files" - running this command and specifying
"csv files/test_data" will extract data from the test data containing duplicates. Also important to note that the
user should not specify the file extension as ".csv" this is automatically appended to the directory the user inputs.
To restrict the user to only extracting from CSV files. If duplicate entries exist within a CSV then they will not
be added to the given directory - such that if someone with surname "Taylor" is detected more than once only the
first encounter will be added whilst every subsequent entry with the same surname is ignored.

By typing "7" and pressing enter, a table of the current directory's contents will be outputted. This is very useful
in checking what is currently in the directory and to validate if an action affected the directory or not.

By typing "8" and pressing enter, the directory's content is written to the CSV file in "csv files/Output.csv".
This directory output is not customizable to the user as the specification only states to customise the output of
the results of the performance results. However if one wishes to change this output directory - one may do so
by changing the String in "Output.java" line 112 from "csv files/Output.csv" to something else.

                // file points to the file to write to
                FileWriter file = new FileWriter("csv files/Output.csv");
                // This creates a buffer-write object
                BufferedWriter fileWriteTo = new BufferedWriter(file);

By typing "9" and pressing enter, this will initiate 240,000 performance tests - sorry for the wait. For more details
about testing please see below. Clarifying how to test - and - what is tested.

Running Tests

Run the "Main" class, you will be prompted to choose a data structure - regardless of data structure choice -
all data structures are tested for all methods using both unique and duplicate data sets. Once prompted with 9 choices,
simply type "9" and press enter, then wait a very long time for 240000 tests to run. Sorry again for the wait.
The results of this test will be outputted to "src/Performance.txt".

The filepath and file output can be modified by navigating to the "Main.java" class and locating this code on line 99

     case "9":
            System.out.println("Running 240,000 Tests - Please Wait");
            output.outputPerformanceStatistics(PerformanceAnalysis.allTests(), "src/Performance.txt");
            break;

Where "src/Performance.txt" is stated in the output method, by changing that String, the output location will be changed.

What is Tested?

There are 3 directories, array, arrayList and hashMap. There are also 4 methods to test, deletion by surname,
deletion by extension, lookup extension, and insertion. Lastly there are two sets of test data one containing only
unique entries and one containing duplicate entries. For each directory each method is tested ten-thousand times
for both sets of data. The results are measured in nano-seconds in which the best, worst and average case for each
test conducted, is written to the text file.

License

See the LICENSE.md file for license details.

Built With

Acknowledgements

Author

  • Name: Lee Taylor Student Number: 190211479

Note

There is no Nucode link due to experiencing problems with Nucode - furthermore
using Nucode was stated as not apart of the mark scheme or specification.

About

University project to learn Java, OOP, and data structures. Achieved 100% mark for this project.

License:Other


Languages

Language:Java 100.0%