Re: [algogeeks] Tower of hanoi

2012-10-20 Thread yogesh chidambarnathan
http://www.cs.cmu.edu/~cburch/survey/recurse/hanoi.html On Fri, Oct 19, 2012 at 3:37 PM, rahul sharma wrote: > can anybody provide me with a link to understand the recursive > implementation of tower of hanoi..thnx in advance > > -- > You received this message because you are subscribed to the Go

Re: [algogeeks] Re: Maximum size square sub-matrix with all 1s

2012-01-10 Thread Yogesh Yadav
g[][]- given matrix r[][]- result matrix copy first row n column from g[][] to r[][] rest for i=1 to n-1 for =1 to n-1j if(g[][]) r[][]=min(r[i][j-1],r[i-1][j],r[i-1][j-1])+1; else r[][]=0; On Wed, Jan 11, 2012 at 10:00 AM, Gene wrote: > The 1's and 0's are in matrix R. We w

Re: [algogeeks] urgent soln needed

2011-09-30 Thread Yogesh Yadav
Already discussed https://groups.google.com/group/algogeeks/browse_thread/thread/8a3e1a6665702f54/66bb2e804b43ae1d?hl=en&lnk=gst&q=MS+question+ankur#66bb2e804b43ae1d . On Fri, Sep 30, 2011 at 2:59 PM, sumit kumar pathak wrote: > *find all the zeros in first iteration and store (size = array

Re: [algogeeks] yahoo qn

2011-09-28 Thread Yogesh Yadav
Count number of space... Add 1 in it... that will be the no of words (say x)... now take two variables m & n m=x/2 n =2 //if m is odd =3 //if m is even now store the values in array a[] as a[0]=m a[1]=(m+n)mod(x) a[2]=(m+n)mod(x) . . a

Re: [algogeeks] Frequency of number

2011-09-27 Thread Yogesh Yadav
Take an array a[1000]input first 1000 values from the stream in it.. Here we are representing a unit time with help of space because 1000 elements in a stream will always come in constant time So just count the occurrence of a given number in that array... then divide the count with 1000 t

Re: [algogeeks] Re: MS question

2011-09-26 Thread Yogesh Yadav
Suppose matrix is 1 0 0 1 1 0 1 0 0 0 0 0 then we traverse the matrix for each 1 we found at a[i][j] , we will check for i=i to i wrote: > If you're given that it's a sparse matrix, then you must assume > storage is in a sparse matrix data structure to get time less than > O(mn). > > In fact, if

Re: [algogeeks] Re: Amazon OS question

2011-09-25 Thread Yogesh Yadav
T1->T2->T3->T6 T1->T2->T4->T7 T1->T2->T5->T8 2 Processor: (T1->T2) ..2 TS (T3&T4)...1 TS (T6&T5)...1 TS (T7&T8)...1 TS 4 Processor (T1->T2) ..2 TS (T3&T4&T5)...1 TS (T6&T7&T8)...1 TS . On Sun, Sep 25, 2011 at 2:33 PM, siva viknesh wrote: > plz give detailed expl

Re: [algogeeks] Re : Non Decreasing Numbers

2011-09-25 Thread Yogesh Yadav
+1 Gohana On Sun, Sep 25, 2011 at 12:28 PM, Sanjay Rajpal wrote: > let the number of digits be n > then answer would be ((n+9)! ) / (9! * n!) > > > Sanju > :) > > > > On Sat, Sep 24, 2011 at 11:51 PM, Yogesh Yadav wrote: > >> mistake in last post...it

Re: [algogeeks] Re : Non Decreasing Numbers

2011-09-24 Thread Yogesh Yadav
mistake in last post...it was not factorialsum upto n i.e =n(n+1)/2 i.e 10! is wrong ...it will be 10(10+1)/2 On Sun, Sep 25, 2011 at 12:14 PM, Yogesh Yadav wrote: >n=1 n=2 n=3 n=4 > 01010!(10!)! > 1

Re: [algogeeks] Re : Non Decreasing Numbers

2011-09-24 Thread Yogesh Yadav
n=1 n=2 n=3 n=4 01010!(10!)! 1 9 9! (9!)! 2 8 8! 3 7 7! 4 6 6! 5 5 5! 6 4

Re: [algogeeks] Amazon Interview Question

2011-09-23 Thread Yogesh Yadav
we cant traverse the string twice... if there is an error in my logic then plz tell my logic is: we have to take starting and ending indexes for '0','1','2' like below 0 1 2 starting_index ending_index now suppose our string "102112011" so w

