The complexity given is not even time, but numbers of comparisons.
@rcgldr, I would agree.
Type: Posts; User: std10093
The complexity given is not even time, but numbers of comparisons.
@rcgldr, I would agree.
Thanks Soma! Jim, isn't that the time complexity? I am interested in the memory complexity!
What's the memory complexity of std::sort? I assume O(n), but I can't find any ref for it!
Also, do I understand the term memory complexity correctly? I understand it as how much memory the...
The version you posted matches the other attempts. The most difficult part for me was GAP C, because the thread agrees that it needs two commands, an assignment and a return and somehow I felt that a...
I checked the first piece of code you have. I see only the different order in the last return and not an extra assignment....oh, I now saw that I hadn't let you know that I had that extra assignment...
No I am not saying you are crazy! I see your point. So, can you present your version of the function to take a look at it?
I tested it it seems OK. Moreover, we want the right child to be more than the parent and the left child to be less, so I feel I am on the right track.
I don't see what you changed, sorry. I mean, line 9 from my attempt is pretty similar to yours.
EDIT
I could keep my last attemt and change the last return with this:
return...
The last attempt is wrong. It doesn't check the values in a perfect tree. For example,
4
2 6
1 8 5 7
will be considered sorted, and it is not!
That's what I am saying!
I think something like this should work:
int fun(Treeptr p, int * ap, int * bp) {
int a, b;
if (p->left == NULL && p->right == NULL) {
*ap = p->value;
After more testing, it seems that the first solution is wrong too. I am now working on the second one however.
Yes, the first solutions works. I use this code, modified to host an integer and not a word.
I used this code to perform this kind of operation.
int BST(Treeptr p, int MIN, int MAX);
int ordtree_old(Treeptr p) {
/* BST = Binary Search Tree.
* You can name your function as...
Thanks for the information!
Ok I see. I will have to read the theory behind the weaker memory order, but I got the big picture.
However, in this problem it would be more reasonable to let the threads run (without...
I want to write a program where, random numbers are going to be created and I am going to track down the greatest of them. Three threads are going to run in parallel.
I do it with two methods....
Yes I agree. My question however is how the tree I posted in the picture would be sorted. I mean let's say that we erase the values and we place them as we want in the picture, in which way should we...
So my worries were correct. Thanks.
However, another question just got in my mind. With this structure of the tree, how would we place the values (1 till 7), so that the tree would be ordered?
I saw an example of a binary tree and I am wondering if it's sorted or not.
13654
I am dangled with the all nodes thing the link says.
What? Did I act like knowing better? :P Moreover, it's not for homework. Anyway, these kind of discussions destroy the archive concept.
The dimension is an argument of the constructor.
:O
I know saw Soma's post. Where did I say I am good in C++? I am learning.
The Point can have as many coordinates as the user wants. Thanks for the all the answers, but I accomplished what I was asked too.
And what GetCoordinates return? Maybe a pointer to the vector of coordinates?
Take into account that because you probably use Visual Studio, this dosn't mean you shall learn Visual C++.
C++ is a programming langugae.
Visual studio is an IDE, an editor to write and run your...
C++ I would say is the way to go then.