[algogeeks] Re: Reversing a string !!

2007-10-30 Thread Sumedh Sakdeo
store the words in linked list while taking the input... As they have not mentioned constraints on data structure .. and reverse the linked list... Regards, Sumedh On 10/31/07, Somesh Jaiswal <[EMAIL PROTECTED]> wrote: > > Hi, > > I was asked a question in an interview to Reverse the order of word

[algogeeks] Re: min height rootless tree

2007-10-30 Thread Satish
If the 'root' node has to be such that the height of the resultant tree should be minimum, then this root node must lie in the middle of the largest possible path between any 2 points in this graph. Given above, start doing a DFS from any arbitrary node. This is doable in O(n). It will return ret

[algogeeks] Reversing a string !!

2007-10-30 Thread Somesh Jaiswal
Hi, I was asked a question in an interview to Reverse the order of words in a sentence. eg. "Google is an awesome place to work" should be reversed as "work to place awesome an is Google" The solution should be efficient and shouldn't use any extra memory. Pl suggest me some solution. Regards,

[algogeeks] Re: coloring a graph of O(|V|) edges

2007-10-30 Thread dor
On Oct 24, 3:25 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > In fact, we could use only 3 colors to do this, if this graph is > connected. > > At first, I guess you know the famous 4-color theorem, so 4 colors is > enough. > In fact, if this graph can be disconnected, then we have to use 4

[algogeeks] Re: Friendly Graphs

2007-10-30 Thread Gene
On Oct 29, 8:26 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Consider the following scenario. > > Let A be the vertex moved from Set 1 to Set 2. Which means that A > had more edges within Set1 compared to those in Set 2. Now it is quite > possible that there might be an edge B in Set