Re: [algogeeks] Divide the array into groups

2011-01-30 Thread Rohit Saraf
@ ^ Why do you try hard not to understand the question or what one meant by the question and instead try hard to find out flaws. I mean ain't that obvious that you need to divide into minimum number of groups? -- Rohit Saraf Third Year Undergraduate

Re: [algogeeks] Re: Frequently one of the Top Question Asked in Amazon

2011-01-30 Thread Rohit Saraf
Isn't it just a coding question? @ ^ : your code is not clean enough for anyone to read. As far as data-structures are concerned... a stack and a queue suffice. There is no algorithmic issue I can see. So, I guess you should solve these problems yourself or some programming forum. For those who

Re: [algogeeks] Divide the array into groups

2011-01-29 Thread Rohit Saraf
I don't see why you need O(n^2) time for rearranging. It can be done in O(n log n) if you maintain the index along with every element. Then reordering would mean sort as per the indices. -- Rohit Saraf Third Year Undergraduate, Dept. of Computer

Re: [algogeeks] and or tree

2011-01-27 Thread Rohit Saraf
Let No of flips reqd = solve(N, V) L=left subtree. R = right subtree N = root node. If V=0, then only problem is when L = 1 and R=1. (otherwise atmax changing the root node will do) then ans = min(solve(L, 0), solve(R,0)) + (R=AND)?0:1 If V=1 then only problem is when L=0 and R=0

Re: [algogeeks] and or tree

2011-01-27 Thread Rohit Saraf
Of course memoization is needed (Can be done by using an array and the fact that it is complete binary tree.) Also if the later half of the array is all 0, then 1 cannot be obtained at the root and vice versa. -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Sparse Matrix multiplication

2011-01-27 Thread Rohit Saraf
http://www.eecs.harvard.edu/~ellard/Q-97/HTML/root/node20.html -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] find a way

2011-01-23 Thread Rohit Saraf
@Divya : In that case, a greedy solution does not seem to exist. You need to use the traditional DP way. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this

Re: [algogeeks] Re: L values and r values

2011-01-23 Thread Rohit Saraf
Perhaps it is not available. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more

Re: [algogeeks] Google Question

2011-01-23 Thread Rohit Saraf
No special approach is needed. In O(log n), you can find the minimum element of the array which makes your circular array - normal array. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] large array initialization

2010-11-01 Thread Rohit Saraf
].Validity = d[n+1].Validity ) then d[n+1].Value else d[i].Value There is a practical issue that Validity may become larger than int etc... however that too can be easily overcome. -- Rohit Saraf Third Year Undergraduate, Dept. of Computer

Re: [algogeeks] search a 2d sorted array in less than O(n)

2010-09-28 Thread Rohit Saraf
be rejected straightforward from just this info. Hence the complexity T(m,n) = 2 * T(m/4,n/4) + c Rohit Saraf Third Year Undergraduate Compter Science Engineering IIT Bombay -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

Re: [algogeeks] clear screen in mysql

2010-09-14 Thread Rohit Saraf
See it here : jfgi http://www.urbandictionary.com/define.php?term=jfgi -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] clear screen in mysql

2010-09-14 Thread Rohit Saraf
well i just wanted u to know that there is a very nice place called www.google,com where u can find many things. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe

Re: [algogeeks] ACTIVATION OF WINDOWS 7

