[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

[algogeeks] Re: Make File

2012-11-05 Thread Don
A Makefile is used by make to build multi-file programs. It usually contains information about the dependencies in the project and instructions on how to build each portion, and then how to link them all together into the final executable. Make will look at the time stamps on the files and

[algogeeks] Re: swap objects without temp variable

2012-11-05 Thread Don
Note that most of these methods fail if you try to swap an item with itself. For example, swap(a[i], a[j]) will fail if i==j and swap is implemented as void swap(int a, intb) { a ^= b; b ^= a; a ^= b; } Don On Nov 4, 3:32 pm, manish narayan.shiv...@gmail.com wrote: Swapping two

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

[algogeeks] Re: OS question..

2012-11-05 Thread Varun
see, ideally for Q1, the answer the NO. But paging has some advantage, therefore its better to have it neverthless Q2, ?? -- 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] swap objects without temp variable

2012-11-05 Thread vaibhav shukla
XOR option wont work for floating points so being generic, using temp variable is the best option for swapping. Anyways, the question requirement was to swap without temp, hence above given solutions go right. On Mon, Nov 5, 2012 at 10:43 AM, atul anand atul.87fri...@gmail.com wrote: a=a^b;

Re: [algogeeks] Make File

2012-11-05 Thread s yogeesh
Makefile is a special file, containing shell commands... Some what like Batch files for Windows... Makefile needs make is a utility that automatically builds executable programs and libraries from source code by reading files called Makefiles which specify how to derive the target program On

[algogeeks] Problem in Step Into (F5) in eclipse Debugging Mode.

2012-11-05 Thread neeraj
1. public static void main(String[] args) { 2. HashMapString,String hashTable =new HashMapString,String(); 3. hashTable.put(one,one); 4. hashTable.put(two,one); 5. } I put break points on line 3 and 4. When i launch my above code in debugging mode

Re: [algogeeks] Make File

2012-11-05 Thread Durgesh Kumar
1 It is a very important linux utility . 2 If U simply type make on terminal , it will look for makefile in the folder and subfolder and will execute it 3 If a program consists of several file eg :- main.c ,fun () in fun.c , type () in type.c . Now , suppose type calls fun() , main call both

Re: [algogeeks] Re: swap objects without temp variable

2012-11-05 Thread Umer Farooq
But how is that going to work for objects? On Mon, Nov 5, 2012 at 6:43 AM, Ashok Varma verma@gmail.com wrote: Try this: a = a + b - (b = a); //single line code to swap On Mon, Nov 5, 2012 at 4:53 AM, Dave dave_and_da...@juno.com wrote: @Manish: Sure. a = a + b; b = a - b; a = a -

Re: [algogeeks] swap objects without temp variable

2012-11-05 Thread Abhishek Jha
yep its right.one mre method will be a=a+b; b=a-b; a=a-b; On Mon, Nov 5, 2012 at 2:02 AM, manish narayan.shiv...@gmail.com wrote: Swapping two objects (not integers/chars),without using temp...? my solution is using xor operation..is that right and ny other solutions ? -- You

Re: [algogeeks] swap objects without temp variable

2012-11-05 Thread Shivam Rohilla
in a single line a^=b^=a^=b; On 05/11/2012, atul anand atul.87fri...@gmail.com wrote: a=a^b; b=a^b; a=a^b; need to check if a and b are equal or not , bcozz a^a =0 On Mon, Nov 5, 2012 at 2:02 AM, manish narayan.shiv...@gmail.com wrote: Swapping two objects (not integers/chars),without

[algogeeks] Check if a binary tree is Binary Search Tree or not.

2012-11-05 Thread shady
Hi, Can we check this by just doing an inorder traversal, and then checking if it is in increasing order or not ? -- 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

[algogeeks] Re: Check if a binary tree is Binary Search Tree or not.

2012-11-05 Thread Don
That would work. But a simpler approach is: bool isBinTree(root *t) { return (!t) || ((!t-left || (t-value t-left-value)) (!t-right || (t-value t-right-value)) isBinTree(t-left) isBinTree(t-right)); } On Nov 5, 2:04 pm, shady sinv...@gmail.com wrote:

[algogeeks] Re: Check if a binary tree is Binary Search Tree or not.

2012-11-05 Thread Don
In English, that is A null tree is a binary tree. Otherwise, it's a binary tree if the root value is greater than the left child and less than the right child, and the left and right subtrees are binary trees. Don On Nov 5, 2:48 pm, Don dondod...@gmail.com wrote: That would work. But a simpler

Re: [algogeeks] Re: Check if a binary tree is Binary Search Tree or not.

2012-11-05 Thread atul anand
@Don : your algo wont work for following tree :- 30 / \ 20 31 / \ 9 41 above tree is not a BST bcozz here 41 should lie on the right side of the 30but it is not. so we need to keep track of max and min as we move left or right part of the tree.and each node

Re: [algogeeks] Re: Check if a binary tree is Binary Search Tree or not.

2012-11-05 Thread CHIRANJEEV KUMAR
@Don, Your method fails for the case below: //Check if a binary tree is Binary Search Tree or not. #includestdio.h typedef struct node { int value; struct node *left,*right; }nodeptr; nodeptr *newnode(int x) { nodeptr* tmp = (nodeptr*)malloc(sizeof(nodeptr)); tmp-value=x;

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] output of the program with explanation

2012-11-05 Thread rajesh pandey
*int *x ,int *y; x=(int *) 50; y=(int *)20; coutx-yendl; why the output is 7.* -- 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/-/wgVXAzGRgU4J. To post to this

Re: [algogeeks] output of the program with explanation

2012-11-05 Thread rahul patil
its because it is integer pointer subtraction, So subtraction result will be divided by integer size. so 30/4 = 7. 2012/11/6 rajesh pandey rajesh.pandey.i...@gmail.com *int *x ,int *y; x=(int *) 50; y=(int *)20; coutx-yendl; why the output is 7.* -- You received this message because

Re: [algogeeks] Check if a binary tree is Binary Search Tree or not.

2012-11-05 Thread vishal chaudhary
hi all, yes you can do it that way, but the thing is why are you increasing the complexity of the problem by again checking the inorder traversal output to be checked for increasing order. just traverse through the ones recursively(as we do it in the inoder traversal) through all the nodes and