Re: [algogeeks] [brain teaser ] Find next number in series 10 june

2011-06-10 Thread ankur aggarwal
42, 49

2011/6/10 • » νιρυℓ « • vipulmehta.1...@gmail.com

 42, 47
 just guessing according to the pattern.


 On Fri, Jun 10, 2011 at 1:37 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote:

 *Find next number in series
 * * ***
 *
 *
 **
 *What are the next two numbers in this sequence?

 7, 14, 17, 21, 27, 28, 35, 37, ?, ?
 * *
 *

 *Update Your Answers at* : Click 
 Herehttp://dailybrainteaser.blogspot.com/2011/06/find-next-number-in-series-10-june.html?lavesh=lavesh

  Solution:
 Will be updated after 1 day




 --

 Never explain yourself. Your friends don’t need it
 and your enemies won’t believe it .

 --
 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.




 --
 Regards,
 Vipul


  --
 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] Re: Smallest window of K[] in N[]. Best order solution

2010-10-25 Thread ankur aggarwal
If the order is same then the nishaanth is right..

let have similar problem with no constrain on order

eg main string 12561465

and query string is 1 2 6 5
then output should be 1 2 5 6


On Sat, Oct 23, 2010 at 11:23 PM, nishaanth nishaant...@gmail.com wrote:

 It is nothing but a common subsequence problem...isnt it ?


 On Wed, Oct 13, 2010 at 3:42 PM, Mridul Malpani 
 malpanimri...@gmail.comwrote:

 @ ankit agarwal, you are right. thanx man.

 On Oct 13, 11:37 am, prodigy 1abhishekshu...@gmail.com wrote:
  Let I,Q be input array,query array respectively.
 
  1. Sort query array. O(klogk)
  2. Allocate an array A of size N.
  3. Fill A such that A[i]= position of Q[i] in I, -1 if not present in
  I.  O(nlogk)
  4. Allocate an array B of size k with all elements initiated to -1.
  5. for(counter=0,i=0,countern,i++)
  {
if(B[i]==-1)
 counter++;
if(A[i]!=-1)
   B[A[i]] = i
   }
  6. Build min-heap of B.(use an auxiliary array  C to keep track of
  position of last occurence of an element of Q in min-heap B.)
  7. for(diff=i-B[1] ; in; i++)
 if(A[i]!=-1)
B[C[A[i]] = i
//percolate up or down if needed
  diff=max(diff,i-B[1]);
 
  8. printdiff
 
  On Oct 7, 1:20 pm, RAHUL KUJUR kujurismonu2...@gmail.com wrote:
 
 
 
   @prodigy: how is it coming O(nlogk) can u 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 S.Nishaanth,
 Computer Science and engineering,
 IIT Madras.

  --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 

With Regards
Ankur Aggarwal
+91-7838289304

Software Engineer
Slideshare
Delhi
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.
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] ATM machine---Google Question

2010-10-02 Thread ankur aggarwal
did not get this question... ??
explain plz..

On Sat, Oct 2, 2010 at 6:52 PM, bittu shashank7andr...@gmail.com wrote:

 as we know that each user has only 4 digit acc . no.we hav billions of
 user wat is  maximum bounds on these no. wat algo used to generate 4
 digit uniqe no.  wat is the posible 4 digit no. we can have...

 Regards
 Shashank Mani

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 

With Regards
Ankur Aggarwal
+91-7838289304

Software Engineer
Slideshare
Delhi
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.
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

2010-09-22 Thread ankur aggarwal
http://www.4shared.com/
 check it..

On Wed, Sep 22, 2010 at 12:00 AM, Nikhil Agarwal
nikhil.bhoja...@gmail.comwrote:

 Can anybody share his/her E-copy of An Introduction to algorithm by Udi
 manber.It's a great resource.If anybody has please share his E-copy.Thanks
 in advance.

 --
 Thanks  Regards
 Nikhil Agarwal
 Senior Undergraduate
 Computer Science  Engineering,
 National Institute Of Technology, Durgapur,India
 http://tech-nikk.blogspot.com
 http://beta.freshersworld.com/communities/nitd


  --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 

With Regards
Ankur Aggarwal
+91-7838289304

Software Engineer
Slideshare
Delhi
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.
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] Yahoo Question

2010-09-15 Thread ankur aggarwal
use heap.. k node min / max heap.


On Wed, Sep 15, 2010 at 3:30 PM, bittu shashank7andr...@gmail.com wrote:

 You are given k sorted lists with total n inputs in all the lists
 devise a algorithm to merge them into one single sorted list in O(n
 logk)



 Regard's
 Shashank Mani Narayan  Don't Be Evil U Can Earn While U learn
 Computer Science  Engineering
 Birla Institute of  Technology,Mesra
 Cell No. +91-9166674831

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 

With Regards
Ankur Aggarwal
+91-7838289304

Software Engineer
Slideshare
Delhi
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.
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:Google Interview Question-Snake and Ladder Design

2010-09-14 Thread ankur aggarwal
@bittuu
write your algo then code


On Tue, Sep 14, 2010 at 1:36 PM, bittu shashank7andr...@gmail.com wrote:

 #includestdlib.h
 #includestdio.h
 #includemath.h
 #includeconio.h

 int turn, square;
 long game, totalgames;
 int seed;
 int chutehit[10], ladderhit[9];
 float RunningTurnTotal;
 float average;

 char reply;


 void ChuteStats()
 {printf(Chute and Ladder Statistics:\n\n);

 printf(Chute0: %d Ladder0: %d\n, chutehit[0], ladderhit[0]);
 printf(Chute1: %d Ladder1: %d\n, chutehit[1], ladderhit[1]);
 printf(Chute2: %d Ladder2: %d\n, chutehit[2], ladderhit[2]);
 printf(Chute3: %d Ladder3: %d\n, chutehit[3], ladderhit[3]);
 printf(Chute4: %d Ladder4: %d\n, chutehit[4], ladderhit[4]);
 printf(Chute5: %d Ladder5: %d\n, chutehit[5], ladderhit[5]);
 printf(Chute6: %d Ladder6: %d\n, chutehit[6], ladderhit[6]);
 printf(Chute7: %d Ladder7: %d\n, chutehit[7], ladderhit[7]);
 printf(Chute8: %d Ladder8: %d\n, chutehit[8], ladderhit[8]);
 printf(Chute9: %d\n, chutehit[9]);
 }



 int main()
 {
 printf(Welcome to the Chutes and Ladders simulation \n);
 printf(...\n);
 srand(1);

 //printf(How many games would you like me to run? __ );
 //scanf(%i,totalgames);
 ///printf(\n You have chosen to run %i games... thank you! \n,
 totalgames);

 totalgames+=2;
 RunningTurnTotal=0.0;
game=1;
do{

turn=0;
square=0; /** Reset game **/
 do   /** Begin game loop
 **/

{
++turn;
RunningTurnTotal = RunningTurnTotal + 1;

square = square + 1 + rand()%6;   /** Spin and move
 **/

printf(square =%d \n,square);

if (square == 1) {square=23; ++ladderhit[0];} /** Ladders?
 **/
if (square == 4) {square=14; ++ladderhit[1];}
if (square == 9) {square=31; ++ladderhit[2];}
if (square == 21) {square=42; ++ladderhit[3];}
if (square == 28) {square=84; ++ladderhit[4];}
if (square == 36) {square=44; ++ladderhit[5];}
if (square == 51) {square=67; ++ladderhit[6];}
if (square == 71) {square=91; ++ladderhit[7];}
if (square == 80) {square=100;++ladderhit[8];}/// so when 80
 comes raech to our goal exit



if (square == 98) {square=78; ++chutehit[0];} /** Chutes ?
 **/
if (square == 95) {square=75; ++chutehit[1];}
if (square == 93) {square=73; ++chutehit[2];}
if (square == 87) {square=24; ++chutehit[3];}
if (square == 62) {square=19; ++chutehit[4];}
if (square == 64) {square=60; ++chutehit[5];}
if (square == 56) {square=53; ++chutehit[6];}
if (square == 49) {square=11; ++chutehit[7];}
if (square == 48) {square=26; ++chutehit[8];}
if (square == 16) {square=6; ++chutehit[9];}

   } while (square100);//terminate if random no. is  100

   printf(\n\n Game over after %d turns\n, turn);
   printf(\nSimulation complete... beginning statistical
 analysis...\n\n);
  printf(Total number of games played: %d \n, game);
  printf(Total number of turns: %f \n, RunningTurnTotal);
  average = RunningTurnTotal / game;
  printf(Avg number of turns per game: %f \n, average);
  printf(\n);
  ChuteStats();
  printf(\n);

 ++game;
 printf(\n\n Would you like to run the simulation again?
 (1=Yes)...);
 scanf(%i,reply);
 if(reply==1)//e.g. reply==1
 totalgames+=1;
 else
 exit(0);// exit


  } while (gametotalgames);



 getch();
 }

  ///O(N^2) solution  Does solution exits
 in O(n) or (nlogn)..? reply me sum1 git dis..
 //i will post analysis of dsi program later   i m solving usig OOPS
 (Java) to represnt everything as object
 //right me if i m wrong or hw we can improve dis alog.




 Regards
 Shashank Mani  Don't Be Evil u Can Earn While U Learn
 BIT Mesra-2010
 09166674831

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 