Re: [algogeeks] plz reply quickly

2011-09-23 Thread Yogesh Yadav
I am not sure about these...but i guess this will do the job In Linked List: (rear->next==front) In Array: after reaching the maximum size or the end of queue ...just add one more element in queue... and after addition just check (queue[front]==new_element_added) ... if yes then circular queue

Re: [algogeeks]

2011-09-22 Thread Yogesh Yadav
Ans. 512 ... On Thu, Sep 22, 2011 at 5:38 PM, Rohit Upadhyaya wrote: > int main() > { > int a=256; > char *p=&a; > *++p=2; > printf("%d",a); > return(0); > } > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, sen

Re: [algogeeks] Re: question

2011-09-22 Thread Yogesh Yadav
759435 now am i right?? On Thu, Sep 22, 2011 at 4:55 PM, Ratan wrote: > the answer should be 759435... > > On Thu, Sep 22, 2011 at 4:45 PM, Yogesh Yadav wrote: > > my logic: if wrong then plz tell... > > > > start from rightmost digit and search towards le

Re: [algogeeks] Re: tree to list

2011-09-22 Thread Yogesh Yadav
inorder traversal will do the job... just make sure to create links... On Thu, Sep 22, 2011 at 1:48 AM, Gene wrote: > #include > > typedef struct node_s { > int data; > struct node_s *left, *right; > } NODE; > > // Convert BST to a sorted list connected by ->right pointers. > NODE *to_li

Re: [algogeeks] Re: question

2011-09-22 Thread Yogesh Yadav
digit =4 search for smaller digit than 4 towards left... it will be 3... then answer 759453 On Thu, Sep 22, 2011 at 4:40 PM, Yogesh Yadav wrote: > @algo geek: > > there is some error in your logic... > > consider a number 759845 > > according to ur logic the number grea

Re: [algogeeks] Re: question

2011-09-22 Thread Yogesh Yadav
@algo geek: there is some error in your logic... consider a number 759845 according to ur logic the number greater than this will be 784559 but it should be 759854 . On Thu, Sep 22, 2011 at 4:24 PM, algo geek wrote: > Keep a pointer ont the rightmost digit. Keep moving right until y

Re: [algogeeks] Amazon question SDE

2011-09-20 Thread Yogesh Yadav
@saurabh: i think may be u left some part of question to mention... the array may be a heap array ... or if the ques is correct then i don't think this sum can be possible in O(log n) for previously existing array... may be we have to make array from start...then as you mention we can use anot

Re: [algogeeks] Re: Question -->

2011-09-20 Thread Yogesh Yadav
@ishan: there is error in your loop bro... for(k=31;k>=0;k++) it should be k-- . On Tue, Sep 20, 2011 at 3:10 PM, vijay singh wrote: > > > On Tue, Sep 20, 2011 at 2:16 PM, Ishan Aggarwal < > ishan.aggarwal.1...@gmail.com> wrote: > >> Hi, >> >> When I am running this program, I am getting seg

Re: [algogeeks] Question -->

2011-09-20 Thread Yogesh Yadav
+1 abhinav but u forgot to change array again into bits... ... On Tue, Sep 20, 2011 at 1:02 PM, Ishan Aggarwal < ishan.aggarwal.1...@gmail.com> wrote: > What are u doing in the first loop running for k=31 to k =0? > > > On Tue, Sep 20, 2011 at 12:50 PM, abhinav gupta > wrote: > >> U can use sin

Re: [algogeeks] is it possible??

2011-09-19 Thread Yogesh Yadav
u dont want to call "main()" or u do not want to call it by name "main" because if u do not want to call it by name "main" then we can do it by macros ... and if u dont want to call "main()"... then i dont think this is possible.. plz correct me if i m wrong ... On Mon, Sep 19, 2011 at 1

Re: [algogeeks] All valid dictionary words must be found and printed.