2010-06-20 Thread Rohit Saraf
So, is this the place for that? And apart from that, it is illegal to discuss about this on public threads. (if you don't know, this thread is public) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay

Re: [algogeeks] There is an array of odd and even numbers. Now, sort them in such a way that the top portion of the array contains odd numbers, bottom portion contains even numbers

2010-06-20 Thread Rohit Saraf
Why not just change the definition of when one number is bigger than another and do normal sort ? I guess that is better and simpler. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http

Re: [algogeeks] Re: SPOJ:RRSCHED

2010-06-20 Thread Rohit Saraf
You must be doing some useless iterations . Otherwise, TLE is too strange for this prob. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Sat, Jun 19, 2010 at 9

Re: [algogeeks] finding nearest neighbour

2010-06-20 Thread Rohit Saraf
It was my lab assignment prob last year. Will send u if i happen to find it by chance. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Mon, Jun 14, 2010 at 10

Re: [algogeeks] Re: SPOJ:RRSCHED

2010-06-20 Thread Rohit Saraf
No -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Sun, Jun 20, 2010 at 3:22 PM, Shravan shravann1...@gmail.com wrote: Did you see the code which I have

Re: [algogeeks] Integer from number in words

2010-06-20 Thread Rohit Saraf
You need to specify the max level upto which you want it to work. For rest, is there any prob? I can't see any. you see ninety - 90 u see thousand - 90*1000 + and so on -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science

Re: [algogeeks] back edges

2010-06-20 Thread Rohit Saraf
You start from a vertex, then if you reach that vertex before dfs on that vertex finishes, then the edge u used to reach it is a back edge. And if you reach after the dfs finishes on that node, it's a cross edge. -- Rohit Saraf Second Year

Re: [algogeeks] STRONG ACTION GIRL REAL STUNTS SWEET AND SEXY http://businproz.blogspot.com/ http://businproz.blogspot.com/ http://businproz.blogspot.com/

2010-06-20 Thread Rohit Saraf
Someone ban this spammer -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Re: coins

2010-06-17 Thread Rohit Saraf
Yes right, i forgot the 1 -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Thu, Jun 17, 2010 at 6:05 PM, Dave dave_and_da...@juno.com wrote: No. The greedy

Re: [algogeeks] coins

2010-06-16 Thread Rohit Saraf
If the coins are all multiple of some number k, you can greedily give as much as possible to the higher domination. Otherwise still, there is an optimal substructure and u can make a recurrence and use memoization(i.e. DP) -- -- Rohit Saraf Second

Re: [algogeeks] Re: coins

2010-06-16 Thread Rohit Saraf
@Dave: The greedy will only work if the coins are k,2k,3k,4k, nk without any of these missing Clear? (Perhaps i did not write it clearly as i was on mobile) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science

Re: [algogeeks] Re: Cycle in Undirected and Directed Graphs

2010-06-15 Thread Rohit Saraf
@vivek : was that a joke? -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Mon, Jun 14, 2010 at 11:40 AM, souravsain souravs...@gmail.com wrote: @sharad: Do

Re: [algogeeks] unique number in an array

2010-06-15 Thread Rohit Saraf
Just to point out : how many times have you all repeated this -- Xor works only -- even number of times. It will not work... Why don't you all read some earlier posts before posting. :P -- Rohit Saraf Second Year

Re: [algogeeks] output

2010-06-13 Thread Rohit Saraf
I read that. But still it should not be compiled as per the standard. The latest GNU C/C++ compiler correctly fails to compile this -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http

Re: [algogeeks] c- pointers

2010-06-13 Thread Rohit Saraf
@divya: u r rite.. that * should not be there -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Sun, Jun 13, 2010 at 11:07 AM, divya jain sweetdivya

Re: [algogeeks] c array

2010-06-13 Thread Rohit Saraf
which compiler do you use? -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Sun, Jun 13, 2010 at 10:46 AM, divya jain sweetdivya@gmail.comwrote: hmm

Re: [algogeeks] union- c

2010-06-13 Thread Rohit Saraf
what is this for... and which conversion are you talking abt? -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Sat, Jun 12, 2010 at 11:20 PM, divya sweetdivya

Re: [algogeeks] Problem with Virtual Function

2010-06-13 Thread Rohit Saraf
M-speed is private and you cannot call it from outside myPlugin. (though i did not understand what u wanted to say) Can you write ur prob explicitly? -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http

Re: [algogeeks] Problem with Virtual Function

2010-06-13 Thread Rohit Saraf
Make those functions public And even if M_speed is public of another class, it is still it another class, you cannot just address it like m_speed in other classes. Does it help? -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science

Re: [algogeeks] Problem with Virtual Function

2010-06-13 Thread Rohit Saraf
yes.. it should... make sure your virtual function is either public or protected but not private. and if it doesn't can u tell me the error? -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http

Re: [algogeeks] Problem with Virtual Function

2010-06-13 Thread Rohit Saraf
Put the function speed or its declaration inside the class b. Did u forget that? -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message

Re: [algogeeks] c array

2010-06-13 Thread Rohit Saraf
today. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Sun, Jun 13, 2010 at 1:47 PM, divya jain sweetdivya@gmail.comwrote: i use tc On 13 June 2010 13:11

Re: [algogeeks] c- pointers

2010-06-13 Thread Rohit Saraf
@jalaj: exactly... so you(@divya) are right. Sharad's ans was right but logic wasn't. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Sun, Jun 13, 2010 at 2:35

Re: [algogeeks] union- c

2010-06-13 Thread Rohit Saraf
If you are not able to print the long int and that's the prob, you can use %ld instead of %d -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Sun, Jun 13, 2010

Re: [algogeeks] Re: bits

2010-06-13 Thread Rohit Saraf
@Souravsain : Is there any serious problem in this. Anyone can just add a [C++] in the subject and uninterested people can make filters in gmail :) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http

