Age | Commit message (Collapse) | Author |
|
|
|
Lots of fun getting this one. I modified the starter code significantly,
so it's more like my Java code (I did deviate away with setID as int).
I'm happy for 2 things:
1. Learned and practiced again of passing by reference and modifying
vector<Table> elements through address
2. Debugging googletests with Eclipse, I tried it and it worked. I had
to click forward a few steps before I can really see variables and their
changes in the debugger. Very nice :)
|
|
I used C++'s priority_queue (queue.h) and C++'s own pair data structure.
Unlike Python and Java's similar data structure, C++'s priority_queue
pops in reverse order, so I had to negate the value, and negate back
when adding them to vectors. Cool use of pair. Fun stuff :)
|
|
It turned out it's more challenging converting Java code to C++ this
time. The for loop, commented in the code, was tricky! The while loop
was better anyway. It was good practice of doing debugging with gdb.
Once again, rewarding experience!
|
|
Fun exercise. Good comparison and contrast with Java.
|
|
Wow, this is so frustrating at times but in the end so much fun!!! My
real issue was creating and using a member function called getChildren,
which returns a node's children. It turned out if I accessed the
children member variable directly (since it's public), problem solved!
Another somewhat interesting observation is that using "vector<Node>" in
the main getHeight function seems slightly more efficient (memory wise)
than "vector<Node*>". I also used Visual Studio Community C++ 2017,
which was cool as well!
|
|
Partially because it didn't pass time limitations for test case 19 out
of 24. I suspect it's pointer reference stuff that was the cause of the
issue. Checking in for now, I need to research and learn more and will
tackle this again so it passes all tests.
|
|
Implementation isn't difficult since I worked the algo out in Java and
Python already. I tried to use VS Code to write this but in the end
decided to stick with Eclipse. Doing this in VS Code may not be worth
the investment.
|