With Regards
Ankur Aggarwal
+91-7838289304

Software Engineer
Slideshare
Delhi
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.
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] sorting range of numbers in O(n)

2010-08-03 Thread ankur aggarwal
radix sort...

On Mon, Aug 2, 2010 at 10:22 AM, Apoorve Mohan apoorvemo...@gmail.comwrote:

 Counting Sort.


 On Mon, Aug 2, 2010 at 6:15 AM, Praveen praveen.yarlaga...@gmail.comwrote:

 There are N numbers in an array and each number is in the range [0,
 n*n -1]. Is there a way to sort the elements in O(n)?

 Thanks,
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 regards

 Apoorve Mohan


  --
 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.comalgogeeks%2bunsubscr...@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.



Re: [algogeeks] Re: number of BST's

2010-08-02 Thread ankur aggarwal
the calatan number can be derived using the code given above.. plz confirm
by using wiki..

try 2 find derivation of catalan number..


On Mon, Aug 2, 2010 at 11:34 AM, bujji jajalabu...@gmail.com wrote:

 Number of BST with n keysf(n) =  [ \sum_{ i=1 to n} f(i-1)* f(n-
 i) ]

 Root node can be any of n keys. if it is ith ney in ascending order,
 it has i-1 keys to left and n-i keys to right.

 Can any one explain how/Why is it equal to catalan number?

 -Thanks
  Bujji

 On Aug 1, 1:08 pm, Manjunath Manohar manjunath.n...@gmail.com wrote:
  int count(int node)
  {
 int sum=0;i,left,right;
 for(i=0;inode;i++)
 {
left=count(node-1);
right=count(node-i);
sum+=left*right;
}
return(sum);
 
 
 
  }- Hide quoted text -
 
  - Show quoted text -

 --
 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.comalgogeeks%2bunsubscr...@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.



Re: [algogeeks] a google question

2010-07-21 Thread ankur aggarwal
this ques was asked by google.. it could find any gud soln than order n*n

On Mon, Jul 19, 2010 at 10:55 AM, 王奇凡 wqfhena...@gmail.com wrote:

 @Kushwaha
 Your programe is wrong.
 Try this input:
 a[ ] = {30,25,19,16,14};
 b[ ] = {20,18,12,10,8};

 the right answer should be 50 48 45 43 42

 but the program output is   50 48 45 43 37。



 2010/5/2 Jitendra Kushwaha jitendra.th...@gmail.com

 Here is a solution of O(n)  , taking 4 pointers 2 for each array


 #include cstdio
 #includeiostream
 using namespace std;

 #define N 10

 int main(void)
 {
 int arr1[N] = {8,7,4,3,2,1,1,1,1,1};
 int arr2[N] = {34,23,21,19,15,13,11,8,4,2};
 int *p11,*p12,*p21,*p22;
 p11 = p12 = arr1;
 p21 = p22 = arr2;
 int f1;
 f1 = 0;

 for(int i=0;iN;i++) {
 int ans=0;
 int a,b,c,d;
 a = *p11 + *p21;
 b = *p11 + *p22;
 c = *p21 + *p12;
 d = *(p11+1) + *(p21+1);

 //printf(a=%d b=%d c=%d d=%d\n,a,b,c,d); //debug

 if(f1==0)ans = a  ,p12++ , p22++ , f1=1;

 else if(b = c  b = d )ans = b  , p22++ ;

 else if(c = b  c = d )ans = c , p12++ ;

 elseans = d , p11++ , p21++ ,printf(4 );

 printf(%d\n,ans);
 }
 }


 Regards
 Jitendra Kushwaha
 Undergradute Student
 Computer Science  Eng.
 MNNIT, Allahabad

 --
 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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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.



Re: [algogeeks] a google question

2010-07-21 Thread ankur aggarwal
this ques was asked by google.. i* could find any gud soln than order n*n




-- 
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] XOR list

2010-07-16 Thread ankur aggarwal
@thread_creator

do u really need a code... try understanding the logic.. coding is not
tough.. i have a code.. i can mail u if u wanaa

On Fri, Jul 16, 2010 at 11:37 AM, Debajyoti Sarma sarma.debajy...@gmail.com
 wrote:

 how to implement xor list ? i.e. doubly linked list using single
 pointer .
 I don't understand how we can write code insertion  deletion
 (beginning,end,middle )
 traversing ( forward and backward )

 Please give a easy code(C) to understand.

 --
 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.comalgogeeks%2bunsubscr...@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.



Re: [algogeeks] XOR list

2010-07-16 Thread ankur aggarwal
read coremen excercise ques of linklist... u will understand...


On Fri, Jul 16, 2010 at 1:13 PM, ankur aggarwal ankur.mast@gmail.comwrote:

 @thread_creator

 do u really need a code... try understanding the logic.. coding is not
 tough.. i have a code.. i can mail u if u wanaa


 On Fri, Jul 16, 2010 at 11:37 AM, Debajyoti Sarma 
 sarma.debajy...@gmail.com wrote:

 how to implement xor list ? i.e. doubly linked list using single
 pointer .
 I don't understand how we can write code insertion  deletion
 (beginning,end,middle )
 traversing ( forward and backward )

 Please give a easy code(C) to understand.

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 With Regards

 Ankur Aggarwal




-- 
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.



Re: [algogeeks] Re: AMAZON Interview Question

2010-07-15 Thread ankur aggarwal
@harit..
logic plz.. not the code..

On Wed, Jul 14, 2010 at 9:50 PM, harit agarwal agarwalha...@gmail.comwrote:

 this is O(n) solution and using O(n) space...

 #includeiostream
 #includevector
 #includestack
 using namespace std;
 void leader_count(vectorint v,int *ar)
 {
 stackint s;
 int n=v.size();
 int i=n-1;
  while(i=0)
 {
 if(s.empty())
  {
 ar[--n]=0;
 s.push(i);
  i--;
 }
 else
  {
 if(v[i] = v[s.top()])
 {
  ar[--n]=s.top();
 s.push(i);
 i--;
  }
 else
 {
  s.pop();
 }
 }
  }
 for(int i=v.size()-1;i=0;i--)
 if(ar[i]!=0)
  ar[i]=ar[ar[i]]+1;

 }
 main()
 {
 int i;
  vectorint v;
 while(cini)
 v.push_back(i);
  int *ar=new int[v.size()];
 leader_count(v,ar);
 for(int i=0;iv.size();i++)
 coutar[i]  ;
 }

  --
 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.comalgogeeks%2bunsubscr...@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.



Re: [algogeeks] online movies streaming

2010-07-15 Thread ankur aggarwal
Hey moderator..

try 2 avoid these members...

On Thu, Jul 15, 2010 at 1:01 AM, X +18 mai...@jadidnet.net wrote:

 http://bit.ly/aRDr4E

 Streaming entertainment network with lots of video clips. ... Use a
 software called qvod player, you can watch the DVD movies online for free.
 ...

 http://bit.ly/aRDr4E

 Watch free Movies, TV-shows, Anime, Documentaries and Cartoons online on
 alluc.org - Worlds biggest video stream Database!

 http://bit.ly/aRDr4E

 --
 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.comalgogeeks%2bunsubscr...@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.



Re: [algogeeks] Re: Difference b/w two elements in a array

2010-07-12 Thread ankur aggarwal
order nlogn is trivial ..
any thing better ??


On Mon, Jul 12, 2010 at 2:51 PM, srikanth sg srikanthini...@gmail.comwrote:

 2 6 3  7
 check for this


 On Mon, Jul 12, 2010 at 12:46 AM, vikas kumar vikas.kumar...@gmail.comwrote:

 traverse array with 2 elements keeping track of 2 min elements. time
 O(n) space O(1)

 On Jul 11, 9:34 pm, Amit Jaspal amitjaspal...@gmail.com wrote:
  Constraint - O(n)
 
  On Sun, Jul 11, 2010 at 9:24 AM, amit amitjaspal...@gmail.com wrote:
   Given an array of size n.find 2 numbers from array whose difference is
   least.
 
   --
   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.comalgogeeks%2bunsubscr...@googlegroups.com
 algogeeks%2bunsubscr...@googlegroups.comalgogeeks%252bunsubscr...@googlegroups.com
 
   .
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
  --
  Amit Jaspal
  Btech IT IIIT- Allahabad

 --
 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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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.



Re: [algogeeks] Re: amazon:-

2010-07-12 Thread ankur aggarwal
edit distance..

On Mon, Jul 12, 2010 at 10:22 AM, Anil Kumar S. R. sra...@gmail.com wrote:

 Use the A* Search approach, which is based on a function f(x) = g(x) +
 h(x), where f(x) is
 the total cost, g(x) is the cost to travel to the current node and h(x) is
 the heuristic
 estimate of the cost remaining to the goal, from the current node. Use the
 hamming distance
 approach to find h(x), which specifies how much two words differ.

 Use the data structures such as hash table and min priority queue to
 compute f(x).

 Anil Kumar S. R.

 The best way to succeed in this world is to act on the advice you give to
 others.



 On 11 July 2010 08:21, sharad kumar sharad20073...@gmail.com wrote:

 @jalaj
 how u make graph
 so that we can apply dijkasta algo
 plz xpalain

  --
 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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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.