Re: [algogeeks] Re: bits

2010-06-13 Thread Rohit Saraf
I agree mass bombarding with such questions is not very good.. but one doesn't join groups and all for getting a few doubts cleared. Anyways, i have no problem with anything. :D -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science

Re: [algogeeks] Cycle in Undirected and Directed Graphs

2010-06-13 Thread Rohit Saraf
In any directed graph just check if dfs has a back edge. For undirected, check if there is a nontree edge -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14

Re: [algogeeks] trees

2010-06-13 Thread Rohit Saraf
Repeated q. Search in the group -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] c array

2010-06-12 Thread Rohit Saraf
@ram : i guess you have used some longer string and not strings btw.. what is Mingw ? gcc/g++ is not mingw, i guess -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in

Re: [algogeeks] output

2010-06-12 Thread Rohit Saraf
when assigning to type ‘char[20]’ from type ‘char *’ -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Sun, Jun 13, 2010 at 8:13 AM, Mahesh_JNU mahesh.jnumc

Re: [algogeeks] Re: Array Problem

2010-06-12 Thread Rohit Saraf
@Satya: I don't think what you have coded will work.. though i have not read the whole code. Don't you think a simple divide and conquer scheme would work...(almost like the mergesort) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer

Re: [algogeeks] Re: infix

2010-06-11 Thread Rohit Saraf
a ( () -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Fri, Jun 11, 2010 at 12:07 PM, Vivek Sundararajan s.vivek.ra...@gmail.com wrote: @Rohit Consider : (a+)b The above is not well formed! :) On 11 June 2010 11:58

Re: [algogeeks] Print large Fibonacci numbers

2010-06-11 Thread Rohit Saraf
Fibonacci numbers can be calculated very efficiently using matrix multiplications. I hope you can think it/google it now.. that is better than me writing so much again :) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science

Re: [algogeeks] sum to x

2010-06-11 Thread Rohit Saraf
I guess it can be done in efficiently using a simple divide and conquer scheme almost imitating mergesort. Can you think of it now? :D -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http

Re: [algogeeks] Re: binary nos

2010-06-10 Thread Rohit Saraf
-- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Thu, Jun 10, 2010 at 11:47 AM, Sundeep Singh singh.sund...@gmail.comwrote: @rohit: fibonacci sequence may

Re: [algogeeks] infix

2010-06-10 Thread Rohit Saraf
) = -1 ( = +1 Keep a sum of all these as u iterate. That should never be negative Plus check for these types (if you need correct arithmetic expressions as well some operator followed by ) * or / after a ( () -- Rohit Saraf Second Year

Re: [algogeeks] c output

2010-06-10 Thread Rohit Saraf
c 1 6,2 u might be expecting 5,1 if u are forgetting the newline character :) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message

Re: [algogeeks] Re: binary nos

2010-06-09 Thread Rohit Saraf
@debajyoti: read the prob before posting -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Wed, Jun 9, 2010 at 2:37 PM, Debajyoti Sarma sarma.debajy

Re: [algogeeks] Single ordered list

2010-06-09 Thread Rohit Saraf
I had answered this question(of multiple lists) 2 or three days back. Go into the archive if u wanna see :P -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Wed

Re: [algogeeks] Re: binary nos

2010-06-09 Thread Rohit Saraf
@junta : are fibonacci sequence is the answer of the prob, it is not used :D -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Wed, Jun 9, 2010 at 9:13 PM, Rohit

Re: [algogeeks] Re: sorted 2-d array

2010-06-08 Thread Rohit Saraf
@senthilnathan : very nice indeed -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Re: constraints satisfied?

2010-06-08 Thread Rohit Saraf
Your time complexity is not O(c) but O(n^2) -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed

Re: [algogeeks] Re: binary nos

2010-06-08 Thread Rohit Saraf
Fib comes because she wants the number of such sequences -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you

Re: [algogeeks] Re: ds

2010-06-08 Thread Rohit Saraf
which is just the recursive version of the abovementioned iterative solution. P.S. -Please remove this quoted text when you are composing -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http

Re: [algogeeks] binary nos

2010-06-07 Thread Rohit Saraf
So u want efficient algo for fibonacci numbers? -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed

Re: [algogeeks] constraints satisfied?

2010-06-07 Thread Rohit Saraf
better. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

Re: [algogeeks] Re: binary nos

2010-06-07 Thread Rohit Saraf
getting fibonacci nos is trivial using matrix multiplication in almost constant time. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message

Re: [algogeeks] ds

2010-06-07 Thread Rohit Saraf
Of course you should do it via swappings.. why would one think of anything else :) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Mon, Jun 7, 2010 at 10:39 PM

