Posted on 2 Comments

Tree, recursive function and my dumb mistake

Reading Time: < 1 minute

Tree data structure is fairly common in software development, and luckily I have quite a bit experience working on those in my career. I started working on this as I was working for UGS/Siemens PLM Software, and I was involved in the development of XML based data adapter for CAD data exchange, a key piece of information we want to translate is the assembly information, or product structure, or in computer/software terms, the tree hierarchy. I did learned a few things on recursive function, etc. Interestingly enough, later on I got a interview phone call from Google, and the guy asked me about recursion, for a simple problem like this: basically they are 100 matches, every time one can take one or 2, how many combinations are there? I said let’s do it in recursive fashion, after quite a bit reminder/hint, finally I said n(100) = n(99) + n(98)

But they were not very impressed with me, as I did not come up with the solutions fast enough, which is fine. I am who I am, I can work on those kind of interesting problems, in my own pace. Or explained in my Chinese name, it’s getting faster gradually 🙂

My dumb mistake
So I got chance to work on tree, and recursion again. And I made a dumb mistake which might be common among people who are new to java, or who have left java for a while/just come back recently (like me). Basically I called a repository function a million times. And I got this error: org.apache.jk.common.channelsocket processconnection status 2

Today I was able to fix it, basically I found it’s unnecessarily to call the repository, I could use 2 hash maps (in memory) for the work.

2 thoughts on “Tree, recursive function and my dumb mistake

  1. […] I was able to fix that performance problem I mentioned in my previous post. But I inadvertently introduced a new problem in my previous fix. And here is how I […]

  2. […] is a continuation of my earlier post of Tree, recursive function and my dumb mistake. As I said in my last post, my solution was to create hash maps (singleton) to store those for the […]

Comments are closed.