Re: [algogeeks] xoring

2010-07-12 Thread ankur aggarwal
i can give an idea..
start from the LHS bit.. ( for 3 =*0*101)

divide all numbers in two groups A0and A1 , A1 = 1XXX, A0 = 0XXX form
we know that an element in A1 xor an element in A0 will give the soln for
this..

IF either of set is empty then we have to go further like this way

now divide A1 = A10 and A11 such that A11 = 11XX and A10 =10XX
and so on..
now XOR of the elements from group A11 and A10 is max or A01 and A00 etc
this way we can do it..

on each stage i am eleminating some elements..


On Mon, Jul 12, 2010 at 12:50 AM, sharad kumar sharad20073...@gmail.comwrote:

 given a set of numbers
 u hve to find the pair which give maximum value if we xor that pair
 ex a={1,3,6,7,8,9}
 then ans is 15 as 7 xor 8

 --
 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.comalgogeeks%2bunsubscr...@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.



Re: [algogeeks] Minimum Window String

2010-07-12 Thread ankur aggarwal
i think ques is not complete..
otherwise above ans is rite.. i suppose..

On Mon, Jul 12, 2010 at 10:00 AM, Anand anandut2...@gmail.com wrote:

 you can use longest common subsequence algorithm to solve it.

 http://codepad.org/NDAeIpxR


 On Sun, Jul 11, 2010 at 9:32 AM, amit amitjaspal...@gmail.com wrote:

 Given a set T of characters and a string S , find the minimum window
 in S which will contain all the characters in T in complexity O(n) .

 Constraint : The characters may appear in any order

 --
 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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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.



Re: [algogeeks] 32 comparisons only

2010-07-12 Thread ankur aggarwal
good 1.

On Tue, Jul 13, 2010 at 2:56 AM, Amir hossein Shahriari 
amir.hossein.shahri...@gmail.com wrote:

 make a bitwise trie
 since the height would be 32 (number of bits in an integer) u only need 32
 comparisons to find an 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.comalgogeeks%2bunsubscr...@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.



Re: [algogeeks] Re: sort 0's 1's and 2's

2010-06-30 Thread ankur aggarwal
dutch flag problem..


On Wed, Jun 30, 2010 at 8:07 AM, Gene gene.ress...@gmail.com wrote:

 On Jun 29, 3:26 pm, sharad kumar sharad20073...@gmail.com wrote:
  how to sort an array containing 0's 1's and 2's in O(n)time and sorting
  technique must be inplace

 #define M 3

 void sort(int *a, int n)
 {
  int i, j, c[M];
  for (j = 0; j  M; j++) c[j] = 0;
  for (i = 0; i  n; i++) ++c[a[i]];
  for (i = j = 0; j  M; j++)
while (c[j]--)
  a[i++] = j;
 }

 --
 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.comalgogeeks%2bunsubscr...@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.



Re: [algogeeks] crazy

2010-06-29 Thread ankur aggarwal
i think it shud be 1/2.. i will try to prove it...


On Mon, Jun 28, 2010 at 8:52 AM, sharad kumar sharad20073...@gmail.comwrote:

 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.comalgogeeks%2bunsubscr...@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.



[algogeeks] c++ and sql

2010-06-04 Thread ankur aggarwal
Write a C/C++ console application that connects to a MySQL server and prints
the number of aborted connects using information provided by MySQL's global
variables.

-- 
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.



Re: [algogeeks] You have to count the occurances of all words in a document. You are given a method chat * GetNextWord, that returns the next word from the document.

2010-03-04 Thread ankur aggarwal
trie data structure

On Sat, Feb 27, 2010 at 1:13 PM, subbu bvss bvss.su...@gmail.com wrote:

 i think u have to use t9 algorithm.. (tree type data structure)...


 On Sat, Feb 27, 2010 at 6:32 PM, abhijith reddy 
 abhijith200...@gmail.comwrote:

 You can use a TRIE  ..  Structure can be something like this

 struct trie
 {
int count; // no of occurences
char *child[SIZE];
 };

 when ever u insert ( it will take just O(length) time) .. just increment
 count by 1

 For each query (also O(length) time) the no of occurrences of the word
 will be count of the last character

 Hope it helps



 On Sat, Feb 27, 2010 at 5:35 PM, piyushgoe...@gmail.com wrote:

 Maintain a hash of word to freq. Keep adding words and incrementing their
 frequencies while reading the documents


 Pigol


 On Feb 27, 2010, at 5:10 PM, vijay auvija...@gmail.com wrote:

 You have to count the occurances of all words in a document. You are
 given a method chat * GetNextWord, that returns the next word from the
 document.
 - Which datastructure can be userd to achieve this
 -

 --
 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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
With Regards

Ankur Aggarwal
Research internee
Optical Zeitgeist Laboratory
Institut National de la Recherche Scientifique (INRS) - ÉMT
800, de la Gauchetière Ouest, bureau 6900
Montréal, QC, H5A 1K6
CANADA

Ph: +1 514 966-2661
E-mail: ankur.1...@gmail.com
Web: www.zeitgeistlab.ca
Group Member Page: http://zeitgeistlab.ca/doc/groupmembers.html

-- 
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: Algorithm intensive Please solve

2010-02-16 Thread ankur aggarwal
@all
i think all the above approaches are greedy..
we need dynamic solution to this problem..


On Sat, Feb 13, 2010 at 11:42 AM, vikrant singh vikrantsing...@gmail.comwrote:

 @sachin : the problem is bit more complex , consider N be 2 , and
 coordinates be (-2,0) (0,0) (1,0) (3,0). your solution( min value=1+5=6)
 wont give the right answer(2+2=4).


 On Sat, Feb 13, 2010 at 6:07 PM, sachin sachin_mi...@yahoo.co.in wrote:

 We can make a spanning tree for these 2N points and then find the
 minimum spanning tree
 keeping in mind that a node can only be considered in one edge and not
 more than once.
 This will give you the minimum total sum of all the pairs.
 You can use kruskal's min spanning tree algorithm to find the minimum
 spanning tree because
 kruskal's method works by finding the least cost edges  then
 proceeding towards the max cost edges.
 I hope it solves your problem.

 Regards,
 Sachin


 On Feb 12, 9:20 am, GentLeBoY vikrantsing...@gmail.com wrote:
  given 2N points in a plane. Pair up to obtain N distinct pairs such
  that total sum of paired distances is minimum.
  N can be atmost 50.

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Vikrant Singh

  --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Ankur Aggarwal
Research internee
Optical Zeitgeist Laboratory
Institut National de la Recherche Scientifique (INRS) - ÉMT
800, de la Gauchetière Ouest, bureau 6900
Montréal, QC, H5A 1K6
CANADA

E-mail: ankur.1...@gmail.com
Web: www.zeitgeistlab.ca

-- 
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: aai + bj + ck =0

2009-11-01 Thread ankur aggarwal
@daizi

i think this will not be n^2.
check it again ..

On Sun, Nov 1, 2009 at 1:09 PM, daizi sheng daizish...@gmail.com wrote:

 with all arrays sorted firstly, if you enumerate ai, bj in ascedning order,
 ck will be sure in descending order.

 foreach(ai in A)
  ck = largest element in C
  foreach(bj in B)
AGAIN:
  if(ai + bj + ck == 0) algorithm over
  if(ai + bj + ck  0) ck change to its neighbor in C and goto AGAIN
  if(ai + bj + ck  0) continue checking next bj


 On Sun, Nov 1, 2009 at 3:10 PM, anilkumarmyla anilkumarm...@gmail.com
 wrote:
  No matter whatever i could think of, I am unable to do better than N^3
 
  @daizi sheng
  I don't get your algorithm
  2. enumerate ai, bj both in ascending order,
  Will that really help ? In what way ?
 
  --
 
  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.
 

 --

 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.




--

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] aai + bj + ck =0

2009-10-30 Thread ankur aggarwal
Given 3 randomly filled array of size N ( say Aa1,a2..aN , Bb1,b2…bN and
Cc1,c2..cN ).give Algorithm to verify if there exists a triplet such that
ai + bj + ck =0 where
0I,j,k=N Time complexity of Your algorithm should be O(NlogN) and state
space complexity of
you’re algorithm .O(N^2) algorithm will get partial credit.

--~--~-~--~~~---~--~~
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] kth number of a large number of data

2009-10-19 Thread ankur aggarwal
If you have a large number of data which are stored on 100 distributed
computers, unsorted, how can you compute the kth number of all the data?

--~--~-~--~~~---~--~~
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: 100!

2009-10-18 Thread ankur aggarwal
yeh..
no shortcut..


On Thu, Oct 15, 2009 at 9:44 PM, harit agarwal agarwalha...@gmail.comwrote:

 no use of all these logics.u have 2 calculate whole value of 100! for
 summation...
 use link list to store final value...after ever product...


 


--~--~-~--~~~---~--~~
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: picture problem

2009-10-16 Thread ankur aggarwal
i think yeh 8 puzzle problem maine convert karke ho sakti hain
we r not provided wid any info about the moves..
i define my move as in 8 puzzle problem


