Re: [algogeeks] MS interview

2011-09-17 Thread Abhishek Yadav
What should be the answer to above questions...? On Sat, Sep 17, 2011 at 5:01 AM, bharatkumar bagana < bagana.bharatku...@gmail.com> wrote: > Memory management has following things.. > 1.Relocation > To maintain the free pages and when a page is to be swapped, we have to add > that page into free

[algogeeks] Pattern Matching

2011-09-02 Thread Abhishek Yadav
Implement a function that receive a string S and a pattern containing wild characters ( * and ? only) in string P. Function return true if S matches the pattern P. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send em

Re: [algogeeks] Re: Closest ancestor of two nodes

2011-09-02 Thread Abhishek Yadav
this solution works if parent pointer is given. 1. Start moving up from both the nodes (if two nodes become equal, fine this is the common ancestor) till you reach the root node and in between count the number of nodes you covered in their path for both the nodes. Say 7 for node A and 10 for node B

Re: [algogeeks] print level by level withoust recursion

2011-08-31 Thread Abhishek Yadav
can we use loops or GOTO statements On Wed, Aug 31, 2011 at 10:03 PM, manish kapur wrote: > Given a binary Tree and a node pointer extra in a tree. print all the node > level by level. You cannot use any Stack ,recursion and queue. > > -- > You received this message because you are subscribed

Re: [algogeeks] Help ! - Explain Sscanf

2011-08-30 Thread Abhishek Yadav
so what should be the correct question after writing % specifier. On Tue, Aug 30, 2011 at 11:48 PM, Sanjay Rajpal wrote: > yes % has to be there. > > Sanju > :) > > > > On Tue, Aug 30, 2011 at 11:12 AM, sukran dhawan wrote: > >> yes conversion specifier missing i think >> >> >> On Tue, Aug 30, 2

Re: [algogeeks] Re: elitmus test

2011-08-29 Thread Abhishek Yadav
can you share some DI questionsurgent On Sun, Aug 28, 2011 at 3:37 PM, Aditya Virmani wrote: > focus on quant & di...verbal wud be easy...as in our college, thr were two > papers, on which had gud level of quant qns...qns were nt tough to crack, > but involved calculations which may take gud

Re: [algogeeks] Probability

2011-08-29 Thread Abhishek Yadav
i guess it would be 0.7 + 0.3*0.6 + 0.3*0.4*0.5 + 0.3*0.4*0.5*0.4 =.964.correct me if i am wrong.?? On Mon, Aug 29, 2011 at 5:34 PM, Naman Mahor wrote: > An anti aircraft gun can fire four shots at a time. If the probabilities of > the first, second, third and the last shot hitting th

Re: [algogeeks] Re: Adding Two no without using any operator...??

2011-08-28 Thread Abhishek Yadav
Very nice solution sourabh. On Sun, Aug 28, 2011 at 9:52 PM, Dave wrote: > @Shravanthi: Write a and b in binary, and then apply the bitwise > exclusive-or to them and you will see why. > > Dave > > On Aug 28, 9:24 am, Shravanthi U M wrote: > > if we give a=10, b=5 we get a^b=15 > > but wen a=10

Re: [algogeeks] Re: Intersection of characters

2011-08-25 Thread Abhishek Yadav
@Don: Can you please explain the 3rd for loop.the working of if statement??? On Thu, Aug 25, 2011 at 11:02 PM, Don wrote: > Sure. It uses a hash table to keep track of which characters occur in > each file. The hash table is 256 bits initialized to zero. When it > encounters a character in f

Re: [algogeeks] C Trick

2011-08-24 Thread Abhishek Yadav
27;re trying for this. ;) >> >> >>> int x =c&0x01; >>> a=a-x*c; >>> >>> Thx, >>> --Gopi >>> >>> >>> On Tue, Aug 23, 2011 at 7:32 PM, Sanjay Rajpal wrote: >>> >>>> @teja : use of comparis

Re: [algogeeks] Re: Adobe Interview - 20/08/2011

