RE: [algogeeks]
As my understanding take the input of traffic in time interval then some all the job and divide them equally to processing unit(assumption processing unit processing one job in one time units) so interval to time is varies on the base how much time is taken by the process to assigned work. One more assumption one work units is not further dividable. Sent from my Windows Phone -- From: w.s miller Sent: 15-04-2013 22:54 To: algogeeks@googlegroups.com Subject: [algogeeks] suppose we have n processing units.we have an incoming traffic which is to be distributed among them.but we have to take in mind that load is to be equally distibuted and if one of the processing units goes down ,then we have to distribute the traffic to rest of the processing units.Also when the processing unit which is down comes up,then the traffic distribution is to be handled please suggest any suitable data structure or algorithm thanks -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
RE: [algogeeks] DE Shaw written test
The sequence of price is make more sense if buy price is less than next value then you can buy even its not the min and next day you can sell all and Buy again when min price stock come. Eg 6, 10, 5, 7, 2,7. There are many case need to consider the above is the only one scenario. Other like random order profits and loss so need to decide min n max for a interval. Here is no profit 9 8 7 6 5 4 3 2 1 :(. Sent from my Windows Phone -- From: Mukul Gupta Sent: 08/05/2012 8:47 PM To: algogeeks@googlegroups.com Subject: Re: [algogeeks] DE Shaw written test Thanks for pointing out the mistake.Though my code will correctly calculate the max_profit but I must keep track of the buying_day.I have made some modification in my code.Hope it works fine now. int min = a[0]; // initialized to first element int max_profit = 0; //when you buy and sell on same day int buying_day = a[0]; for ( int i = 1; i < n; i++ ){ if ( max_profit < (a[i] - min ) ){ max_profit = a[i] - min; buying_day = min; } if ( a[i] < min ) min = a[i]; } Finally. I'll have buying_day and max_profit, so if you need to find the selling day you can easily calculate : Selling day = buying_day+max_profit; Correct me if I'm wrong. On Sun, Aug 5, 2012 at 5:43 PM, Arun Kindra wrote: > @harsha : yes, the problem is if u r finding only min and max value, it > might happen that u sell the stock before buying. Ex- int a [ ] = { 5, 10, > 4, 6, 7 }; the min value is 4 and max is 10 and 10 comes before 4, means u > sell the stock before buying. > and i think the sol given by mukul does the same mistake.we need to keep > track this case also whether the day(array index) i m buying is not more > than the day(array index) we are selling the stock. > > *correct me if m wrong*. > > -- > 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 options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Oracle Interview ..Need Help!!
first2 must the 3rd one depend on company... if u r prepairing for ms then first two is ok .. On Thu, Aug 4, 2011 at 6:18 PM, priya v wrote: > Thanks a lot! Will questions on OS appear in the written round? Any > particular book i should refer for > 1- DS? > 2-Programming? > 3-Aptitude? > > > On Thu, Aug 4, 2011 at 10:19 AM, Akanksha . wrote: > >> In our college they were also looking for the sound fundamentals of header >> files, libraries, macros etc. So be prepared with these also. >> >> >> On Thu, Aug 4, 2011 at 9:21 AM, umesh kewat wrote: >> >>> Better way of using DS, able to write good algo and programming puzzles >>> >>> >>> Thanks >>> Umesh >>> MSIDC hyd >>> Sent from my Windows Phone >>> -- >>> From: priya v >>> Sent: Thursday, August 04, 2011 7:16 AM >>> To: algogeeks@googlegroups.com >>> Subject: Re: [algogeeks] Oracle Interview ..Need Help!! >>> >>> Microsoft's conducting campus test this saturday. Need help! >>> What should i concentrate on for the written round? >>> >>> -- >>> 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 options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >>> -- >>> 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 options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> -- >> 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 options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > 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 options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Thanks & Regards Umesh kewat -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
RE: [algogeeks] Oracle Interview ..Need Help!!
Better way of using DS, able to write good algo and programming puzzles Thanks Umesh MSIDC hyd Sent from my Windows Phone -- From: priya v Sent: Thursday, August 04, 2011 7:16 AM To: algogeeks@googlegroups.com Subject: Re: [algogeeks] Oracle Interview ..Need Help!! Microsoft's conducting campus test this saturday. Need help! What should i concentrate on for the written round? -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
RE: [algogeeks] Swapping two variables without using a temporary variable
Adding two huge no will cross the integer or what's its range will fall under overflow categories same case goes to negative which fall under underflow .. In both the case numbers will change.. For example no range is -10 to 10 so if x =5 and y=7 then addition will produce the result -9 so u can see we r loosing number this is a overflow same for negative number will produce underflow Thanks Umesh Sent from my Windows Phone -- From: Supraja Jayakumar Sent: Tuesday, June 14, 2011 2:28 AM To: algogeeks@googlegroups.com Subject: Re: [algogeeks] Swapping two variables without using a temporary variable @Wladimir: Can you kindly explain the overflow and underflow you mentioned. Thanks Supraja J On Fri, Jun 10, 2011 at 9:58 PM, Wladimir Tavares wrote: > Swapping two variables without using a temporary variable using the + and > -: > > x = a; > y = b; > > x = x + y / / x = a + b; > y = x - y / / y = a + b-b = a; > x = x - y / / x = a + b-a = b; > > y = b; > x = a; > > Problems with this approach: > 1) It can cause overflow in the operation (+) > 2) It can cause underflow on operation (-) > > Swapping two variables without using variables > Temporary using XOR: > > x = a; > y = b; > > x = x ^ y; > y = x ^ y / / y = (x xor y) xor y = x xor (y xor y) xor x = 0 = x > x = x ^ y / / x = (x xor y) xor x = (x xor y) xor y xor x = (x xor x) = y > xor y = 0 > > Note that we use some properties of XOR: > > 1) Associativity > 2) Commutativity > 3) X = X 0 XOR > > We have no problems neither underflow nor overflow! > > Wladimir Araujo Tavares > *Federal University of Ceará > > * > > > > -- > 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 options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- U -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] ONLY FOR MEN
these all are coming as sparm in google group, so admin should blocked them so further no one can sparm us... On Fri, Apr 8, 2011 at 4:07 PM, Vishnutej Mylavarapu < mylavarapu.vishnu...@gmail.com> wrote: > Hello, > I dont think this is the right place for u to post these kinda things. > Also,if the admin of this group is still active,kindly delete this user > from the group. > Thnx. > -Vishnutej > > > On Fri, Apr 8, 2011 at 4:04 PM, Manikanta Babu > wrote: > >> Hello Sunitha, >> >> Can you please stop posting these kind of things into this google group. >> Please go to some other appropriate group. >> >> Thanks, >> Mani >> >> On Fri, Apr 8, 2011 at 3:56 PM, SUNITHA BUSETTY < >> sunitha.buse...@gmail.com> wrote: >> >>> hot lipkiss >>> http://hotactressstoyou.blogspot.com/2011/04/lipkiss-2.html >>> lipkiss in without dress >>> http://hotactressstoyou.blogspot.com/2011/04/lipkiss.html >>>seepika padukone sexy back look >>> http://hotactressstoyou.blogspot.com/2011/04/deepika-padukone.html >>> sexy katrina kaif >>> http://hotactressstoyou.blogspot.com/2011/04/katrina-kaif.html >>>beauty keerthi chawla >>> http://hotactressstoyou.blogspot.com/2011/04/keerthi-chawla.html >>> saloni sexy photos >>> http://hotactressstoyou.blogspot.com/2011/04/saloni.html >>> deeksha seth in a hot saree >>> http://hotactressstoyou.blogspot.com/2011/04/deeksha-seth.html >>> asin hot wallpapers >>> http://hotactressstoyou.blogspot.com/2011/04/asin.html >>>ramba in a red dress >>> http://hotactressstoyou.blogspot.com/2011/04/ramba.html >>> sexy ilieana is in scert >>> http://hotactressstoyou.blogspot.com/2011/04/ileana.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 >>> algogeeks+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >>> >> >> >> -- >> Thanks & Regards, >> Mani >> http://www.sanidapa.com - The music Search engine >> >> -- >> 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 options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > > *-Vishnutej Mylavarapu.* > > -- > 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 options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Thanks & Regards Umesh kewat iiit hyderabad -- 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 options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] C puzzle
Dear prasad after pre-compiling the expression is like const char* p = &a, so now u can understand y its const pointer On Sun, Oct 10, 2010 at 1:07 AM, Soumya Prasad Ukil wrote: > > #include > main() > { > char a ='c'; > typedef char* charp; > const charp p=&a; > p++; > } > > Why p is a constant pointer ? > > -- > regards, > soumya prasad ukil > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Amazon Interview
still there is some problem related to numbers encoding like.. 22333101 here how will u going to encode it??? On Tue, Sep 28, 2010 at 1:38 AM, ligerdave wrote: > it's a compression problem. using hex instead of oct saves more space > > 00aaa0ss yyy => 50 2a 0 1s 3f 1\s ay > > On Sep 15, 8:21 am, bittu wrote: > > A file is given with many 0s stored in continuous way , store it in > > another file such that when you store try saving the space by using > > minimum amount of space. When you want to create the original file , > > you should be able to do so with the new file created > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] help required...
@coolfrog in case of AB we asked to A know B after checking this we eliminate A n same case go for CD den A B CD | | AD AD Same approach | D (D will be celebrity) On Fri, Sep 24, 2010 at 10:57 AM, kartheek muthyala wrote: > @coolfrog, > > What I meant by remained is > > Considering your case of A,B,C,D and B is the celebrity, > > The sequence is > > First A,B ask the question to A, then remained=B > Then B,C ask the question to B, then remained=B > Then B,D ask the question to B, then remained= B > Then ask A,C,D whether they know B > Then ask B whether they know A,C,D > > So, that's how I said 3(n-1) questions... > Correct me if I am wrong > > On Thu, Sep 23, 2010 at 8:32 PM, coolfrog$ < > dixit.coolfrog.div...@gmail.com> wrote: > >> >> @kartheek >> i am getting. this prudent approach >> but what is "add what remained to the remainder." >> suppose u have A,B,C,D and B is celebrity ... >> >> if( A knows B) >> { A is not celb. >>if( B knows C){} >> else{ C is not celb. >> if (C knows B ) >>{ if( D knows B) >> { D is not celb. >>only B remain... hence it celeb... >> /* suppose if u have A,B,C,D,E >> and B is celeb. >> then again if (E knows B) >> {E is not >> celb >> only B >> remain... hence it celeb... >> } >> */ >> } >>} >> } >> } >> look in every if condition we are Asking Sequentially to A >> ,B,C,D,E... >> can these be correct solution >> correct me plz... if wrong.. >> On Thu, Sep 23, 2010 at 12:56 AM, kartheek muthyala < >> kartheek0...@gmail.com> wrote: >> >>> Take 2 persons, suppose say A and B >>> ask one of them the question about other >>> if A Knows B, then A cannot be the celebrity, >>> if A does not know B, then B cannot be the celebrity. >>> add what remained to the remainder. >>> >>> repeat this process for the remaining n-1 until one or none remained. >>> >>> Then if it is none then there is no celebrity. >>> If there is one ask the question whether this person is known by >>> remaining n-1 and this person does n't know the remaining n-1. So a total of >>> 3(n-1) questions is used to determine the celeb. >>> >>> Time complexity is O(n). >>> >>> Repeat this for the remaining n-1 persons, if the remainder contain one >>> then >>> >>> >>> On Wed, Sep 22, 2010 at 9:37 PM, Divesh Dixit < >>> dixit.coolfrog.div...@gmail.com> wrote: >>> >>>> Among n people, a celebrity is defined as someone who is known to >>>> everyone, but who knows no >>>> one. Design and analyze to identify the celebrity, if one exists, by >>>> asking only questions of the >>>> following form: "Excuse me, do you know person x?" You will get a >>>> binary answer for each such >>>> question asked. Find the celebrity by asking only O(n) questions. >>>> >>>> -- >>>> 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 >>>> algogeeks+unsubscr...@googlegroups.com >>>> . >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>>> >>> -- >>> 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 >>> algogeeks+unsubscr...@googlegroups.com >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> -- >> You received this mes
Re: [algogeeks] Amazon Interview
do the encoding like = 80 if der is other number then like 8(0)..and write the new file and when want to generate original do decoding in reverse On Thu, Sep 23, 2010 at 11:15 PM, janak wrote: > http://en.wikipedia.org/wiki/Run-length_encoding > > > On Wed, Sep 15, 2010 at 5:51 PM, bittu wrote: > > A file is given with many 0s stored in continuous way , store it in > > another file such that when you store try saving the space by using > > minimum amount of space. When you want to create the original file , > > you should be able to do so with the new file created > > > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] help required...
Use divide and conquer strategy of algorithm by diving in 2-2 group like merge sort make tree where every level we dropping people by using logic of above post so root will be celebrity On Thu, Sep 23, 2010 at 11:26 AM, kartheek muthyala wrote: > Take 2 persons, suppose say A and B > ask one of them the question about other > if A Knows B, then A cannot be the celebrity, > if A does not know B, then B cannot be the celebrity. > add what remained to the remainder. > > repeat this process for the remaining n-1 until one or none remained. > > Then if it is none then there is no celebrity. > If there is one ask the question whether this person is known by remaining > n-1 and this person does n't know the remaining n-1. So a total of 3(n-1) > questions is used to determine the celeb. > > Time complexity is O(n). > > Repeat this for the remaining n-1 persons, if the remainder contain one > then > > > On Wed, Sep 22, 2010 at 9:37 PM, Divesh Dixit < > dixit.coolfrog.div...@gmail.com> wrote: > >> Among n people, a celebrity is defined as someone who is known to >> everyone, but who knows no >> one. Design and analyze to identify the celebrity, if one exists, by >> asking only questions of the >> following form: "Excuse me, do you know person x?" You will get a >> binary answer for each such >> question asked. Find the celebrity by asking only O(n) questions. >> >> -- >> 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 >> algogeeks+unsubscr...@googlegroups.com >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Point lies inside or outside of triangle?
@praveen thanks for ur solution .. but thats a programming que required efficient algo... On Mon, Sep 20, 2010 at 9:06 PM, Praveen Baskar wrote: > here is the hint > we can easily solve this > > draw a triangle > draw a point is inside the triangle > connect the three vertices of the triangle with this point > you will get three small triangle > > if ( area(big triangle)== sum of area of small triangles) then the point is > inside the triangle else it is outside the triangle > > > On Mon, Sep 20, 2010 at 10:02 PM, umesh wrote: > >> Initially we have given three point A , B, C in plane represent three >> nodes of triangle, now given another point Z which lies in same >> plane, find out whether that point lies on/inside the triangle or >> outside of triangletry to get in minimum time and space >> complexity >> >> >> -- >> Thanks & Regards >> >> Umesh kewat >> >> -- >> 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 >> algogeeks+unsubscr...@googlegroups.com >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> > > > -- > By B. Praveen > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] point lies inside or outside of triangle..
Initially we have given three point A , B, C in plane represent three nodes of triangle, now given another point Z which lies in same plane, find out whether that point lies on/inside the triangle or outside of triangletry to get in min time and space complexity -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Yahoo Question
Create binary search tree using n nodes of K list den do in-order and make a single list On Fri, Sep 17, 2010 at 12:58 PM, vikas kumar wrote: > @Bittu > I am confused about one point you need to process atleast n*k > elements so how will you do it in nlogk time. It seems really > tricky if possible.it's min time should be O(nk). correct me if I > am wrong. > > On Sep 17, 6:34 am, tkcn wrote: > > Use k-way merging +1. > > > > 1. Before the merging start, sorting these lists according to the > > first element of each list. // O(k log k) > > 2. So the first element in the first list is the smallest element. Put > > the smallest into the result array. // O(1) > > 3. Then, using binary search to find the new position of the first > > list // O(k) > > 4. These lists are still sorted, so the first element in the first > > list is still smallest. Just repeat the step 2, 3 n times. > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Explain
HI, Here are some fact related to macros.. its a preprocessor directory so before comping the code will replaced by appropriate macros... these are not comping or executing ..so macros replaced one by one and other fact macro will not replaced the content of other macros... so code of 1st code will be like that after preprocessing 1st all A will be replaced by B except #define B A, 2nd replaced in code where ever is B is replaced by A so like.. sorry for my 1st post giving wrong explanation... @saurabh in ur 2nd post after preprocessing of 1st macro code be like that include int main(){ int A =4; #define B A printf("%d",B); return 0; } after 2nd preprocessing include int main(){ int A =4; printf("%d",A); return 0; } so out put is 4 if need more explanation of above logic you can see by running those example #include int main() { int A =4; #define A B #define B A*3 printf("%d",A); return 0; } #include int main() { int A =4; #define A B*B #define B A printf("%d",A); return 0; } the 1st statement will not affect by preprocessor becoz those macros definition are coming after that otherwise u can see #include int main() { int A =4; printf("%d",B) #define A B return 0; } for some more #include int main() { int A =4; printf("%d",A); printf("%d",B); #define A B printf("%d",B); #define B A printf("%d",B); printf("%d",A); return 0; } by looking compilation error u will able to see the scope of macros and their preprocessing .. thanks for reading long post.. :) On Fri, Sep 10, 2010 at 3:28 PM, praveen wrote: > After preprocessing > > Where ever there is 'A' in your program, it is replaced by 'B' > Where ever there is 'B' in your program, it is replaced by 'B' > > this will be the program look like > #include > int main(){ > int B =4; > > printf("%d",B); > return 0; > > } > therefore, the program will compile and run :) > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Explain
HI Saurabh, #include int main() { int A =4; #define A B #define B A*3 printf("%d",A); return 0; } Above example will explain ur doubt... On Fri, Sep 10, 2010 at 9:59 AM, saurabh agrawal wrote: > @umesh kewat > > #include > int main(){ > int A =4; > > #define A B > #define B A > printf("%d",A); > return 0; > } > > This code works fine...but as you have explained the later A used in printf > statement must have replaced by B. In that case there must be a compiler > error "The identifier not defined". But this code compiless fine. and there > seems no visible effect of these two macros. > > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Explain
Hi saurabh, it will not going to infinite... 1st all A will be replaced by B so later #define B B be remaining so this statement is valid.. program will going to execute fine.. On Thu, Sep 9, 2010 at 7:22 PM, saurabh agrawal wrote: > Can somebody explain how the macros are expanded regarding order in which > they are used...etc... > > also explain this example : > > #define A B > #define B A > > what is the effect of this and whether it will go in an infinite recursive > call or not and why? > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Dynamic Programming Problem on Strings
Calculate the number of string can be formed by this formula in one statement.. for cross check the result is 2N!/((N+1)! * N!) where is number of A or B in string On Thu, Aug 5, 2010 at 8:54 AM, Ashish Goel wrote: > >> >> void dyckWords(int index, int open, int close) >> { >> static int dyck=0; >> if (index == 2 *n) >> { >> printf("%s\n", out); >> return ; >> } >> >> out[index] = '('; //or A >> if ((open + 1) <= n && open >= close) >> >> >> >> { >> dyckWords(index + 1, open + 1, close); >> } >> out[index] = ')';//or B >> >> if ((close + 1) <= n && open >= close) >> { >> dyckWords(index + 1, open, close + 1); >> } >> } >> >> Best Regards >> Ashish Goel >> "Think positive and find fuel in failure" >> +919985813081 >> +919966006652 >> >> >> On Mon, Jul 19, 2010 at 1:25 AM, Amir hossein Shahriari < >> amir.hossein.shahri...@gmail.com> wrote: >> >>> @ashish: AAA is the prefix of the string and it is valid as a prefix and >>> it's only used for strings with length >= 6 (where it is a valid prefix) >>> actually only dp[i][j] where i==j counts the number of such strings and >>> otherwise there is no string where i!=j and it that case dp[i][j] counts the >>> number of valid prefixes for string >>> dp[0][0]=1 does satisfy both properties because 0=0 so the number of As & >>> Bs are the same >>> the logic behind n/2 is that if the length of the string is n this means >>> that it has n/2 As and n/2 Bs (n must be even) >>> the dp for n=4 doesn't look like that! this is how it looks (i just >>> compiled the code and checked values of dp): >>> 1 0 0 >>> 1 1 0 >>> 1 2 2 >>> so dp[2][2]=2 which means the number of strings with 2 As and 2 Bs is 2 >>> >>> >>> -- >>> 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 >>> algogeeks+unsubscr...@googlegroups.com >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] confusion
Hi tarak, output is right, because every printf print 1 so there is 3 printf call...so 111 is right On Thu, Jul 29, 2010 at 2:16 PM, tarak mehta wrote: > #include > int main() > { > int i=1; > printf("%d\n",printf("%d",printf("%d",i))); return 0; > } > > > output is 111..i was expecting it to be 11..plz explain?? > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Oracle-Java Developer interview question
one another solution using counting array... void findwidth(BST* bt, int *arr, int count)//initially count is 0 for root { if(bt) return; arr[count]++; count++; if(bt->left) findwidth(bt->left, arr, count); if(bt->right) findwidth(bt->right, arr, count); return; } int maxwidth(BST* bt) { int count = 0, temp = 0, i = 0; int arr = (int*) malloc(sizeof(int)*n); //here n is no of node findwidth(bt, arr, count); while(arr[i]) { if(temp wrote: > use levelorder traversal and calculate the number of node in same level by > putting some condition :) > > On Mon, Jul 26, 2010 at 1:53 PM, vineel yalamarth < > vineelyalamar...@gmail.com> wrote: > >> >> >> No dude, they asked me to find width , in the sense ... find the maximum >> number of nodes in any level. >> And if you know how to find the diameter do post it >> >> >> -- >> 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 >> algogeeks+unsubscr...@googlegroups.com >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > Thanks & Regards > > Umesh kewat > > > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Oracle-Java Developer interview question
use levelorder traversal and calculate the number of node in same level by putting some condition :) On Mon, Jul 26, 2010 at 1:53 PM, vineel yalamarth < vineelyalamar...@gmail.com> wrote: > > > No dude, they asked me to find width , in the sense ... find the maximum > number of nodes in any level. > And if you know how to find the diameter do post it > > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Google Interview Question
Hi, suppose we have given n distinct numbers are a[n]. 1. sort them using quick or any other sort in O(nlogn) 2. use then int find(int *arr, int n) /* return largest number if fing it otheriwse retirn 0*/ { int i,j,k, temp; for(k=n-1; k>2;k--) { j = k-1 i=0; while(i!=j) { temp = arr[i]+arr[j]; if(temp== arr[k]) return arr[k]; else if(temp wrote: > sort using counting sort or quickselect > > now a and b are less than c > > so find c first > suppose c's index is k > the start two indexes i=0 and j=k-1, if a[i]+a[j] ==a[k] return these > numbers, else add elements at i,j if the sum is greater than c reduce j, if > less than c increase i > > alternatively sort array, find index of c, make a BST or a hash table, > starting from index 0 of the sorted array, find c-athis is overhead on > second thoughts, i will proceed with first approach > > > Best Regards > Ashish Goel > "Think positive and find fuel in failure" > +919985813081 > +919966006652 > > > > On Wed, Jul 14, 2010 at 9:55 PM, siddharth shankar < > siddharth.shanka...@gmail.com> wrote: > >> O ( n^2 ) soln can be done >> step : >> >> 1 . sort array in n*log(n) . >> 2. for every "C" from last find two number A & B such that A+B=C ... O( >> n^2 ) >> Total :- O(N^2) >> >> can we improve it further ?? any help please >> >> On Wed, Jul 14, 2010 at 10:57 AM, Debajyoti Sarma < >> sarma.debajy...@gmail.com> wrote: >> >>> An array contains the set of positive integer. Find the largest number >>> c such that c=a+b where a,b,c are distinct number of the set? >>> [Consider , reducing complexity] >>> >>> -- >>> 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 >>> algogeeks+unsubscr...@googlegroups.com >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >>> >> >> >> -- >> siddharth shankar >> >> >> -- >> 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 >> algogeeks+unsubscr...@googlegroups.com >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] recursive
Hi Sarad, use queue with recursion, void levelorder traverse(QUEUE qt) { if(isempty(qt)) return; bst *temp = remove(qt); printf("%d",temp->data); if(temp->left) insert(qt, temp->left); if(temp->right) insert(qt, temp->right); levelordder(qt), } On Sat, Jul 10, 2010 at 10:45 PM, sharad kumar wrote: > How to do level order traversal using recursion ? > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: microsoft.
Hi, My solution is : int Find_repeat(int *array, int n) { int index=0, index1 =0; while(array[index]>0) // assume number are in between 1 to n and size of array is n also atleast one is repeated. { array[index] = -array[index]; indeax = abs(array[index])-1; } printf("repeated number is = %d", index+1); //if you want to print otherwise comment out while(array[index1]<0) { array[index1] = -array[index1]; index1 = abs(array[index1])-1; } return index+1; } *Time complexity O(n); space complexity O(1);* On Fri, Jul 9, 2010 at 9:18 AM, aejeet wrote: > Hi Umesh/Priyanka, > Ur solution felt so intuitive once i understood it. > > Cheers > > > > On Jul 8, 11:21 am, umesh kewat wrote: > > Hi Priyanka, > > > > Thanks For explaining my solution with example.. > > > > -- > > Thanks & Regards > > Umesh Kewat > > > > On Thu, Jul 8, 2010 at 1:32 PM, Priyanka Chatterjee >wrote: > > > > > > > > > > > > > I totally agree with Umesh's algo which gives O(K+1) time and an > inplace > > > solution. The only point is the first K+1 numbers may get negated and > the > > > array is modified. In that case after finding the duplicate we can > traverse > > > the array again for the first k+1 no.s and make the negative numbers > > > positive. > > > > > code is -(considering array contains only positive numbers) > > > > > for(i=0;i > > if(A[abs(A[i])])<0) return abs(A[i]); //1st duplicate, abs is absolute > > > function > > > > > A[abs(A[i])]*=(-1); > > > > > } > > > > > I am explaining Umesh's solution with an example > > > > > let k=6 , k > > > > A= 1,6,4,5,2,6,3,.. > > > A[0]-1st element, a[k]-k+1 element in array > > > > > now A[0]=1; and A[1]=6 now A[1]= -6 > > > A[1]=6 and A[6]=3 now A[6]=-3 > > > A[2]=4 and A[4]=2 now A[4]=-2 > > >A[3]=5 and A[5]=6 now A[5]=-6 > > > A[4]=-2 and A[abs(-2)]=4 now A[2]=-4 > > > A[5]=-6 and A[abs(-6]<0 therefore return 6 > > > > > time complexity=O(k+1) and very much inplace solution . > > > > > -- > > > Thanks & Regards, > > > Priyanka Chatterjee > > > Final Year Undergraduate Student, > > > > > Computer Science & Engineering, > > > National Institute Of Technology,Durgapur > > > India > > >http://priyanka-nit.blogspot.com/ > > > > > -- > > > 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 > > > algogeeks+unsubscr...@googlegroups.com > > > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/algogeeks?hl=en. > > > > -- > > Thanks & Regards > > > > Umesh kewat > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] microsoft.
Hi Priyanka, Thanks For explaining my solution with example.. -- Thanks & Regards Umesh Kewat On Thu, Jul 8, 2010 at 1:32 PM, Priyanka Chatterjee wrote: > > > I totally agree with Umesh's algo which gives O(K+1) time and an inplace > solution. The only point is the first K+1 numbers may get negated and the > array is modified. In that case after finding the duplicate we can traverse > the array again for the first k+1 no.s and make the negative numbers > positive. > > code is -(considering array contains only positive numbers) > > for(i=0;i if(A[abs(A[i])])<0) return abs(A[i]); //1st duplicate, abs is absolute > function > > A[abs(A[i])]*=(-1); > > } > > I am explaining Umesh's solution with an example > > let k=6 , k > A= 1,6,4,5,2,6,3,.. > A[0]-1st element, a[k]-k+1 element in array > > now A[0]=1; and A[1]=6 now A[1]= -6 > A[1]=6 and A[6]=3 now A[6]=-3 > A[2]=4 and A[4]=2 now A[4]=-2 >A[3]=5 and A[5]=6 now A[5]=-6 > A[4]=-2 and A[abs(-2)]=4 now A[2]=-4 > A[5]=-6 and A[abs(-6]<0 therefore return 6 > > time complexity=O(k+1) and very much inplace solution . > > -- > Thanks & Regards, > Priyanka Chatterjee > Final Year Undergraduate Student, > > Computer Science & Engineering, > National Institute Of Technology,Durgapur > India > http://priyanka-nit.blogspot.com/ > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: microsoft.
Hi Gaurav, yup solution is quite right but that is the worst casebut if wanna that solution in O(n) time complexity and O(1) space complexity but in ur solution it is O(k) space complexity. On Wed, Jul 7, 2010 at 7:17 AM, Gaurav Singh wrote: > I think you can use counting array in this algo. And keep checking > whenever the count of any element goes ahead of 1, it will be the > first repeating element. > Is it something more difficult than this ?? Please correct me if > anything is wrong in my thought. > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] microsoft.
if space complexity is O(1) then hash map will not work.. On Wed, Jul 7, 2010 at 10:54 AM, Ashish Goel wrote: > have a hash map trace through all the elements to store the count > > now trace through the array again and return the element whose count is > found to be 2 as the first repeating element > > > Best Regards > Ashish Goel > "Think positive and find fuel in failure" > +919985813081 > +919966006652 > > > > On Wed, Jul 7, 2010 at 10:23 AM, Anand wrote: > >> Since we know the range of numbers in an array. Counting sort is a trivial >> solution for it >> >> >> On Tue, Jul 6, 2010 at 9:48 PM, Anil C R wrote: >> >>> do you need an algorithm which is O(1) in space? if not it's trivial. >>> Anil >>> >>> >>> >>> On Tue, Jul 6, 2010 at 7:29 PM, sharad kumar >>> wrote: >>> >>>> Given an array of n numbers in which all the members are less than or >>>> equal to k (k>>> repeating element >>>> >>>> -- >>>> 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 >>>> algogeeks+unsubscr...@googlegroups.com >>>> . >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>> >>> -- >>> 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 >>> algogeeks+unsubscr...@googlegroups.com >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> -- >> 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 >> algogeeks+unsubscr...@googlegroups.com >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] microsoft.
use array element as index in linear traversal and der index pointing value as negative when u wll get pointing value negative mean that array index position is 1st repeated element. On Wed, Jul 7, 2010 at 10:18 AM, Anil C R wrote: > do you need an algorithm which is O(1) in space? if not it's trivial. > Anil > > > > On Tue, Jul 6, 2010 at 7:29 PM, sharad kumar wrote: > >> Given an array of n numbers in which all the members are less than or >> equal to k (k> repeating element >> >> -- >> 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 >> algogeeks+unsubscr...@googlegroups.com >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] addition using bitwise
Hey Priyanka.. Both code are same here u induse temp variable and using later to assign it with a, so shrinivas code is right and its working fine... in code value of a is being used in smart way.. a= a^b if we again do ex-oring a with b den we will get a orignal value. a = a^b suppose value of a= 3 and b = 1 then a =2(a = a^b ) but after we again do ex-oring then a = 3(a = a^b ) a = 3 = 011 b= 1 = 001 after exroing --- a = 2 =010 (a = a^b) b=1 = 001 - a = 3 = 011 (that value being used in that expression of shrinivas code b=(a^b)&b; in place of bracket. -- Thanks & Regards Umesh kewat On Thu, Jul 1, 2010 at 8:55 AM, Priyanka Chatterjee wrote: > @shrinivas : your iterative code is wrong > > It should be: > >> >> int add(int a, int b) >> { int temp; >> do >> { >> temp=a^b; >> b=a&b; >> b=b<<1; >> > a=temp; > >> } while(b); >> >> return(a); >> } >> >> >> it is working well for negative numbers also . i tried lot but can not >> understand logic behind it can any one explain it in easy manner ... >> thanks in advance >> >> -- >> 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 >> algogeeks+unsubscr...@googlegroups.com >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> > > > -- > Thanks & Regards, > Priyanka Chatterjee > Final Year Undergraduate Student, > Computer Science & Engineering, > National Institute Of Technology,Durgapur > India > http://priyanka-nit.blogspot.com/ > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] crazy
1/100 On Tue, Jun 29, 2010 at 12:37 PM, ankur aggarwal wrote: > i think it shud be 1/2.. i will try to prove it... > > > On Mon, Jun 28, 2010 at 8:52 AM, sharad kumar wrote: > >> Problem :- A line of 100 airline passengers is waiting to board a plane. >> They each hold a ticket to one of the 100 seats on that flight. (For >> convenience, let's say that the nth passenger in line has a ticket for the >> seat number n.) >> Unfortunately, the first person in line is crazy, and will ignore the seat >> number on their ticket, picking a random seat to occupy. All of the other >> passengers are quite normal, and will go to their proper seat unless it is >> already occupied. If it is occupied, they will then find a free seat to sit >> in, at random. >> What is the probability that the last (100th) person to board the plane >> will sit in their proper seat (#100)? >> >> -- >> 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 >> algogeeks+unsubscr...@googlegroups.com >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > With Regards > > Ankur Aggarwal > > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: microsoft
Hi All, here you people are considering series as sorted except 0 as input and have to rearrange like mansion output.. do it like if there input is unsorted and will get same output.. e.g. input: 0,2,0,8,0,1,0,4,,6,7,5,0,0,0,3 output: 1 2 3 4 5 6 7 8 0 0 0 0 0 0 time complexity: in O(n) not possible try it to in O(nlogn) space complexity : O(1) On Mon, Jun 28, 2010 at 2:04 PM, sharad kumar wrote: > nice soln > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Thanks & Regards Umesh kewat IIIT - Hyderabad -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Where to Set the POST-OFFICE
in the middle of the points, not middle of line.. On Wed, Jun 23, 2010 at 5:48 PM, amit wrote: > There are N points on a LINE. U neeed to place a post office such that > its total distance from each of the N points is minimised. > > The post office need not necessarily be on one of the N Points. > > -- > 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 > algogeeks+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Thanks & Regards Umesh kewat -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] ant problem
Hi ankur, can you give some more elaboration of that problem becoz i think some condition will be der. whether max time, min time avg time .. like of ant can traverse each once like that On Tue, Nov 3, 2009 at 9:44 AM, ankur aggarwal wrote: > An ant stays at one corner of a cube. It can go only along the side with > equal probability, and taking one minute to get to another corner. What is > the expect minutes for the ant coming back to the original position? > > -- > 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. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Thanks & Regards Umesh kewat Sent from Hyderabad, AP, India -- 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. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Identify The f(x) :you are given a series of numbers(asked by MICROSOFT )?
Identify the F(n) required some AI for 1st identify type of sequence whether it is GP, AP, HP or some other special sequence then right the function according the series. On Fri, Oct 30, 2009 at 10:02 AM, Shiqing Shen wrote: > > match the sequence exactly? > how to get that polynomial function, i am curious > > 2009/10/29, Vladimir Reshetnikov : > > Any finite sequence of numbers can be matched by polynomial function. > > > > > > On Thu, Oct 29, 2009 at 3:19 PM, Pawandeep > > wrote: > > > > > > hello everyone , > > > you are given a series of numbers like > > > > > > 2,4,6,8,10,12this is simple though > > > > > > nd u hve to identify that f(x) = x+ 2 for this series .. > > > > > > now can you write a program to identify the f(x) for any series of > > > numbers.. > > > > > > // i know it is tough but don't say its not possible > > > > > > > > > > > > > > > > > > > > > > -- Thanks & Regards Umesh kewat Sent from Hyderabad, AP, India --~--~-~--~~~---~--~~ 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 options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: How to find number of Cycles in a Graph...
Hi mithun can u give some detail about graph like connected, disconnected or etc? On Wed, Oct 21, 2009 at 4:45 PM, mithun wrote: > > Given a graph can anyone suggest me good algorithm to find out Number > of Cycles in a Graph.. > > -Thanks > Mithun > > > > -- Thanks & Regards Umesh kewat Sent from Hyderabad, AP, India --~--~-~--~~~---~--~~ 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 options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: use putchar to print out an unsigned long in decimal
Thanks Debanjan for intimating the bug in my code and Sorry i forget to add 48 in second putchar statement. now rite code is #include void print(unsigned long int n) { if(n>9) print(n/10); putchar('0'+(n%10)); } int main() { unsigned long n; scanf("%ld",&n); print(n); return 0; } On Fri, Oct 16, 2009 at 12:08 AM, Debanjan wrote: > > On Oct 15, 10:45 am, umesh kewat wrote: > > Hi, > > Here is the code for problem... > > > > void print(unsigned long int n) > > { > > if(n<10) > > > > putchar(n+48); > > else > > { > > print(n/10); > > putchar(n%10); > > } > > > > } > > > > int main() > > { > > unsigned long int n; > > scanf("%ld",&n); > > print(n); > > return 0; > > > > } > > > > On Thu, Oct 15, 2009 at 9:33 AM, ankur aggarwal < > ankur.mast@gmail.com>wrote: > > > > > 1. Given only putchar (no sprintf, itoa, etc.) write a routine > > > putlong that prints out an unsigned long in decimal. > > > > OOPS you code will print 1 when the input will be 10,100,100... > > -- > > Thanks & Regards > > > > Umesh kewat > > > > Sent from Hyderabad, AP, India > > > > -- Thanks & Regards Umesh kewat Sent from Hyderabad, AP, India --~--~-~--~~~---~--~~ 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 options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: use putchar to print out an unsigned long in decimal
Hi, Here is the code for problem... void print(unsigned long int n) { if(n<10) putchar(n+48); else { print(n/10); putchar(n%10); } } int main() { unsigned long int n; scanf("%ld",&n); print(n); return 0; } On Thu, Oct 15, 2009 at 9:33 AM, ankur aggarwal wrote: > 1. Given only putchar (no sprintf, itoa, etc.) write a routine > putlong that prints out an unsigned long in decimal. > > > > -- Thanks & Regards Umesh kewat Sent from Hyderabad, AP, India --~--~-~--~~~---~--~~ 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 options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: use putchar to print out an unsigned long in decimal
no need to take care of negative numbers because given number is unsigned long integer .. apply simple algo :) On Thu, Oct 15, 2009 at 1:07 PM, Siddharth S wrote: > > void putlong(long n) > { >if(n == 0) // special case >{ > putchar('0'); > return; >} >else >if(n < 0) // if number is negative, print "-" sign and continue as if it > is a positive number > putchar('-'), n = -n; > >int arr[30]; >int arr_cnt = 0; >while(n) > { > arr[arr_cnt++] = n % 10; // split number into digits > n /= 10; > } >for(int i = arr_cnt-1; i>=0; i--) // print the digits (in reverse order) > putchar(arr[i]+'0'); > } > > On Thu, Oct 15, 2009 at 9:33 AM, ankur aggarwal > wrote: > >> 1. Given only putchar (no sprintf, itoa, etc.) write a routine >> putlong that prints out an unsigned long in decimal. >> >> >> > > > > -- Thanks & Regards Umesh kewat Sent from Hyderabad, AP, India --~--~-~--~~~---~--~~ 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 options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: ROTATE
*n=(n>>x)|(n<<(32-x));* *ex: n=11101001, x=2 suppose here n is 8 bit long* * n=(11101001>>2)|(11101001<<4) n=(00111010)|(0100) now n is 0010*. On Tue, Oct 13, 2009 at 9:18 AM, Raghavendra Sharma < raghavendra.vel...@gmail.com> wrote: > @Ankur I am assuming the integer to be 32 bits. actually it should be > 0x > step 1 : temp = (0x >> (32 - x)) & n; > step 2 : n = (n >> x) | ( temp << (32 -x)); > > The first step extracts the lower x bits and second step moves upper bits > to left side and puts the lower x bits at the beginning. > > for example the integer is 0x12345678 and x = 4 then > temp = 0x8 > > (n >> x) = 0x01234567 and temp << (32 - x) is 0x8000 > > and (n >> x) | (temp << (32 -x)) ix 0x81234567 > > > So temp will contain > > On Tue, Oct 13, 2009 at 12:07 AM, GauravNITW wrote: > >> >> How abt this..? >> >> for(i=0;i> { >>res=no&1U; >>no=no>>1; >>if(res==1) >> no=no|32768U; >>else >> no=no|0U; >> } >> printf("\nFinal value %u",no); >> >> >> On Oct 12, 8:11 pm, Raghavendra Sharma >> wrote: >> > temp = (0x >> (32 - x)) & n; >> > n = (n >> x) | ( temp << (32 -x)); >> > >> > On Mon, Oct 12, 2009 at 5:32 PM, ankur aggarwal < >> ankur.mast@gmail.com>wrote: >> > >> > >> > >> > > *You are given a integer and you want to rotate the bits of the number >> by >> > > a value x. Consider the right rotation by x means the least >> significant x >> > > bits should go out from left and take the position of most significant >> x >> > > bits.*- Hide quoted text - >> > >> > - Show quoted text - >> >> >> > > > > -- Thanks & Regards Umesh kewat --~--~-~--~~~---~--~~ 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 options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: Traversing a binary tree from bottom to top
hi, add some more constrain on above problem here desired output isg e d c b a for given tree what will be approach if desired output level wise like degbca Traversing the tree from left to right in place of right to left in level wise bottom to top.. [:)] 2009/10/7 hopper > > harit's method is the typical one about width first search, it can > solve the problem. > > On 10月7日, 上午3时59分, Manisha wrote: > > Thanks a Ton everybody! > > > > -- Thanks & Regards Umesh kewat Hyderabad Sent from Hyderabad, AP, India --~--~-~--~~~---~--~~ 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 options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: multiply by 2 and subtract by 1
hi i have one doubt if negative by 1 in a row if any element got zero and again doing same operation to get another element to be zero so 1st element is negative so could u please tell me the matrix automatically do the positive value else as it. if it is negative then ans is No, we will not get O matrix(one with all zeroes in it.) else there have some solution to get O matrix. On Wed, Aug 26, 2009 at 12:13 AM, ankur aggarwal wrote: > I've always wanted to feel the excitement in these interviews. I got a > chance, and I liked it. > > Here is the question: > > You are given a matrix: r rows, c cols. r x c matrix. > > Now they all have positive integers. Assume that the computer has no > overflow, it can store all possible integer values. > > Now there are only two operations you can perform on the matrix: > > a. Multiply one whole column (of size r elements) by 2 aij = aij * 2 > b. Decrement a whole row (of size c elements) by 1. aij = aij - 1 > > Now you are required to find out if it's possible with these operations to > convert this matrix into the O matrix. (one with all zeroes in it.) > > If so, how do you solve it? Or when do you decide to terminate? > > give the algo.. > not the code. > > > > -- Thanks & Regards Umesh kewat IIIT-Hyderabad --~--~-~--~~~---~--~~ 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 options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: Finding repeated element in most efficient way
Any Body can tell me what is the exact problem? because i m reading this thread 1st time over here. whether u wanna one repeated element in array or all set of all repeated element in given array. i have some solution with single traversal without using extra space but they depend on constraint so please give the detailed problem. On Mon, Aug 17, 2009 at 5:32 AM, Shyam wrote: > > I think I could do it in O(n) . > > var bits=0 > var @array > > for each i in array >if (bits & i)!=0 > return i >else > bits=bits | i; >end if > end for > > I just use the pattern for powers of two > > let array be 2,4,2 > > so first > bits=0 i=2 so bits(000) & i(010) is 0 so bits= bits | i which is > bits=010 > next > bits=2 i=4 so bits(010) & i(100) is 0 so bits= bits | i which is > bits=110 > next > bits=6 i=2 so bits(110) & i(010) is 2 which is !=0 so we return i. > > I think that should be it. > > > > -- Thanks & Regards Umesh kewat 09966796569 --~--~-~--~~~---~--~~ 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 options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: bits required to convert A to B
Sorry for 1st solution thr i dod one mistake now this one is rite one... #include int BitSwapReqd(int A, int B); { int tmp=1, count=0; while(A || B) { if(A&1 != B&1) count++ A=A>>1; B=B>>1; } return count; } int main() { int a,b; printf("Enter the Value of A & B\n"); scanf("%d%d",&a,&b); printf("these no of bits required to convert from A to B = %d\n",BitSwapReqd(a,b)); return 0; } > On Sun, Aug 16, 2009 at 11:09 PM, richa gupta wrote: > >> >> Given two integers A & B. Determine how many bits required to convert >> A to B.how to write a function int BitSwapReqd(int A, int B); >> >> -- >> Richa Gupta >> (IT-BHU,India) >> >> >> >> > > > - > > > *Thanks & Regards Umesh kewat (IIIT-Hyderabad India) * --~--~-~--~~~---~--~~ 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 options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: bits required to convert A to B
#include int BitSwapReqd(int A, int B); { int tmp=1, count=0; while(A || B) { if(A&1==B&1) count++ A=A>>1; B=B>>1; } return count; } int main() { int a,b; printf("Enter the Value of A & B\n"); scanf("%d%d",&a,&b); printf("these no of bits required to convert from A to B = %d\n",BitSwapReqd(a,b)); return 0; } On Sun, Aug 16, 2009 at 11:09 PM, richa gupta wrote: > > Given two integers A & B. Determine how many bits required to convert > A to B.how to write a function int BitSwapReqd(int A, int B); > > -- > Richa Gupta > (IT-BHU,India) > > > > -- Thanks & Regards Umesh kewat (IIIT-Hyderabad India) --~--~-~--~~~---~--~~ 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 options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: bits required to convert A to B
yup this will be also rite On Mon, Aug 17, 2009 at 11:21 AM, Pramod Negi wrote: > i guess XORing A and B and count the no of set bits will do. > > On Sun, Aug 16, 2009 at 11:09 PM, richa gupta wrote: > >> >> Given two integers A & B. Determine how many bits required to convert >> A to B.how to write a function int BitSwapReqd(int A, int B); >> >> -- >> Richa Gupta >> (IT-BHU,India) >> >> >> > > > > -- Thanks & Regards Umesh kewat 09966796569 --~--~-~--~~~---~--~~ 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 options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: Question asked in MS interview
Do just opposite thing to get result delete k elements from Max heap of element der u also get k largest numbers On Fri, Aug 14, 2009 at 3:25 PM, Arun N wrote: > > This question was asked to me in Amazon interview > > 1)use hash table to store a word and its count > now the problem is reduced to find 'K' largest numbers(based on count) in > the hash table > > the optimal solution is to use minheap of size 'K' > > add first k elements in the minheap > now take the k+1 element > [as it is min heap the root will have minimum of all 'K' elements] > > while(k > if( a[k+1] > root) > pop the root and add to heap and heapify > else if(a[k+1] < root) >go to k+2 element > } > > at the end the heap will have "K" elements which is the required answer > > time complexity O( n-K + nlogK ) > space complexity O(K) for heap > > as u get new words u can do the same check to add to heap or discard > > Arun, > > On Fri, Aug 14, 2009 at 12:53 PM, richa gupta wrote: > >> >> You have to develop a piece of code that can be attached to a program >> like Microsoft Word, which would list the last "N" words of the >> document in descending order of their occurence, and update the list >> as the user types. What code would you write? Using pseudo code is >> fine, just list the basic things you would consider >> >> -- >> Richa Gupta >> (IT-BHU,India) >> >> >> > > > -- > Potential is not what U have, its what U think U have!!! > It is better to worn out than rust. > > > > > -- Thanks & Regards Umesh kewat 09966796569 --~--~-~--~~~---~--~~ 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 options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---