[algogeeks] Facebook Interview Question

2012-07-30 Thread sengar.mahi
There are K pegs. Each peg can hold discs in decreasing order of radius when looked from bottom to top of the peg. There are N discs which have radius 1 to N; Given the initial configuration of the pegs and the final configuration of the pegs, output the moves required to transform from the

Re: [algogeeks] Re: Directi Interview Ques

2012-07-14 Thread sengar.mahi
@naveen : 3*7+2*9+1*3 =42 is not maximum.. sum of the product would me maximum wen, i guess, most weighted elements are adjacent like in this case if c={1,2,3,3,7,9} 1*2 + 3*3 + 7*9=74 (maximum ) thus this question is just merging both strings such resultant (here C) is in sorted order which can

Re: [algogeeks] Find peak element in log(n)

2012-06-23 Thread sengar.mahi
@adarsh :its nt dat easy as u see it.. On Sun, Jun 24, 2012 at 1:45 AM, Sourabh Singh singhsourab...@gmail.comwrote: @adarsh kumar are u sure it's worst case will be O (log n) ?? i think iff array is fully sorted O(n) will be required to say NO such element present On Sat, Jun 23, 2012 at

Re: [algogeeks] Please explain

2012-06-14 Thread sengar.mahi
sry i got confused its 3 then 2 then 1. i thought its 321 On Thu, Jun 14, 2012 at 2:13 PM, Mahendra Sengar sengar.m...@gmail.comwrote: main() { static i=3; printf(%d,i--); return i0 ? main():0; } the above code gives output 321 Please Explain how? -- You

Re: [algogeeks] Re: Can anyone explain this strange behavior ?

2012-06-11 Thread sengar.mahi
Nope ,the output is correct.as I had studied somewhere ,i don't remember where exactly but in (x||y) type condition's,if x evaluates to true( non zero) then value of y doesn't matter and is not evaluated and condition turns out to be true anyhow without even checking y ,control never goes to y and

Re: [algogeeks] Re: wrong output of C program

2012-06-08 Thread sengar.mahi
@naveen :read the his doubt properly...he was expecting 5 10 15 but was getting 8 32 96...and dats the correction required which i made On Fri, Jun 8, 2012 at 8:08 AM, Navin Kumar algorithm.i...@gmail.comwrote: @Mahendra: for ur above code with t=(a2)+a o/p will be 5,10, 15 as i explained

Re: [algogeeks] If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2012-06-07 Thread sengar.mahi
http://users.ece.utexas.edu/~adnan/afi-samples.pdf is dis wat u al r lukin 4?? On Thu, Jun 7, 2012 at 3:01 PM, Abhishek Sharma abhi120...@gmail.comwrote: yes,it is helpful,but read it only if u have fully understood Introduction to algorithms or if u have strong foundation of algorithms/data

Re: [algogeeks] wrong output of C program

2012-06-07 Thread sengar.mahi
Good Question ,eagerly waiting for some good explanation to this one !!! On Fri, Jun 8, 2012 at 5:46 AM, Mad Coder imamadco...@gmail.com wrote: The following is a simple C program which tries to multiply an integer by 5 using the bitwise operations. But it doesn't do so. Explain the reason

Re: [algogeeks] Simple Question ,Find Error

2012-06-04 Thread sengar.mahi
Answer: Compiler error: Lvalue required in function main This was the answer given along with the question..pls explain !! On Mon, Jun 4, 2012 at 10:04 PM, abhishek zeal.gosw...@gmail.com wrote: This code have issue. names[3]=names[4]; names[4]=t; -Original Message- From: