|
look man i'm not here to chat with you, if you really read , first if the question ask to find the smallest value from the list I have already answered that question read my first replay . second of all this one is not HW because the professor gave that answer i'm here because I believe that answer is wrong i'm here to work together to solve that question
just leave the question and don't waste our time.
|
|
|
|
|
demo 2 wrote: just leave the question and don't waste our time. Who's wasting whose time?
Use the best guess
|
|
|
|
|
stupid replay waste my time to read it. you spend all your time here for making stupid replay
|
|
|
|
|
And what are you doing?
Use the best guess
|
|
|
|
|
play chatting with stupid kid
modified 12-Jun-13 1:21am.
|
|
|
|
|
You said it.
Use the best guess
|
|
|
|
|
Your algorithm, as Richard said earlier, should include a sorting step.
1. Read in the n integers.
2. Sort those n integers using a sorting algorithm to arrange them in ascending order (if you can use quicksort, nothing like that; but I presume your n will be a reasonably small number - so you can use any sorting algorithm).
3. Report out the first m numbers from this sorted list. These will be the m smallest numbers.
This should be enough.
In the code written above, there is no sorting step. Or, your professor might have told you (over voice) that the array A[n] is already sorted. Get that clarification from your professor.
|
|
|
|
|
Just arrange the numbers in the Ascending order (smallest to largest) then pick how many numbers you want form start..
|
|
|
|
|
|
The key is to keep track of the largest number in the array of small numbers. Let its index be named L. Then the comparison is if (A[i] < xsmall[L]). When a smaller value is found, replace xsmall[L] with A[i], and search thru xsmall for a new largest element xsmall[L]. There is no reason to sort xsmall-- if m becomes large then some data structure other than an array might help (a heap?)
|
|
|
|
|
Hi all,
I am writing a program to find the closest ancestor in a binary tree (not BST). I found a sample working code:
mynode *closestAncestor(mynode* root, mynode* p, mynode* q)
{
mynode *l, *r, *tmp;
if(root == NULL)
{
return(NULL);
}
if(root->left==p || root->right==p || root->left==q || root->right==q)
{
return(root);
}
else
{
l = closestAncestor(root->left, p, q);
r = closestAncestor(root->right, p, q);
if(l!=NULL && r!=NULL)
{
return(root);
}
else
{
tmp = (l!=NULL) ? l : r;
return(tmp);
}
}
}
I am trying to do something like the following (passing only the data values and finding only the data value of ancestor, not concerned with its pointer)
int closestanc(node * root, int n1, int n2)
{
int l, r;
if(root == NULL)
return -1;
if(root->right->data == n1 || root->right->data == n2 || root->left->data == n1 || root->left->data == n2)
return root->data;
else
{
l = closestanc(root->left, n1, n2);
r = closestanc(root->right, n1, n2);
if(l!= -1 && r!= -1)
return root->data;
else
return (l != -1 ? l : r);
}
}
But this thing doesn't work. Can you please point out where I am doing it wrong ?
|
|
|
|
|
You say it doesn't work, but you don't explain how it doesn't work. Does it error, or just give the wrong answer?
From what I can see, you check to see if root = NULL, which is good. But then you compare the values of root->right->data and root->left->data against n1 and n2. But what if root->right or root->left is NULL? Then it's data will be undefined, and the compare will fail. If it doesn't error out at this point, it may just go on to the else condition, which is fine. But as I said, I don't know how it is failing.
Roy.
|
|
|
|
|
I want to know whether opcode can give me the messages besides triangle. As mesh defined in the opcode is consist of triangles, but most of my model is constructed using polygons, so before my collision qurey, I have to transform the polygons to triangles, but i want to know wether i could know which polygon the triangles detected are belong to. if the anwser is yes, how can i get the message?
I had got the resource from the OPCODE net address, and i also have read the mannual about the OPCODE, but as I wanted to learn some details about the OPCODE, I found it was difficult. And i had got the two projects "opcode" and "CDTestFramework" from that address. because i had not found the information about how to get which polygon the detected triangle is belong to in the user mannual. i hoped to find my anwser in the two projects above, but I find it was difficult to read the code in the two projects. if you had some experience about using OPCODE, i really wished you could give some suggestion about how to read the two projects. And as the most important one of my requests is to get the polygons, so if you know, can you tell me is there any manner i can get the polygons. If the answer is NO, i think I have to think about take us of other detection manners.
|
|
|
|
|
Having read this a second time. It still makes no sense.
What is OPCODE?
Please give Links/URL so that somebody might know what you are talking about.
|
|
|
|
|
|
Given that no one has offered a suggestion on this, you can be reasonably sure that no one has used it. You need to make use of the information on the OPCODE website, although it does not look like it has been updated for the last 10 years.
Use the best guess
|
|
|
|
|
Wow, exactly 10 years since the last update. It is possible to browse to the Main site page and get the authors email address by clicking the link in the upper left corner.
http://codercorner.com/Pierre.htm[^]
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
Yes, I know, hence my response to OP.
Use the best guess
|
|
|
|
|
Given that FreeSOLID is still actively maintained, it makes you wonder why the OP won't go with it. The other alternative, linked from there hasn't been updated since 1997.
Is he stuck in a timewarped VRML world?
|
|
|
|
|
dusty_dex wrote: Is he stuck in a timewarped VRML world? Something like that.
Use the best guess
|
|
|
|
|
Do any one here know how to predict weather based on some sample data for pressure, humidity, wind speed, air temperature, etc.. ?
I am know that we can predict weather if the data for certain factors (pressure, temperature, etc..) are known.
I want an efficient algorithm or general concept on predicting weather from those data.
|
|
|
|
|
Member 10059044 wrote: Do any one here know how to predict weather based on some sample data for pressure, humidity, wind speed, air temperature, etc.. ?
I am know that we can predict weather if the data for certain factors (pressure, temperature, etc..) are known.
I want an efficient algorithm or general concept on predicting weather from those data.
Professional Meteorologists can't predict it for more than a few days, and they have vast amounts of data and computing resources.
You should read this to understand why.
|
|
|
|
|
@dusty_dex : What i am trying is to predict weather for just one specific location, and prediction for just half - one hour ahead of current time. In that case, is it possible to obtain near-to accurate prediction using atmospheric data of about 5 days prior ?
|
|
|
|
|
nootanghimire wrote: prediction for just half - one hour ahead of current time. In that case, is it possible to obtain near-to accurate prediction using atmospheric data of about 5 days prior ?
That sounds like a contradiction to me.
As explained in the link I gave, you would have to use data much more recent than 5 days. Also I believe this problem has more to do with the accumulated errors arising from limitations in floating point math.
Maybe someone else can shed light on those issues, but it's not really my area of expertise.
|
|
|
|
|
How about this.
Can YOU predict the weather for the next hour without looking out the window??
Probably not... So how do you expect a computer to do it??
|
|
|
|