[algogeeks] Re: Sort string based upon the count of characters
How we can preserve order of the string. When you sort the array, How you can track the specific count of character after the sort? On Jan 13, 12:46 pm, Bhavesh agrawal agr.bhav...@gmail.com wrote: we can also the concept of HASHING to count the frequency of each character . On Thu, Jan 13, 2011 at 11:53 AM, Davin dkthar...@googlemail.com wrote: Smaple Data : input : abcdacdc Output : cadb If the count is same for characters. maintain the original order of the characters from input string. Please do let me know for any clarification. -- 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.comalgogeeks%2Bunsubscribe@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.
[algogeeks] Re: Sort string based upon the count of characters
@Davin. Please provide an example of output for this - cabbaacc -- 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: Sort string based upon the count of characters
cab As 'c' and 'a' have same count but 'c' was before 'a' in the input string. On Jan 13, 1:39 pm, juver++ avpostni...@gmail.com wrote: @Davin. Please provide an example of output for this - cabbaacc -- 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: Sort string based upon the count of characters
@above, in order of the first occurence of the character -- 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: Sort string based upon the count of characters
@Davin maintain count of each character, along with the first occurence of it in the string. then write your own comparator and run sort using 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.
[algogeeks] Re: Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.
Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations. How about a circular doubly linked list for the push and pop, and then a priority queue for the min? -- 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: Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.
@above What is the complexity of the pop_front() operation? -- 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: Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.
@above What is the complexity of the pop_front() operation? O(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.
[algogeeks] Re: Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.
@above Really? When one removes head then, min element should be updated. -- 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] Symmetric matrix
I am wondering what data structure would best suit for this? - Azhar. On Wed, Jan 12, 2011 at 11:11 AM, Abdul Rahman Shariff ears7...@gmail.comwrote: i can tell 1 thing tht only (((n*n)-n)/2) +n elements are unique and the (((n*n)-n)/2) term is the one shoes the no of repeated elements and n represents the diagonal elements hope this gives some usefull info (i havent gone through any book nor do i guarantee optimal or best memory usage) On Wed, Jan 12, 2011 at 9:50 AM, Azhar Hussain azhar...@gmail.com wrote: I have a symmetric matrix. I am wondering what would be the best data structure to store such a matrix? How many elements do I need to store for a nxn matrix? Thanks in advance for the help. - Azhar. -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Ehab Abdul Rahman Shariff -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to 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] Symmetric matrix
One-dimensional array. 1 2 4 2 3 5 4 5 6 = [1, 2, 3, 4, 5, 6] Is your matrix summetric on a diagonal? -- 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: Sort string based upon the count of characters
@juver++ Thanks for hint. Problem solved. On Jan 13, 1:48 pm, juver++ avpostni...@gmail.com wrote: @Davin maintain count of each character, along with the first occurence of it in the string. then write your own comparator and run sort using 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.
[algogeeks] [amazon] data transfer
there are two systems and transfer a data of 1TB. The hardware is best possible available. Tell the conditions which will optimize the data transfer. -- 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] [amazon] data transfer
can you explain more? are you mean ec2? 2011/1/13 snehal jain learner@gmail.com there are two systems and transfer a data of 1TB. The hardware is best possible available. Tell the conditions which will optimize the data transfer. -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to 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] Symmetric matrix
Thanks for the help. It may not be symmetric on a diagonal. I have to consider both situations - Azhar. On Thu, Jan 13, 2011 at 3:37 PM, juver++ avpostni...@gmail.com wrote: One-dimensional array. 1 2 4 2 3 5 4 5 6 = [1, 2, 3, 4, 5, 6] Is your matrix summetric on a diagonal? -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to 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: Find The Looping Node
@snehal ..although ur approach ir good but u make d problem little complex,also missed out little checking, it can be done by using 2 pointers single while loop--Now Instruction(CPU) Matters. Rather then presenting different-2 algorithm i will present very famous algorithm Floyd’s Cycle-Finding Algorithm: it is the fastest method. Traverse linked list using two pointers. Move one pointer by one and other pointer by two. If these pointers meet at some node then there is a loop. If pointers do not meet then linked list doesn’t have loop. Time complexity O(n) Space Complexity O(1) Code-Snippet Below int is_loop(struct node *list) { struct node *slow_p = list, *fast_p = list; while(slow_p fast_p slow_p-next fast_p-next fast_p-next-next ) { slow_p = slow_p-next; fast_p = fast_p-next-next; if (slow_p == fast_p) { printf(Found Loop); return 1; } } return 0; } It Will Surely Works. Regards Shashank Mani Don't b Evil U Can Learn whilw U Earn -- 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: Amazon Analytical Puzzle
@dave how about this.. There are only 2 possible combinations when all labels are tagged incorrectly. All you need to do is pick one fruit from the one marked Apples + Oranges. If it's Apple, then change Apple + Orange to Apple The Apple one change to Orange The Orange one change to Apple + Orange If it's Orange, then change Apple + Orange to Orange The Apple one change to Apple + Orange The Orange one change to Apple Thanks Regrads Shashank Don't b Evil U Can Earn while U Learn -- 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: Find The Looping Node
@ above your code is only detecting loop.. my code is detecting loop and then removing loop as well On Thu, Jan 13, 2011 at 5:04 PM, bittu shashank7andr...@gmail.com wrote: @snehal ..although ur approach ir good but u make d problem little complex,also missed out little checking, it can be done by using 2 pointers single while loop--Now Instruction(CPU) Matters. Rather then presenting different-2 algorithm i will present very famous algorithm Floyd’s Cycle-Finding Algorithm: it is the fastest method. Traverse linked list using two pointers. Move one pointer by one and other pointer by two. If these pointers meet at some node then there is a loop. If pointers do not meet then linked list doesn’t have loop. Time complexity O(n) Space Complexity O(1) Code-Snippet Below int is_loop(struct node *list) { struct node *slow_p = list, *fast_p = list; while(slow_p fast_p slow_p-next fast_p-next fast_p-next-next ) { slow_p = slow_p-next; fast_p = fast_p-next-next; if (slow_p == fast_p) { printf(Found Loop); return 1; } } return 0; } It Will Surely Works. Regards Shashank Mani Don't b Evil U Can Learn whilw U Earn -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to 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] Adobe Question
1. 10 test cases for entering 3 values representing sides of a triangle and the program giving output as scalene, isosceles or equilateral--Means At Least 10 2 .Question on a program that calculates P=R/I where R, I are integer inputs and P a floating point output. Write 10 test cases for thisAt Least 10 Regards Shashank -- 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: Sort string based upon the count of characters
use linked list. to improve the look up performance, use a binary tree to map the objects in the linked list On Jan 13, 1:23 am, Davin dkthar...@googlemail.com wrote: Smaple Data : input : abcdacdc Output : cadb If the count is same for characters. maintain the original order of the characters from input string. Please do let me know for any clarification. -- 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: google paper/...plz help..its urgent
Answer for question 6 maybe b) also for question 7 maybe b) On Jan 12, 2:14 pm, snehal jain learner@gmail.com wrote: 1. Quick-sort is run on two inputs shown below to sort in ascending order (i) 1,2,3, ….,n (ii) n, n - 1, n - 2, …., 2, 1 Let C1 and C2 be the number of comparisons made for the inputs (i) and (ii) respectively. Then, a) C1 C2 b) C1 C2 c) C1 = C2 d) We cannot say anything for arbitrary n 2. Which of the following languages over {0, 1} is regular? a) 0i1j such that i ≤ j b) 0iw1j such that w ∈ {0, 1}∗ and i ≥ 0 c) All strings of 0s and 1s such that every pth character is 0 where p is prime d) None of the above 3. We are given a set X = {x1, x2, ..., xn} where xi = 2i. A sample S (which is a subset of X) is drawn by selecting each xi independently with probability pi = 1 / 2. The expected value of the smallest number in sample S is: a) 1 / n b) 2 c) sqrt(n) d) n 4. Let S be an NP-complete problem and Q and R be two other problems not known to be in NP. Q is polynomial time reducible to S and S is polynomial-time reducible to R. Which one of the following statements is true? a) R is NP-complete b) R is NP-hard c) Q is NP-complete d) Q is NP-hard 5. For any string s ∈ (0 + 1)*, let d(s) denote the decimal value of s (eg: d(101) = 5, d(011) = 3). Let L = {s ∈ (0+1)* | d(s) mod 5 = 2 and d(s) mod 7 = 4}. Which of the following statements is true? a) L is recursively enumerable, but not recursive b) L is is recursive, but not context-free c) L is context-free, but not regular d) L is regular Common data for questions 6 and 7 The 2n vertices of a graph G corresponds to all subsets of a set of size n. Two vertices of G are adjacent if and only if the corresponding sets intersect in exactly 2 elements 6. The number of vertices of degree zero in G is: a) 1 b) n c) 2n - 1 d) None 7. The number of connected components in G is: a) 2n b) n + 2 c) n C 2 d) None 8. There are 5 nested loops written as follows, int counter = 0; for (int loop_1=0; loop_1 10; loop_1++) { for (int loop_2=loop_1 + 1; loop_2 10; loop_2++) { for (int loop_3=loop_2 + 1; loop_3 10; loop_3++) { for (int loop_4=loop_3 + 1; loop_4 10; loop_4++) { for (int loop_5=loop_4 + 1; loop_5 10; loop_5++) { counter++;} } } } } What will be the value of counter in the end (after all the loops finished running)? a) 15C5 b) 14C5 c) 10C5 d) 10 * 9 * 8 * 7 * 6 * 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.
[algogeeks] Re: amazon questions
@snehal 1. Both are valid. 2. see taocp's sol. The probability of selecting AB to shoot is 1/3, so is BC,AC If AB were selected, the probability of hitting the target is (1- probability of both of them missed) = (1-(1-P(A)(1-P(B)), similar with case BC and AC. On Jan 11, 11:58 am, snehal jain learner@gmail.com wrote: 1. what is valid in cpp char *cp; const char* cpp; 1. cpp=cp 2. cp=cpp 2 there r 3 ppl A B C A can shoot the target 4 out of 5 times B can shoot 6 out of 7 times and C can shoot 8 out of times. 2 people r selected at random. then wat is the probability of hitting the target? -- 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: Sort string based upon the count of characters
sort on two keys, primary key is frequency, secondary key is occurrence. using namespace std; struct Item{ int freq; int occur; char chr; Item(){ freq = 0; occur = -1; chr = -1;}; }; bool sortItem(const Item a, const Item b){ if(a.freq != 0 b.freq != 0){ if(a.freq != b.freq){ return a.freq b.freq; }else{ return a.occur b.occur; } }else{ return b.freq a.freq; } } void sortBasedOnFreq(char *str){ Item *array = new Item[256]; for(int i = 0; str[i]!='\0'; i++){ int offset = str[i] + 128; array[offset].freq++; array[offset].chr = str[i]; if(array[offset].occur==-1){ array[offset].occur = i; } } std::sort(array, array+256, sortItem); for(int i = 0; i 256; i++){ if(array[i].freq0){ coutchar(array[i].chr) ; } } coutendl; } On Jan 13, 1:23 am, Davin dkthar...@googlemail.com wrote: Smaple Data : input : abcdacdc Output : cadb If the count is same for characters. maintain the original order of the characters from input string. Please do let me know for any clarification. -- 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] Coupon collector problem(Randomized algorithm problem)
Hi all, Can someone help me to solve this randomized algorithm related puzzle? Let p(t) = Probability (atmost k copies of coupon1 are collected at time t) If p(t)= (1/2n), then prove that the expected time to get k+1 copies of all n coupons =2t. With regards, Sugi -- 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] Coupon collector problem(Randomized algorithm problem)
Hi all, Can someone help me to solve this randomized algorithm related puzzle? Let p(t) = Probability (atmost k copies of coupon1 are collected at time t) If p(t)= (1/2n), then prove that the expected time to get k+1 copies of all n coupons =2t. -- 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: Symmetric matrix
You haven't provided enough information for anyone to give you any kind of reasonable answer. What language will you use to store manipulate the matrix? WHY do you wish to store the matrix? How BIG is the matrix that you anticipate storing? Do you need to store just one of them or several? What will you do with the matrix once it is stored? What type of algorithm do you intend to apply to the matrix data? Can you overwrite the matrix while you manipulate it? Do you need the same data over and over again? How much memory is available to you to use? Of course if none of the above matters, I'd say that you should just store it in a 2D array of some type. Of course, not all languages have 2D array capability. So... even this may be a bad answer. Side Note: This sounds a bit like a Homework problem??? You know, the kind that a teacher can't reasonably expect you to answer. Dan :-) -- 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: amazon c questn
Apart from that , In Unicode application each char would be 2 bytes in length and its always advisable to use malloc(sizeof(char) * 25) which seamlessly works fine in ASCII application as well. On Wed, Jan 12, 2011 at 7:20 AM, Kiran K kira...@gmail.com wrote: p= (char*)malloc(25); KK: p should be checked for null after this statment q = (char*)malloc(25); KK: q should be checked for null after this statement -Kiran On Jan 11, 9:44 pm, snehal jain learner@gmail.com wrote: what is the wrong in the program? main() { char *p,*q; p=(char *)malloc(25); q=(char *)malloc(25); strcpy(p,amazon); strcpy(q,hyd); strcat(p,q); printf(%sp); } -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to 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: [Athena 2011]
No need for calculating individual magic(x), just count the number of ordered list L with max(L)=11. Partition those ordered list by its gcd, and check each part, then you can see the trick. On 2011-1-13 11:06, Pratik Bhadkoliya wrote: For example, for 1: divisor is only 1 so, answer is magic(1) = 1 [since (1,1,1,1,1,...,1,1) is the only list possible.] for 2: divisors are 1 and 2 answer is [magic(1) + magic(2)] % 10^8 for 3: answer is [magic(1) + magic(3)] % 10^8 for 4: answer is [magic(1) + magic(2) + magic(4)] % 10^8 by ordered list means : (1,1,1,1,1,1,2) is different from (1,1,1,1,1,,2,1).. that is order of all integers in the list is important. some starting values of magic function magic(1) = 1 magic(2) = 67108862 magic(3) = 2541798719464 magic(4) = 4501057694433304 magic(5) = 1485612519757395128 magic(6) = 169091609518327614304 On Jan 12, 10:23 pm, ashish agarwalashish.cooldude...@gmail.com wrote: didn't get your question dude On Wed, Jan 12, 2011 at 10:39 PM, Pratik Bhadkoliya pkbhadkol...@gmail.comwrote: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) is an ordered list of positive integers Let magic(value) denote the number of such ordered lists that exist such that gcd(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)=1 AND max(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)=value Find the divisors of 11(18 -digits) . For each of the divisors D , compute magic(D) . Find the last 8 digits of the sum of all the magic(D) computed . -- 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.comalgogeeks%2Bunsubscribe@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] Modular Arithmetic
(a/b)mod m = (amodm)*(Bmodm) where B is the multiplicative inverse of b i.e (b*B)modM = 1 or B = 1/b Look into the wiki page of Multiplicative inverse for more. Hope this helps Cheers Nikhil Jindal On Wed, Jan 12, 2011 at 7:06 AM, mittal mohitm.1...@gmail.com wrote: Somehelp with (a/b)modm expression. http://en.wikipedia.org/wiki/Modular_arithmetic i visited this link but found only for addition,subtraction and multiplication. -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. Please access the attached hyperlink for an important electronic communications disclaimer: http://dce.edu/web/Sections/Standalone/Email_Disclaimer.php -- 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] Randomized Algorithm puzzle(coupon collector problem)
*Hi all,* *Can someone help me to solve this randomized algorithm related puzzle?* * * *Let p(t) = Probability (atmost k copies of coupon1 are collected at **time t)* *If p(t)= (1/2n), then prove that the expected time to get k+1 copies **of all n coupons =2t.* -- 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] Symmetric matrix
1 + 2 + + n ( max diagonal) = n ( n + 1) / 2. Max elements you can store is n ( n + 1) / 2 . You can take an array of size n (n + 1) / 2 and store them. Thanks, Sathaiah On Wed, Jan 12, 2011 at 9:50 AM, Azhar Hussain azhar...@gmail.com wrote: I have a symmetric matrix. I am wondering what would be the best data structure to store such a matrix? How many elements do I need to store for a nxn matrix? Thanks in advance for the help. - Azhar. -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to 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] Symmetric matrix
Well, u can use List of Lists. The List would contain head nodes of all the lists and each list would contain a row. The length of every list will be 1 greater than the next of it's next list. In this way: The tail of list would contain a diagonal element which L L1 1 L2 4 2 L3 4 3 4 L4 5 4 4 2 On Thu, Jan 13, 2011 at 2:50 PM, Azhar Hussain azhar...@gmail.com wrote: I am wondering what data structure would best suit for this? - Azhar. On Wed, Jan 12, 2011 at 11:11 AM, Abdul Rahman Shariff ears7...@gmail.com wrote: i can tell 1 thing tht only (((n*n)-n)/2) +n elements are unique and the (((n*n)-n)/2) term is the one shoes the no of repeated elements and n represents the diagonal elements hope this gives some usefull info (i havent gone through any book nor do i guarantee optimal or best memory usage) On Wed, Jan 12, 2011 at 9:50 AM, Azhar Hussain azhar...@gmail.comwrote: I have a symmetric matrix. I am wondering what would be the best data structure to store such a matrix? How many elements do I need to store for a nxn matrix? Thanks in advance for the help. - Azhar. -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Ehab Abdul Rahman Shariff -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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.
Re: [algogeeks] Re: Modular Arithmetic
On Thu, Jan 13, 2011 at 12:06 AM, Aviral Gupta aviral@gmail.com wrote: we can do it when hcf(b,m)=1 , in that case find inverse of b by extended euclidean mod m and then multiply it by a Yes. And when m is prime, B(mulitplicative inverse of b) = b^(m-2) As b^(m-1)mod m = 1 if m is prime. Regards Aviral http://coders-stop.blogspot.com/ On Jan 12, 6:36 am, mittal mohitm.1...@gmail.com wrote: Somehelp with (a/b)modm expression. http://en.wikipedia.org/wiki/Modular_arithmetic i visited this link but found only for addition,subtraction and multiplication. -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. Please access the attached hyperlink for an important electronic communications disclaimer: http://dce.edu/web/Sections/Standalone/Email_Disclaimer.php -- 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: Amazon Analytical Puzzle
Cut each slice into 8 equal pieces. Total 24 pieces. One part consists of 3 pieces. Total 8 parts. On Wed, Jan 12, 2011 at 6:14 PM, bittu shashank7andr...@gmail.com wrote: 2nd puzzle You have a birthday cake and have exactly 3 slices to cut it into 8 equal pieces. How do you do it? Thanks Regards Shashank -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. Please access the attached hyperlink for an important electronic communications disclaimer: http://dce.edu/web/Sections/Standalone/Email_Disclaimer.php -- 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-pour1
No BFS, only mathematics. Get the better one out of the 2 choices. (Maybe simulating each of the 2 choices also fits into the time limit, given the input range in the problem page.). On 2011-1-12 9:28, Bharath 2009503507 CSE wrote: i tried solving this prob... http://www.spoj.pl/problems/POUR1/ i tried using BFS...getting TLE in judge.. pl suggest some optimisation or better solution.. Thanks in advance.. Code: http://ideone.com/qIgcU -- 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: Amazon Analytical Puzzle
A similar question http://ocw.mit.edu/courses/mathematics/18-s34-problem-solving-seminar-fall-2007/18.s34-problem-solving-seminar-fall-2007-home-page-answer/ On 1/12/11, vaibhav shukla vaibhav200...@gmail.com wrote: @Dave: gud one :) On Wed, Jan 12, 2011 at 7:48 PM, Dave dave_and_da...@juno.com wrote: Open the box labeled apples and oranges and inspect one piece of fruit. Say that it is an apple. Then label this box apples since it cannot be apples and oranges or oranges. To identify the boxes that should be labeled oranges and apples and oranges, realize that since the remaining boxes are mislabeled, the one labeled oranges cannot contain only oranges, so it must be apples and oranges. And the last box is oranges. Deal with discovering an orange in the first box in a similar way. Dave On Jan 12, 6:52 am, bittu shashank7andr...@gmail.com wrote: 3rd Puzzle There are three boxes, one contains only apples, one contains only oranges, and one contains both apples and oranges. The boxes have been incorrectly labeled such that no label identifies the actual contents of the box it labels. Opening just one box, and without looking in the box, you take out one piece of fruit. By looking at the fruit, how can you immediately label all of the boxes correctly? Thanks Regards Shashank -- 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.comalgogeeks%2bunsubscr...@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. -- Rahul K Rai rahulpossi...@gmail.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.
[algogeeks] Re: palindrome
if you meant starting the leftmost 1, to check if its palindrome: unsigned int o = v; unsigned int r; for (r = 0; v; v = 1) { r = 1; r |= v 1; } if (o == r) printf(palindrome\n); else printf(not a palindrome\n); On Jan 12, 5:50 am, awesomeandroid priyaranjan@gmail.com wrote: @azhar good solution Thanks and Regards Priyaranjan code-forum.blogspot.com On Dec 22 2010, 1:55 pm, Azhar Hussain azhar...@gmail.com wrote: Hi, Here is the simple solution unsigned int r = v; // r will be reversed bits of v; first get LSB of v int s = sizeof(v) * CHAR_BIT - 1; // extra shift needed at end for (v = 1; v; v = 1) { r = 1; r |= v 1; s--; } r = s; // shift when v's highest bits are zero if (v == r) printf(palindrome\n); else printf(not a palindrome\n); source and more optimized versionshttp://www-graphics.stanford.edu/~seander/bithacks.html#BitReverseObv... - Azhar. On Wed, Dec 22, 2010 at 2:09 PM, pacific pacific pacific4...@gmail.comwrote: On Wed, Dec 22, 2010 at 12:11 PM, mohan@ismu mohan...@gmail.com wrote: if x is a 32 bit number if((x0x)==((x16)0x))) x's bit pattern is a polyndrome @snehal :Do you want to consider binary representation of 5 as 101 or ..0101 ? -- 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.comalgogeeks%2Bunsubscribe@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.comalgogeeks%2Bunsubscribe@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: amazon c questn
what is the wrong in the program? main() { char *p,*q; p=(char *)malloc(25); // check p==null q=(char *)malloc(25);//check q == null strcpy(p,amazon); strcpy(q,hyd); strcat(p,q); printf(%sp); } -- 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: No. of ways to Merge 2 arrays
The number of ways that n things can be positioned within 2n things is 2n choose n. This is equal to (2n!) / (n!)^2. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: No. of ways to Merge 2 arrays
Sorry I just noticed that Dave got it, too. -- 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] Building A Special Tree
A special type of tree is given, where all leaf are marked with L and others are marked with N. every node can have 0 or at most 2 nodes. Trees preorder traversal is given give a algorithm to build tree from this traversal. -- 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: amazon c questn
@Harish You are wrong. It doesn't matter when it is Unicode or ASCII application. Size of the char type is ALWAYS 1 byte. To use unicode characters introduce wchar_t or something related. -- 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] probability
An unbalanced dice (with 6 faces, numbered from 1 to 6) is thrown. The probability that the face value is odd is 90% of the probability that the face value is even. The probability of getting any even numbered face is the same. If the probability that the face is even given that it is greater than 3 is 0.75, which one of the following options is closest to the probability that the face value exceeds 3? (A) 0.453 (B) 0.468 (C) 0.485 (D) 0.492 -- 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.