Re: [algogeeks] Re: MS [Written Question]
@ Nathiya: My statement was a question to whether the function is working or not. I know how -2 in converted to -1 :P @ All: The question is actually to tell whether the function mentioned will work for rounding off or not. The answer is half the times. It doesn't work for negative numbers. @ Ankur Khurana: I didn't mark it due to the type mismatch in *return*. Very doubtful if you haven't tried the same thing anywhere before. @ John_geek: The question is actually a good one. I wrote linked list, but I am sure there is a better data structure. One of my friends suggested to use a variable array. This way calculations can be fast. According to my friend, you should know how to use realloc() so that, in case of varying length of numbers, the size can also be adjusted. I think there is not a specific answer to this question. You have to explain in argument, why you chose the data structure perfectly. -- 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/-/KCgLW7nwSscJ. 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: MS [Written Question]
@poised yeah On Thu, Aug 4, 2011 at 2:18 PM, Amol Sharma wrote: > someone explain the 3rd question of section 2 related to the datastructure > -- > > > Amol Sharma > Third Year Student > Computer Science and Engineering > MNNIT Allahabad > > > > > On Thu, Aug 4, 2011 at 1:42 AM, Ankur Khurana wrote: > >> I dont know , but the double function question was highly ambigous one. >> They were satified by my arguements whie giving written test and asked me >> write explaintation down but still they went on to deduct two marks. Kaafi >> strange tha.. >> >> >> On Thu, Aug 4, 2011 at 1:33 PM, Nathiya Perumal > > wrote: >> >>> see first its performing the operation (-2+0.5) so the ans is -1.5 and >>> then its rounding off.. the final ans is -1. >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to algogeeks@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> >> >> -- >> Ankur Khurana >> Computer Science >> Netaji Subhas Institute Of Technology >> Delhi. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "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 SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT 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] Re: MS [Written Question]
someone explain the 3rd question of section 2 related to the datastructure -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad On Thu, Aug 4, 2011 at 1:42 AM, Ankur Khurana wrote: > I dont know , but the double function question was highly ambigous one. > They were satified by my arguements whie giving written test and asked me > write explaintation down but still they went on to deduct two marks. Kaafi > strange tha.. > > > On Thu, Aug 4, 2011 at 1:33 PM, Nathiya Perumal > wrote: > >> see first its performing the operation (-2+0.5) so the ans is -1.5 and >> then its rounding off.. the final ans is -1. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > Ankur Khurana > Computer Science > Netaji Subhas Institute Of Technology > Delhi. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: MS [Written Question]
I dont know , but the double function question was highly ambigous one. They were satified by my arguements whie giving written test and asked me write explaintation down but still they went on to deduct two marks. Kaafi strange tha.. On Thu, Aug 4, 2011 at 1:33 PM, Nathiya Perumal wrote: > see first its performing the operation (-2+0.5) so the ans is -1.5 and then > its rounding off.. the final ans is -1. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Ankur Khurana Computer Science Netaji Subhas Institute Of Technology Delhi. -- You received this message because you are subscribed to the Google Groups "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: MS [Written Question]
see first its performing the operation (-2+0.5) so the ans is -1.5 and then its rounding off.. the final ans is -1. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: MS [Written Question]
@ Ashish: The function is for rounding off decimal numbers. how is -2 rounded off to -1? @Gene: Unfortunately, I was not selected in the first round itself :( @ Sagar Pareek: Thats what I missed, I should searched for the questions before hand to atleast clear the first round. No wonder the selections were a bit odd at our college. Do you where Amazon has already visited? -- 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/-/4_fdg4CBdPAJ. 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: MS [Written Question]
@Gene: nice one :D On Wed, Aug 3, 2011 at 11:02 PM, sagar pareek wrote: > same questions...not a single diff were asked in NIT allahabad on 17 july > this yr... > > > On Wed, Aug 3, 2011 at 8:21 PM, Vengadanathan wrote: > >> It may not work for all , the parameter input is double what happens >> if the user gives a number greater the range of int datatype , in the >> return statement during type casting overflow in int occurs and wrong >> value is returned . >> check this >> http://www.ideone.com/oZbCf >> i have given the input as 2147483649 which is one greater the range of >> int .. check the output ... >> >> On Aug 3, 6:26 pm, Ashish Sachdeva wrote: >> > @poised: >> > i think this: >> > >> > double round(double num) >> > { return (int)(num+0.5) >> > >> > } >> > >> > works for all...http://www.ideone.com/WfEIw >> > >> > On Aug 3, 5:45 pm, Gene wrote: >> > >> > >> > >> > >> > >> > >> > >> > > Your solution to 1 works fine. I hope you get the job. But it needs >> > > O(N) additional storage for the stack. You can also do with constant >> > > additional storage. >> > >> > > #include >> > > int main(void) >> > > { >> > > #define N (sizeof a / sizeof a[0]) >> > > int a[] = {7, 9, 4, 8, 2}; >> > > int result[N], i, product; >> > > for (i = 0, product = 1; i < N; product *= a[i++]) >> > > result[i] = product; >> > > for (i = N - 1, product = 1; i >= 0; product *= a[i--]) >> > > result[i] *= product; >> > > for (i = 0; i < N; i++) printf("%d ", result[i]); >> > > printf("\n"); >> > > return 0; >> > >> > > } >> > >> > > On Aug 3, 7:08 am, Poised~ wrote: >> > >> > > > I am not looking for answer. Just sharing these Section 2 questions: >> > >> > > > 1. Given an array arr[] of n integers, construct a Product Array >> prod[] (of >> > > > same size) such that prod[i] is equal to the product of all the >> elements of >> > > > arr[] except arr[i]. Solve it without division operator. Give an >> efficient >> > > > code. >> > > > (if you are interested, here is my solution:http://ideone.com/EaTUF >> , >> > > > developed at the test time itself). >> >> -- >> You received this message because you are subscribed to the Google Groups >> "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 > SAGAR PAREEK > COMPUTER SCIENCE AND ENGINEERING > NIT 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. > -- You received this message because you are subscribed to the Google Groups "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: MS [Written Question]
same questions...not a single diff were asked in NIT allahabad on 17 july this yr... On Wed, Aug 3, 2011 at 8:21 PM, Vengadanathan wrote: > It may not work for all , the parameter input is double what happens > if the user gives a number greater the range of int datatype , in the > return statement during type casting overflow in int occurs and wrong > value is returned . > check this > http://www.ideone.com/oZbCf > i have given the input as 2147483649 which is one greater the range of > int .. check the output ... > > On Aug 3, 6:26 pm, Ashish Sachdeva wrote: > > @poised: > > i think this: > > > > double round(double num) > > { return (int)(num+0.5) > > > > } > > > > works for all...http://www.ideone.com/WfEIw > > > > On Aug 3, 5:45 pm, Gene wrote: > > > > > > > > > > > > > > > > > Your solution to 1 works fine. I hope you get the job. But it needs > > > O(N) additional storage for the stack. You can also do with constant > > > additional storage. > > > > > #include > > > int main(void) > > > { > > > #define N (sizeof a / sizeof a[0]) > > > int a[] = {7, 9, 4, 8, 2}; > > > int result[N], i, product; > > > for (i = 0, product = 1; i < N; product *= a[i++]) > > > result[i] = product; > > > for (i = N - 1, product = 1; i >= 0; product *= a[i--]) > > > result[i] *= product; > > > for (i = 0; i < N; i++) printf("%d ", result[i]); > > > printf("\n"); > > > return 0; > > > > > } > > > > > On Aug 3, 7:08 am, Poised~ wrote: > > > > > > I am not looking for answer. Just sharing these Section 2 questions: > > > > > > 1. Given an array arr[] of n integers, construct a Product Array > prod[] (of > > > > same size) such that prod[i] is equal to the product of all the > elements of > > > > arr[] except arr[i]. Solve it without division operator. Give an > efficient > > > > code. > > > > (if you are interested, here is my solution:http://ideone.com/EaTUF, > > > > developed at the test time itself). > > -- > You received this message because you are subscribed to the Google Groups > "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 SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT 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.
[algogeeks] Re: MS [Written Question]
It may not work for all , the parameter input is double what happens if the user gives a number greater the range of int datatype , in the return statement during type casting overflow in int occurs and wrong value is returned . check this http://www.ideone.com/oZbCf i have given the input as 2147483649 which is one greater the range of int .. check the output ... On Aug 3, 6:26 pm, Ashish Sachdeva wrote: > @poised: > i think this: > > double round(double num) > { return (int)(num+0.5) > > } > > works for all...http://www.ideone.com/WfEIw > > On Aug 3, 5:45 pm, Gene wrote: > > > > > > > > > Your solution to 1 works fine. I hope you get the job. But it needs > > O(N) additional storage for the stack. You can also do with constant > > additional storage. > > > #include > > int main(void) > > { > > #define N (sizeof a / sizeof a[0]) > > int a[] = {7, 9, 4, 8, 2}; > > int result[N], i, product; > > for (i = 0, product = 1; i < N; product *= a[i++]) > > result[i] = product; > > for (i = N - 1, product = 1; i >= 0; product *= a[i--]) > > result[i] *= product; > > for (i = 0; i < N; i++) printf("%d ", result[i]); > > printf("\n"); > > return 0; > > > } > > > On Aug 3, 7:08 am, Poised~ wrote: > > > > I am not looking for answer. Just sharing these Section 2 questions: > > > > 1. Given an array arr[] of n integers, construct a Product Array prod[] > > > (of > > > same size) such that prod[i] is equal to the product of all the elements > > > of > > > arr[] except arr[i]. Solve it without division operator. Give an efficient > > > code. > > > (if you are interested, here is my solution:http://ideone.com/EaTUF, > > > developed at the test time itself). -- You received this message because you are subscribed to the Google Groups "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: MS [Written Question]
@poised: i think this: double round(double num) { return (int)(num+0.5) } works for all... http://www.ideone.com/WfEIw On Aug 3, 5:45 pm, Gene wrote: > Your solution to 1 works fine. I hope you get the job. But it needs > O(N) additional storage for the stack. You can also do with constant > additional storage. > > #include > int main(void) > { > #define N (sizeof a / sizeof a[0]) > int a[] = {7, 9, 4, 8, 2}; > int result[N], i, product; > for (i = 0, product = 1; i < N; product *= a[i++]) > result[i] = product; > for (i = N - 1, product = 1; i >= 0; product *= a[i--]) > result[i] *= product; > for (i = 0; i < N; i++) printf("%d ", result[i]); > printf("\n"); > return 0; > > } > > On Aug 3, 7:08 am, Poised~ wrote: > > > > > > > > > I am not looking for answer. Just sharing these Section 2 questions: > > > 1. Given an array arr[] of n integers, construct a Product Array prod[] (of > > same size) such that prod[i] is equal to the product of all the elements of > > arr[] except arr[i]. Solve it without division operator. Give an efficient > > code. > > (if you are interested, here is my solution:http://ideone.com/EaTUF, > > developed at the test time itself). -- You received this message because you are subscribed to the Google Groups "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: MS [Written Question]
Your solution to 1 works fine. I hope you get the job. But it needs O(N) additional storage for the stack. You can also do with constant additional storage. #include int main(void) { #define N (sizeof a / sizeof a[0]) int a[] = {7, 9, 4, 8, 2}; int result[N], i, product; for (i = 0, product = 1; i < N; product *= a[i++]) result[i] = product; for (i = N - 1, product = 1; i >= 0; product *= a[i--]) result[i] *= product; for (i = 0; i < N; i++) printf("%d ", result[i]); printf("\n"); return 0; } On Aug 3, 7:08 am, Poised~ wrote: > I am not looking for answer. Just sharing these Section 2 questions: > > 1. Given an array arr[] of n integers, construct a Product Array prod[] (of > same size) such that prod[i] is equal to the product of all the elements of > arr[] except arr[i]. Solve it without division operator. Give an efficient > code. > (if you are interested, here is my solution:http://ideone.com/EaTUF, > developed at the test time itself). -- You received this message because you are subscribed to the Google Groups "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: MS [Written Question]
@ samby : (int) (num+0.5), works only for positive integers. e.g (int) (-2+0.5) = -1. so the answer is, it works half the times. -- 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/-/HFMHbLgkU3sJ. 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: MS [Written Question]
@Poised: Whats the answer of : double round(double num) { return (int)(num+0.5) } will it work all the time? I think the answer should be Yes. -- You received this message because you are subscribed to the Google Groups "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: MS [Written Question]
Section 1 problems. Total time 30 minutes: 1. x = x^x; printf("%d", x); o/p? 2. some automation-graph question. I think it was based on Automata. Not sure though. 3. z = scanf("%d %d", &x, &y); printf("%d", z); o/p? 4. a question on double loop. o/p related. 5. double round(double num) { return (int)(num+0.5) } will it work all the time? 5 more questions based on C only. -- 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/-/6tEnET0fN1UJ. 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: MS [Written Question]
Section 1 problems. Total time 30 minutes: 1. x = x^x; printf("%d", x); o/p? 2. some automation-graph question. I think it was based on Automata. Not sure though. 3. z = scanf("%d %d", &x, &y); printf("%d", z); o/p? 4. a question on double loop. o/p related. 5. double round(double num) { return (int)(num+0.5) } will it work all the time? 3 more questions based on C only. -- 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/-/kkF1VgdqtU8J. 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.