Re: [algogeeks] function overloading query
http://www.ideone.com/JQFNh CHECK THE OUTPUT THERE IS NO AMBIGUITY BUT PLEASE EXPLAIN THE RESULTS On Sun, Nov 20, 2011 at 11:00 PM, Akash Coder akash.coder.g...@gmail.comwrote: it wont work even this wont function(char a[]) function (char *) coz the two forms are interchangeable On Sun, Nov 20, 2011 at 10:12 PM, saurabh singh saurab...@gmail.comwrote: wont work..Thre is no way compilers gonna guess which function to call.The const qualifier only guarantees that the value at the address wont be altered inside the function.That has nothing to do with calling, On Sun, Nov 20, 2011 at 9:50 PM, rahul vatsa vatsa.ra...@gmail.comwrote: yes, it will work. On Sun, Nov 20, 2011 at 9:12 PM, Akash Coder akash.coder.g...@gmail.com wrote: no it wont work ... const is not a datatype. its a qualifier On Sun, Nov 20, 2011 at 7:49 PM, rahul sharma rahul23111...@gmail.comwrote: void fun(char *) void fun(const char *) is this overloading works or these are same type of arguments?? -- 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. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @MNNIT ALLAHABAD* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Silly question
As already told by others try solving as many problems if possible try solving exercise of Alen Weiss, book, it will improve ur problem soving skills On Nov 20, 10:48 pm, Akash Coder akash.coder.g...@gmail.com wrote: yup... solve new varieties of problem... u will get used to it On Sun, Nov 20, 2011 at 11:09 PM, amrit harry dabbcomput...@gmail.comwrote: i have a silly question to ask. im gud in ALGO and gud in DATA STR. but i can solve a problem if i know the algorithm or if earlier faced it. i can't able to think my own logics and solve new mathematical problems. even i dont know about how to come up with new TEST DATA. i knw we can develop this skill only by practice. but is there any method or steps to be followed during solving a problem? -- 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] function overloading query
this is what i am getting after executing code meintion in the above link. (using gcc compiler ) temp.c:12: error: conflicting types for 'fun' temp.c:7: error: previous definition of 'fun' was here On Mon, Nov 21, 2011 at 3:09 PM, UTKARSH SRIVASTAV usrivastav...@gmail.comwrote: http://www.ideone.com/JQFNh CHECK THE OUTPUT THERE IS NO AMBIGUITY BUT PLEASE EXPLAIN THE RESULTS On Sun, Nov 20, 2011 at 11:00 PM, Akash Coder akash.coder.g...@gmail.comwrote: it wont work even this wont function(char a[]) function (char *) coz the two forms are interchangeable On Sun, Nov 20, 2011 at 10:12 PM, saurabh singh saurab...@gmail.comwrote: wont work..Thre is no way compilers gonna guess which function to call.The const qualifier only guarantees that the value at the address wont be altered inside the function.That has nothing to do with calling, On Sun, Nov 20, 2011 at 9:50 PM, rahul vatsa vatsa.ra...@gmail.comwrote: yes, it will work. On Sun, Nov 20, 2011 at 9:12 PM, Akash Coder akash.coder.g...@gmail.com wrote: no it wont work ... const is not a datatype. its a qualifier On Sun, Nov 20, 2011 at 7:49 PM, rahul sharma rahul23111...@gmail.com wrote: void fun(char *) void fun(const char *) is this overloading works or these are same type of arguments?? -- 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. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @MNNIT ALLAHABAD* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Silly question
@Mustafa : are you talking about this book?? Data Structures and Algorithm Analysis in C++ http://www.amazon.com/Data-Structures-Algorithm-Analysis-2nd/dp/0201361221 On Mon, Nov 21, 2011 at 6:41 PM, Mustafa mustafa.fai...@gmail.com wrote: As already told by others try solving as many problems if possible try solving exercise of Alen Weiss, book, it will improve ur problem soving skills On Nov 20, 10:48 pm, Akash Coder akash.coder.g...@gmail.com wrote: yup... solve new varieties of problem... u will get used to it On Sun, Nov 20, 2011 at 11:09 PM, amrit harry dabbcomput...@gmail.com wrote: i have a silly question to ask. im gud in ALGO and gud in DATA STR. but i can solve a problem if i know the algorithm or if earlier faced it. i can't able to think my own logics and solve new mathematical problems. even i dont know about how to come up with new TEST DATA. i knw we can develop this skill only by practice. but is there any method or steps to be followed during solving a problem? -- 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] LCA of a Binary tree not a binary search tree
For BST it would be rather simpler. find the first node which lies in between the two. On Wed, Nov 16, 2011 at 1:44 PM, anshu mishra anshumishra6...@gmail.comwrote: Node *LCA(node *root, node *e1, node *e2, int x) { Node *temp =NULL; Int y = 0; If (root-left) temp = LCA(root-left, e1, e2, y); x+=y; if (temp) return temp; if (x==2) return node; y = 0; If (root-right) temp = LCA(root-right, e1, e2, y); x+=y; if (temp) return temp; if (x==2) return node; If (root == e1 || root == e2) x++; Return null; } -- 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: Silly question
yes, btw, intent was to participate and practice. On Mon, Nov 21, 2011 at 10:14 PM, atul anand atul.87fri...@gmail.comwrote: @Mustafa : are you talking about this book?? Data Structures and Algorithm Analysis in C++ http://www.amazon.com/Data-Structures-Algorithm-Analysis-2nd/dp/0201361221 On Mon, Nov 21, 2011 at 6:41 PM, Mustafa mustafa.fai...@gmail.com wrote: As already told by others try solving as many problems if possible try solving exercise of Alen Weiss, book, it will improve ur problem soving skills On Nov 20, 10:48 pm, Akash Coder akash.coder.g...@gmail.com wrote: yup... solve new varieties of problem... u will get used to it On Sun, Nov 20, 2011 at 11:09 PM, amrit harry dabbcomput...@gmail.com wrote: i have a silly question to ask. im gud in ALGO and gud in DATA STR. but i can solve a problem if i know the algorithm or if earlier faced it. i can't able to think my own logics and solve new mathematical problems. even i dont know about how to come up with new TEST DATA. i knw we can develop this skill only by practice. but is there any method or steps to be followed during solving a problem? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Linked List Problem-Suggest Algo
As you mentioned, the numbers designating the gaps can only be repeated so in your example 2 20 can be broken into 19 1 but 19 is already there in the list (the first couplet) and it's not the one which describes the gap. can you please clarify? On Mon, Nov 21, 2011 at 5:23 AM, Ankur Garg ankurga...@gmail.com wrote: a linked list contains 2 19 _ _ 3 47 _ _ _ 2 20 _ _ ..and so on I have to fill those empty nodes with numbers whose sum is equal to the numbers occurring just before the gaps and the number of gaps is determined by the node which is at 2 distance before the gaps with the limitation that their would be no repetition in list only the nodes designating the number of gaps can be repeated for example 2 20 should be broken in two parts like 19 1 3 47 should be broken in three parts like 42 2 3 and not in 44 1 2 because 1 already occurred in the list due previous partition -- 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: K-way merging...
In K way Merging , we implement Heap sort . You can go through the link http://www.site.uottawa.ca/~nat/Courses/DFS-Course/DFS-Lecture-9/tsld021.htm Tournament tree also uses Heap . For it's implementation we need sorted set of arrays and need to precalcuate the height of the tournament tree . Suppose u have got 5 set of sorted array we can find the height of the tree by ceil(log 5) = 3 . Now at level 3 , there will be 2^3=8 leaf nodes and we have 5 set of array .The leaf nodes will contain 5 pointers to the set of each sorted element and the remaining 3 leaf node is marked a infinity. So the value of the leaf node will be equal to the first element of each set . Now pair up the leaf nodes to find the parent nodes one level up in the tree . The value of the parent node will be equal to the min(left set element , right set element ) or max(left set element , right set element ) depending on the order u follow . Keep on pairing the new parent nodes until single node is encountered . the value . The value of the root node will give the 1st winner . Similarly for getting the next winner we need to repeat the process , after setting the leaf node of the to the next value in the set from which the 1st winner was present , until the all the leaf node are emptied . Can refer to http://www.geeksforgeeks.org/archives/11556 -- 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: Time Complexity
@Gene : i guess you are considering balanced tree. what if the tree is left skewed or right skewed . then height of thee will ne H=No. of node. so we will get :- 1+2+3+4H so recurrence will be T(n) = T(n-1) + O(n) hence complexity will be O(N^2) correct me if i am missing somthing. Thanks in advance. On Sun, Nov 20, 2011 at 3:40 PM, Gene gene.ress...@gmail.com wrote: My advice is don't guess. Do the math. To print level L of a perfectly balanced tree, you will traverse 2^L -1 nodes. The outer loop that prints levels 1 .. H will therefore traverse sum_{L=1..H} (2^L - 1) = 1 + 3 + 7 + ... 2^H - 1 Let N = 2^H - 1 be the number of nodes in the tree. Then sum_{L=1..;H} (2^L - 1) = sum_{L=1..H} (2^L) - H = 2^(H+1) - 2 - H = 2 N - log(N+1) = O(N) On Nov 20, 7:13 am, Ankuj Gupta ankuj2...@gmail.com wrote: I guess its NlogN for balanced tree as it is traversing N nodes for H times ie the height of tree which is logN for balanced and N for skewed tree. So it should be Nlogn and N^2 On Nov 20, 9:27 am, tech coder techcoderonw...@gmail.com wrote: @ sravanreddy001 complexity is O(N^2) whether tree is balanced or not doesn't matter For each level it's visiting elements. all elements upto n-1 level . i dont know from where u got the concept of logn , the code is not making any decision to go in left or right , it is going in left and right both , so how it is nlogn. On Sun, Nov 20, 2011 at 3:12 AM, sravanreddy001 sravanreddy...@gmail.comwrote: Its NlogN if balanced.. Else N^2 For each element it's visiting at most log N elements.(assuming balanced) -- 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/-/hVQH5EtOfK4J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- * Regards* *The Coder* *Life is a Game. The more u play, the more u win, the more u win , the more successfully u play*- 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] Query: Function returning void pointer
Can a function return a void pointer ? -- 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] Query: Function returning void pointer
Ofcrse yes... hvnt you use Malloc ?? On Tue, Nov 22, 2011 at 1:23 PM, Aniket aniket...@gmail.com wrote: Can a function return a void pointer ? -- 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: Soritng
@Dave: let us leave about Radix sort ,for it there are specific constraints on the numbers. @Amol sharma: i dont know what is cycle sort? Convey your answer in well known sorting methods. Ankur garg:In the phase of merging it compares the sorted sub arrays to merge them .So it is not correct.. On 20 November 2011 22:56, Amol Sharma amolsharm...@gmail.com wrote: quoted from wiki While selection sort is preferable to insertion sort in terms of number of writes (Θ(*n*) swaps versus Ο(*n*2) swaps), it almost always far exceeds (and never beats) the number of writes that cycle sorthttp://en.wikipedia.org/wiki/Cycle_sortmakes, as cycle sort is theoretically optimal in the number of writes. This can be important if writes are significantly more expensive than reads, such as with EEPROM http://en.wikipedia.org/wiki/EEPROM or Flashhttp://en.wikipedia.org/wiki/Flash_memorymemory, where every write lessens the lifespan of the memory. so i think answer for the second will be cycle sort -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad http://gplus.to/amolsharma99 http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://youtube.com/amolsharma99 On Mon, Nov 21, 2011 at 12:15 PM, Ankur Garg ankurga...@gmail.com wrote: I think Merge Sort doesnt require any swapping . So , for 3 my answer wud be Merge Sort On Mon, Nov 21, 2011 at 11:55 AM, Dave dave_and_da...@juno.com wrote: @Kumar: For question 1, the answer is radix sort. It doesn't use data comparisons at all. Dave On Nov 21, 12:04 am, kumar raja rajkumar.cs...@gmail.com wrote: if we have set of n elements then 1) which sorting method uses least number of comparisons?? 2) which sorting method uses least number of swaps?? 3) suppose the array is 2 8 4 6 5 9 if we want to swap 8 and 5 the cost is 2(5-2)=6 .here 5 and 2 are indices of 5 and 8. so what sorting method minimizes the cost, i want the answer in general case ,not for this particular array. it is also called least distance sorting -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in -- 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] Query: Function returning void pointer
yes.. On Tue, Nov 22, 2011 at 1:23 PM, Aniket aniket...@gmail.com wrote: Can a function return a void pointer ? -- 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.