Re: [algogeeks] Re: Largest even length palindrome in a string!!

2010-06-06 Thread Rohit Saraf
but actually we need something better as per prob, cannot be done in O(n). so we need to think of something like O(n lg n) or O( n ^ 3/2) :) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http

Re: [algogeeks] array question

2010-06-06 Thread Rohit Saraf
No it will be O(n). -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed to the Google Groups Algorithm

Re: [algogeeks] Print the string in reverse order (not revstr

2010-06-05 Thread Rohit Saraf
Tokenization is done in linear time. Just save the words in an list (And what makes you think of non-linearity in tokenization!) And then iteration over the tokens is trivially linear. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer

Re: [algogeeks] Quick short stack space reduction

2010-06-05 Thread Rohit Saraf
Actually he means the case when you implement quicksort using stacks. -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you

Re: [algogeeks] dynamic vs greedy aproach

2010-06-05 Thread Rohit Saraf
. Dynamic programming is a more general approach which is generally used when there is optimal substructure and has mostly found use in doing exponential looking problems in polynomial time. i hope u understood -- Rohit Saraf Second Year Undergraduate

Re: [algogeeks] o/p

2010-06-05 Thread Rohit Saraf
If you make it unsigned short int.. then it goes to 65535 on g++/gcc -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you

Re: [algogeeks] Print the string in reverse order (not revstr

2010-06-05 Thread Rohit Saraf
Ok. so you have a list. Iterating over it is linear isn't it? Ahh... you will need a doubly linked list or an arraylist.does it solve ur prob? -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http

Re: [algogeeks] Re: o/p

2010-06-05 Thread Rohit Saraf
oh... why did u put %u. i did not even notice that :P -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you

Re: [algogeeks] Re: Largest even length palindrome in a string!!

2010-06-05 Thread Rohit Saraf
What makes you think it is O(n^3). I did not read the code one but divya's solution seems to be O(n^2) for worst case. -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in

Re: [algogeeks] Re: Largest even length palindrome in a string!!

2010-06-05 Thread Rohit Saraf
Just read your code. It wont even work. Do you assume only one even length palindrome!? -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received

Re: [algogeeks] One question on Heap sort

2010-06-05 Thread Rohit Saraf
Can u elaborate on the 2nd step. btw, did u understand my soln? -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you

Re: [algogeeks] Re: partion of array

2010-06-05 Thread Rohit Saraf
This is almost the most basic dp. Read some of the examples from eva tardos. That would help. -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received

Re: [algogeeks] Valid permutation of the brackets

2010-06-04 Thread Rohit Saraf
@jitendra: How can you say that no polynomial algo can be found. I think you are wrong. A simple memoized formulation will make this polynomial because of the optimal substructure.. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science

Re: [algogeeks] Valid permutation of the brackets

2010-06-04 Thread Rohit Saraf
Oh i am talking only about printing the total number of solutions... If you backtrack... Obviously it would not be polynomial -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http

Re: [algogeeks] Quick short stack space reduction

2010-06-04 Thread Rohit Saraf
if you short the larger one first, then the smaller one will be in the stack for a long time. Which is wasting stack space. Now stop shorting and start sorting ! :) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering

Re: [algogeeks]

2010-06-04 Thread Rohit Saraf
Make a hashmap... Any problem doing that? -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed

Re: [algogeeks] Re: partion of array

2010-06-04 Thread Rohit Saraf
What precisely did you not understand?? -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed to the Google

Re: [algogeeks] Print the string in reverse order (not revstr)

2010-06-04 Thread Rohit Saraf
Have you posted the same question twice or i am feeling sleepy? -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you

Re: [algogeeks] Removing extra parentheses in an infix string

2010-06-04 Thread Rohit Saraf
Exactly that's what you need to do. -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed to the Google

Re: [algogeeks] Re: partion of array

2010-06-03 Thread Rohit Saraf
@divya: but still haven't you seen Jagadish's example? It is a counterexample to your greedy approach. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You

Re: [algogeeks] Re: Can you solve this?

2010-06-03 Thread Rohit Saraf
Still the solution will be similar and actually a bit simpler. -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you

Re: [algogeeks] Removing extra parentheses in an infix string

2010-06-03 Thread Rohit Saraf
A*(B+C*D) -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group

Re: [algogeeks] Removing extra parentheses in an infix string

2010-06-03 Thread Rohit Saraf
So there is a prob algoose A*(B*C) and a*(b*c+d) i hope you understood -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message

Re: [algogeeks] Valid permutation of the brackets

2010-06-03 Thread Rohit Saraf
why don't you make use of the optimal substructure. You can easily use the recurrence relation as DP @all : people don't just paste your code. Words are better than code -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

Re: [algogeeks] Check if 2 linked lists are identical

2010-06-03 Thread Rohit Saraf
! -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com

Re: [algogeeks] Re: another google telephone interview question

2010-05-18 Thread Rohit Saraf
at http://groups.google.com/group/algogeeks?hl=en. -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed

Re: [algogeeks] partion of array

2010-05-17 Thread Rohit Saraf
+200)-500)abs((2000)-(500+200)) so we ll put 200 in array B. now since B has n/2 elements rest of the element goes to array which is 1. so the ans is A={2000,1} b={500,200} On 15 May 2010 19:10, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: so what will ur algo give for array

