Comments (5)
I will look at it. I think there is error in validation function. Do you see infinite loop in some reasonable size string which can be debugged?
On Sunday, October 25, 2015 1:46 PM, mfazeen <[email protected]> wrote:
Hi,You have done a wonderful job in the implementation. However, when I try to insert a large String (I can provide the test string) It throws the following exception. It never completed inserting the full string.Exception in thread "main" java.lang.NullPointerException
at SuffixTree.nextChar(SuffixTree.java:426)
at SuffixTree.startPhase(SuffixTree.java:322)
at SuffixTree.build(SuffixTree.java:143)
at SuffixTree.main(SuffixTree.java:101)The string i was trying to insert was 63027 in length. However, another large string with a length of 63067 inserted without and error (I can provide this test string as well). However, the second large string failed at your validation function;Failed at 58 for index 56
Failed validation
falseI was trying to debug it but couldn't track it down. Wanted to bring it to your attention. Thanks.—
Reply to this email directly or view it on GitHub.
from interview.
Hi,
Thank you for your prompt reply. The NullPointerException is thrown even before it gets to the validation function. It did not load the complete string to the tree.
The exception is generated when the nextChar(int i) function try to access the start value of the activeNode child at the line:
return input[active.activeNode.child[input[active.activeEdge]].start + active.activeLength];
(last return statement in the else block in the nextChar function)
At this line the "active.activeNode.child[input[active.activeEdge]]" is null for sum reason and that failed the tree creation.
I.e. the activeNode child at the input[active.activeEdge] location is null for some reason. I assume that either this child is not created correctly in a previous step or the index of the child is incorrect. Hope this will help you.
I did not see any infinite loops though.
Thanks
from interview.
I meant do you have a smaller example where you get NPE instead of this 63K long string.
from interview.
Sorry, I did not get any NPE with smaller strings that I tried with. If I come across one I will let you know.
from interview.
fixed some bugs. Probably that will fix this issue.
from interview.
Related Issues (20)
- FenwickTree.java is not working properly.
- Time complexity for johnson's algorithm
- Interview
- Array given as test case is not sorted HOT 1
- MaxSumForNonAdjacentElements doesnt give correct result if first element of array is negative
- it should remove the allnodes.get(0).key
- Big O complexity of NumberOfPathsInMxNMatrix.java HOT 1
- shouldDeleteCurrentNode should also check if the current node is not having other word isEndOfWord as true.
- Fix the variable name in matrix multiplication problem
- countDownLatch.countDown() should be inside execute function
- Index access out of range in regex expression matching implementation.
- The project uses Gradle 2.11 which is incompatible with IDEA running on Java 10 or newer.
- MedianOfTwoSortedArrayOfDifferentLength.java Incorrect test case
- MedianOfTwoSortedArrayOfDifferentLength.java HOT 1
- Edit Distance Recursive solution HOT 5
- Small improvement to the power of 2 loop
- how to add item from the search selection which item name is brown sugar and 1 KG from bigbasket
- Egg Dropping Puzzle & min jumps to reach the end
- Where do companies pull technical software developer interview questions from?
- What are all the common software development technical online assessments companies use?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from interview.