Hello
Just joined. Hello Everyone.
I have two brain teaser. I don't know the answer to the first one and I think have a working C++ version of the second posted in my journal. Can anyone get the first one?
1. Describe an algorithm to determine whether a singly-linked list is corrupt. By corrupt, I mean one node is back linked to a previous node, so that if you start at the beginning and go node by node, you'll never come to a terminating node. Don't allocate memory doing it, e.g., space for each pointer.
2. Describe a simple algorithm for reversing the order of words in a string. For example, "The quick brown fox jumped" becomes "jumped fox brown quick The" Do it in place, that is, without using a temporary or output string.
I didn't make these brain teasers up, they supposedly come from questions asked in interviews for jobs at Microsoft.
I have two brain teaser. I don't know the answer to the first one and I think have a working C++ version of the second posted in my journal. Can anyone get the first one?
1. Describe an algorithm to determine whether a singly-linked list is corrupt. By corrupt, I mean one node is back linked to a previous node, so that if you start at the beginning and go node by node, you'll never come to a terminating node. Don't allocate memory doing it, e.g., space for each pointer.
2. Describe a simple algorithm for reversing the order of words in a string. For example, "The quick brown fox jumped" becomes "jumped fox brown quick The" Do it in place, that is, without using a temporary or output string.
I didn't make these brain teasers up, they supposedly come from questions asked in interviews for jobs at Microsoft.
