Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrote SequentialSearchST class and comments #2

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updated basic test client
jromeall committed Mar 16, 2023
commit b98cf33c1f7c68c3a5fe71ac086fc8e6838b8512
29 changes: 23 additions & 6 deletions src/BasicTestClient.java
Original file line number Diff line number Diff line change
@@ -14,9 +14,8 @@ public static void main(String[] args) {

Scanner input = new Scanner(inputString);

// You can replace the implementation with any class that implements
// SymbolTable interface
SymbolTable<String, Integer> st = new TreeMapWrapper<>();
// OrderedSymbolTable interface
OrderedSymbolTable<String, Integer> st = new BST<>();

int i = 0;
while (input.hasNext()) {
@@ -25,8 +24,26 @@ public static void main(String[] args) {
i++;
}

for (String s : st.keys()) {
System.out.println(s + " " + st.get(s));
}
// Test min
System.out.println("Min key: " + st.min());

// Test max
System.out.println("Max key: " + st.max());

// Test floor
String floorKey = "F";
System.out.println("Floor of " + floorKey + ": " + st.floor(floorKey));

// Test ceiling
String ceilingKey = "C";
System.out.println("Ceiling of " + ceilingKey + ": " + st.ceiling(ceilingKey));

// Test select
int k = 3;
System.out.println("Key with rank " + k + ": " + st.select(k));

// Test rank
String rankKey = "E";
System.out.println("Rank of " + rankKey + ": " + st.rank(rankKey));
}
}