Re: [algogeeks] Re: Run Length Decoding... inplace
Hope this works http://ideone.com/MCLqO On Sun, Mar 25, 2012 at 4:37 PM, atul anand atul.87fri...@gmail.com wrote: @ Kalyanasundaram : no need to check you algo , bcozz i can clearly see you are not saving output to the bufffer , you are just printing it to stdout . please read prev comment for better understanding the problem, On Sun, Mar 25, 2012 at 11:54 AM, Kalyanasundaram nks.22.1...@gmail.comwrote: scanf(%s,a); l=strlen(a); for(i=l-1;i=0;i-=2) { while((a[i]--)-'0') printf(%c,a[i-1]); } This works fine when the count of characters is a 10 .Also no extra space used.If you find any mistake, please do correct me! On Sun, Mar 25, 2012 at 10:18 AM, SAMM somnath.nit...@gmail.com wrote: In this question is it mandatory to use array here .Because the output and the space were the string is stored is required .. I was thinking of using LL approach .. Need four pointers to keep track of the positions . begin - store the beginning of the LL initially containing the pointer to he 1st node a1b2c3d4. end - store the end node of the input string . outputbegin - store the position where the output index begin .. It will be appended to the next node of the input string . outputend -store the end node of the LL. begin -- a 1 b 2 c 3 d 4(-end) (outputbegin-) NULL -(outputend) Delete d4 we hav now:- begin -- a 1 b 2 c 3 (-end) (outputbegin-) d d d d -(outputend) Take the character and corresponding value from the end index, change the end pointer to '3' on the left of d4 , delete both nodes of d4 and append it characters at the end .. All u have to do is remove and append , no extra memory greater than length(output) is used here .. As Nothing has been mentioned abt printing the output in the question , we will keep printing the character on the console while appendiing the character in the LL ). -- 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. -- *Kalyan Dont take life seriously as it isnt Permanent! * -- 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. -- Regards Anurag Atri III year Computer Engineering Delhi College Of Engineering -- 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 : Any hints[kth smallest contiguous sum] ?
Indian Institute Of Technology,Roorkee -- 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. -- Sunny Aggrawal B.Tech. V year,CSI Indian Institute Of Technology,Roorkee -- 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. -- Sunny Aggrawal B.Tech. V year,CSI Indian Institute Of Technology,Roorkee -- 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. -- Sunny Aggrawal B.Tech. V year,CSI Indian Institute Of Technology,Roorkee -- 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. -- Sunny Aggrawal B.Tech. V year,CSI Indian Institute Of Technology,Roorkee -- 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. -- Regards Anurag Atri -- 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] puzzle
nth term : (n! + 2^n - n) On Wed, Feb 29, 2012 at 11:05 AM, Vaibhav Mittal vaibhavmitta...@gmail.comwrote: Ntn else is provided..?? On Feb 28, 2012 12:51 PM, Gaurav Popli abeygau...@gmail.com wrote: Given a sequance of natural numbers. Find N'th term of this sequence. a1=2, a2=4, a3=11, a4=36, a5=147, a6=778 ... ... ... ... aN. this is a coding quesn and O(n) soln is also welcome... -- 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. -- Regards Anurag Atri -- 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] puzzle
@shady: Observation only .. On Wed, Feb 29, 2012 at 9:03 PM, shady sinv...@gmail.com wrote: anurag how did you reach that solution ? can you elaborate... On Wed, Feb 29, 2012 at 8:11 PM, Anurag atri anu.anurag@gmail.comwrote: nth term : (n! + 2^n - n) On Wed, Feb 29, 2012 at 11:05 AM, Vaibhav Mittal vaibhavmitta...@gmail.com wrote: Ntn else is provided..?? On Feb 28, 2012 12:51 PM, Gaurav Popli abeygau...@gmail.com wrote: Given a sequance of natural numbers. Find N'th term of this sequence. a1=2, a2=4, a3=11, a4=36, a5=147, a6=778 ... ... ... ... aN. this is a coding quesn and O(n) soln is also welcome... -- 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. -- Regards Anurag Atri -- 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. -- Regards Anurag Atri III year Computer Engineering Delhi College Of Engineering -- 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] BYTES - LESS THAN 45 MINS TO GO
Problems are not visible ..? On Fri, Feb 17, 2012 at 5:22 PM, ghanta.coder black.b...@gmail.com wrote: ANNUAL ONLINE PROGRAMMING CONTEST OF DELHI COLLEGE OF ENGINEERING Hello Geeks , BYTES 12 - a 6-hour acm-icpc style online programming contest organised under the annual technical fest TROIKA of Delhi Technological Unviersity ( formerly Delhi College Of Engineering ) is going to start soon. Time : 6 pm to 12 am ( 6 hours ) Date : 17th February URL : http://www.spoj.pl/BYTES12/ Problems : 8-9 interesting problems with varying diffculty Prize Money : Win and find out :P -- 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 Anurag Atri -- 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] Microsoft Internship
Exactly , easy questions will be asked , make sure you catch given hints :) On Wed, Aug 3, 2011 at 9:01 PM, coder coder i.code.program...@gmail.comwrote: the interviewers are asking easy questions like spiral finding, loop in the list, common ancestor etc.. -- 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 Anurag Atri III year Computer Engineering Delhi College Of Engineering -- 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] Microsoft Internship
you have to be in formals for sure ! yes , people who clear the written will have 3 interviews . On Tue, Aug 2, 2011 at 2:15 PM, saurabh modi saurabhmodi102...@gmail.comwrote: hey man,could you tell something abt the attire and all.? we dont need to go in formals,right? plus,koi interview and all hoga? -- 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 Anurag Atri III year Computer Engineering Delhi College Of Engineering -- 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] binary search
int Modified_BinarySearch(int A[], int N, int value) { int low = 0; int high = N; while (low high) { int mid = (low + high)/2; if (A[mid] value) low = mid + 1; else high = mid; } if ((low N) (A[low] == value)) return low; else return -1; } Regards Anurag Atri -- 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] microsoft ques
Time O(n) , Space O(1) int maximum_continuous_product ( int numbers[] , int size ) { int i ; int before_negative = 0 ; int current_p = 1 ; int max_p = 0 ; int is_negative = 0 ; for ( i = 0 ; i size ; i ++ ) { if ( numbers[i] 0 ) { if ( is_negative == 0 ) { is_negative = 1 ; } else { is_negative = 0 ; } if ( before_negative == 0 ) { before_negative = current_p ; current_p *= -1 ; } else { current_p *= -1 ; current_p *= before_negative ; before_negative = 0 ; } } current_p *= numbers[i] ; if ( is_negative == 0 ) { if ( current_p max_p ) { max_p = current_p ; } } if ( current_p == 0 ) { current_p = 1 ; before_negative = 0 ; is_negative = 0 ; } } return max_p ; } -- 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] microsoft ques
@surender yup , thanx for pointing :) On Tue, Jul 26, 2011 at 7:27 AM, surender sanke surend...@gmail.com wrote: @anurag , it fails for {4,5,-2,0,-3,-4,4,2,3,5,-7}; urs calculates from index 4 to 9. but maximum product is from index 5 to 10 surender On Mon, Jul 25, 2011 at 11:38 AM, Anurag atri anu.anurag@gmail.comwrote: Time O(n) , Space O(1) int maximum_continuous_product ( int numbers[] , int size ) { int i ; int before_negative = 0 ; int current_p = 1 ; int max_p = 0 ; int is_negative = 0 ; for ( i = 0 ; i size ; i ++ ) { if ( numbers[i] 0 ) { if ( is_negative == 0 ) { is_negative = 1 ; } else { is_negative = 0 ; } if ( before_negative == 0 ) { before_negative = current_p ; current_p *= -1 ; } else { current_p *= -1 ; current_p *= before_negative ; before_negative = 0 ; } } current_p *= numbers[i] ; if ( is_negative == 0 ) { if ( current_p max_p ) { max_p = current_p ; } } if ( current_p == 0 ) { current_p = 1 ; before_negative = 0 ; is_negative = 0 ; } } return max_p ; } -- 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. -- Regards Anurag Atri III year Computer Engineering Delhi College Of Engineering -- 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] output plzz
The output will be This is 10 times charlie Thisis10timescharlie and it makes sense , this will be helpful http://www.cplusplus.com/reference/clibrary/cstdio/sscanf/ Regards Anurag Atri -- 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] output plzz
Dev c++ , which one are you using ? On Sun, Jul 24, 2011 at 12:01 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: No. Its not coming like dat. This is 10 times charlie Thisis10charlie This is the output *Muthuraj R. 4TH Year BE.** Information Science Dept* *PESIT, Bengaluru . * On Sat, Jul 23, 2011 at 11:23 PM, shady sinv...@gmail.com wrote: it is not coming like that ? On Sun, Jul 24, 2011 at 11:41 AM, Anurag atri anu.anurag@gmail.comwrote: The output will be This is 10 times charlie Thisis10timescharlie and it makes sense , this will be helpful http://www.cplusplus.com/reference/clibrary/cstdio/sscanf/ Regards Anurag Atri -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Anurag Atri III year Computer Engineering Delhi College Of Engineering -- 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] output plzz
yup , on ideone it indeed is giving the output you suggested .. On Sun, Jul 24, 2011 at 12:10 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @Anrag: i am using gcc on Ubuntu.I also checkd it on Ideone online compiler. But Declare the character strings char five[7]; char four[7]; int three; char two[7]; char one[7]; int his order and we get the correct output. But i dont know y?Its something to do with Memory location where the strings are defined. *Muthuraj R. 4TH Year BE.** Information Science Dept* *PESIT, Bengaluru . * On Sat, Jul 23, 2011 at 11:34 PM, Anurag atri anu.anurag@gmail.comwrote: Dev c++ , which one are you using ? On Sun, Jul 24, 2011 at 12:01 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: No. Its not coming like dat. This is 10 times charlie Thisis10charlie This is the output *Muthuraj R. 4TH Year BE.** Information Science Dept* *PESIT, Bengaluru . * On Sat, Jul 23, 2011 at 11:23 PM, shady sinv...@gmail.com wrote: it is not coming like that ? On Sun, Jul 24, 2011 at 11:41 AM, Anurag atri anu.anurag@gmail.com wrote: The output will be This is 10 times charlie Thisis10timescharlie and it makes sense , this will be helpful http://www.cplusplus.com/reference/clibrary/cstdio/sscanf/ Regards Anurag Atri -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Anurag Atri III year Computer Engineering Delhi College Of Engineering -- 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. -- Regards Anurag Atri III year Computer Engineering Delhi College Of Engineering -- 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: Adding w/o +
int a = 20 ; //whatever value you like int b = 30 ; // again int sum = a - (-b) ; cout sum ; //eh ? On Wed, Jul 13, 2011 at 6:17 PM, vaibhav shukla vaibhav200...@gmail.comwrote: :D :D ;) On Wed, Jul 13, 2011 at 6:11 PM, Anika Jain anika.jai...@gmail.comwrote: @ vaibhav: ohh sorry, ya its leaving the columns.. so we can do int a=9,b=4; int sum=printf(%*s%*s,a,,b,); printf(\r%d\n,sum); On Wed, Jul 13, 2011 at 6:09 PM, Anika Jain anika.jai...@gmail.comwrote: @vaibhav: no it wont coz its printing empty strings.. nothing will be printed On Wed, Jul 13, 2011 at 4:42 PM, vaibhav shukla vaibhav200...@gmail.com wrote: @anika : ur ans will give the sum but will also leave that much amount of space before printing the sum one betther idea is to use bitwise int Mysum(int a,int b) { if(b==0) return a; else { int sum=a^b; int carry=(ab)1; return Mysum(sum,carry); } On Wed, Jul 13, 2011 at 4:15 PM, dinesh bansal bansal...@gmail.comwrote: never mind...thanks. On Wed, Jul 13, 2011 at 2:29 PM, dinesh bansal bansal...@gmail.comwrote: Can you explain how its working? On Wed, Jul 13, 2011 at 1:58 PM, Anika Jain anika.jai...@gmail.com wrote: a better idea is use this: int a=9,b=4; int sum=printf(%*s%*s,a,,b,); printf(%d\n,sum); On Wed, Jul 13, 2011 at 1:52 PM, nicks crazy.logic.k...@gmail.com wrote: if someone has better idea...then please suggest that. plz explain how this is calculating sum -- sum= (int)p[b]; On Wed, Jul 13, 2011 at 1:50 PM, nicks crazy.logic.k...@gmail.com wrote: I am looking for a code which can add without using + sign i searched the net and found the following code..can anyone explain me whats happening in this ?? #includestdio.h #includeconio.h int main() { int a=3000,b=20,sum; char *p; p=(char *)a; sum= (int)p[b]; //adding a b printf(Answer is :); printf(%d,sum); 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?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. -- Dinesh Bansal The Law of Win says, Let's not do it your way or my way; let's do it the best way. -- 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?hl=en. -- best wishes!! Vaibhav Shukla DU-MCA -- 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. -- best wishes!! Vaibhav Shukla DU-MCA -- 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 Anurag Atri III year Computer Engineering Delhi College Of Engineering -- 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: C OUTPUT HELP
@Nicks : Kindly share the source from where you are practicing these c output questions .. Thank 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?hl=en.
Re: [algogeeks] puzzle
The answer is 14 . On Thu, Jul 7, 2011 at 11:25 PM, Sumit chauhan sumitchauhan...@gmail.comwrote: The ans is 16 because :- if we drop from 16th floor and if egg1 breaks floor to be tested is b/w 1-16 . Then start from floor 1 with egg2 and floor from which it breaks first is obtained and will lie b/w 1-16. the attempts are no more than 16. however If egg1 doesn't break on 16 floor then try on (16+15)th i.e. 31st floor , it will have 16 attempts at max in both cases then (16+15+14)th and so on floor to be tried will be 16,31,45,58,70,81,91. In case it is 100th floor max attempts can be 7 attempts(earlier frm 1691) and 9(92-100)attempts more i.e. 16 attempts. -- 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 Anurag Atri III year Computer Engineering Delhi College Of Engineering -- 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: meaning of null in output
#includestdio.h int main () { int * p = NULL ; printf ( %s , p ) ; getchar () ; } On Sat, Jul 2, 2011 at 3:33 AM, hary rathor harry.rat...@gmail.com wrote: Rajeev : please can u explain by a c 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?hl=en. -- Regards Anurag Atri III year Computer Engineering Delhi College Of Engineering -- 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] [brain teaser ] Hardest Brain Teaser 22april
hehe :) here is a hint : dots and dashes :) On Fri, Apr 22, 2011 at 12:53 PM, Shuaib aries.shu...@gmail.com wrote: Well, I know the answer, but won't spoil the fun(?) for others. This is less of a brain teaser, and more of a general knowledge question. -- Shuaib http://twitter.com/ShuaibKhan http://bytehood.com/ On Friday, April 22, 2011 at 12:19 PM, Lavesh Rawat wrote: * A palindrome is a word that reads the same when spelled backwards (eg rotavator). How could the following word be considered a palindrome? FOOTSTOOL ** Hardest Brain Teaser * *Update Your Answers at* : Click Herehttp://dailybrainteaser.blogspot.com/2011/04/hardest-brain-teaser-22april.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. -- 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 Anurag Atri II year Computer Engineering Delhi College Of Engineering -- 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] [brain teaser ] sequence number puzzle 18april
the numbers are sorted alphabetically . 'e'ight 'f'ive 'f'our . . . . . 'z'ero On Mon, Apr 18, 2011 at 2:11 PM, Vandana Bachani vandana@gmail.comwrote: A funny one... until I figure out... It contains all numbers from 0 to 10 :P On Mon, Apr 18, 2011 at 1:58 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote: * sequence number puzzle What is special about the following sequence of numbers? 8 5 4 9 1 7 6 10 3 2 0 * *Update Your Answers at* : Click Herehttp://dailybrainteaser.blogspot.com/2011/04/sequence-number-puzzle-18april.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. -- 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 Anurag Atri II year Computer Engineering Delhi College Of Engineering -- 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: Square of Large integer
i strongly believe that you should have tried harder . still , here goes #includeiostream #includecstdio #includestdlib.h using namespace std; int mulmod ( int a , int b , int c ) { int x = 0 , y = a % c ; while ( b 0 ) { if ( b % 2 == 1 ) { x = ( x + y ) % c ; } y = ( y * 2 ) % c ; b /= 2 ; } return x % c ; } int modulo ( int a , int b , int c ) { int x = 1 , y = a ; while ( b ) { if ( b 1) { x = mulmod ( x , y , c ) ; } y = mulmod ( y ,y, c ) ; b /= 2 ; } return x % c ; } int main () { printf ( %d , modulo ( 33554432 , 2 , 10 ) ) ; } On Thu, Apr 14, 2011 at 9:39 PM, AAMIR KHAN ak4u2...@gmail.com wrote: On Thu, Apr 14, 2011 at 9:08 PM, Dave dave_and_da...@juno.com wrote: @AAmir: The easiest way is to declare A as long long int. Be sure to change the printf format string. I know that. But since i want to have only the last 9 digits of the answer that can be accommodated in int only so there is no need for long long i think. Dave On Apr 14, 8:31 am, AAMIR KHAN ak4u2...@gmail.com wrote: #includecstdio #define MOD (int)1e9 using namespace std; int main() { int A = 33554432; printf(%d\n,A*A); printf(%d\n,((A*A)%MOD)); return 0; } How can i calculate, lets say last 9 digits of square of 33554432 ? Thanks, Aamir -- 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. -- Regards Anurag Atri II year Computer Engineering Delhi College Of Engineering -- 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: Interview Question
if innitially temp is pointing to A then there is no problem in deleting the middle node .. On Fri, Apr 8, 2011 at 4:49 PM, murthy.krishn...@gmail.com murthy.krishn...@gmail.com wrote: hii, Small correction For the second case, Consider, A - B - C - NULL Initially temp is pointing to A. Accor 2 me he has asked to reverse d list to make it as C - A by deleting B, which can be done like this, temp-next = temp-next-next; // A-C-NULL temp-next-next = temp; //A-C-A temp = temp-next; //C-A-C temp-next-next = NULL; //C-A-NULL Correct me, If am wrong Thanks, On Fri, Apr 8, 2011 at 4:47 PM, murthy.krishn...@gmail.com murthy.krishn...@gmail.com wrote: For the second case, Consider, A - B - C - NULL Accor 2 me he has asked to reverse d list to make it as C - A by deleting B, which can be done like this, temp-next = temp-next-next; // A-C-NULL temp-next-next = temp; //A-C-A temp = temp-next; //C-A-C temp-next-next = NULL; //C-A-NULL Correct me, If am wrong Thanks, now temp is poiting to On Fri, Apr 8, 2011 at 2:13 PM, cegprakash cegprak...@gmail.com wrote: for the second case it is possible only if the node contains the previous node's address. Else there should be data movement -- 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. -- P.V.N.S.S. Krishna Murthy, Intern at Broadcom Private Limited, Bangalore, Contact no:- +919845812996. -- P.V.N.S.S. Krishna Murthy, Intern at Broadcom Private Limited, Bangalore, Contact no:- +919845812996. -- 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 Anurag Atri II year Computer Engineering Delhi College Of Engineering -- 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] Interview Question
@All yeah my solution does move data ... I am very interested in knowing a solution that moves no data , someone please come up with a solution . On Thu, Apr 7, 2011 at 9:23 PM, balaji a peshwa.bal...@gmail.com wrote: lets say there are two pointers - temp1,temp2 and the start of the node is head now, temp1=head; temp2=head-next; temp1-next=temp2-next; now temp1 points to the first node and the temp2 points to the second node(which got deleted from the list). On Thu, Apr 7, 2011 at 5:43 PM, Umer Farooq the.um...@gmail.com wrote: That can be moved. Basically, he is trying to convey that move the data of temp-next to temp. That's perfectly fine. On Thu, Apr 7, 2011 at 2:05 PM, Akash Mukherjee akash...@gmail.comwrote: @ anurag temp - data = ( temp - next ) - data ; but data cannot be moved, ryt?? On 4/6/11, Anurag atri anu.anurag@gmail.com wrote: in case you are given a pointer to the first node simply do temp -next = ( temp - next ) - next . if you are given a pointer to the second node do , temp - data = ( temp - next ) - data ; temp - next = NULL ; correct me if I am wrong . On Mon, Apr 4, 2011 at 9:48 PM, Umer Farooq the.um...@gmail.com wrote: Hello friends, The following question has appeared in two top companies of my city. I'd appreciate if anyone is able to answer it. Given a singly liked list comprising of three nodes Delete the middle node such that: 1- A temp pointer is pointing to the first node 2- A temp pointer is pointing to the second node. You can not use any other pointer and you can not move data. -- Umer -- 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 Anurag Atri -- 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. -- Umer -- 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. -- A.Balaji -- 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 Anurag Atri II year Computer Engineering Delhi College Of Engineering -- 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] Interview Question
in case you are given a pointer to the first node simply do temp -next = ( temp - next ) - next . if you are given a pointer to the second node do , temp - data = ( temp - next ) - data ; temp - next = NULL ; correct me if I am wrong . On Mon, Apr 4, 2011 at 9:48 PM, Umer Farooq the.um...@gmail.com wrote: Hello friends, The following question has appeared in two top companies of my city. I'd appreciate if anyone is able to answer it. Given a singly liked list comprising of three nodes Delete the middle node such that: 1- A temp pointer is pointing to the first node 2- A temp pointer is pointing to the second node. You can not use any other pointer and you can not move data. -- Umer -- 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 Anurag Atri -- 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: 23march
@Dave : like ! On Wed, Mar 23, 2011 at 11:14 PM, Kunal Patil kp101...@gmail.com wrote: @dave: Very nice answer yaar..Excellent !!! On Wed, Mar 23, 2011 at 7:08 PM, Dave dave_and_da...@juno.com wrote: It is LCM(2,3,4,5,6,7,8,9,10) - 1 = 2^3 * 3^2 * 5 * 7 - 1 = 2519. LCM = least common multiple. Dave On Mar 23, 2:41 am, Lavesh Rawat lavesh.ra...@gmail.com wrote: *A Remainder is chasing me Problem Solution* * *I just found a number with an interesting property: When I divide it by 2, the remainder is 1. When I divide it by 3, the remainder is 2. When I divide it by 4, the remainder is 3. When I divide it by 5, the remainder is 4. When I divide it by 6, the remainder is 5. When I divide it by 7, the remainder is 6. When I divide it by 8, the remainder is 7. When I divide it by 9, the remainder is 8. When I divide it by 10, the remainder is 9. It's not a small number, but it's not really big, either. When I looked for a smaller number with this property I couldn't find one. Can you find it? Update Your Answers at : Click Here http://dailybrainteaser.blogspot.com/2011/03/23march.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. -- 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 Anurag Atri -- 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] If any one have algorithms for interviews by adnan aziz ebook... Please mail ...
and me too :) On Tue, Mar 22, 2011 at 9:28 PM, Nikhil Mishra mishra00...@gmail.comwrote: count me too On Tue, Mar 22, 2011 at 11:16 AM, kunal srivastav kunal.shrivas...@gmail.com wrote: plz send it to me too On Tue, Mar 22, 2011 at 11:14 AM, D.N.Vishwakarma@IITR deok...@gmail.com wrote: -- *With Regards Deoki Nandan Vishwakarma IITR MCA Mathematics Department * -- 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. -- thezeitgeistmovement.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?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. -- Regards Anurag Atri -- 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] prime number using Sieve of Eratosthenes
what did you not understand in this ? On Mon, Mar 21, 2011 at 4:59 PM, rohit scofiel...@rediffmail.com wrote: genrate prime number using Sieve of Eratosthenes method explanation is here http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes pls help me out -- 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 Anurag Atri -- 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: prime number using Sieve of Eratosthenes
take an array and put 0 at all positions in it (except 2 ) , then when you mark a number as a multiple of a prime number ( 2 to start with ) put 1 in that place ..then look for the first number in the array that has a 1 ( this time 3 ) do the same procedure again . On Mon, Mar 21, 2011 at 5:41 PM, rohit scofiel...@rediffmail.com wrote: i just want to know , when we make a program how update array after deleting alternate element. On Mar 21, 4:37 pm, Anurag atri anu.anurag@gmail.com wrote: what did you not understand in this ? On Mon, Mar 21, 2011 at 4:59 PM, rohit scofiel...@rediffmail.com wrote: genrate prime number using Sieve of Eratosthenes method explanation is herehttp://en.wikipedia.org/wiki/Sieve_of_Eratosthenes pls help me out -- 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 Anurag Atri -- 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 Anurag Atri -- 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: SPOJ problem-BRCKTS
yes , please suggest a nice tutorial for segment trees .. On Mon, Mar 21, 2011 at 5:48 PM, cegprakash cegprak...@gmail.com wrote: hey i want to learn segment trees.. suggest me a tutorial plz.. pdf or word anything.. i don't understand wiki page -- 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 Anurag Atri -- 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: prime number using Sieve of Eratosthenes
better explained by Reddy's program :) On Mon, Mar 21, 2011 at 6:00 PM, Anurag atri anu.anurag@gmail.comwrote: take an array and put 0 at all positions in it (except 2 ) , then when you mark a number as a multiple of a prime number ( 2 to start with ) put 1 in that place ..then look for the first number in the array that has a 1 ( this time 3 ) do the same procedure again . On Mon, Mar 21, 2011 at 5:41 PM, rohit scofiel...@rediffmail.com wrote: i just want to know , when we make a program how update array after deleting alternate element. On Mar 21, 4:37 pm, Anurag atri anu.anurag@gmail.com wrote: what did you not understand in this ? On Mon, Mar 21, 2011 at 4:59 PM, rohit scofiel...@rediffmail.com wrote: genrate prime number using Sieve of Eratosthenes method explanation is herehttp://en.wikipedia.org/wiki/Sieve_of_Eratosthenes pls help me out -- 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 Anurag Atri -- 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 Anurag Atri -- Regards Anurag Atri -- 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] chk dis out
http://mathforum.org/library/drmath/view/57919.html check this out . On Sun, Mar 20, 2011 at 7:38 PM, Akash Mukherjee akash...@gmail.com wrote: Majid is a 3rd-grade elementary student and quite well in mathematics. Once, Majid's teacher asked him to calculate the sum of numbers 1 through n. Majid quickly answered, and his teacher made him another challenge. He asked Majid to calculate the sum of the digits of numbers 1 through n. Majid did finally find the solution. Now it is your turn, can you find a solution? Input Two space-separated integers 0 = a = b = 109. Program terminates if a and b are -1. Output The sum of the digits of numbers a through b. Example *Input:* 1 10 100 777 -1 -1 *Output:* 46 8655 ne ideas?? -- 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 Anurag Atri -- 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] SPOJ problem-BRCKTS
@krishna - yeah as Bharath said that case should give NO , anyways you got it now :) On Mon, Mar 21, 2011 at 5:50 AM, murthy.krishn...@gmail.com murthy.krishn...@gmail.com wrote: @bharath yaa now I got the ques, thanx :-) On Mon, Mar 21, 2011 at 4:47 AM, bharath kannan bharathgo...@gmail.comwrote: @murthy:no..the op must be NOits not a valid expression..read the two conditions for a valid expression.. On Sun, Mar 20, 2011 at 8:23 PM, murthy.krishn...@gmail.com murthy.krishn...@gmail.com wrote: @anurag accor to me the output must be YES, correct me if I am wrong On Sun, Mar 20, 2011 at 10:40 AM, bharath kannan bharathgo...@gmail.com wrote: i thot tat i had some mistake in my code and typed it all over again.. finally i noticed this :) On Sat, Mar 19, 2011 at 12:12 AM, Kunal Patil kp101...@gmail.comwrote: Hey.. I also got into same trouble today... I submitted it 6 times..then got bored and de moralised cause i cudnt find flaw in code... When i read your mail and corresponding sorry mail...it just struck me..I also had to print YES and NOand i was printing NO as NoIt got ac den... :P thnx anyway !!! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 Anurag Atri -- 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] chk dis out
@Sanchit - :) On Mon, Mar 21, 2011 at 9:38 AM, Akash Mukherjee akash...@gmail.com wrote: thanks, :) On Sun, Mar 20, 2011 at 8:21 PM, Anurag atri anu.anurag@gmail.comwrote: http://mathforum.org/library/drmath/view/57919.html check this out . On Sun, Mar 20, 2011 at 7:38 PM, Akash Mukherjee akash...@gmail.comwrote: Majid is a 3rd-grade elementary student and quite well in mathematics. Once, Majid's teacher asked him to calculate the sum of numbers 1 through n. Majid quickly answered, and his teacher made him another challenge. He asked Majid to calculate the sum of the digits of numbers 1 through n. Majid did finally find the solution. Now it is your turn, can you find a solution? Input Two space-separated integers 0 = a = b = 109. Program terminates if a and b are -1. Output The sum of the digits of numbers a through b. Example *Input:* 1 10 100 777 -1 -1 *Output:* 46 8655 ne ideas?? -- 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 Anurag Atri -- 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. -- Regards Anurag Atri -- 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: SPOJ problem-BRCKTS
@Krishna }{ what about this case ? On Sun, Mar 20, 2011 at 2:11 AM, murthy.krishn...@gmail.com murthy.krishn...@gmail.com wrote: can any 1 explain why we have 2 use segment trees ?? I am under the impression that in order to distinguish correct bracket expressions, we can just count the number of left brackets and compare that with the number of right brackets, if they are equal then it is a correct bracket expression. can u please correct me with an example if I am wrong Thanks, Krishna. On Sat, Mar 19, 2011 at 4:13 PM, cegprakash cegprak...@gmail.com wrote: could someone plz help me with a pdf for learning segment tree? i don't understand the wiki page -- 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. -- Regards Anurag Atri -- 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] SPOJ Problem : PRIME1
you should try sieve of eratosthenes http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes there are far more efficient algorithms but i think this shoild be a good one to start with . ( even i got AC with this one :) ) On Fri, Mar 18, 2011 at 10:11 PM, samby ankitsamb...@gmail.com wrote: The problem goes like this : Peter wants to generate some prime numbers. Your task is to generate all prime numbers between two given numbers! Input The input begins with the number t of test cases in a single line (t=10). In each of the next t lines there are two numbers m and n (1 = m = n = 10, n-m=10) separated by a space. Output For every test case print all prime numbers p such that m = p = n, one number per line, test cases separated by an empty line. Example Input: 2 1 10 3 5 Output: 2 3 5 7 3 5 the following is my code : int main() { int t,trialdiv,a1,b1,i,j,candidate,flag,a[10],b[10]; scanf(%d,t); for(i=0;it;i++) { scanf(\n%d %d,a[i],b[i]); } for(i=0;it;i++) { a1=a[i]; b1=b[i]; for(candidate=a1;candidate=b1;candidate++) { flag=1; for(trialdiv=2;(trialdiv*trialdiv)=candidate;trialdiv++) { if((candidate % trialdiv) == 0) { flag = 0; break; } } if(flag==1 candidate != 1) printf(\n%d,candidate); } printf(\n); } return 0; } I AM GETTING TIME LIMIT EXCEEDED. CAN ANYBODY HELP ME WITH AN EFFICIENT ALGORITHM ?? -- 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 Anurag Atri -- 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] [brain teaser ] 17march
lee ( hint : use those two things that you call eyes :P ) On Thu, Mar 17, 2011 at 2:43 PM, nishaanth nishaant...@gmail.com wrote: :P On Thu, Mar 17, 2011 at 10:52 AM, kunal srivastav kunal.shrivas...@gmail.com wrote: lol On Thu, Mar 17, 2011 at 2:20 PM, Srirang Ranjalkar srira...@gmail.comwrote: @amit have you considered Lee as an answer for that question? :P Thank you, Srirang Ranjalkar -- Luck is when hard work meets opportunity On Thu, Mar 17, 2011 at 2:19 PM, amit singh amit.lu...@gmail.comwrote: Lu (hint a,e,i ,o,u) On Thu, Mar 17, 2011 at 1:58 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote: *Problem Solution* * *Lee's parents have five children, the names of the first four are La, Le, Li, and Lo. What's the name of the fifth child? Update Your Answers at : Click Herehttp://dailybrainteaser.blogspot.com/2011/03/17march.html 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. -- Amit Kumar Singh Software Engineer Samsung India Software Operations Banglore India -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?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. -- thezeitgeistmovement.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?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 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 Anurag Atri -- 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] Another maths problem
2 On Thu, Mar 17, 2011 at 8:25 PM, saurabh singh saurab...@gmail.com wrote: Find the smallest divisor of 17^13+13*17... PS:please dont say 1 -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- Saurabh Singh B.Tech (Computer Science) 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 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 Anurag Atri -- 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.