2011-09-19 Thread Yogesh Yadav
PM, Yogesh Yadav wrote: > i=0; > char *str; > while(a[i]!=NULL) > { >j=0; > >while(j!=i) >{ > for(k=j;k<=i;k++) > { > l=0; > str[l]=a[j]; > } > if(Dictionary.findword(str)) > printf(str); &

Re: [algogeeks] All valid dictionary words must be found and printed.

2011-09-19 Thread Yogesh Yadav
i=0; char *str; while(a[i]!=NULL) { j=0; while(j!=i) { for(k=j;k<=i;k++) { l=0; str[l]=a[j]; } if(Dictionary.findword(str)) printf(str); j++; } } ... On Mon, Sep 19, 2011 at 8:20 PM, Sangeeta wrote: > given an array of character

Re: [algogeeks]

2011-09-18 Thread Yogesh Yadav
current position is index n (say) largest=0; second_largest=0; for(i=1;i<=n;i++) { if(a[i]>a[n]) { if(a[i]>largest) { second_largest=largest; largest=a[i]; } elseif(a[i]>second_largest) second_largest=a[i]; } } On Mon, Sep 19, 2011 at 2:15 AM, sagar pareek wrote: > Give some examples ,i

Re: [algogeeks] Re: K-LCS

2011-09-18 Thread Yogesh Yadav
gest count... ... On Sun, Sep 18, 2011 at 5:24 PM, pooja wrote: > > sorry.. i meant the longest common substring.. > eg. consider 4 string.. ababa , bab , babba, abab > so the longest common substring is bab. > > On Sep 18, 4:40 pm, Yogesh Yadav wrote: > > stru

Re: [algogeeks] K-LCS

2011-09-18 Thread Yogesh Yadav
struct string_node { char str[]; int length; struct string_node *ptr; } now traverse the strings and saving strings in "str[]",their length in "length" and point it to next string_node On Sun, Sep 18, 2011 at 4:47 PM, pooja wrote: > Can some one please help me with this.. > the pr

Re: [algogeeks] Re: Directi Questions - needed answers

2011-09-17 Thread Yogesh Yadav
Q3. 101 matches .. On Sun, Sep 18, 2011 at 8:02 AM, VIHARRI wrote: > hey i'm also thinking n + logn -2.. but couldnt able to figure out > how??? can you please explain the logic > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To po

Re: [algogeeks] Directi Questions - needed answers

2011-09-17 Thread Yogesh Yadav
12 west ...12 south On Sat, Sep 17, 2011 at 5:24 PM, Dheeraj Sharma wrote: > 12 west and 10 south.. i thnk..is the correct one.. > > > On Sat, Sep 17, 2011 at 5:22 PM, Yogesh Yadav wrote: > >> yeah it will be 62.5% >> >> >> >> >&

Re: [algogeeks] Directi Questions - needed answers

2011-09-17 Thread Yogesh Yadav
> see here the basic operation is comparision so we can express comaprision >> in terms of order of O(n). newazz we still require n-1 comparisions to find >> second max . >> >> On Sat, Sep 17, 2011 at 5:06 PM, Yogesh Yadav wrote: >> >>> @aditya: >>>

Re: [algogeeks] Directi Questions - needed answers

2011-09-17 Thread Yogesh Yadav
gt;> see here the basic operation is comparision so we can express comaprision >> in terms of order of O(n). newazz we still require n-1 comparisions to find >> second max . >> >> On Sat, Sep 17, 2011 at 5:06 PM, Yogesh Yadav wrote: >> >>> @aditya: >>

Re: [algogeeks] Directi Questions - needed answers

2011-09-17 Thread Yogesh Yadav
@aditya: comparing isn't complexity here... here it means no. of comparisons between 2 numbers... On Sat, Sep 17, 2011 at 5:04 PM, aditya kumar wrote: > @yogesh: we can get second max by comparing n elements ie O(n). > > > On Sat, Sep 17, 2011 at 4:59 PM, Ashima . wrote:

Re: [algogeeks] Directi Questions - needed answers

2011-09-17 Thread Yogesh Yadav
.(Tech)Information Systems > 4th year > BITS Pilani > Rajasthan > > > > > On Sat, Sep 17, 2011 at 4:20 AM, Yogesh Yadav wrote: > >> Ans 1. apply bubble sort. outer loop should run just two times because in >> 2nd time the 2nd largest element will be at 2nd last

Re: [algogeeks] Directi Questions - needed answers

2011-09-17 Thread Yogesh Yadav
Ans 1. apply bubble sort. outer loop should run just two times because in 2nd time the 2nd largest element will be at 2nd last position... comparisons=(n-1)+(n-2) On Sat, Sep 17, 2011 at 4:27 PM, Ashima . wrote: > ans 2: > http://www.qbyte.org/puzzles/p131s.html > > Ashima > M.Sc.(Tech)Informati

Re: [algogeeks] C Problem

2011-09-17 Thread Yogesh Yadav
4,5 statements inside sizeof() does not get executed...it will tell just size... int a=3; printf("%d",sizeof(a++)); here a++ will not be executed ...it will just tell size ... Also, lets suppose it execute statements ...then sizeof(int),sizeof(node *) ...will always produce error because int a

Re: [algogeeks] Plz explain the output..........

2011-09-17 Thread Yogesh Yadav
@Ashima.. u r right...it is always printing first float variable value On Sat, Sep 17, 2011 at 2:05 PM, Ashima . wrote: > @yogesh : but if in place of x=1 in above code, I write t=54. that means i > m assigning somevalue to a float variable.Then it should print 54 > afterwards.

Re: [algogeeks] Plz explain the output..........

2011-09-16 Thread Yogesh Yadav
x==9 is not an error... it will be 1 when true and 0 when false...and both are executable statements... when we print float with %d then compiler prints 0...and when we print integer with %f then compiler prints last assigned or printed float value to any float variablehere it is assigned for

Re: [algogeeks] Find the output

2011-09-16 Thread Yogesh Yadav
a[]= {1, 2, 3, 4,5} a &a a+1 &a+1 &a is address of whole array...so &a+1 means next element after array completion. so ptr-1 will point to 5 ... On Fri, Sep 16, 2011 at 1:25 PM, Anup Gha

Re: [algogeeks] Find the element in Array

2011-09-15 Thread Yogesh Yadav
*//this method can be applied only when the value of elements in array are not very large int count[]; for(i = 0 to n-1) { if(count[arr[i]] == 1) printf(" %d ", arr[i]); else count[arr[i]]++; }* .. On Wed, Aug 31, 2011 at 12:38 PM, Yuchen Liao wrote: > Hi Akshat, > >

Re: [algogeeks] Re: Microsoft Question

2011-09-15 Thread Yogesh Yadav
For Stack: just make a structure: struct stack_with_priorityqueue { int num; int priority; struct stack_with_priorityqueue *ptr; } now when we add another number just increase the priority... priority++ For Queue: do same...just decrease priority...priority-- ...

Re: [algogeeks] pgm3

2011-09-13 Thread Yogesh Yadav
//don't know this is completely correct or not 1.find sum of elements of both arrays a[] and b[]...from 0 to n-1 2.check whichever is smaller sum_a or sum_b...say sum_a is smaller 3.generate a random number i=random(sum_a)... generates random number between o to (sum_a)-1 //random genera

Re: [algogeeks]

2011-09-07 Thread Yogesh Yadav
prime no has only 2 factors. number itself and 1. On Wed, Sep 7, 2011 at 12:14 PM, aayush jain wrote: > can anybody tell me the code of find the prime no. and after finding prime > no. find its prime factore using linkes list?? > > -- > You received this message because you are subscribed

Re: [algogeeks] MS question

2011-09-05 Thread Yogesh Yadav
, jul, aug, oct, dec)) > return 31; > else if(m belongsTo(apr, jun, sep, nov)) > return 30; > > else if(m belongsTo(feb)){ >if(isLeapYear(y)) >return 29; >else return 28; > > } > > > } > On Mon, Se

Re: [algogeeks] MS question

2011-09-05 Thread Yogesh Yadav
ote: > @yogesh : Looking for more efficient solution > > -- > 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,

Re: [algogeeks] MS question

2011-09-05 Thread Yogesh Yadav
//Num is our given number obtained from date Int num1,num2; Int count1=0,count2=0; void nearestpalindrome() { Num1=num; For(;;) { If(Checkpalindrome(num1))

Re: [algogeeks] c problem

2011-09-03 Thread Yogesh Yadav
@Priya: Because a is *unmodifiable* LValue. When we are using a=a+1(a++) , this means that we are changing the *base address* of array a[], and that can not be possible due to Library files. On Sun, Sep 4, 2011 at 11:49 AM, priya ramesh < love.for.programm...@gmail.com> wrote: >

Re: [algogeeks] c problem

2011-09-03 Thread Yogesh Yadav
@Priya: Lvalue is not a contant value. It can be modifiable or unmodifiable. Lvalue stands for location value that means that we can store some value here in this location and rvalue stands for read value that means that it can be stored at some location that is in memory having lvalue. Here in c

Re: [algogeeks] Re: C dot

2011-08-23 Thread Yogesh Bhati
can any1 tell me wat type of question are asked in TCS nd INFOSYS interview. -- 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 algog

Re: [algogeeks] Re: ????programming question

