[algogeeks] Can anyone tell algorithm for solving sudoku
*Thanks Regards *Deoki Nandan Vishwakarma -- 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:INUMBER
BFS Regards Vaibhav On , Anshul AGARWAL anshul.agarwa...@gmail.com wrote: hi friends,im not able to find any logic to solve this problem. Can any one suggest me good algorithm of spoj_problem: (INUMBER). thanx in advance -- 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] JAVA: Print all paths from root to leaf
@Mihir Just understood what you were asking... atul is nearly right. You got to remove the unused items from LinkedList after calling print(left,..) and print(right, ..), which might contain more than one item. Since I'm not a Java guy, I just wrote some snippet using F# to illustrate the idea. Hope it helps. type BinaryTree'a = | Node of BinaryTree'a * BinaryTree'a * 'a | None let rec PrintPath (root : BinaryTree'a) list = match root with | None - () | Node(left, right, value) - let list = value :: list PrintPath left list PrintPath right list if left = None right = None then printfn %A (List.rev list) let tree = Node(Node(Node(None, None, 1), Node(None, None, 5), 2), None, 7) let list = [] PrintPath tree list -- 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:INUMBER
@vaibhav plz explain how to apply bfs.. *Anshul Agarwal Nit Allahabad Computer Science** * On Mon, Jan 30, 2012 at 4:21 AM, vaibhavmitta...@gmail.com wrote: BFS Regards Vaibhav On , Anshul AGARWAL anshul.agarwa...@gmail.com wrote: hi friends,i m not able to find any logic to solve this problem. Can any one suggest me good algorithm of spoj_problem: (INUMBER). thanx in advance -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] JAVA: Print all paths from root to leaf
Although there is no pointer concept in java, but still underlying containers in java get passed through functions via there base address. What you want is to send a copy of your list again recursively. --- public static void paths(Node node, LinkedListInteger list) { if(node == null) return; list.add(node.data); if(node.left == null node.right == null) { print(list); } else { paths(node.left, list.clone()); paths(node.right, list.clone()); } } public static void print(LinkedListInteger list) { System.out.println(Contents of list: + list); } --- Regards Vaibhav Mittal NSIT, Dwarka On , Mihir Kulkarni mihirk...@gmail.com wrote: Hello,This method below is not giving correct paths. Can someone please tell me the mistake. public static void paths(Node node, LinkedList list) { if(node == null) return; list.add(node.data); if(node.left == null node.right == null) { print(list); } else { paths(node.left, list); paths(node.right, list); } } public static void print(LinkedList list) { System.out.println(Contents of list: + list); } eg: 7 / 2 / \ 1 5 It prints: 7 2 1 7 2 1 5 cheers,Mihir Kulkarni Graduate Student University of California, Irvine http://goo.gl/CvRcG -- 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.
[algogeeks] Re: Can anyone tell algorithm for solving sudoku
For each group (either a row, column, or square) keep track of what values it still needs. For each cell, if there is exactly one value needed by its row, column, and square, assign that value and update the needed values for the row, column, and square. Repeat until there is nothing more you can do with that method. Now, for each group, look at each value that it needs and determine where that value could be placed. If there is exactly one place where it could go, assign it there and update row, column, and square. If you get to the point where none of these methods succeed, you have to guess. Pick the cell with the smallest number of possible values. Plug them in one by one and try to solve from there. If it leads to a contradiction, back that guess out and try another. I think I posted code which does this a few months back. You can search for it if you are interested. Don On Jan 30, 2:07 am, Deoki Nandan deok...@gmail.com wrote: *Thanks Regards *Deoki Nandan Vishwakarma -- 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: JAVA: Print all paths from root to leaf
Right idea. But you only need to remove the last item once, right at the end of the function. Don On Jan 30, 1:01 am, atul anand atul.87fri...@gmail.com wrote: @Mihir : actually you are using linked listso you are keep on adding the nodes but not removing it..hence...you are getting wrong output.. i guess this should be done to fix the code. public static void paths(Node node, LinkedListInteger list) { if(node == null) return; list.add(node.data); if(node.left == null node.right == null) { print(list); } else { paths(node.left, list); * removeLastNodefromLinkedList();* paths(node.right, list); * removeLastNodefromLinkedList();* } r*emoveLastNodefromLinkedList();* } public static void print(LinkedListInteger list) { System.out.println(Contents of list: + list); } On Mon, Jan 30, 2012 at 11:41 AM, Mihir Kulkarni mihirk...@gmail.comwrote: I only intend to print the root to leaf paths. The correct output should be: 721 725 It works fine when I use array instead of LinkedList. cheers, Mihir Kulkarni Graduate Student University of California, Irvine http://goo.gl/CvRcG On Sun, Jan 29, 2012 at 10:06 PM, Rujin Cao drizzle...@gmail.com wrote: Is the correct output 7 2 1 5 ? Did you intend to print the leaf node ? -- 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.- Hide quoted text - - Show quoted text - -- 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: JAVA: Print all paths from root to leaf
@don : right didn't check the flow of code correctly On Mon, Jan 30, 2012 at 9:53 PM, Don dondod...@gmail.com wrote: Right idea. But you only need to remove the last item once, right at the end of the function. Don On Jan 30, 1:01 am, atul anand atul.87fri...@gmail.com wrote: @Mihir : actually you are using linked listso you are keep on adding the nodes but not removing it..hence...you are getting wrong output.. i guess this should be done to fix the code. public static void paths(Node node, LinkedListInteger list) { if(node == null) return; list.add(node.data); if(node.left == null node.right == null) { print(list); } else { paths(node.left, list); * removeLastNodefromLinkedList();* paths(node.right, list); * removeLastNodefromLinkedList();* } r*emoveLastNodefromLinkedList();* } public static void print(LinkedListInteger list) { System.out.println(Contents of list: + list); } On Mon, Jan 30, 2012 at 11:41 AM, Mihir Kulkarni mihirk...@gmail.com wrote: I only intend to print the root to leaf paths. The correct output should be: 721 725 It works fine when I use array instead of LinkedList. cheers, Mihir Kulkarni Graduate Student University of California, Irvine http://goo.gl/CvRcG On Sun, Jan 29, 2012 at 10:06 PM, Rujin Cao drizzle...@gmail.com wrote: Is the correct output 7 2 1 5 ? Did you intend to print the leaf node ? -- 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.- Hide quoted text - - Show quoted text - -- 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.
[algogeeks] Disjoint Set data structure
Hi, The disjoint set data structure has FIND and UNION operations for optimized versions of Find we use path compression and for union we use union by rank, which costs O(M log* n) , n is the input size and M the no. of makeset opns. log* n is inverse ackermann's function Can anyone tell me how inverse ackermann's function is related to this method . pls suggest me any idea or article Thanx in advance -- 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] Reverse Engg.
hi, can anyone tell me how i can convert exe back to c source? -- 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] JAVA: Print all paths from root to leaf
+1 @atul anand On Mon, Jan 30, 2012 at 12:31 PM, atul anand atul.87fri...@gmail.comwrote: @Mihir : actually you are using linked listso you are keep on adding the nodes but not removing it..hence...you are getting wrong output.. i guess this should be done to fix the code. public static void paths(Node node, LinkedListInteger list) { if(node == null) return; list.add(node.data); if(node.left == null node.right == null) { print(list); } else { paths(node.left, list); * removeLastNodefromLinkedList();* paths(node.right, list); * removeLastNodefromLinkedList();* } r*emoveLastNodefromLinkedList();* } public static void print(LinkedListInteger list) { System.out.println(Contents of list: + list); } On Mon, Jan 30, 2012 at 11:41 AM, Mihir Kulkarni mihirk...@gmail.comwrote: I only intend to print the root to leaf paths. The correct output should be: 721 725 It works fine when I use array instead of LinkedList. cheers, Mihir Kulkarni Graduate Student University of California, Irvine http://goo.gl/CvRcG On Sun, Jan 29, 2012 at 10:06 PM, Rujin Cao drizzle...@gmail.com wrote: Is the correct output 7 2 1 5 ? Did you intend to print the leaf node ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Thanks Regards Saurabh Yadav -- 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] kth largest element in two sorted arrays
Hi, I am trying to write code for this problem but having issues. Can you help Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 -- 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 Max Sum Value Pairs
how to do it DP way? Anyone with code? Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Sat, Sep 3, 2011 at 9:00 PM, Dave dave_and_da...@juno.com wrote: @Piyush: Try your code with n = 10 a[10] = {11,22,33,44,55,66,77,88,99,110} b[10] = {10,20,30,40,50,60,70,80,90,100} Your code gets (110, 100) = 210 (110, 90) = 200 (99, 100) = 199 (110, 80) = 190 (88, 100) = 188 (110, 70) = 180 (77, 100) = 177 (110, 60) = 170 (66, 100) = 166 (110, 50) = 160 but it should get (110, 100) = 210 (110, 90) = 200 (99, 100) = 199 (110, 80) = 190 (99, 90) = 189 (88, 100) = 188 (110, 70) = 180 (99, 80) = 179 (88, 90) = 178 (77, 100) = 177 It fails because, after choosing the first four pairs, it does not consider all three candidates, (110, 70) = 180, (99, 90) = 189, and (88, 100) = 188. It only looks at the first and last of these. Later on, it fails to consider (99, 80) = 179 and (88, 90) = 178. After you have chosen the maximum pair, every unused pair that is the last unused pair in both its row and column of the (implicit) n by n matrix of pairwise sums is a candidate. When you have chosen n-1 pairs, there can be O(sqrt(n)) candidates for the last choice. You are considering only two of them. Dave On Sep 2, 3:09 pm, Piyush Grover piyush4u.iit...@gmail.com wrote: if I have understood the question correctly then: a[n-1] + b[i] a[j] + b[i] for all 0 = j n-1 and a[j] + b[n-1] a[j] + b[i] for all 0 = i n-1 therefore, i = j =n-1; count = 1; S[0] -- (a[n-1], b[n-1]) p = a[n-1] + b[n-2]; q = a[n-2] + b[n-1] while(count n){ if(p q){ j--; S[count++] -- (a[n-1], b[j]); }else{ i--; S[count++] -- (a[i], b[n-1]); } p = a[n-1] + b[j-1]; q = a[i-1] + b[n-1]; } Time complexity: O(n) : http://ideone.com/FXfVj On Fri, Sep 2, 2011 at 10:05 PM, WgpShashank shashank7andr...@gmail.com wrote: @Dave Correct , Missed to Provide the Correct Time Complexity in Worst Case it Will be O(N^2) , as we need to find out n such maximum pair , will think about O(N0) Algo, if able to do it, will post the Algo here Thanks Shashank Mani Computer Science Birla Institute of Technology,Mesra -- 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/-/a14Pj22tbJgJ. 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.- Hide quoted text - - Show quoted text - -- 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] Reverse Engg.
its not possible to convert exe back to C. u can get the assembly code of that only. for that u can use the tool IDA or olly debugger -- 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: Represent a number in base of minus 2 ????
@zyro May be this solves your problem... #include iostream using namespace std; int main() { int no; char digit[50]; int counter=0; cin no; do { if ( no% 2 == 0) { digit[counter++]='0'; } else { digit[ counter++ ]='1'; } if ( no 0 ){ no = (1 - no)/2; } else if(no0){ no = -no/2; } } while ( no ); for ( int i = counter- 1; i = 0; i--) { cout digit[ i ] ; } cout endl; return 0; } On Sun, Jan 29, 2012 at 8:51 PM, saurabh singh saurab...@gmail.com wrote: Use a pen and paper:) Generate a few numbers in base -2 by hand.You will get the logic. Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Sun, Jan 29, 2012 at 11:44 PM, Zyro vivkum...@gmail.com wrote: 0 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- -Sharad Dixit B.Tech(IT) Indian Institute of Information Technology Allahabad - We aim above the mark to hit the mark. ~ Ralph Waldo Emerson -- 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] JAVA: Print all paths from root to leaf
use array, not clear on JAVA front though, but logic is fine, pass the vector and index instead Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Mon, Jan 30, 2012 at 11:04 AM, Mihir Kulkarni mihirk...@gmail.comwrote: Hello, This method below is not giving correct paths. Can someone please tell me the mistake. public static void paths(Node node, LinkedListInteger list) { if(node == null) return; list.add(node.data); if(node.left == null node.right == null) { print(list); } else { paths(node.left, list); paths(node.right, list); } } public static void print(LinkedListInteger list) { System.out.println(Contents of list: + list); } e.g: 7 / 2 / \ 1 5 It prints: 7 2 1 7 2 1 5 cheers, Mihir Kulkarni Graduate Student University of California, Irvine http://goo.gl/CvRcG -- 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] kth largest element in two sorted arrays
to find kth largest element in the 2 sorted array can be done by simple merge... obv no need for extra space...two indexes will do. you just need to check arr1[i...n] == arr2[j..m] if(arr1[i] arr2[j]) { cnt++; index=arr2[j]; j++; } else { cnt++; index=arr1[i]; i++; } if(k==cnt) { print kthe largest element is at position arr[index] break; } On Tue, Jan 31, 2012 at 1:15 AM, Ashish Goel ashg...@gmail.com wrote: Hi, I am trying to write code for this problem but having issues. Can you help Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 -- 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.
[algogeeks] Re: Represent a number in base of minus 2 ????
@Sharad.. Thanx.. :) On Jan 31, 2:42 am, sharad dixit sharad.emine...@gmail.com wrote: @zyro May be this solves your problem... #include iostream using namespace std; int main() { int no; char digit[50]; int counter=0; cin no; do { if ( no% 2 == 0) { digit[counter++]='0'; } else { digit[ counter++ ]='1'; } if ( no 0 ){ no = (1 - no)/2; } else if(no0){ no = -no/2; } } while ( no ); for ( int i = counter- 1; i = 0; i--) { cout digit[ i ] ; } cout endl; return 0; } On Sun, Jan 29, 2012 at 8:51 PM, saurabh singh saurab...@gmail.com wrote: Use a pen and paper:) Generate a few numbers in base -2 by hand.You will get the logic. Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Sun, Jan 29, 2012 at 11:44 PM, Zyro vivkum...@gmail.com wrote: 0 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- -Sharad Dixit B.Tech(IT) Indian Institute of Information Technology Allahabad --- -- We aim above the mark to hit the mark. ~ Ralph Waldo Emerson -- 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: kth largest element in two sorted arrays
@Atul: Yours is an O(k) algorithm. Is there an O(log k) solution? Dave On Jan 30, 9:56 pm, atul anand atul.87fri...@gmail.com wrote: to find kth largest element in the 2 sorted array can be done by simple merge... obv no need for extra space...two indexes will do. you just need to check arr1[i...n] == arr2[j..m] if(arr1[i] arr2[j]) { cnt++; index=arr2[j]; j++; } else { cnt++; index=arr1[i]; i++; } if(k==cnt) { print kthe largest element is at position arr[index] break; } On Tue, Jan 31, 2012 at 1:15 AM, Ashish Goel ashg...@gmail.com wrote: Hi, I am trying to write code for this problem but having issues. Can you help Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 -- 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: kth largest element in two sorted arrays
@dave: checkout this link:- http://www.geeksforgeeks.org/archives/2105 algo given in this link has complexity of O(log n) .btw i have doubt if they would work if two array are of different size. for O(log k) ...thinking On Tue, Jan 31, 2012 at 11:06 AM, Dave dave_and_da...@juno.com wrote: @Atul: Yours is an O(k) algorithm. Is there an O(log k) solution? Dave On Jan 30, 9:56 pm, atul anand atul.87fri...@gmail.com wrote: to find kth largest element in the 2 sorted array can be done by simple merge... obv no need for extra space...two indexes will do. you just need to check arr1[i...n] == arr2[j..m] if(arr1[i] arr2[j]) { cnt++; index=arr2[j]; j++; } else { cnt++; index=arr1[i]; i++; } if(k==cnt) { print kthe largest element is at position arr[index] break; } On Tue, Jan 31, 2012 at 1:15 AM, Ashish Goel ashg...@gmail.com wrote: Hi, I am trying to write code for this problem but having issues. Can you help Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] kth largest element in two sorted arrays
i think this can be done much faster similar to findling median of two sorted arrays by proceeding with comparing medians of two arrays and then reducing the data set to approx 3/4th of 2n. I am looking for that algo if osmeone have. Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Tue, Jan 31, 2012 at 9:26 AM, atul anand atul.87fri...@gmail.com wrote: to find kth largest element in the 2 sorted array can be done by simple merge... obv no need for extra space...two indexes will do. you just need to check arr1[i...n] == arr2[j..m] if(arr1[i] arr2[j]) { cnt++; index=arr2[j]; j++; } else { cnt++; index=arr1[i]; i++; } if(k==cnt) { print kthe largest element is at position arr[index] break; } On Tue, Jan 31, 2012 at 1:15 AM, Ashish Goel ashg...@gmail.com wrote: Hi, I am trying to write code for this problem but having issues. Can you help Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.