[algogeeks] Re: There is an array of odd and even numbers. Now, sort them in such a way that the top portion of the array contains odd numbers, bottom portion contains even numbers
I think in this case, bubble sorting will be a better idea. just replace the condition of comparison with the condition that earlier number is even and later number is odd. I mean we can do sumthing lyk this : for i=1 to n-1 for j=1 to n-i-1 if iseven(ar[j]) AND (NOT iseven(ar[j+1])) then swap both of them. Please correct me if I am wrong somewhere. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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] sum k in sub array
@amir ur algo works only for positive elements array.. correct me if m wrong On 23 June 2010 00:28, Amir hossein Shahriari amir.hossein.shahri...@gmail.com wrote: for each element find sum[i] which is the summation of all elements with index less than or equal to i ( note that this array is always sorted) this can be done in O(n) then sum[i]-sum[j] when ji is the sum of range [j,i] then for each sum[i] binary search for sum[i]-k in the array sum which yields the overall running time of O(nlogn) On Tue, Jun 22, 2010 at 7:48 PM, sharad kumar sharad20073...@gmail.comwrote: How will you find the subarray whose sum is k in an array of negative and positive numbers -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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 algoge...@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 algoge...@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] Max(Xor (X([i],X[j]))
add all the elements in a trie tree and then search all the elements for their best matching complement -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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: There is an array of odd and even numbers. Now, sort them in such a way that the top portion of the array contains odd numbers, bottom portion contains even numbers
Hi Jagadish, Anurag's algo has O(n) for pre-processing. After that any sorting algorithm will be applied there also. On Wed, Jun 23, 2010 at 7:22 PM, Jagadish M jagadis...@gmail.com wrote: Why not just change the definition of when one number is bigger than another and do normal sort ? I guess that is better and simpler. Normal sort takes O(n log n), while Anurag's algo is O(n). Regards, Jagadish http://www.cse.iitb.ac.in/~jagadishhttp://www.cse.iitb.ac.in/%7Ejagadish On Jun 20, 2:18 pm, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: Why not just change the definition of when one number is bigger than another and do normal sort ? I guess that is better and simpler. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombayhttp://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 On Sun, Jun 20, 2010 at 7:52 AM, Anurag Sharma anuragvic...@gmail.com wrote: Keep 2 pointers 'start' and 'end' and make them point to start and beginning of the array. Now keep decresing *end* pointer until an odd element is found Keep increasing the *start* pointer until an even element is found swap the elements at start and end Continue the above 3 steps till startend Now the start/end points to a border element which divides the array in 2 parts, 1st have having all odd numbers and 2nd half with all even numbers. Now use any inplace sorting algorithm to sort in descending order the portion containing all odd numbers and in increasing order the portion containing all even numbers. Hope its clear. Anurag Sharma On Sun, Jun 20, 2010 at 2:15 AM, vijay auvija...@gmail.com wrote: There is an array of odd and even numbers. Now, sort them in such a way that the top portion of the array contains odd numbers, bottom portion contains even numbers. The odd numbers are to be sorted in descending order and the even numbers in ascending order. You are not allowed to use any extra array and it has to use a conventional sorting mechanism and should not do any pre or post processing -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%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 algoge...@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. -- Regards Bhanu Mobile +91 9886738496 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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] getting smallest 1 million numbers....
make a max-heap of size 1 million and insert the first 1 million numbers in it for each new number from hard disk compare it to the maximum element of the heap if it's bigger than max check next element else extract-max from heap and insert the new element the running time would be 1 trillion x log (1 million ) On 6/23/10, amit amitjaspal...@gmail.com wrote: Given a set of 1 Trillion integers on hard disk, find the smallest 1 million of them. You can fit at most 1 million integers in memory at a time. State the fastest solution you can think of. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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 algoge...@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] Next higher element
@Kumar: The next higher of 5 will be 7 as it comes first in the array. On Wed, Jun 23, 2010 at 5:28 PM, Kumar Vishal kumar...@gmail.com wrote: hi the number should be just next higher element or any higher element like if my arr is like arr= 2 5 1 3 7 6 the next higher element for 5 should be what (7 or 6 ) because 6 is more closer to 7 but 7 comes first in arr On Wed, Jun 23, 2010 at 11:18 AM, Raj N rajn...@gmail.com wrote: Design a data structure to find the next higher element for each element in an array. For e.g. if array is 1 2 3 4 5 8 6 o/p should be (element) (next higher element) 1 2 2 3 3 4 4 5 5 8 8 nothing 6 nothing The array need not be sorted. Constraints-O(n) time complexity -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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. -- Kumar Vishal StAy HunGrY , StAy fOOlisH Contact No:- 09560193839 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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 algoge...@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] check divisibility
let n be the number. a) if n is zero, then it is of the form 2^k-1. b) if n is negative then replace n with -n. c) take m=n+1. d) check if m(m-1)==0 then n is of the form 2^k-1, otherwise not. On 6/23/10, divya sweetdivya@gmail.com wrote: u are given any binary no.. u have to check its divisbility by 3,7,15, 31..(any no. of the form 2^x-1) .u cant use any division and modulo operator for that. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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 algoge...@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: Where to Set the POST-OFFICE
Use median, it solves the problem I think. Thanks, Sathaiah On Thu, Jun 24, 2010 at 12:21 AM, Dave dave_and_da...@juno.com wrote: Let the given points be x_i, i = 1, 2, ..., n. For any point x on the line, let f(x) = sum_{i=1}^n | x - x_i |. Then, from calculus, we know that f(x) attains its extreme point at a point where its derivative is zero or undefined. Because of the absolute value signs, the derivative is undefined at the x_i. Since f(x) is linear between adjacent x_i, it suffices to check only f(x_i) in search of the minimum. As you proceed toward the right from the leftmost x_i, the function decreases as long as there are more x_i to the right of x than to the left, and increases whenever there are more x_i to the left than to the right. Hence, if N is odd, the minimum occurs at the median of the {x_i}. If N is even, the post office can be anywhere in the center interval. Dave On Jun 23, 7:18 am, amit amitjaspal...@gmail.com wrote: There are N points on a LINE. U neeed to place a post office such that its total distance from each of the N points is minimised. The post office need not necessarily be on one of the N Points. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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 algoge...@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] check divisibility
sorry my solution is wrong i missed that the number should be divisible by a number of that type. On 6/24/10, nisha goyal nisha.goyal1...@gmail.com wrote: let n be the number. a) if n is zero, then it is of the form 2^k-1. b) if n is negative then replace n with -n. c) take m=n+1. d) check if m(m-1)==0 then n is of the form 2^k-1, otherwise not. On 6/23/10, divya sweetdivya@gmail.com wrote: u are given any binary no.. u have to check its divisbility by 3,7,15, 31..(any no. of the form 2^x-1) .u cant use any division and modulo operator for that. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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 algoge...@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] triplets summing to zero
sort the array for each element a[i] find two elements that sum to -a[i] (this can be done in O(n) ) the overall time is O(n^2) On 6/23/10, Raj N rajn...@gmail.com wrote: Given a list of n integers?(negative and positive), not sorted and duplicates allowed, you have to output the triplets which sum upto 0. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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 algoge...@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] linked list
Keep a pointer list1 at the beginning of one of the lists, and call the function below on the other list. int reverseCheck(NODE *p) { list2=p; if(list2-next==NULL) return; reverseCheck(list2-next); if(list2-next-data==list1-data) list1=list1-next; else flag=0; return flag; } On Wed, Jun 23, 2010 at 6:00 PM, divya jain sweetdivya@gmail.comwrote: if we dont want to change original list.. is there ny efficient method for that? On 23 June 2010 06:49, ANUJ KUMAR kumar.anuj...@gmail.com wrote: reverse one of the linked lists in O(n) time and then see if the resulting one is same as the other one On Wed, Jun 23, 2010 at 1:56 AM, divya sweetdivya@gmail.com wrote: Two link lists are given ...check if one is reverse of other. Do it without using extra space. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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 algoge...@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 algoge...@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 algoge...@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] Maximum subset of cuboid boxes
Hi Raj, What if the boxes are given in some different order. The solution given depends very much on the order in which boxes are given. On Wed, Jun 23, 2010 at 2:10 PM, Raj N rajn...@gmail.com wrote: Given a lot of cuboid boxes with different length, breadth and height. We need to find the maximum subset which can fit into each other. For example: If Box 1 has LBH as 7 8 9 If Box 2 has LBH as 5 6 8 If Box 3 has LBH as 5 8 7 If Box 4 has LBH as 4 4 4 then answer is 1,2,4 A box can fit into another only and only if all dimensions of that is less than the bigger box.Rotation of boxes is not possible. My approach: Constructing trees... Box 1 dim: 7,8,9 Make it as root1. The root also has a counter associated with it. Now count1=1. Then Box 2 dim: 5,6,8 7,8,9. Make it as a left child of root1 and count1=2. Box 3 dim: 5,8,7 doesn't fit in any and hence make it a tree by itself i.e root2 its count2=1. Box 4 dim: 4,4,4 it can be made as the left child of box 2 as well as Box 3. count1=3, count2=2. Print the reverse inorder traversal of the highest counter valued tree. Please correct me if I'm wrong. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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. -- Regards Bhanu Mobile +91 9886738496 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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: getting smallest 1 million numbers....
@ above can u plz specify how to sort a 1 Tb file with 64 bytes of Ram. I got this heap methodbut ur approach seems interesting ..if u can give some links dat wud be very appreciated.. On Thu, Jun 24, 2010 at 1:01 AM, Douglas Diniz dgdi...@gmail.com wrote: If you have a memory that has less than 1 million integers, you have to sort through co-sequential process (File Structures in C++, Folk), that use heapsort too, and list the first 1 million integers from the sorted file. With this method you can have only 64bytes of Ram (or less, depending of your file register size) to sort a 1Tb file. On Wed, Jun 23, 2010 at 4:06 PM, Dave dave_and_da...@juno.com wrote: Form the first million numbers into a max-heap, where the largest number at the root. Any number in the input file that is larger than the root can be ignored. If it is smaller than the root, replace the root with the number and trickle it down the heap to restore the heap condition. Worst case is if the file is in descending order, in which case, there are about 2 * 0.99 trillion * log_2(1 million) data comparisons. Dave On Jun 23, 7:18 am, amit amitjaspal...@gmail.com wrote: Given a set of 1 Trillion integers on hard disk, find the smallest 1 million of them. You can fit at most 1 million integers in memory at a time. State the fastest solution you can think of. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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 algoge...@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 algoge...@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] Trie
Hi, Can anyone explain me the implementation of trie. I would be grateful if one could provide me the link to a good learning resource. Thanks!! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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] Next higher element
push the elements into stack , when the element to be pushed is greater than the 'top' element.. pop the elements and write then eg : if array is 1 2 3 4 5 8 6 insert 1 - stack : 1 insert 2 ( as 2 top i.e 1) - output 1 - 2 stack : 2 insert 3 ( as 3 top i.e 2) - output 1-2, 2-3 stack 3 . . . insert 8 ( as 8 top i.e 5) -- output 1-2, 2-3,3-4,4-5 stack 8 insert 6 --- output 1-2, 2-3,3-4,4-5,5-8 stack 8,6 final output : 1-2, 2-3,3-4,4-5,5-8,8- -1 , 6 - -1 On Wed, Jun 23, 2010 at 10:48 PM, Raj N rajn...@gmail.com wrote: @Kumar: The next higher of 5 will be 7 as it comes first in the array. On Wed, Jun 23, 2010 at 5:28 PM, Kumar Vishal kumar...@gmail.com wrote: hi the number should be just next higher element or any higher element like if my arr is like arr= 2 5 1 3 7 6 the next higher element for 5 should be what (7 or 6 ) because 6 is more closer to 7 but 7 comes first in arr On Wed, Jun 23, 2010 at 11:18 AM, Raj N rajn...@gmail.com wrote: Design a data structure to find the next higher element for each element in an array. For e.g. if array is 1 2 3 4 5 8 6 o/p should be (element) (next higher element) 1 2 2 3 3 4 4 5 5 8 8 nothing 6 nothing The array need not be sorted. Constraints-O(n) time complexity -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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. -- Kumar Vishal StAy HunGrY , StAy fOOlisH Contact No:- 09560193839 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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 algoge...@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 algoge...@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 next number for a given number without using any arithmetic operators(use bit operations)
@Dave Can u plz explain the logic behind this.. Mohit On Thu, Jun 24, 2010 at 12:44 AM, Dave dave_and_da...@juno.com wrote: c = 1 repeat d = n and c n = n xor c c = d left shifted by 1 until c = 0 Dave On Jun 23, 11:05 am, vijay auvija...@gmail.com wrote: Find the next number for a given number without using any arithmetic operators(use bit operations) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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 algoge...@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: Trie
Think of a datastructure where you can search any alphabetic string in the X steps (X = number of characters in string). So basically it can be a tree with 27 childs per internal node. So according to binary search rule and help of one simple link list, this tree can fetch you any string in X steps. So this tree is Trie. -Regards Amit Agarwal blog.amitagrwal.com On Thu, Jun 24, 2010 at 3:39 PM, Dhritiman Das dedhriti...@gmail.comwrote: Useful links: http://www.cs.mcgill.ca/~cs251/OldCourses/1997/topic7/http://www.cs.mcgill.ca/%7Ecs251/OldCourses/1997/topic7/ http://www.allisons.org/ll/AlgDS/Tree/Trie/ http://www.allisons.org/ll/AlgDS/Tree/Suffix/ On Jun 23, 11:24 pm, Raj N rajn...@gmail.com wrote: Hi, Can anyone explain me the implementation of trie. I would be grateful if one could provide me the link to a good learning resource. Thanks!! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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 algoge...@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] Array Problem
Sorry, this point is already pointed out by Sharad. Anurag Sharma On Thu, Jun 24, 2010 at 4:42 PM, Anurag Sharma anuragvic...@gmail.comwrote: @jalaj Your approach will not work, what I perceived from your solution, as in question the maximum difference S is defined as:- S = a[i] - a[j] where* ij * Perhaps you forgot that the 'order' of the max and min also matters :) Anurag Sharma On Mon, Jun 21, 2010 at 10:34 PM, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote: traverse the array ...take two variables min and max ... and update them ...while traversing. finally min will contain the most negative value,,, and max will contain the most positive vale... do max-min.. that will be S On Mon, Jun 21, 2010 at 5:38 PM, amit amitjaspal...@gmail.com wrote: There is an integer array consisting positive and negative integers. Find maximum positive difference S defined as: S = a[i] - a[j] where ij and S 0 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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. -- With Regards, Jalaj Jaiswal +919026283397 B.TECH IT 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 algoge...@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 algoge...@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] triplets summing to zero
Its a repeated question. Kindly search the archives for detailed discussion. Anurag Sharma On Wed, Jun 23, 2010 at 10:55 PM, Amir hossein Shahriari amir.hossein.shahri...@gmail.com wrote: sort the array for each element a[i] find two elements that sum to -a[i] (this can be done in O(n) ) the overall time is O(n^2) On 6/23/10, Raj N rajn...@gmail.com wrote: Given a list of n integers?(negative and positive), not sorted and duplicates allowed, you have to output the triplets which sum upto 0. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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 algoge...@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 algoge...@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] Array Problem
@jalaj Your approach will not work, what I perceived from your solution, as in question the maximum difference S is defined as:- S = a[i] - a[j] where* ij *Perhaps you forgot that the 'order' of the max and min also matters :) Anurag Sharma On Mon, Jun 21, 2010 at 10:34 PM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote: traverse the array ...take two variables min and max ... and update them ...while traversing. finally min will contain the most negative value,,, and max will contain the most positive vale... do max-min.. that will be S On Mon, Jun 21, 2010 at 5:38 PM, amit amitjaspal...@gmail.com wrote: There is an integer array consisting positive and negative integers. Find maximum positive difference S defined as: S = a[i] - a[j] where ij and S 0 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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. -- With Regards, Jalaj Jaiswal +919026283397 B.TECH IT 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 algoge...@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 algoge...@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] call mobile from internet for free
call mobile from internet for free http://voip-sofa.blogspot.com/ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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: There is an array of odd and even numbers. Now, sort them in such a way that the top portion of the array contains odd numbers, bottom portion contains even numbers
Hi, how about this - Do a merge sort, now, while merging two sorted list, give more priority to odd numbers :) I believe this falls into the right solutions :) Any breaking cases? On 24 June 2010 09:41, Gaurav Singh gogi.no...@gmail.com wrote: I think in this case, bubble sorting will be a better idea. just replace the condition of comparison with the condition that earlier number is even and later number is odd. I mean we can do sumthing lyk this : for i=1 to n-1 for j=1 to n-i-1 if iseven(ar[j]) AND (NOT iseven(ar[j+1])) then swap both of them. Please correct me if I am wrong somewhere. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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. -- Reduce, Reuse and Recycle Regards, Vivek.S -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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] BST
I think in-order traversal would solve the problem. On Thu, Jun 24, 2010 at 4:24 PM, Anurag Sharma anuragvic...@gmail.comwrote: I once posted it to my blog. Perhaps its the same you are asking : http://anuragsharma-sun.blogspot.com/2010/03/converting-bst-to-circular-doubly.html Anurag Sharma On Mon, Jun 21, 2010 at 1:55 PM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote: CAN ANY 1 GIVE THE ALGORITHM.. HOW TO CONVERT BST TO dLL -- With Regards, Jalaj Jaiswal +919026283397 B.TECH IT 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 algoge...@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 algoge...@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. -- Thanks, Chakravarthi. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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.