On Thu, Oct 15, 2009 at 10:58 PM, Pawandeep bhatti.pawand...@gmail.comwrote:


 Case 1:   We have the Big Picture to verify the result
 solution: 1.first we will identify the 16 regions and assign a unique
 id to them,
 2.then , we can check the given 16 squares(shuffled) one
 by one to match the unique number in databse,
 3. finallly we can arrange the picture by sorting the
 unique ids.

 Case 2:   We don't have the Big Picture to verify the result.
 Solution : Wait for next 10 years until i make the global database of
 AI picture generation Neural network
   (which will learn by observing the common objects in
 nature) ,then we solve the problem (except abstract art pictures)





 


--~--~-~--~~~---~--~~
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

2009-10-14 Thread ankur aggarwal
@umesh
gud logic..

On Wed, Oct 14, 2009 at 3:32 PM, umesh kewat umesh1...@gmail.com wrote:

 *n=(nx)|(n(32-x));*

 *ex: n=11101001, x=2 suppose here n is 8 bit long*
 *
 n=(111010012)|(111010014)

 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 gauravkis...@gmail.comwrote:


 How abt this..?

 for(i=0;ix;i++)
  {
res=no1U;
no=no1;
if(res==1)
  no=no|32768U;
else
  no=no|0U;
  }
  printf(\nFinal value %u,no);


 On Oct 12, 8:11 pm, Raghavendra Sharma raghavendra.vel...@gmail.com
 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.comwrote:
 
 
 
   *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] picture problem

2009-10-14 Thread ankur aggarwal
A square picture is cut into 16 squares and they are shuffled.  Write a
program to rearrange the 16 squares  to get the original big square.

--~--~-~--~~~---~--~~
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] use putchar to print out an unsigned long in decimal

2009-10-14 Thread ankur aggarwal
1.  Given only putchar (no sprintf, itoa, etc.) write a routine putlong
that prints out an unsigned long in decimal.

--~--~-~--~~~---~--~~
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

2009-10-14 Thread ankur aggarwal
@pradeep
your ques is not clear..


On Thu, Oct 15, 2009 at 7:58 AM, Arun arunm...@gmail.com wrote:



 *
 n=(111010012)|(**111010014)
 *
 *n=(00111010)|(0100)

 *


 *111010014 is 1001*



 *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 gauravkis...@gmail.comwrote:


 How abt this..?

 for(i=0;ix;i++)
  {
res=no1U;
no=no1;
if(res==1)
  no=no|32768U;
else
  no=no|0U;
  }
  printf(\nFinal value %u,no);


 On Oct 12, 8:11 pm, Raghavendra Sharma raghavendra.vel...@gmail.com
 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.comwrote:
 
 
 
   *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: optimum algo for second largest

2009-10-12 Thread ankur aggarwal
in that case it is ok..

--~--~-~--~~~---~--~~
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] ROTATE

2009-10-12 Thread ankur aggarwal
*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.*

--~--~-~--~~~---~--~~
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

2009-10-12 Thread ankur aggarwal
@raghav
plz give an example
wat r u trying 2 do.


On Mon, Oct 12, 2009 at 8:41 PM, Raghavendra Sharma 
raghavendra.vel...@gmail.com 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.comwrote:

 *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.*



 


--~--~-~--~~~---~--~~
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: Y shaped linklist

2009-10-11 Thread ankur aggarwal
*...@manisha
  one traversal for each of the lists
 *

After* two traversals, *both pointers will surely meet at intersection
point..

--~--~-~--~~~---~--~~
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: Y shaped linklist

2009-10-11 Thread ankur aggarwal
*...@manisha
 one traversal for each of the lists
*

--~--~-~--~~~---~--~~
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: 100!

2009-10-11 Thread ankur aggarwal
@gautam
i dont understand

On Sun, Oct 11, 2009 at 6:59 PM, Prunthaban Kanthakumar 
pruntha...@gmail.com wrote:



 On Sun, Oct 11, 2009 at 6:40 PM, Gautham Muthuravichandran 
 gautha...@gmail.com wrote:


 9.. All the factorials above 5! is divisible by 9.


 Divisible by 9 does not mean exactly 9.


 -Gautham

 On Sun, Oct 11, 2009 at 11:54 AM, Debanjan debanjan4...@gmail.com
 wrote:
 
 
 
  On Oct 11, 10:29 am, Anil C R cr.a...@gmail.com wrote:
  Project Euler!!
 
  I remember I cheated on this problem :P At first I used my SPOJ FCTRL2
  solution to get the factorial of 100 then I simply add up those
  digits :D
 
  Most problems of Project Euler can be brute forced !
 
  
 




 


--~--~-~--~~~---~--~~
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] minimum number of comparisons

2009-10-11 Thread ankur aggarwal
Q1. Give steps to sort 5 numbers in minimum number of comparisons .Justify
that number of comparisons are minimum. Extend your argument for *N*numbers.

--~--~-~--~~~---~--~~
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] gold bar

2009-10-11 Thread ankur aggarwal
You've got someone working for you for seven days and a gold bar to pay
them. The gold bar is segmented into seven connected pieces. You must give
them a piece of gold at the end of every day. If you are only allowed to
make two breaks in the gold bar, how do you pay your worker?

--~--~-~--~~~---~--~~
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: Y shaped linklist

2009-10-11 Thread ankur aggarwal
@manisha
that is the ques..
there are many soln for 2 traversal
like loop in the linklist.
simple travesal
n many more..


On Sun, Oct 11, 2009 at 1:20 PM, ankur aggarwal ankur.mast@gmail.comwrote:



 *...@manisha
  one traversal for each of the lists
 *

 After* two traversals, *both pointers will surely meet at intersection
 point..

--~--~-~--~~~---~--~~
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: 100!

2009-10-11 Thread ankur aggarwal
@gautam
*
find sum of all the digits in number-100!*

now show wat is significance of 9 in this ques ??

--~--~-~--~~~---~--~~
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] sum of subsequence.

2009-10-09 Thread ankur aggarwal
2. Given an array all of whose elements are positive numbers, find the
maximum sum of a subsequence with the constraint that no 2 numbers in the
sequence should be adjacent in the array.

 i) 3 2 7 10 should return 13 (sum of 3 and 10)

ii) 3 2 5 10 7 should return 15 (sum of 3, 5 and 7)

--~--~-~--~~~---~--~~
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] Y shaped linklist

2009-10-09 Thread ankur aggarwal
How to find the intersection point in linked list with the following
constraints
1) one traversal for each of the lists
2) should not find the LENGTH of the lists
3) can USE recursion It goes like this ...

--~--~-~--~~~---~--~~
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] infinite memory

2009-10-09 Thread ankur aggarwal
How will you implement infinite memory(infinite strings) in finite space

Propose some method...

--~--~-~--~~~---~--~~
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] search your friend

2009-10-09 Thread ankur aggarwal
You are standing at a crossing from where there emerge four roads extending
to infinity. Your friend is somewhere on one of the four roads.  You do not
know on which road he is and how far he is from you. You have to walk to
your friend and the total distance traveled by you must be at most a
constant times the actual distance of your friend from you. In terminology
of algorithms, you should traverse  O(d) distance, where d  is the distance
of your friend from you.

--~--~-~--~~~---~--~~
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: Y shaped linklist

2009-10-09 Thread ankur aggarwal
@sharad

wat about space ??
extra space ?

--~--~-~--~~~---~--~~
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: coloring (Marking)

2009-10-09 Thread ankur aggarwal
it is NP hard problem i suppose..

On Fri, Oct 9, 2009 at 4:20 PM, Miroslav Balaz gpsla...@googlemail.comwrote:

 LOL search for dominance in graph.

 2009/10/7 ankur aggarwal ankur.mast@gmail.com

 Given a graph..

 Find the minimum number of coloring (Marking) required to node such that
 every node in the final graph is connected by at least one of the
 colored(marked) node.

 ex:
 AB
 AC
 BD
 BE
 CF

 sol: 2 nodes to be colored.

 i.e. Colouring C and B would suffice..




 


--~--~-~--~~~---~--~~
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: search your friend

2009-10-09 Thread ankur aggarwal
yes anil
your approach is rite..

--~--~-~--~~~---~--~~
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] balls and lines

2009-10-09 Thread ankur aggarwal
Given 13 balls, how would you arrange them in 9 lines, such that there are 4
balls in each line? You can assume that the lines are arranged in 2-D space
and that a ball
cannot be placed on top of another ball.
Bonus: if you find that too easy, and have loads of time to kill, then how
about arranging
22 balls in 21 lines of 4?

--~--~-~--~~~---~--~~
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] add data members at runtime.

2009-10-07 Thread ankur aggarwal
  Implement a c++ class such that it allows us to add data members at
runtime.

--~--~-~--~~~---~--~~
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] coloring (Marking)

2009-10-07 Thread ankur aggarwal
Given a graph..

Find the minimum number of coloring (Marking) required to node such that
every node in the final graph is connected by at least one of the
colored(marked) node.

ex:
AB
AC
BD
BE
CF

sol: 2 nodes to be colored.

i.e. Colouring C and B would suffice..

--~--~-~--~~~---~--~~
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 many different permutations of a Rubik's cube are possible?