2011-08-23 Thread Abhishek Yadav
@vikas: can you please put some light over interval graph to solve this problem or provide some useful links?? On Mon, Aug 22, 2011 at 6:47 PM, Decipher wrote: > @vikas - Can u post ur answer using segment trees ?? > > -- > You received this message because you are subscribed to the Google Group

[algogeeks] C Trick

2011-08-23 Thread Abhishek Yadav
Write a method which finds the maximum of two numbers You should not use if-else or any other comparison operator. -- 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 unsubscrib

Re: [algogeeks] Re: C dot

2011-08-23 Thread Abhishek Yadav
Moreover they also asked what is .NET as if they heard it for the first timecome on...can you believe it...!!! On Tue, Aug 23, 2011 at 4:18 PM, Dheeraj Sharma wrote: > yeah..the interview was total nakli :D .. they always..take the toppers.. > :) i mean..among the top ten who are sitting.. >

Re: [algogeeks] c++

2011-08-21 Thread Abhishek Yadav
@Thayumanavar: thanks for the link On Sun, Aug 21, 2011 at 10:33 PM, Thayumanavar S wrote: > > folks during temporary object creation constructor is called >> right..but constructor is called here only 2 times.. >> According to me,either copy constructor and constructor should have been >

Re: [algogeeks] c++

2011-08-21 Thread Abhishek Yadav
@jagannath: no its not i am totally confused. On Sun, Aug 21, 2011 at 5:57 PM, priya ramesh < love.for.programm...@gmail.com> wrote: > it is not an error. > > check this code: I compiled it > > > #include > using namespace std; > > class X > { > public: > X() > { > } > }; > main(){ > > } > > X fu

Re: [algogeeks] c++

2011-08-21 Thread Abhishek Yadav
what are you trying to say?...can you please explain? On Sun, Aug 21, 2011 at 1:35 PM, JAIDEV YADAV wrote: > try to use X b = a ; b.fun() ; > > On Sun, Aug 21, 2011 at 1:33 PM, Abhishek Yadav < > algowithabhis...@gmail.com> wrote: > >> ok...may be i forgot , can you

Re: [algogeeks] c++

2011-08-21 Thread Abhishek Yadav
21, 2011 at 12:53 PM, Abhishek Yadav < > algowithabhis...@gmail.com> wrote: > >> Check this code: the thing i couldn't understand is when the object is >> being returned neither the copy constructor is being called nor the >> assignment operator overload is called

Re: [algogeeks] c++

2011-08-21 Thread Abhishek Yadav
Check this code: the thing i couldn't understand is when the object is being returned neither the copy constructor is being called nor the assignment operator overload is calledthen how the object is being copied into b. i don't think default copy constructor should be called if i have made ou

Re: [algogeeks] c++

2011-08-21 Thread Abhishek Yadav
The code is correct..return X will make a temporary object and for that a constructor and corresponding destructor will be called and that object is returned. On Sun, Aug 21, 2011 at 12:24 PM, Puneet Chawla wrote: > It will show error > > On Sun, Aug 21, 2011 at 12:21 PM, Sanjay Rajpal wrote: >

Re: [algogeeks] c++

2011-08-20 Thread Abhishek Yadav
But if you try making a copy constructor of your own and check whether it is called or not.it does not. On Sun, Aug 21, 2011 at 12:21 PM, Sanjay Rajpal wrote: > I think it will not be an error. > > This is because X() will create a temporary object, and when the > object is returned in the f

Re: [algogeeks] Google Question:Given a BST and a number, Find the closest node to that number in the BST.

2011-08-20 Thread Abhishek Yadav
@atul yes sure why not... On Sat, Aug 20, 2011 at 1:39 PM, Naman Mahor wrote: > i think there will be three candidate.. > 1. TreeSuccessor(nd) 2. TreePredecessor(nd) 3. nd it self. > > > On Sat, Aug 20, 2011 at 12:56 PM, Abhishek Yadav < > algowithabhis...@gmail.c

Re: [algogeeks] C question

2011-08-20 Thread Abhishek Yadav
got it ...thanks On Sat, Aug 20, 2011 at 4:04 PM, Sanjay Rajpal wrote: > if(!(x & x-1)) printf("No. is power of 2"); > > > Sanju > :) > > > > On Sat, Aug 20, 2011 at 3:32 AM, Abhishek Yadav < > algowithabhis...@gmail.com> wrote: > >>