2011-08-21 Thread Yogesh Bhati
> > 3.web crawler. > -- 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, vis

Re: [algogeeks] Re: ????programming question

2011-08-21 Thread Yogesh Bhati
h can ny suggest me some link for 1. compiler contruction 2. Web OS construction nd suggest some good final year projects.. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegrou

Re: [algogeeks] c programe explain

2011-08-21 Thread Yogesh Bhati
error in c++ becoz this type of function signature is not allowed in c++ " main() " where as in see if return type is not given then by default it takes it as integer so it is not an error in c. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group.

Re: [algogeeks] Re: ????programming question

2011-08-21 Thread Yogesh Bhati
Thanx... read it sumwhere nd was trying it .bt couldnt find it for n>3 will try again. -- 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

Re: [algogeeks] help on this

2011-08-21 Thread Yogesh Bhati
we have to do final year project in colg itself. intership project is another thing. I hv done that. so ,any links frm where i can get detail for compiler contruction or web crawler plz suggest -- You received this message because you are subscribed to the Google Groups "Algorithm Geek

[algogeeks] ????programming question

2011-08-21 Thread Yogesh Bhati
how to find determinant of a matrix of order n x n. -- 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...@googlegr

[algogeeks] help on this

2011-08-21 Thread Yogesh Bhati
h can ny suggest me some link for 1. compiler contruction 2. Web OS construction nd suggest some good final year projects... -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegro

Re: [algogeeks] SAP!!

2011-08-21 Thread Yogesh Bhati
do post ur experiences nd questions asked in SAP interview. -- 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...@

Re: [algogeeks] Syllogism

2011-08-20 Thread Yogesh Bhati
conclusion : Is at least some girls are beautiful dnt knw abt rest bt some are -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] thanx...

2011-08-20 Thread Yogesh Bhati
congrats dude! -- 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

Re: [algogeeks] help!!!!!

2011-08-20 Thread Yogesh Bhati
thanx dude -- 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 gr

Re: [algogeeks] help!!!!!

2011-08-20 Thread Yogesh Bhati
4.ERP also webos wat is it?? brief is it related to *webOS* is a proprietary mobile operating system running on the Linux kernel . -- You received

Re: [algogeeks] help!!!!!

2011-08-20 Thread Yogesh Bhati
> > area of interest : > > 1.web related koi application 2.database 3.core programming -- 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

[algogeeks] help!!!!!

2011-08-20 Thread Yogesh Bhati
I m a CSE student Plz suggest me sum final yr project 1. good project that help me learn or 2.that solve sum real lyf situation means projects that are needed to make thngs easy for others do post ur suggestion -- You received this message because you are subscribed to the Google Groups "Algorit

Re: [algogeeks] Re: Algorithms For Interviews

2011-08-16 Thread Yogesh Yadav
plz upload it againi cant open it... On Tue, Aug 16, 2011 at 8:31 PM, Nitin Nizhawan wrote: > sent to you ravi > > On Tue, Aug 16, 2011 at 8:16 PM, ravi kumar wrote: > >> >> heyy nitin.. it says da file izz locked .. can u mail me da buk.. thanx in >> advance >> >> -- >> You received this me

Re: [algogeeks] Re: amazon

2011-07-19 Thread Yogesh Yadav
be pointing to 3/4th, > same way for m/n th node. But this works best for even number of nodes in > list. > > For odd numbers we need to compromise like finding the middle node :) > > Cheers, > Mani > > On Tue, Jul 19, 2011 at 4:20 PM, Yogesh Yadav wrote: > >>

Re: [algogeeks] Re: amazon

2011-07-19 Thread Yogesh Yadav
Part 1: Take 2 pointers moving at different speed... 1st with head->next 2nd with head->next->next when 2nd will reach the end 1st will be pointing middle... so one result is obtained Part 2: when 1st result is obtained then start with the node pointed by 1st as it will be on 1/2th part of the l

Re: [algogeeks] Re: Missing Number in an array

2011-07-18 Thread Yogesh Yadav
a[]={1,2,3,4,5} //real a[] a[]={1,2,3,4,3} //unreal a[]...as 2 numbers not present once...3 is 2 times and 5 is 0 times step 1: sum=n*(n+1)/2 sum real a[]=5*6/2=15 sum unreal a[]=1+2+3+4+3=13 this means if a is 1 number nd b is 2nd

Re: [algogeeks] MS