2009-10-04 Thread ankur aggarwal
The original (3×3×3) Rubik's Cube has eight corners and twelve edges. There
are 8! http://en.wikipedia.org/wiki/Factorial (40,320) ways to arrange the
corner cubes. Seven can be oriented independently, and the orientation of
the eighth depends on the preceding seven, giving 37 (2,187) possibilities.
There are 12!/2 (239,500,800) ways to arrange the edges, since an odd
permutation of the corners implies an odd permutation of the edges as well.
Eleven edges can be flipped independently, with the flip of the twelfth
depending on the preceding ones, giving 211 (2,048)
possibilities.[19]http://en.wikipedia.org/wiki/Rubik%27s_Cube#cite_note-18
[image: {8! \times 3^7 \times 12! \times 2^{10}} \approx 4.33 \times
10^{19}]

There are exactly 43,252,003,274,489,856,000
permutationshttp://en.wikipedia.org/wiki/Permutation,
which is approximately forty-three
quintillionhttp://en.wikipedia.org/wiki/Quintillion.
The puzzle is often advertised as having only
billionshttp://en.wikipedia.org/wiki/10_%28number%29
of positions, as the larger numbers could be regarded as incomprehensible to
many. To put this into perspective, if every permutation of a
57-millimeterhttp://en.wikipedia.org/wiki/MillimeterRubik's Cube
were lined up end to end, it would stretch out approximately
261 light years http://en.wikipedia.org/wiki/Light_years. Alternatively,
if laid out on the ground, this is enough to cover the earth with 273 layers
of cubes, recognizing the fact that the radius of the earth sphere increases
by 57 mm with each layer of cubes.

The preceding figure is limited to permutations that can be reached solely
by turning the sides of the cube. If one considers permutations reached
through disassembly of the cube, the number becomes twelve times as large:
[image: {8! \times 3^8 \times 12! \times 2^{12}} \approx 5.19 \times
10^{20}.]

The full number is 519,024,039,293,878,272,000 or 519
quintillionhttp://en.wikipedia.org/wiki/Quintillionpossible
arrangements of the pieces that make up the Cube, but only one in
twelve of these are actually solvable. This is because there is no sequence
of moves that will swap a single pair of pieces or rotate a single corner or
edge cube. Thus there are twelve possible sets of reachable configurations,
sometimes called universes or
orbitshttp://en.wikipedia.org/wiki/Orbit_%28group_theory%29,
into which the Cube can be placed by dismantling and reassembling it.
*http://en.wikipedia.org/wiki/Rubik%27s_Cube*

--~--~-~--~~~---~--~~
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: string comparison ignoring one char

2009-09-25 Thread ankur aggarwal
edit distance..

--~--~-~--~~~---~--~~
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: string comparison ignoring one char

2009-09-25 Thread ankur aggarwal
tries

On Fri, Sep 25, 2009 at 11:30 PM, ankur aggarwal
ankur.mast@gmail.comwrote:

 edit distance..



--~--~-~--~~~---~--~~
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: What algorithm can be used to decide the denomination of notes in an ATM machine?

2009-09-20 Thread ankur aggarwal

@dufus

i dont think
becoz if u have to take 1000rs then we have 500 note and 100 rs note
though we have 1000rs note.
IT is in INDIA..

i dont know about other countries

On 9/20/09, Dufus rahul.dev.si...@gmail.com wrote:

 Is it different from classic Coin Denomination problem?

 _dufus

 On Sep 19, 11:20 pm, eSKay catchyouraak...@gmail.com wrote:
 for example: if I draw 2000, what I get is
 1000+500+100+100+100+100+100.

 What algorithm can be used to decide how to break up the entered
 amount?

 


--~--~-~--~~~---~--~~
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: What algorithm can be used to decide the denomination of notes in an ATM machine?

2009-09-20 Thread ankur aggarwal
i think there is no use of discussing this ques..

On Sun, Sep 20, 2009 at 2:25 PM, eSKay catchyouraak...@gmail.com wrote:


 yes it is different.

 Coin Denomination Problem [http://haroonsaeed.wordpress.com/2006/06/06/
 coin-denomination-problem/http://haroonsaeed.wordpress.com/2006/06/06/%0Acoin-denomination-problem/]
 [http://www.seeingwithc.org/
 topic1html.html http://www.seeingwithc.org/%0Atopic1html.html]
 would give 2000=1000+1000.

 Thats not the case with an ATM machine.

 On Sep 20, 10:21 am, Dufus rahul.dev.si...@gmail.com wrote:
  Is it different from classic Coin Denomination problem?
 
  _dufus
 
  On Sep 19, 11:20 pm, eSKay catchyouraak...@gmail.com wrote:
 
 
 
 
 
   for example: if I draw 2000, what I get is
   1000+500+100+100+100+100+100.
 
   What algorithm can be used to decide how to break up the entered
   amount?

 


--~--~-~--~~~---~--~~
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] find words which satisfy some criteria

2009-09-17 Thread ankur aggarwal
 All of you guys must have played a game in which a 2-D Matrix of characters
is given. The goal to find words which satisfy some criteria (eg. Names of
various countries etc...) The words can
be present horizontally, vertically and
diogonally both in forward and reverse order.
This is a pretty tough problem. Lets restrict our current problem to a
single word.
Given a matrix of characters (2-D array of characters) find the number of
occurrence of a word in that matrix. The word can be present in
1. Row
2. Coloum
3. Diagonally.

In all three cases, the word can be present both in forward and reverse
manner.

--~--~-~--~~~---~--~~
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] function problem

2009-09-17 Thread ankur aggarwal
5. void foo1()
{
if(AB)
Then {_/* */}
else
if(CD)
then foo2()
}
How many time foo2() would get called given
AB 25% of the times and CD 75% of the times and
foo1() is called 5000 times