Re: [algogeeks] partion of array

2010-05-17 Thread Rohit Saraf
} the difference is 40 the correct ans: A = { 110, 100 , 10 } B = { 90 , 70 , 60 } the difference is 0 i don't believe a greedy algorithm would work for this problem! On Mon, May 17, 2010 at 5:06 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: @divya : descending order sorting works

Re: [algogeeks] string question

2010-05-16 Thread Rohit Saraf
@Navin: and that works ! :) @all : i am sure no heuristic/greedy strategy can be applied. @divya : did you check your array partitioning algorithm with my example ! -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering

Re: [algogeeks] tree question

2010-05-16 Thread Rohit Saraf
suggesting will be polynomial. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed to the Google Groups Algorithm

Re: [algogeeks] question

2010-05-16 Thread Rohit Saraf
@anurag : won't work -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] regarding DSW algortihm

2010-05-16 Thread Rohit Saraf
Read it up : http://www.eecs.umich.edu/~qstout/pap/CACM86.pdf -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you

Re: [algogeeks] Re: median of a bst

2010-05-16 Thread Rohit Saraf
@Nikhil : For that size of subtrees at all nodes needs to be maintained. And in that case this is a trivial problem. @Sathaiah : See my solution :) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http

Re: [algogeeks] Re: partion of array

2010-05-15 Thread Rohit Saraf
/2 where n is the no. of elements in the given aaray. then store rest element in the other array. 5. repeat step 5 until both array A n B get n/2 elements.. hope my approach is clear and correct. comments are welcomed. On 15 May 2010 08:47, Rohit Saraf rohit.kumar.sa...@gmail.com wrote

Re: [algogeeks] k the smallest in BST without using static variable

2010-05-15 Thread Rohit Saraf
. -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

Re: [algogeeks] median of a bst

2010-05-14 Thread Rohit Saraf
-- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] compute kth smallest element from union of two lists

2010-05-14 Thread Rohit Saraf
. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] partion of array

2010-05-14 Thread Rohit Saraf
A simple DP should work. Should it not? -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Fri, May 14, 2010 at 4:15 PM, Sathaiah Dontula don.sat

Re: [algogeeks] 2nd shortest path in a graph

2010-05-14 Thread Rohit Saraf
I think... it will work :) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Fri, May 14, 2010 at 2:20 PM, divya sweetdivya@gmail.com wrote: Given a graph's

  1   2   >