2011-07-11 Thread Yogesh Yadav
largest size of square would be = H.C.F of width and height . now with size known we have to just arrange squares this can be done such that we can make a big square by adding them... for ex 1st square can be made by just (1 square) 2nd square can be made by adding 3 sqaures around it l

Re: [algogeeks] MS

2011-07-11 Thread Yogesh Yadav
largest size of square would be = H.C.F of width and height . now with size known we have to just arrange squares this can be done such that we can make a big square by adding them... for ex 1st square can be made by just (1 square) 2nd square can be made by adding 3 sqaures around it l

Re: [algogeeks] Re: GOOGLE Q1

2011-07-11 Thread Yogesh Yadav
with matrix this problem will be in O(n^2). We don' have to just check the max number present in matrix. We have to check as array a[]= 1,2,3,4,5,6,8,10,12,14 diff[][]= 1 2 3 4 5 6 8 10 12 14 2 0 1 2 3 4 6 8 10 12 3 -1 0 1 2 3 5 79 11

Re: [algogeeks] GOOGLE Q1

2011-07-10 Thread Yogesh Yadav
Step 1: first make a diff[][] Step 2: search the diff in matrix Complexity will be O(n^2) On Sun, Jul 10, 2011 at 6:24 AM, JAIDEV YADAV wrote: > try Matrix search... > > > On Sun, Jul 10, 2011 at 7:34 PM, Yogesh Yadav wrote: > >> yeah then it will be possible in O(n^2)

Re: [algogeeks] GOOGLE Q1

2011-07-10 Thread Yogesh Yadav
yeah then it will be possible in O(n^2) On Sun, Jul 10, 2011 at 5:57 AM, Yogesh Yadav wrote: > @sunny : thanks ..i got it... > > > On Sun, Jul 10, 2011 at 5:55 AM, sunny agrawal wrote: > >> Longest AP for that Example is of 7 elements >> 2,4,6,8,10,12

Re: [algogeeks] GOOGLE Q1

2011-07-10 Thread Yogesh Yadav
't work > > > On Sun, Jul 10, 2011 at 7:18 PM, Yogesh Yadav wrote: > >> @sunny: my algo will give 6 as answer and i guess its right... if am >> wrong plz explain where and why my logic is wrong >> >> On Sun, Jul 10, 2011 at 5:37 AM, sunny agrawal

Re: [algogeeks] GOOGLE Q1

2011-07-10 Thread Yogesh Yadav
@sunny: my algo will give 6 as answer and i guess its right... if am wrong plz explain where and why my logic is wrong On Sun, Jul 10, 2011 at 5:37 AM, sunny agrawal wrote: > @Yogesh > your solution will give maximum Contiguous AP only > it will fail for th

Re: [algogeeks] GOOGLE Q1

2011-07-10 Thread Yogesh Yadav
@sunny: my algo will give 5 as answer and i guess its right... if am wrong plz explain where and why my logic is wrong On Sun, Jul 10, 2011 at 5:37 AM, sunny agrawal wrote: > @Yogesh > your solution will give maximum Contiguous AP only > it will fail for th

Re: [algogeeks] GOOGLE Q1

2011-07-10 Thread Yogesh Yadav
@sunny: my algo will give 5 as answer and i guess its right... if am wrong plz explain where and why my logic is wrong On Sun, Jul 10, 2011 at 5:37 AM, sunny agrawal wrote: > @Yogesh > your solution will give maximum Contiguous AP only > it will fail for th

Re: [algogeeks] GOOGLE Q1

2011-07-10 Thread Yogesh Yadav
i thinks mine is just O(n) On Sun, Jul 10, 2011 at 5:31 AM, Yogesh Yadav wrote: > @raj : > > array a[]= 2,3,5,6,7,8,10,12 > diff[]= 1,2,1,1,1,2,2 > > maxcount=tempcount=1 // because am not takin in consideration of 0th > index value of diff[] > > now in for lo

Re: [algogeeks] GOOGLE Q1

2011-07-10 Thread Yogesh Yadav
:23 AM, raj singh wrote: > @yogesh- can u explain with an example pls? > > -- > 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 unsub

Re: [algogeeks] macro

2011-07-10 Thread Yogesh Yadav
Thats wonderful parag :) On Sun, Jul 10, 2011 at 4:56 AM, Yogesh Yadav wrote: > Thats wonderful para :) > > > On Sat, Jul 9, 2011 at 10:50 AM, John Hayes wrote: > >> refer K&Rit's clearly mentioned in it >> >> >> On Sun, Jul 10, 2011 at 12:1

Re: [algogeeks] macro

2011-07-10 Thread Yogesh Yadav
Thats wonderful para :) On Sat, Jul 9, 2011 at 10:50 AM, John Hayes wrote: > refer K&Rit's clearly mentioned in it > > > On Sun, Jul 10, 2011 at 12:12 AM, parag khanna > wrote: > >> >> no text substitution occurs if the identifier is within the quotes >> >> -- >> You received this message b

Re: [algogeeks] GOOGLE Q1

2011-07-10 Thread Yogesh Yadav
array a[] stores numbers for(i=1;imaxcount) maxcount=tempcount; tempcount=1; } } On Sat, Jul 9, 2011 at 11:22 PM, Navneet Gupta wrote: > Sorry typo below > > On Sun, Jul 10, 2011 at 12:49 PM, Navneet Gupta wrote: > >> Try this >> >> 1. Find the min and max in O(n) time.

Re: [algogeeks] Re: Interview question

2011-07-09 Thread Yogesh Yadav
@gopi: i didnt really understand what u want to say... what start,end and destination denotes here?? u said it should start with 1 but in result it is starting with 9...plz explain ur question again On Sat, Jul 9, 2011 at 7:21 PM, Gopi wrote: > Hi Geeks > > Can anyone please comment on this

Re: [algogeeks] BIT MANIPULATION

2011-07-09 Thread Yogesh Yadav
int count1=count2=0; given number=n; int m=n; //save in temp variable m while(m!=0) //count number of bits in given number { m=m & (m-1); count1++; } m=n; //save in temp variable m while(count1!=count2) //check no. of bits same or not { m=m+1; //increm

Re: [algogeeks] puzzle

2011-07-09 Thread Yogesh Yadav
91,110,134161 i guess 6,24,60,120210 On Sat, Jul 9, 2011 at 5:46 PM, Aman Goyal wrote: > 210 for the last one you posted > > > On Sat, Jul 9, 2011 at 4:33 PM, amit the cool wrote: > >> 6,24,60,120,_ >> >> -- >> You received this message because you are subscribed to the Google Groups >>

Re: [algogeeks] GOOGLE Q3

2011-07-08 Thread Yogesh Yadav
gp2[l][1]=m[n]; l++; n--; } On Sat, Jul 9, 2011 at 2:27 AM, Yogesh Yadav wrote: > let 10 digit phone number stored in array a[] > > take a array b[10] and initialise its elements with 0 > > int gp2[][2]; // group with 2 elements will store here > int gp3[][3]; // gro

Re: [algogeeks] GOOGLE Q3

2011-07-08 Thread Yogesh Yadav
let 10 digit phone number stored in array a[] take a array b[10] and initialise its elements with 0 int gp2[][2]; // group with 2 elements will store here int gp3[][3]; // group with 3 elements will store here int l=0,r=0,count=0; int m[],n; //l,m,n is global for(i=0;i<10;i++)

Re: [algogeeks] Re: find the integer