--~--~-~--~~~---~--~~
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: Z[n^2]={such that z belongs to X+Y

2009-09-15 Thread ankur aggarwal
*For each of the n*m sums add it to the heap (if it ain't full with k
elements) or replace the root and heapify if the sum is lesser than the
root.* how u can judge which is the next value to be added..

try your algo at

array a 1 2 3 4 5 7 9
and array b 2 3 5 6 7

--~--~-~--~~~---~--~~
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: Citrix interview question

2009-09-15 Thread ankur aggarwal
compiler dependent as simple as that..

--~--~-~--~~~---~--~~
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: what will happen in the village

2009-09-14 Thread ankur aggarwal
@dufus
plz clearify
i know u have something in mind..

thanxs

On Sun, Sep 13, 2009 at 11:26 PM, Dufus rahul.dev.si...@gmail.com wrote:


 Old wine in new bottle.
 Try induction.

 _dufus

 On Sep 13, 10:23 pm, Dave dave_and_da...@juno.com wrote:
  Except that the craftiest demon only pretends to take a bite. When the
  others fall asleep, he chows down.
 
  Dave
 
  On Sep 13, 7:24 am, jaspreet singh jaspreet.singh...@gmail.com
  wrote:
 
   the demons share the sleeping man amongst themselves.and hence
 all
   fall asleep and cant eat each other either...
 
   On Sun, Sep 13, 2009 at 5:42 PM, ankur aggarwal 
 ankur.mast@gmail.comwrote:
 
nothing happens...
 
On Sun, Sep 13, 2009 at 5:32 PM, Vikram Sridar 
 vikramsridar...@gmail.comwrote:
 
The man lives forever... sleeps forever actually- Hide quoted text -
 
   - Show quoted text -

 


--~--~-~--~~~---~--~~
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: addition without using arithmetic operators

2009-09-13 Thread ankur aggarwal
this soln may fail on -ve number
i havenot tried ..
but the basic funda is this ..



On Sun, Sep 13, 2009 at 11:23 AM, ankur aggarwal
ankur.mast@gmail.comwrote:

 size of char is 1 byte but that of int is 4
 If i use int then output for a,b will be a+4*b

 in the program the value of ptr is a after the assignment
 address of ptr[c] will be  ptr +c*sizeof(type)
 if the type is char then it equals a+c*1=a+c

 value of ptr is stored as a hexadecimal number
 so the use (int)ptr in last line

 That is why it outputs the sum
 size of char is 1 byte but that of int is 4
 If i usize of char is 1 byte but that of int is 4
 If i use int then output for a,b will be a+4*b

 in the program the value of ptr is a after the assignment
 address of ptr[c] will be  ptr +c*sizeof(type)
 if the type is char then it equals a+c*1=a+c

 value of ptr is stored as a hexadecimal number
 so the use (int)ptr in last line

 That is why it outputs the sum
 se int then output for a,b will be a+4*b

 in the program the value of ptr is a after the assignment
 address of ptr[c] will be  ptr +c*sizeof(type)
 if the type is char then it equals a+c*1=a+c

 value of ptr is stored as a hexadecimal number
 so the use (int)ptr in last line

 That is why it outputs the sum

   int main() {

 int a,b;
   cinab;

   char *ptr = (char *) a;
   char *ptr2 = ptr[b];
   cout (int) ptr2 endl;
   return 0;
  }





--~--~-~--~~~---~--~~
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: what will happen in the village

2009-09-13 Thread ankur aggarwal
nothing happens...

On Sun, Sep 13, 2009 at 5:32 PM, Vikram Sridar vikramsridar...@gmail.comwrote:

 The man lives forever... sleeps forever actually

 


--~--~-~--~~~---~--~~
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: Z[n^2]={such that z belongs to X+Y

2009-09-12 Thread ankur aggarwal
@dufus

lokking at your soln of young tableau
i think there is a problem of repition of some number
given
array A={1,2,3,4}
array B={2,3,4,5};

and try to look wat i say..
3 will repeated , 4 , 5 and so on..

On Sat, Sep 5, 2009 at 12:35 PM, Dufus rahul.dev.si...@gmail.com wrote:


 It seems EXTRACT_MIN for Z[n^2] can be done in O(n) time.
 http://lyle.smu.edu/~saad/courses/cse3358/ps5/problemset5sol.pdfhttp://lyle.smu.edu/%7Esaad/courses/cse3358/ps5/problemset5sol.pdf

 Then using it we can find the kth smallest element in O(nk) time.

 _dufus


 On Sep 4, 10:03 pm, ankur aggarwal ankur.mast@gmail.com wrote:
   Find nth smallest inO(n) Given two arrays of length n in sorted order
  X[n]  Y[n].
  Now make another array Z[n^2]={such that z belongs to X+Y}.
  AS all possible sum of x+y is there in Z. You have to give the nth
 smallest
  no of Z in O(n) time.
  Space complexity : No bound on it. But try to optimize it if possible.

 


--~--~-~--~~~---~--~~
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: find minimum number of races

2009-09-11 Thread ankur aggarwal
7

On Fri, Sep 11, 2009 at 8:14 PM, Dave dave_and_da...@juno.com wrote:


 Answered recently: see
 http://groups.google.com/group/algogeeks/msg/077bdb6a282a1184

 Dave

 On Sep 11, 9:32 am, dinesh bansal bansal...@gmail.com wrote:
  Hi All,
 
  I got a question:
  I have 25 horses and I need to find the 1st, 2nd and 3rd fastest among
 all.
  I have a race course of 5 tracks. That means I can run 5 horses at a
 time.
  What are the minimum number of races required for this.
 
  Thanks,
 
  --
  Dinesh Bansal
  The Law of Win says, Let's not do it your way or my way; let's do it the
  best way.
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: addition without using arithmetic operators

2009-09-11 Thread ankur aggarwal
@all

 int main() {

  int a,b;
  cinab;

  char *ptr = (char *) a;
  char *ptr2 = ptr[b];
  cout (int) ptr2 endl;
  return 0;
}

--~--~-~--~~~---~--~~
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: find triangle in a graph

2009-09-11 Thread ankur aggarwal
@dufus
i read this ques from somewhere .
dont know wat the examiner is looking for...

i think it mite work,,

On Tue, Sep 8, 2009 at 8:38 PM, manish bhatia mb_mani...@yahoo.com wrote:

 how about finding all the connected-components and checking which all have
 3 edges?

  --
 *From:* ankur aggarwal ankur.mast@gmail.com
 *To:* i...@mca_2007 iit_rmca_2...@googlegroups.com;
 lets-talk-g...@googlegroups.com; algogeeks@googlegroups.com
 *Sent:* Sunday, 6 September, 2009 2:58:40 PM
 *Subject:* [algogeeks] find triangle in a graph

  google question : find triangle in a graph Given an undirected graph,
 design a O(V+E) algo to detect whether there is a triangle in the graph ot
 not.

 --
 Looking for local information? Find it on Yahoo! 
 Localhttp://in.rd.yahoo.com/tagline_local_1/*http://in.local.yahoo.com/

 


--~--~-~--~~~---~--~~
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: [Let's Talk] Re: random number...

2009-09-09 Thread ankur aggarwal
http://stackoverflow.com/questions/137783/given-a-function-which-produces-a-random-integer-in-the-range-1-to-5-write-a-fun

and wat about it




  return
 (((rand_5()+rand_5()+rand_5()+rand_5()+rand_5()+rand_5()+rand_5())-7)%7 + 1
 )


--~--~-~--~~~---~--~~
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: random number...

2009-09-08 Thread ankur aggarwal
@dave

*
*On Tue, Sep 8, 2009 at 7:27 AM, Dave dave_and_da...@juno.com wrote:


 Use the rejection technique, something like this:

 do
 {
do
U1 = random_1_to_5();
while( U1 == 5 );
 // At this point, U1 is a uniform integer in the range 1 to 4.
U2 = random_1_to_5();
   * if( U1  2 )//* plz explain this step..
 *   U2 += 5;* // plz explain this step..
 }
 while( U2  7 );
 // At this point, U2 is a uniform random integer in the range 1 to 7.

 It takes on average 45/14 1_to_5 random numbers to make a 1_to_7
 random number.

 D

--~--~-~--~~~---~--~~
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: random number...

2009-09-08 Thread ankur aggarwal
@dufus

tell me 1 thing
do we have to make algo so that the prob is 1/7 or do we have to make so
that prob of generating number between 1 to 7 is same may be( 1/10) etc ???

On Tue, Sep 8, 2009 at 11:42 AM, Dufus rahul.dev.si...@gmail.com wrote:


 Hardest part of this problem is to prove that the generated number
 INDEED follow uniform distribution :D

 _dufus


 On Sep 8, 6:57 am, Dave dave_and_da...@juno.com wrote:
  Use the rejection technique, something like this:
 
  do
  {
  do
  U1 = random_1_to_5();
  while( U1 == 5 );
  // At this point, U1 is a uniform integer in the range 1 to 4.
  U2 = random_1_to_5();
  if( U1  2 )
  U2 += 5;}
 
  while( U2  7 );
  // At this point, U2 is a uniform random integer in the range 1 to 7.
 
  It takes on average 45/14 1_to_5 random numbers to make a 1_to_7
  random number.
 
  Dave
 
  On Sep 7, 10:56 am, ankur aggarwal ankur.mast@gmail.com wrote:
 
 Given a random number generator that generates numbers in the range 1
 to
   5, how can u create a random number generator to generate numbers in
 the
   range 1 to 7. (remember that the generated random numbers should follow
 a
   uniform distribution in the corresponding range)

 


--~--~-~--~~~---~--~~
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: linked list questions

2009-09-08 Thread ankur aggarwal
for 1st

use hare and tortoise algo to find the mid point of the linklist ...
and reverse the other end

like

a-b--c-d-v-u
a-b--c-d-v-u

pointer 1 will point to a and other pointer will point to u
then it is done ..

u can check..



2nd

for(p = original; p != null; p = p-next-next)
p-next-random = p-random-next;

(i) insert one new node in original list for every node .

(ii) then change random links of newly inserted nodes
i.e; for every new node (p-next)
p-next-random = p-random-next


(iii)then split 2 lists

Now Split the Lists

code is


for( q =original-next,r = original-next,p = original; p != null; p =
p-next,q=q-next)
{ p-next = p-next-next;
q-next = q-next-next;
}

--~--~-~--~~~---~--~~
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: random number...

2009-09-08 Thread ankur aggarwal
@karthik
but look at the prob part..
it seems ok 2 me..
it is random generator u cannot guarntee which number is going 2 come..


On Tue, Sep 8, 2009 at 7:34 PM, Karthik Singaram Lakshmanan 
karthiksinga...@gmail.com wrote:


 The rejection technique may never halt...(with an infinitesimally
 small probability of course)...

 In the case of Dave's algorithm:
  if the following random_1_to_5() keeps returning 5.
U1 = random_1_to_5();
   while( U1 == 5 );

 In the case of Ankur's algorithm
   if rand_5() keeps returning 2 or Random_bit() keeps returning 1

 I do not have any solutions or hints to go on...but it seems like a
 harder problem to find a solution with provably finite running time or
 prove that one such solution cannot exist.

 - Karthik

 


--~--~-~--~~~---~--~~
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: random number...

2009-09-08 Thread ankur aggarwal
@dave
plz quote the name of the person u r taking / pointing..


On Tue, Sep 8, 2009 at 8:11 PM, Dave dave_and_da...@juno.com wrote:


 Your comment is moot, since if any random number generator returns the
 same number forever, you are not going to be able to use it to
 generate other random numbers with a uniform density.

 On Sep 8, 9:04 am, Karthik Singaram Lakshmanan
 karthiksinga...@gmail.com wrote:
   The rejection technique may never halt...(with an infinitesimally
  small probability of course)...
 
  In the case of Dave's algorithm:
if the following random_1_to_5() keeps returning 5.
 U1 = random_1_to_5();
 while( U1 == 5 );
 
  In the case of Ankur's algorithm
 if rand_5() keeps returning 2 or Random_bit() keeps returning 1
 
  I do not have any solutions or hints to go on...but it seems like a
  harder problem to find a solution with provably finite running time or
  prove that one such solution cannot exist.
 
  - Karthik
 


--~--~-~--~~~---~--~~
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: n balls having k colors

2009-09-08 Thread ankur aggarwal
@manish
wat is the complexity ??
think about it...


sort balls[] on the basis of code[color_tag]

wat r u doing here ??

On Tue, Sep 8, 2009 at 8:35 PM, manish bhatia mb_mani...@yahoo.com wrote:

 Assign 0 to K numbers to all K colors, such that color - color_tag (a
 number b/w [0,K-1]).
 code[k] = {0,2,..,k-1}
 foreach (permutation from all possible-permuations of code[])
 sort balls[] on the basis of code[color_tag]
 print balls[]


  --
 *From:* ankur aggarwal ankur.mast@gmail.com
 *To:* lets-talk-g...@googlegroups.com; algogeeks@googlegroups.com
 *Sent:* Sunday, 6 September, 2009 1:36:01 PM
 *Subject:* [algogeeks] n balls having k colors

 You have N balls having one of K colors. Arrange them into groups of same
 colors. e.g.

 RRGRG
 can be arranged as
 RRRGG (Answer)
 GGRRR
 --
 See the Web's breaking stories, chosen by people like you. Check out Yahoo!
 Buzz http://in.rd.yahoo.com/tagline_buzz_1/*http://in.buzz.yahoo.com/.

 


--~--~-~--~~~---~--~~
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: random number...

2009-09-08 Thread ankur aggarwal
On Tue, Sep 8, 2009 at 9:04 PM, ankur aggarwal ankur.mast@gmail.comwrote:

 @dave
 plz quote the name of the person u r *talking* / pointing..


 On Tue, Sep 8, 2009 at 8:11 PM, Dave dave_and_da...@juno.com wrote:


 Your comment is moot, since if any random number generator returns the
 same number forever, you are not going to be able to use it to
 generate other random numbers with a uniform density.

 On Sep 8, 9:04 am, Karthik Singaram Lakshmanan
 karthiksinga...@gmail.com wrote:
   The rejection technique may never halt...(with an infinitesimally
  small probability of course)...
 
  In the case of Dave's algorithm:
if the following random_1_to_5() keeps returning 5.
 U1 = random_1_to_5();
 while( U1 == 5 );
 
  In the case of Ankur's algorithm
 if rand_5() keeps returning 2 or Random_bit() keeps returning 1
 
  I do not have any solutions or hints to go on...but it seems like a
  harder problem to find a solution with provably finite running time or
  prove that one such solution cannot exist.
 
  - Karthik
 



--~--~-~--~~~---~--~~
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: linked list questions

2009-09-08 Thread ankur aggarwal
@barath
u r using extra space..
wat is new about this sol
change to array..
then do as simple
using a[i]==a[n-i] ???

On Tue, Sep 8, 2009 at 8:04 PM, Bharath bharath1...@gmail.com wrote:


 Q: Check whether given singly linked list is palindrome or not in
 single pass.

 Instead of making two passes, can we do it in single pass on a list?

 One method i can think of is, hashing character to its postion and
 check for the sum.

 abccba
 123456

 a: 1+6=7
 b: 2+5=7
 c: 3+4=7

 On Sep 8, 5:33 pm, ankur aggarwal ankur.mast@gmail.com wrote:
  for 1st
 
  use hare and tortoise algo to find the mid point of the linklist ...
  and reverse the other end
 
  like
 
  a-b--c-d-v-u
  a-b--c-d-v-u
 
  pointer 1 will point to a and other pointer will point to u
  then it is done ..
 
  u can check..
 
  2nd
 
  for(p = original; p != null; p = p-next-next)
  p-next-random = p-random-next;
 
  (i) insert one new node in original list for every node .
 
  (ii) then change random links of newly inserted nodes
  i.e; for every new node (p-next)
  p-next-random = p-random-next
 
  (iii)then split 2 lists
 
  Now Split the Lists
 
  code is
 
  for( q =original-next,r = original-next,p = original; p != null; p =
  p-next,q=q-next)
  { p-next = p-next-next;
  q-next = q-next-next;
 
  }

 


--~--~-~--~~~---~--~~
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: n balls having k colors

2009-09-08 Thread ankur aggarwal
extra space is sol to  this problem..

--~--~-~--~~~---~--~~
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: linked list questions

2009-09-08 Thread ankur aggarwal
@bharath
how will u recognize
which a to compare to which a

or apply on malayalam

--~--~-~--~~~---~--~~
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] phone numbers.

2009-09-07 Thread ankur aggarwal
3.You have 50,000 html files, some of which contain phone numbers. How would
you create a list of all the files which contain phone numbers?

Solutions should be optimal

--~--~-~--~~~---~--~~
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: find triangle in a graph

2009-09-07 Thread ankur aggarwal
*
*

 *
 @kunzmilan *

* *

 * What do you mean by polynomial of the graph ? 
 *

*
*

--~--~-~--~~~---~--~~
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: Find longest palindrom in a give n string in O(N)

2009-09-07 Thread ankur aggarwal
nagendra..
plz show the working using an example ..
take input

babbaabbc


On Sun, Sep 6, 2009 at 2:07 PM, Nagendra Kumar nagendra@gmail.comwrote:


 @all:

   T(i,j) : denotes the length of longest palindrome with start index
 i  and end index  j index.
  T(i,j )=
  max {
 1   ,  if   i == j;
  2+T(i+1,j-1)  if x[i] == x[j];
  max(T(i+1,j) T(i,j-1))

  }
   This is the recurrence relation
Now algorithm:
  T(i,i-1) = 0 for 1= i = n.

for i=  1   to n
   T(i)(i)  = 1;
 start with the distnace d
for d =  1  to n
 for i = 1 to n -d
{j  = i+d;
 if(x[i] == x[j])
   T[i][j] = 2+ T[i+1][j-1];
else
T[i][j]  = max (T[i+1][j], T[i][j-1])

}

  return T[1][n];

 On Tue, Sep 1, 2009 at 12:01 AM, Dufusrahul.dev.si...@gmail.com wrote:
 
  This is one of the most difficult dynamic programming problem I have
  faced so far.
 
  A good discussion on this problem and different solutions can be found
  at
 
 http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/
 
  _dufus
 
 
  On Aug 31, 6:01 pm, ankur aggarwal ankur.mast@gmail.com wrote:
  @abhijeet
  dryrun on this
 
  abbaabba
 
  On Mon, Aug 31, 2009 at 5:45 PM, Abhijeet Kumar
  abhijeet.k.s...@gmail.comwrote:
 
   u can push the string onto a stack ... so last element will be on top
 ...
   den u can pop out element and compare ...
   if u have 2 or more set of palindromes ..
   u can keep a counter and keep a check on dat...
 
  
 

 


--~--~-~--~~~---~--~~
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: random number...

2009-09-07 Thread ankur aggarwal
I KNow a sol for given a rand_5() function which generates *0* to 5
and we have to find rand_7() for *0* to 7

could not think about it...



On Mon, Sep 7, 2009 at 9:26 PM, ankur aggarwal ankur.mast@gmail.comwrote:

  Given a random number generator that generates numbers in the range 1 to
 5, how can u create a random number generator to generate numbers in the
 range 1 to 7. (remember that the generated random numbers should follow a
 uniform distribution in the corresponding range)


--~--~-~--~~~---~--~~
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] random number...

2009-09-07 Thread ankur aggarwal
  Given a random number generator that generates numbers in the range 1 to
5, how can u create a random number generator to generate numbers in the
range 1 to 7. (remember that the generated random numbers should follow a
uniform distribution in the corresponding range)

--~--~-~--~~~---~--~~
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: Z[n^2]={such that z belongs to X+Y

2009-09-06 Thread ankur aggarwal
@dufus
wat is your complexity ??


On Sat, Sep 5, 2009 at 8:17 PM, Dufus rahul.dev.si...@gmail.com wrote:


 In that case I would sacrifice a little bit on time complexity and
 instead of storing I would recompute the values.

 _dufus


 On Sep 5, 5:10 pm, ankur aggarwal ankur.mast@gmail.com wrote:
  @dufus..
  if there is constant space requirement then ??
  wat will be your soln ??
 
  On Sat, Sep 5, 2009 at 12:35 PM, Dufus rahul.dev.si...@gmail.com
 wrote:
 
   It seems EXTRACT_MIN for Z[n^2] can be done in O(n) time.
  http://lyle.smu.edu/~saad/courses/cse3358/ps5/problemset5sol.pdfhttp://lyle.smu.edu/%7Esaad/courses/cse3358/ps5/problemset5sol.pdf
 http://lyle.smu.edu/%7Esaad/courses/cse3358/ps5/problemset5sol.pdf
 
   Then using it we can find the kth smallest element in O(nk) time.
 
   _dufus
 
   On Sep 4, 10:03 pm, ankur aggarwal ankur.mast@gmail.com wrote:
 Find nth smallest inO(n) Given two arrays of length n in sorted
 order
X[n]  Y[n].
Now make another array Z[n^2]={such that z belongs to X+Y}.
AS all possible sum of x+y is there in Z. You have to give the nth
   smallest
no of Z in O(n) time.
Space complexity : No bound on it. But try to optimize it if
 possible.

 


--~--~-~--~~~---~--~~
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] find triangle in a graph

2009-09-06 Thread ankur aggarwal
 google question : find triangle in a graph Given an undirected graph,
design a O(V+E) algo to detect whether there is a triangle in the graph ot
not.

--~--~-~--~~~---~--~~
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] n balls having k colors

