Posts

Showing posts from December, 2016

Print multi tree data structure ascii visualization on console with java

Image
I was struggling with a debugging problem in one of my programs, which showed intermittent bugs when working on a huge amount of text data. The program was performing pattern matching using a tree prediction as discussed in my other blog at http://coffeefromme.blogspot.com/2015/10/to-extract-date-from-given-text-with.html Since debugging huge set of text data is very hard, I required my tree to show on console visually to help me find the bug source. I tried to find available algorithms to print tree on the console. There were programs which could print binary trees, but not for the multi-children tree. So I created the following code to print the tree. Sample Tree using text in class Test Class : Test (To build and print the tree) import java.util.ArrayList; import java.util.List; public class Test { public static void main(String a[]) { List<String> l = new ArrayList<String>(); l.add( "DDDD*DD*DD" ); l.add( "DDDD*