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

Ternary Tree print improvements #84

merged 7 commits into from Feb 21, 2019


Copy link

@amichair amichair commented Feb 14, 2019

Ternary Tree had some bugs in its printing implementation, like not printing the complete tree (or not printing at all small trees) on some platforms, first-level indentation was wrong (some second-level nodes appeared at the same indentation of the root node), etc.

Also optimized it to use a single StringBuilder instead of creating a whole lot of them, made the code shorter and cleaner, added command line option to print the full path on every line (easier for some analyses, and useful to see full words and not just their suffix), added indication of words ending in the middle of a path (prefix of other words), and changed the chars and spacing to make the printout look more like a standard tree diagram.

This helped me in analysing and understanding later modifications and their effect on the tree structure, correctness and performance.

@@ -187,6 +188,8 @@ public static void main(final String[] args)
distance = Integer.parseInt(args[++i]);
} else if ("-p".equals(args[i])) {
print = true;
} else if ("-pp".equals(args[i])) {
Copy link

@dfish3r dfish3r Feb 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this switch to the usage statement. ~ line 253.

Copy link

dfish3r commented Feb 20, 2019

Looks good. Just had one trivial comment.

Copy link
Contributor Author

amichair commented Feb 20, 2019


Updated the usage, hope the wording is ok.

@dfish3r dfish3r merged commit dd1cb15 into vt-middleware:master Feb 21, 2019
@amichair amichair deleted the tree-print-improvements branch Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants