[algogeeks] Re: Algorithms for Interviews _scan ocr_.pdf
thank u aditi.. sindhu Student of B. Tech. IV Year -- 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.
[algogeeks] microsoft paper that i wrote today..
1. write a method to find the smallest angle between two hands when the time is given as input??? 2. given a number between 1 to 1000 convert it to words..example 235..it should print as two hundred thirty five.. 3. write test cases for elevator in a multistory building.. 4. a chessboard of size 64 blocks is given..a knight can move two n half moves at a time..how many steps will it take to cover all the 64 blocks...and change the algorithm if the knight moves three and a half moves. 5. what will be the result if you execute the following code segment: 1+2+4 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: A Nice Programming Challenge Question
@Dave: after p++ is executed hw will ur pgm continue?? -- 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: strings
@snehi .. your solution does not come upto the O(n) as for n elements of string it will take O(lg n) for each , so a total of O ( n * lg n ) Otherwise a better variation to Solution is taking a count member in each node and incrementing it when another occurrence is made of that character. Correct me if i am wrong , On Thu, Jun 23, 2011 at 12:51 AM, snehi jain snehijai...@gmail.com wrote: the binary tree for the above example will be k(1) \ a(2) / \ (7) a p(3) \ i(4) \ l(5) \ r (6) number in the bracket denotes the order of insertion like k inserted first then a then p and so on .. now if inorder is performed ... arent we getting kaapilr On Thu, Jun 23, 2011 at 12:43 AM, oppilas . jatka.oppimi...@gmail.comwrote: May be I didn't understood your logic. According to original question for I/P kapilra O/P --kaapilr.. Now, -what if we create a binary tree with root as the first element of the string and if the next character is equal then place it to left else place it to right. Similar comparison will be done while inserting all the other nodes too . At root you will insert k(count=1) After that a k(1) / a(1) Then you will insert p, k(1) / \ a(1)p(1) And so on. after that if InOrder traversal is performed.. it would give us the desired output. If by inoder traversal we can get desired output then please how me how using a small example :). Snehi On Wed, Jun 22, 2011 at 9:48 PM, DK divyekap...@gmail.com wrote: No. This is equivalent to a sort with comparisons based on index of first occurrence in the input string. Any comparative algorithm is O(n log n) and a non comparative algorithm can be O(n) only by using counting or radix sorting etc. -- DK http://twitter.com/divyekapoor http://www.divye.in -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/GeqwF_snzQQJ. 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 , -- Rohit Sindhu -- 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] String Swapping Problem
The function swap just swaps it's local copy of pointers which does not mean that it swap array elements. You have to do it explicitly. On Fri, Jun 17, 2011 at 3:17 AM, udit sharma sharmaudit...@gmail.comwrote: Ohh Sry... The qus was: #includestdio.hvoid swap(char *,char *);int main(){char *ps[2]={ Hello, Good Mornning, };swap(ps[0],ps[1]);printf(%s \t %s\n,ps[0],ps[1]);return 0;} void swap(char *p,char *q){char *t;t=p;p=q;q=t;} why the output is: HelloGood Mornning Regards UDIT 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 -- Rohit Sindhu -- 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] String Swapping Problem
#includestdio.h void swap(char **p,char **q) { char *t; t=*p; *p=*q; *q=t; } int main(){ char *ps[2]={ Hello, Good Morning, }; swap( ps[0] , ps[1]); printf(%s \t %s\n,ps[0],ps[1]); return 0; } This one breaks the ice ... as you have to change the contents of the array which is a pointer , you have to send a pointer to that pointer only that pointer as if u do it will be taken as local variable and no effect will be visible in actual array. On Fri, Jun 17, 2011 at 3:17 AM, udit sharma sharmaudit...@gmail.comwrote: Ohh Sry... The qus was: #includestdio.hvoid swap(char *,char *);int main(){char *ps[2]={ Hello, Good Mornning, };swap(ps[0],ps[1]);printf(%s \t %s\n,ps[0],ps[1]);return 0;} void swap(char *p,char *q){char *t;t=p;p=q;q=t;} why the output is: HelloGood Mornning Regards UDIT 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, -- Rohit Sindhu. -- 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 15 june ] Engineer Physicist Mathematician puzzle
@jeeva ... rather we can say that that the mathematician made a dot (circle of zero radius) and declared everything inside the circle (point) outside the fence :) On Wed, Jun 15, 2011 at 6:41 PM, subramania jeeva subramaniaje...@gmail.com wrote: The mathematician made a small fence around himself and declared himself to be on the outside the fence... :-) Cheers ~ Jeeva ~ On Wed, Jun 15, 2011 at 5:40 PM, amit kumar amitthecoo...@gmail.comwrote: @anika jain: will u plz xplain?? On Wed, Jun 15, 2011 at 4:02 PM, Anika Jain anika.jai...@gmail.comwrote: earth is a sphere i.e consisiting of infinite circles.. so mathematician had put the fence around that circle of the sphere where fence's length is equal to the circle's perimeter. On Wed, Jun 15, 2011 at 12:44 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote: Engineer Physicist Mathematician puzzle - 15 june * * ** ** ** *A farmer challenges an engineer, a physicist, and a mathematician to fence off the largest amount of area using the least amount of fence. The engineer made his fence in a circle and said it was the most efficient. The physicist made a long line and said that the length was infinite. Then he said that fencing half of the Earth was the best. The mathematician laughed at the others and with his design, beat the others. What did he do? * * * *Update Your Answers at* : Click Herehttp://dailybrainteaser.blogspot.com/2011/06/engineer-physicist-mathematician-puzzle.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. -- 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. -- ROHIT SINDHU B.Tech (IT) -- 6th sem. INDIAN INSTITUTE OF INFORMATION TECHNOLOGY, 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.
Re: [algogeeks] MS interview question
I this this code will solves it ... *#include stdio.h #include stdlib.h struct node{ int val; struct node *next; }; int main(){ struct node *head = NULL , *next_ptr = head; int n = 1; while ( n = 6 ){ struct node *temp = (struct node*) malloc (sizeof(struct node) ); temp-val = n++; temp-next = NULL; if (head == NULL ){ head = temp ; next_ptr = head; }else{ next_ptr-next = temp; next_ptr = temp; } } next_ptr = head; head = NULL; struct node *prev = NULL; while ( next_ptr != NULL next_ptr-next != NULL ){ struct node *swp = next_ptr-next-next; if ( head == NULL){ head = next_ptr-next; } if ( prev == NULL ){ prev = next_ptr; }else{ prev-next = next_ptr-next; prev = next_ptr; } next_ptr-next-next = next_ptr; next_ptr-next = swp; next_ptr = swp; } while ( head != NULL ){ printf(%d \n , head-val); head = head-next; } return 0; } * On Thu, Jun 2, 2011 at 7:18 AM, Anurag Bhatia abhati...@gmail.com wrote: Have a look at this recursive soln in java - Node convertList(Node head) { if(head ==null) return null; Node node = head; Node next = node.next; Node next2next = next.next; next.next = node; node.next = convertList(next2next); return next; } This soln assumes even number of nodes in the list. The code is quite self explanatory. --Anurag On Wed, Jun 1, 2011 at 6:26 AM, Anand anandut2...@gmail.com wrote: Given a linked list of the form, 1-2-3-4-5-6, convert it into the form 2-1-4-3-6-5. Note that the nodes need to be altered and not the data contained in them -- 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. -- ROHIT SINDHU B.Tech (IT) -- 6th sem. INDIAN INSTITUTE OF INFORMATION TECHNOLOGY, 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.
Re: [algogeeks] C floating point issue....
Your format specifiers in the printf statements are not right. Also integers and floats are stored differently internally. Also, you have to explicitly cast float into int as automatic conversion is not applicable here in printf. I hope this code helps your cause , #includestdio.h int main() { float a[]={13.24,1.5,1.5,5.4,3.5}; float *j; j=a; j=j+4; printf(\n%p,%f,%f,j,*j,a[4]); float p=3.5; printf(\n%f,%d,p,(int)p); p=4.5; printf(\n%d,%f,(int)p,p); } On Sat, Jun 4, 2011 at 2:21 PM, himanshi narang himanshinarang...@gmail.com wrote: #includestdio.h int main() { float a[]={13.24,1.5,1.5,5.4,3.5}; float *j; j=a; j=j+4; printf(\n%d,%d,%d,j,*j,a[4]); float p=3.5; printf(\n%f,%d,p,p); p=4.5; printf(\n%d,%f,p,p); } output -1080027596,0,1074528256 3.50,0 0,0.00 plzz explain y i m getting dis output.. -- 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. -- Rohit Sindhu -- 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
Order of evaluation of operands is not defined in C and secondly the result will be compiler implementation dependent. A compiler may store the sub expressions operand values in a temporary storage or can make use of variable value as an operand. *In each case, either of the ++b may be executed first. * 1. If the operand values is to be stored in temporaries the first evaluation will make one operand to be 4 and next evaluation make the other one to be 5. So in this case the result is 4*5 = 20. 2. But if variable b is to be used as operands the result will be 5*5 = 25 As a good practice using sub expressions which modify same data object should be avoided in an expression. On Sat, Jun 4, 2011 at 2:23 PM, Dv!! ITs nt me now!! sunny.verma...@gmail.com wrote: statement starts executing from the right side!!! 1st it reads it from left !! while reading b increment two times and new value of b is thn 5 nw it gets executed!!! am i right?? On 6/4/11, hary rathor harry.rat...@gmail.com wrote: in 1st pass both ++b ++b= 4 then ++b= 5; at second pass a= 5*5; because ++b is 5 -- 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. -- Dhruva Verma BTech(IT)-2nd year IIIT-Allahabad -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to 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. -- ROHIT SINDHU B.Tech (IT) -- 6th sem. INDIAN INSTITUTE OF INFORMATION TECHNOLOGY, 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.