2009-09-06 Thread ankur aggarwal
You have N balls having one of K colors. Arrange them into groups of same
colors. e.g.

RRGRG
can be arranged as
RRRGG (Answer)
GGRRR

--~--~-~--~~~---~--~~
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: Largest span of Increasing Pair in an array

2009-09-06 Thread ankur aggarwal
o(n) is the best sol known to me..


On Sun, Sep 6, 2009 at 1:54 PM, Pramod Negi negi.1...@gmail.com wrote:

 i guess sorting will do the work.
 any other constraint??


 On Sun, Sep 6, 2009 at 9:52 AM, p0r$h 1987.shis...@gmail.com wrote:


 Given an array of integers A[N], find the maximum value of (j-k) such
 that A[k] = A[j]  jk.
 I am looking for a solution with time complexity better than O(N^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+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: 1 Trillion integers on hard disk, find the smallest 1 million of them

2009-09-05 Thread ankur aggarwal
@vishwanathan

i think this is same as external sort..
this is the same i was thinking..
external sort in *mark allen wiese*

On Fri, Sep 4, 2009 at 8:59 PM, viswanath ramakrishnan 
srviswanat...@gmail.com wrote:



 Q.3: Given a set of 1 Trillion integers on hard disk, find the
 smallest 1
 million of them. You can fit at most 1 million integers in memory at a
 time.
 State the fastest solution you can think of.

 take the first 1 million out of 1 trillion and sort the 1 million
 integersand store it back in the hard disk.
 In this way carry on the sorting for every group of 1 million integers
 and store it in the hard drive . Now groups of 1 million integers are
 sorted upto 1 trillion.
 now compare the first element of all the sorted groups the minimum of
 them is the minimum of the 1 trillion. store it as the first element
 in the memory.
 next take the second element from the group from which the smallest
 elemnt came and then check it with all other groups first element.
 In this way repeat the procedureuntil the first 1 million is sorted
 and stored in the memory.

 correct me if i am 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
-~--~~~~--~~--~--~---



[algogeeks] Re: Z[n^2]={such that z belongs to X+Y

2009-09-05 Thread ankur aggarwal
*find the posiible sums using brute force.then apply this algo

this is the main problem ..
how to do efficiently ??
*

--~--~-~--~~~---~--~~
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: Z[n^2]={such that z belongs to X+Y

2009-09-05 Thread ankur aggarwal
@dufus..
if there is constant space requirement then ??
wat will be your soln ??

On Sat, Sep 5, 2009 at 12:35 PM, Dufus rahul.dev.si...@gmail.com wrote:


 It seems EXTRACT_MIN for Z[n^2] can be done in O(n) time.
 http://lyle.smu.edu/~saad/courses/cse3358/ps5/problemset5sol.pdfhttp://lyle.smu.edu/%7Esaad/courses/cse3358/ps5/problemset5sol.pdf

 Then using it we can find the kth smallest element in O(nk) time.

 _dufus


 On Sep 4, 10:03 pm, ankur aggarwal ankur.mast@gmail.com wrote:
   Find nth smallest inO(n) Given two arrays of length n in sorted order
  X[n]  Y[n].
  Now make another array Z[n^2]={such that z belongs to X+Y}.
  AS all possible sum of x+y is there in Z. You have to give the nth
 smallest
  no of Z in O(n) time.
  Space complexity : No bound on it. But try to optimize it if possible.

 


--~--~-~--~~~---~--~~
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: 1 Trillion integers on hard disk, find the smallest 1 million of them

2009-09-05 Thread ankur aggarwal
@all

i got a sol this from my friend ..

Sort chunks of 1Million numbers. There will be 10^6 (1-million) set of 1
million numbers in 1 trillion numbers.

Now initialize a min-heap of size 1 million with first element of each set.

Keep removing the minimum element (1 million times) and replacing it by the
next element of the corresponding array.

--~--~-~--~~~---~--~~
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: 1 Trillion integers on hard disk, find the smallest 1 million of them

2009-09-05 Thread ankur aggarwal
@nayan
u can stop reading ..
but i still does not get the sol ...


On Sat, Sep 5, 2009 at 7:35 PM, Nayn nayanish.hi...@gmail.com wrote:


 Guys, this is going in totally different direction.
 Solution given by Shishir (using Max-Heap) works perfectly. If anybody
 has any better solution please put it here, or lets close the topic.
 -Nayn

 On Sep 5, 5:11 pm, sharad kumar aryansmit3...@gmail.com wrote:
  divide the horses into 5 groups a,b,c,d,e number them as a1,a2,..,a5,
  b1..b5, c1..c5, d1..d5 and e1..e5. Conduct 5 races within the groups.
 Youve
  15 winners (3 frm each race). a1,a2,a3,b1,b2,b3...,e1,e2,e3. Now conduct
 a
  sixth race among a1,b1,c1,d1,e1. Youve 3 winners say they are a1,b1,c1.
 Now
  you can eliminate all the d's and e's. since d1 and e1 isnt even in the
 top
  3. You also eliminate b3,c2,c3 as they cannot be in the top 3 as there
 are
  already altleast 3 horses faster than them. After this elimination, you
 are
  left with a1,a2,a3,b1,b2,c1.
  a1 is the fastest of them all. So conduct a 7th race among a2,a3,b1,b2,c1
 to
  determine the next 2.
 
 
 
  On Sat, Sep 5, 2009 at 5:18 PM, manoj janoti m.jan...@gmail.com wrote:
   If someone gives the answer of this puzzle can easily solve this
 puzzle.
 
   There are 25 horses.
   We have to find out 3 most fastest horses among them.
   But there are only 5 tracks in the field i.e only 5 horses can run at a
   time.
 
   manoj
 
   On Sat, Sep 5, 2009 at 4:40 PM, Ajith G ajith...@gmail.com wrote:
 
   i think this doesnt work.
   consider first million numbers all of them to be 1.
   next million number(all of them ) to be 2.
   and so on
 
   if you take first element from each million then you will end up with
   1,2
   but the smallest million numbers are all 1.
 
   On Fri, Sep 4, 2009 at 8:29 AM, viswanath ramakrishnan 
   srviswanat...@gmail.com wrote:
 
   Q.3: Given a set of 1 Trillion integers on hard disk, find the
   smallest 1
   million of them. You can fit at most 1 million integers in memory at
 a
   time.
   State the fastest solution you can think of.
 
   take the first 1 million out of 1 trillion and sort the 1 million
   integersand store it back in the hard disk.
   In this way carry on the sorting for every group of 1 million
 integers
   and store it in the hard drive . Now groups of 1 million integers are
   sorted upto 1 trillion.
   now compare the first element of all the sorted groups the minimum of
   them is the minimum of the 1 trillion. store it as the first element
   in the memory.
   next take the second element from the group from which the smallest
   elemnt came and then check it with all other groups first element.
   In this way repeat the procedureuntil the first 1 million is sorted
   and stored in the memory.
 
   correct me if i am 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
-~--~~~~--~~--~--~---



[algogeeks] Z[n^2]={such that z belongs to X+Y

2009-09-04 Thread ankur aggarwal
 Find nth smallest inO(n) Given two arrays of length n in sorted order
X[n]  Y[n].
Now make another array Z[n^2]={such that z belongs to X+Y}.
AS all possible sum of x+y is there in Z. You have to give the nth smallest
no of Z in O(n) time.
Space complexity : No bound on it. But try to optimize it if possible.

--~--~-~--~~~---~--~~
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] divide two extremely large numbers

2009-09-04 Thread ankur aggarwal
 Write an algorithm two divide two extremely large numbers, which cannot be
stored in an int, long int, float, double etc. Find the remainder and
quotient .

--~--~-~--~~~---~--~~
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: adobe interview question

2009-09-02 Thread ankur aggarwal
1 or 2
depends if diagonal sqaure are considered to be same as adjacent


On Wed, Sep 2, 2009 at 8:28 PM, Nagendra Kumar nagendra@gmail.comwrote:


 Can anyone recheck and rephrase the question becuase i think it would
 be always '0'


 On Wed, Sep 2, 2009 at 10:40 AM, Naynnayanish.hi...@gmail.com wrote:
 
  Guys, We are anticipating an algorithm here.
 
  The input would be an array containing 0/1 representing black and
  white boxes.
 
  On Sep 1, 8:37 pm, yash yashpal.j...@gmail.com wrote:
  Given a chessboard in which u dont know how the black and white boxes
  are arranged but this is sure that there will 32 black squares and 32
  white squares.You have to find the least possible disatnce between any
  two sqaures of same colour ...
 
  
 

 


--~--~-~--~~~---~--~~
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: Find longest palindrom in a give n string in O(N)

2009-09-01 Thread ankur aggarwal
@nitin
wat is the complexity ??

can it be done linear ??



On Mon, Aug 31, 2009 at 6:07 PM, nitin mathur
nitinkumar.mat...@gmail.comwrote:

 We can use the concept of longest common substring. For that use following
 steps:
 1) take the original string say A.
 2) make a copy of it say B.
 3) find the longest common substring of them.

 Nitin Mathur

 


--~--~-~--~~~---~--~~
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] 1 Trillion integers on hard disk, find the smallest 1 million of them

2009-09-01 Thread ankur aggarwal
* Q.3: Given a set of 1 Trillion integers on hard disk, find the smallest 1
million of them. You can fit at most 1 million integers in memory at a time.
State the fastest solution you can think of.

--~--~-~--~~~---~--~~
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: Median Finding algorithms.

2009-09-01 Thread ankur aggarwal
On Tue, Sep 1, 2009 at 6:04 PM, ankur aggarwal ankur.mast@gmail.comwrote:

 @shishir

 i could *not  *understand
 cann u give an example..



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



  1   2   >