diff --git a/src/Assignments/A3/TestInterpolationSearch.java b/src/Assignments/A3/TestInterpolationSearch.java index 8def1f5..0f0dfba 100644 --- a/src/Assignments/A3/TestInterpolationSearch.java +++ b/src/Assignments/A3/TestInterpolationSearch.java @@ -6,12 +6,13 @@ public class TestInterpolationSearch { /** Holds the list of 1024 unique values used to search through */ public int[] values; - + /** Holds the size of the table to generate */ + public int tableSize; /** * Generates a list of 1024 random, non-repeating, integers and assigns them to the values field. */ - public void RandomDistinct() { + public void randomDistinct() { /* Used to track what ints have been used */ HashSet isUsed = new HashSet<>(); int[] newList = new int[1024]; @@ -34,4 +35,17 @@ public class TestInterpolationSearch { Arrays.sort(newList); this.values = newList; } + + public void runIntSearch() { + int totalDivisions; + Random rand = new Random(); + + System.out.println(" Key\t\tFound\t\tIndex\t\tDivisions"); + System.out.println("----------------------------------------------"); + for (int i = 0; i < this.tableSize; i++) { + int key = rand.nextInt(9999) + 1; + InterpolationSearch results = new InterpolationSearch(this.values, key); + System.out.println(" " + key + "\t\t" + results.isFound() + "\t\t" + results.getIndex() + "\t\t" + results.getDivisions()); + } + } }