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
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
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
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
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
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;
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
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
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
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 -
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
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
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
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:
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
@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
@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;
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 -
*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
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
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
21 matches
Mail list logo