Ask your own question, for FREE!
Computer Science 9 Online
OpenStudy (hyroko):

Hello, I have an issue with a recursive method I have in my program, which when called on the file I need to call it on, it recurses too deep and gives me a stack overflow error. With this program, I need to read in a file, convert capital letters to lowercase, trim all spaces and all non-alphabetical symbols, then create a binary tree and convert that binary tree into a huffman tree using a priority queue. Then I need to output the resulting condensed file, and compare the size of the file with the original. Here's the code I'm having trouble with currently. public static BinaryTree readBinaryTree( Scanner scan){ //read a line and trim leading and trailing spaces then creates Binary tree. String data = scan.next(); if(data.equals("null")){ return null; } else{ BinaryTree leftTree = readBinaryTree(scan); BinaryTree rightTree = readBinaryTree(scan); return new BinaryTree<>(data, leftTree, rightTree); } }

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!