[algogeeks] time complexity of gcd euclid algo(recursive)

2012-11-15 Thread Shruti Gupta
hi Can anyone help me find out the time complexity of recursive gcd algorithm (using euclid's algo) i.e. for the following program : int gcd(int n,int m) //given nm { if(n%m==0) return m; else return gcd(m,n%m); } i think the soln is lg(a*b) but have no idea how.. -- You

Re: [algogeeks] time complexity of gcd euclid algo(recursive)

2012-11-15 Thread Rahul Kumar Dubey
The complexity is O(h^2) where h is the number of digits in the smaller number *m* in base 10. On Tue, Nov 13, 2012 at 3:34 PM, Shruti Gupta fundooshr...@gmail.comwrote: hi Can anyone help me find out the time complexity of recursive gcd algorithm (using euclid's algo) i.e. for the

[algogeeks] Time Complexity Analysis

2012-11-05 Thread shady
Here the time complexity of the solution should be O(n * log(n)) http://www.geeksforgeeks.org/archives/21781 -- 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

Re: [algogeeks] Time Complexity Analysis

2012-11-05 Thread shady
Sorting takes linear time, but it doesnt get repeated n times, it is like - T(n) = 2*T(n/2) + O(n) worst case solution is O(n^2) it is similar to quick sort On Mon, Nov 5, 2012 at 9:15 PM, rahul sharma rahul23111...@gmail.comwrote: dude n for build tree and n in this for finding

Re: [algogeeks] Time Complexity Analysis

2012-11-05 Thread atul anand
building tree will take O(n) time but for each node we need to find max i.e i = max (inorder, start, end); so complexity in worst case will we O(n^2). On Tue, Nov 6, 2012 at 12:26 AM, shady sinv...@gmail.com wrote: Sorting takes linear time, but it doesnt get repeated n times, it is like -

[algogeeks] Time Complexity Ques

2012-01-15 Thread Ankur Garg
Hello I was going through this link http://www.geeksforgeeks.org/archives/3187 Wonder what is the time complexity for this..?Can anyone explain Regards Ankur -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] Time Complexity

2011-11-19 Thread shady
this doesn't seem like level order printing, because you are simply printing the tree starting with the children as the root node. On Sat, Nov 19, 2011 at 12:57 PM, Ankuj Gupta ankuj2...@gmail.com wrote: What is the time complexity of this code for Level Order Traversal. void

Re: [algogeeks] Time Complexity

2011-11-19 Thread tech coder
the complexity is N^2 for each level you are traversing all the nodes below that level. for nth level , you have to traverse all n-1 nodes. so O(N^2) better to use queue , we can traverse level order in O(n). On Sat, Nov 19, 2011 at 4:58 PM, shady sinv...@gmail.com wrote: this doesn't seem like

Re: [algogeeks] Time Complexity

2011-11-19 Thread atul anand
@shady : i guess code is fineit will print the node only when level=1 , and level is in loop so for level = 1 it will print root when level=2 then it will print all nodes at level 2 and so on... i guess we can optimize this code.. On Sat, Nov 19, 2011 at 3:28 PM, shady sinv...@gmail.com

Re: [algogeeks] Time Complexity

2011-11-19 Thread atul anand
void printLevelOrder(BinaryTree *root) { node *temp; enqueue(root); while((temp=dequeue()) != NULL) { printf(%d ,temp-data); if (temp-left) { enqueue(temp-left); } if ( temp-right) { enqueue(temp-right); } } } i guess this approach is much

[algogeeks] Time Complexity

2011-11-19 Thread sravanreddy001
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

Re: [algogeeks] Time Complexity

2011-11-19 Thread tech coder
@ 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

Re: [algogeeks] Time Complexity

2011-11-19 Thread Jagannath Prasad Das
I think any traversal has o(n) complexity as we traverse all the nodes.There is no skipping of nodes.Very simple logic:) On Sun, Nov 20, 2011 at 9:57 AM, tech coder techcoderonw...@gmail.comwrote: @ sravanreddy001 complexity is O(N^2) whether tree is balanced or not doesn't matter For each

[algogeeks] Time Complexity

2011-11-18 Thread Ankuj Gupta
What is the time complexity of this code for Level Order Traversal. void printLevel(BinaryTree *p, int level) { if (!p) return; if (level == 1) { cout p-data ; } else { printLevel(p-left, level-1); printLevel(p-right, level-1); } } void printLevelOrder(BinaryTree *root) {

[algogeeks] Time complexity of morris traversal

2011-10-01 Thread Ankuj Gupta
What is the time complexity of morris traversal ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

[algogeeks] Time complexity

2011-09-21 Thread sivaviknesh s
for(i=0;in;i++) for(j=0;ji*i;j++) for(k=0;kj;k++) sum++; Is itn^5 log n . n * (n^2 log n) * (n^2 log n) ??? correct me if i m wrong? also anybody can tell some easy approach to tackle these ques ?? I worked out for some values of n and arrived at the ans.

[algogeeks] Time complexity

2011-08-06 Thread Puneet Gautam
Its quite long... but its simple... pls tell me its worst case time complexity..!!! #includestdio.h #includestring.h #includeconio.h #includestdlib.h int check(char *p,int n)// this function checks for pallindromicity of the string passed. { char a[100],b[100]; int k; for(k=0;k=n;k++)

[algogeeks] Time Complexity of Merge Sort(Linked list)

2011-06-23 Thread Anantha Krishnan
Hi All, Can someone explain about the time complexity of Merge sort(Linked list with billions of node)? There is no way to find the middle of sub-list without traversing completely. Please clear my doubts. Thanks Regards, Anantha Krishnan -- You received this message because you are

Re: [algogeeks] Time Complexity of Merge Sort(Linked list)

2011-06-23 Thread Piyush Sinha
Merge sort is often the best choice for sorting a linked list. Reason because it requires only Θ(1) extra space only and generally beats other algorithms like quicksort,heapsort for sorting linked lists. The overall complexity remain O(N log N) even in the worst case On 6/23/11, Anantha Krishnan

Re: [algogeeks] Time Complexity of Merge Sort(Linked list)

2011-06-23 Thread Piyush Sinha
I googled a better explaination for this and found this... hope this will be useful... Sorting a LinkedList is different from sorting an Array as you can not make index based references to any arbitrary item in the List. Instead you need to remember the items during each recursive step and then

Re: [algogeeks] Time Complexity of Merge Sort(Linked list)

2011-06-23 Thread Piyush Sinha
Also u can refer http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html On 6/24/11, Piyush Sinha ecstasy.piy...@gmail.com wrote: I googled a better explaination for this and found this... hope this will be useful... Sorting a LinkedList is different from sorting an Array as you

Re: [algogeeks] Time Complexity of Merge Sort(Linked list)

2011-06-23 Thread Anantha Krishnan
Thanks. I think if we make k traversals at each step it would be O(n * n/2 * log n) If I know value of K we can do it in O(n log n) I agree. What will be the time complexity if there are billion nodes i.e even if i know node count i cannot store it in integer variable? Thanks Regards, Anantha

[algogeeks] time complexity of sqrt(n)

2011-01-16 Thread rgap
What is the time complexity of sqrt function of c++? -- 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] Time complexity - is anybody bothered about it anyway?

2010-08-17 Thread Ashutosh Tamhankar
Greetings How many of you guys calculate the time complexity of an algorithm before implementing it on a day to day basis? When you review your code, before committing it to the live source code base, does anybody discuss the time complexity? Would love to hear your interesting experiences..

Re: [algogeeks] Time complexity - is anybody bothered about it anyway?

2010-08-17 Thread Swapnil Chavada
yes ofcourse.the efficiency of my code is always a concern to me... On 17 August 2010 18:54, Ashutosh Tamhankar asshuto...@gmail.com wrote: Greetings How many of you guys calculate the time complexity of an algorithm before implementing it on a day to day basis? When you review your

[algogeeks] Time complexity................

2010-07-16 Thread UMESH KUMAR
Hello . How to decide insertion sort takes less cost of time for small input size. -- 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

[algogeeks] Time complexity

2010-06-08 Thread Raj N
What is the time complexity of insertion and deletion in 1. Linked list 2. Queue 3. Queue implemented using a linked list -- 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

Re: [algogeeks] Time complexity

2010-06-08 Thread Anand
Linked List: Insertion O(n) deletionO(n) Queue using linked list : Insertion O(1) deletion O(n). On Tue, Jun 8, 2010 at 1:38 AM, Raj N rajn...@gmail.com wrote: What is the time complexity of insertion and deletion in 1. Linked list 2. Queue 3. Queue implemented using a linked list --

[algogeeks] time complexity of algorithms

2006-12-15 Thread programming
Hi all, i have 3 short questions that i would like answered. 1) What is the best case complexity for a tree of degree(4). I said B(n) = n. Is it B(n)=1? I think it is the first case 2) Also, is the average case for a doubly circular queue A(n)=n+1/2 3) Lastly, is the worst-case of a search