2011-07-08 Thread Yogesh Yadav
a[]={2,2,3,3,3,4,4,5,6,6,7} size of array = n if not sorted than sort for(i=1;iwrote: > Well your method can solve this problem when the range of the array > elements is given. > Try considering 2*10^9 as one of the element of the array, how big your > temp array be? > > -- > You received this m

Re: [algogeeks] Re: Merging Sorted Arrays

2011-07-08 Thread Yogesh Yadav
size of a=m size of b =n a[]={1,3,77,78,90} and b[]={2,5,79,81} lr while(l<=m && r<=n) { if(b[r]wrote: > @aman: wat u dint get??? > > > On Fri, Jul 8, 2011 at 6:34 PM, Aman Goyal wrote: > >> i dint get you.. >> >> one loop to access the first array

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-07 Thread Yogesh Yadav
Q3. start with 7000 //8 digit number 7000 7001 //as 7 is 1 time so 8th place is 1 6001 //as due to 1 on 8th place no. of zeros =6 6010 //as 6 is present so 7th place is 1 and 7 is not present so 8th place is again changed to 0 6110 //as 1 is present on 7th place so at 2nd p

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-07 Thread Yogesh Yadav
Q10. array a[]={19 16 18 3 50 70 12 11 14} array b[]; sum required=30 3 11 12 14 16 18 19 50 70 //sort 0 1 2 3 4 5 6 7 8 //index lr count=0,i=0; while(lsum r--; elseif(a[l]+a[r]) wrote: > Anyone for Q10, i wonder if it can really be solved in O

[algogeeks] Re: An interesting question

2011-03-09 Thread yogesh kumar
e matrix [j][0] else remain unchanged. Step 8: Now to find the value at matrix [0][0], you need to do matrix [0][0] & Temp and save it into matrix [0][0]. Step 9: Print your matrix and exit. I think, now you will be get all the answers. Thanks Yogesh Kumar On Mar 9, 7:39 pm, bittu wrote: > @

[algogeeks] Re: printing without loop

2011-03-06 Thread yogesh kumar
@ Ruturaj: Your Problem's Solution.. :) public class Sorting { public static void main(String arg[]) { int[] a = {2,4,5,1,7,3}; a = checkNumber(0,1,a); // to Print an Array for(int k=0;ka[j]) {

[algogeeks] Re: An interesting question

2011-03-06 Thread yogesh kumar
@pacific: Good Algorithm // This is the preface solution of this problem [:)] // Time complexity: O(n^2) // Space complexity: O(1) public class BinaryMatrix { public static void main(String arg[]) { int[][] matrix = new int[][] {{1,0,1,1,0},{0,1,1,1,0},{1,1,1,1,1}

[algogeeks] Re: Check divisibility by 3

2009-08-14 Thread Yogesh Aggarwal
u can use the itoa function for that... On Fri, Aug 14, 2009 at 7:31 PM, sharad kumar wrote: > brother how do u get the digits of number ???u use % and / rite?? > > > On Fri, Aug 14, 2009 at 7:28 PM, Yogesh Aggarwal < > yogesh.aggarwa...@gmail.com> wrote: > >> (CORR

[algogeeks] Re: Check divisibility by 3

2009-08-14 Thread Yogesh Aggarwal
= 15 (sum > 10) sum2 = 6 since sum < 10, we stop here and since final sum = 6 so the given no. is divisible by 3 On Fri, Aug 14, 2009 at 7:25 PM, Yogesh Aggarwal < yogesh.aggarwa...@gmail.com> wrote: > (CORRECTED ALGO.) > We can do like dis... > - add all d digits of the

[algogeeks] Re: Check divisibility by 3

2009-08-14 Thread Yogesh Aggarwal
can apply the same logic > recursively to q+r and return the remainder obtained for q+r.. > > > On Fri, Aug 14, 2009 at 7:11 PM, Yogesh Aggarwal < > yogesh.aggarwa...@gmail.com> wrote: > >> @arun : we are not supposed to use / operator. but in ur algo u r using / >&

[algogeeks] Re: Check divisibility by 3

2009-08-14 Thread Yogesh Aggarwal
Gupta >> (IT-BHU,India) >> >> >> > > > -- > Potential is not what U have, its what U think U have!!! > It is better to worn out than rust. > > > > > > -- Best Wishes & Regards Thank You Yogesh Aggarwal B.Tech(IT), University School of

[algogeeks] Re: Question asked in MS interview

2009-08-14 Thread Yogesh Aggarwal
sider >> >> -- >> Richa Gupta >> (IT-BHU,India) >> >> >> > > > -- > Potential is not what U have, its what U think U have!!! > It is better to worn out than rust. > > > > > > -- Best Wishes & Regards Thank You Yoge

[algogeeks] Re:

2009-06-02 Thread Yogesh Aggarwal
t; > * 9+7=???* > > > *The answer is the password to open the file attached* > > * * > > * * > > *Best Regards* > > *Aminooo.com* <http://www.aminooo.com> > > > > > -- Best Wishes & Regards Thank You Yogesh Aggar

[algogeeks] Re: programming contest

2008-11-16 Thread Yogesh Aggarwal
say > > > -- Best Wishes & Regards Thank You Yogesh Aggarwal B.Tech(IT), University School of Information Technology GGS Indraprastha University Delhi mailto: [EMAIL PROTECTED] #9990956582 --~--~-~--~~~---~--~~ You received this message because you are sub

[algogeeks] Re: Pick up elements based on their priorities

2006-11-29 Thread yogesh
re of any well known algo. please inform me if come across. Regds Yogesh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegro

[algogeeks] Re: Pick up elements based on their priorities

2006-11-27 Thread yogesh
Hi, U can do this by decreasing priority after printing the element. U can choose any criterion to pick element at same priority level. I picked the lexiographic order. the resulting sequence is A B A B C D A B C D E --~--~-~--~~~---~--~~ You received this m

  1   2   >