[algogeeks] C question

2011-08-20 Thread Abhishek Yadav
Give a one-line C expression to test whether a number is a power of 2. -- 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+u

Re: [algogeeks] Challenge

2011-08-20 Thread Abhishek Yadav
yah this is a good approach...but one thing in worst case it would be m^2 instead of n^2 On Sat, Aug 20, 2011 at 3:22 PM, Sanjay Rajpal wrote: > Yes, thats right. > I think we can do the following also : > > Lets us assume rows are sorted in increasing order. > > start from first row say i. Trav

Re: [algogeeks] Google Question:Given a BST and a number, Find the closest node to that number in the BST.

2011-08-20 Thread Abhishek Yadav
-->predecessor > -->current node > -->successor. > > On Sat, Aug 20, 2011 at 1:13 PM, Abhishek Yadav < > algowithabhis...@gmail.com> wrote: > >> No your solution is correct tooits just that in your solution number >> of comparisons done with the origin

Re: [algogeeks] Google Question:Given a BST and a number, Find the closest node to that number in the BST.

2011-08-20 Thread Abhishek Yadav
is there anything wrong in my algo? > do tell me. > > > On 20 August 2011 12:56, Abhishek Yadav wrote: > >> Hey i tried it now and got to another solution >> O(log n) solution: >> 1. try searching for the number , if found,return the node, otherwise, you >> will

Re: [algogeeks] Google Question:Given a BST and a number, Find the closest node to that number in the BST.

2011-08-20 Thread Abhishek Yadav
; // search is over > > // proceed to next element in tree which might be closer to the num > if ( num < root-> val) >find_min_ele(root->left, num); > else >find_min_ele(root->right, num); > } > > ^^ Complexity : O(logn) > > On 20 August 2011 12:3

Re: [algogeeks] Google Question:Given a BST and a number, Find the closest node to that number in the BST.

2011-08-20 Thread Abhishek Yadav
yes, the interviewer said that there is a solution in O(log n) On Sat, Aug 20, 2011 at 12:29 PM, sukran dhawan wrote: > ur traversing the tree once so it shud be o(n).does the question demand > 0(logn) ? > > On Sat, Aug 20, 2011 at 12:27 PM, Abhishek Yadav < > algowithabhis..

Re: [algogeeks] Google Question:Given a BST and a number, Find the closest node to that number in the BST.

2011-08-19 Thread Abhishek Yadav
mum after traversing the tree that is the element . u can > getback the element using another element which keeps sign of the element so > that original element can be obtained from diff > > On Sat, Aug 20, 2011 at 12:15 PM, Abhishek Yadav < > algowithabhis...@gmail.com> wrote:

[algogeeks] Google Question:Given a BST and a number, Find the closest node to that number in the BST.

2011-08-19 Thread Abhishek Yadav
Given a BST and a number, Find the closest node to that number in the BST. Give an algorithm for that. Let there be binary search tree having nodes with values 12,34,64,23,64,25,76,6 and the number given is 28, then the answer would be 25 as it is the closest node. -- You received this message be

Re: [algogeeks]

2011-08-19 Thread Abhishek Yadav
Hey try queue instead of stack On Fri, Aug 19, 2011 at 9:47 PM, sagar pareek wrote: > traverse the list and print only odd numbers and if even number encounter > store it in a stack and later on print it > > On Fri, Aug 19, 2011 at 9:29 PM, sukran dhawan wrote: > >> There is a Circular Singly Li

Re: [algogeeks] query.. amazon question

2011-08-19 Thread Abhishek Yadav
; -- > 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 option

[algogeeks] Re: array question

2011-08-17 Thread Abhishek Yadav
Thats right...by doing xor this can't be done...hey sanjay please reconsider your answer. On Aug 17, 2:05 pm, sukran dhawan wrote: > when u xor nos with odd number of times we will get back the same no.only > even occurences will give 0.question is to find the no with even >  occurence.how will y