For example, i didn't know what a virtual function was, but I've used it before. So any tips on what to read up on is appreciated too. On the phone interview: Interviewer: How do you find if a linked list has a cycle? Me:(feeling very confident) Use a set and every time a new element is traversed, write its pointer part into the set. Keep track of the number of nodes visited and size of the set. If/When they get unequal, you have found a loop! Him: Er... use two pointers, one for the first element and the second for the next element. When both of their next elements are the same, its a loop. Me: Oh...yeah. :|
So, you guys get the idea i hope. And yeah, wish me luck. :) Thanks in advance.
No comments yet.