|
Integer or floating point arithmetic?
|
|
|
|
|
|
how old are you ?
|
|
|
|
|
Muliply 30 with half and subtract 5.
------------------------------
PROST Roleplaying Game
War doesn't determine who's right. War determines who's left.
"Would you like us to drop a bomb on you too? We have 10,000 of them!"
- espeir
"Perhaps we should lend them a nuke or two."
- espeir
|
|
|
|
|
maybe lying on his birthdate... i don't think 1984 seems correct... lol
|
|
|
|
|
toxcct wrote: maybe lying on his birthdate... i don't think 1984 seems correct... lol
Or someone was using the account of his big brother
------------------------------
PROST Roleplaying Game
War doesn't determine who's right. War determines who's left.
"Would you like us to drop a bomb on you too? We have 10,000 of them!"
- espeir
"Perhaps we should lend them a nuke or two."
- espeir
|
|
|
|
|
What are the ways to find a cube of a number other than
1. X~3 = X * X * X
note : ~ = to the power
|
|
|
|
|
X2*X
"I know which side I want to win regardless of how many wrongs they have to commit to achieve it." - Stan Shannon
Web - Blog - RSS - Math - LinkedIn
|
|
|
|
|
X^3 = (2X)^2 + (X^2)*(X-4)
^ power
* multiply
|
|
|
|
|
|
If X doesnt work then, you can make use of Y
Y~3 = Y * Y * Y
note : ~ = to the power
|
|
|
|
|
noname71 wrote: X~3 = X * X * X
Y = X³ = X * X * X
Are you looking for X?
Then you should take the third root out of Y.
Are You looking for the power (3 in this case) with X^n?
Y = X^n
log(Y) = n * log(X)
n = log(Y) / log(X)
If you are looking for Y just multiply
Regards,
Ingo
------------------------------
PROST Roleplaying Game
War doesn't determine who's right. War determines who's left.
"Would you like us to drop a bomb on you too? We have 10,000 of them!"
- espeir
"Perhaps we should lend them a nuke or two."
- espeir
|
|
|
|
|
|
Don't post homework problems here
Do it yourself!
That's no moon, it's a space station. - Obi-wan Kenobi
|
|
|
|
|
thanks for your help and just to let you know i have tried to do it myself and the idea of this site is to ask for help.we are not all as clever as others when it comes to c++.
thanks for your advice
klck2000
|
|
|
|
|
klck2000 wrote: we are not all as clever as others when it comes to c++.
Nobody is gonna write a whole program for you. Most people tend to rather you put some effort into solving the problem yourself, rather than just post your homework question so other people can do your dirty work while you don't learn the material.
None of the uber programmers started off as such you know. It takes effort.
BTW, if you don't understand something, why can't you ask your teacher for clairty? I mean, that's what they are there for right?
Jeremy Falcon
|
|
|
|
|
Calculating the mean and median are a fairly easy task. Standard Deviation is a little harder.
What do you need help with, exactly what don’t you understand how to do?
Before you answer that, write out some pseudo code and go through the logic.
Post a specific question that proves you have attempted this on your own, otherwise I don’t think you will get much help.
If you need links to information for standard deviation you can find more then enough information using google. However, I will start you off.
http://www.med.umkc.edu/tlwbiostats/variability.html#deviation[^]
Good luck and enjoy the challenge.
will
I hate users. Not all of them, just the ones who talk.CP member: Al Einstien
|
|
|
|
|
Given two arrays, containing equal number of elements but not in the same order of appearance, what is the fastest method of checking whether the elements in the arrays match or not?
Note - This should be accomplished without sorting the arrays.
Cutebug
|
|
|
|
|
There are only two efficient ways do compare such datastructures: building two efficient ones (like trees or hash table) or by sorting them. Why don't sort, it would be the fasted? Is it for school, I can't imagine another problem with such "curious" restrictions???
Perhaps you should go a little bit into detail, perhaps we can find another solution then.
Regards,
Ingo
------------------------------
PROST Roleplaying Game
War doesn't determine who's right. War determines who's left.
|
|
|
|
|
I'd do the following:
another array of the same size as the first two. used to store flags (say: all values initialized as 'o' and they are to be set to 'x')
if array1.size != array2.size
abort with message "not identical"
arraysize = array1.size
For i = 0 to arraysize
iterate over array1 with i
For j = 0 to arraysize
iterate over array2 with j
if array1[i] == array2[j] && array3[j] != 'x'
array3[j] = 'x'
else if j == arraysize - 1 abort with message "not identical"
else continue
message "identical"
(i wrote this down from memory. if this doesnt work, my memory failed me.)
Basically, you need to examine each element of the first array and see if there is a match in the second array. If there is a match, you need to exclude that element from further comparison (so you can have multiple identical objects in one array and you dont match one object against 2 others). The check is over once you reach the end of the second array without finding a match for an element of the first array.
Since the arrays are unsorted, you need additional space for each element of array2 to remember if it was already used for a match. Also, in the worst case, you have to make (n² + n) comparisons and n assignments to compare both arrays.
if you had 2 containers with sorted contents, you would not have to make any assignments and only n comparisons in the worst case.
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
hash each element, count the hashes, if number of hashes is 2 for every number of hashed entries, you have identicle arrays, this trades memory for time. You said fastest, but made no requirements for memory, so use a good and fast hash like superfast hash. you can always terminate the hash count if you ever find a 1 count unless you need to know how many differing items occur. allocate your hash at 2.5 times n (n-length array), which gives you the worst case possibility that there are no matches between the two arrays.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
The only problem with this approach is if 2 elements from array 1 have the same hash, and 2 elements from array 2 have the same hash (but the elements from array 1 do not match those of array 2 -- that is, they have differing hashes), you will end up with 2 hashes that each match 2 elements, but those elements wouldn't have a match in the corresponding array.
That problem goes away if the elements in each array are guaranteed to be unique.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
The problem also goes away if you add in separate bytes, high byte, low byte, this differentiates and still limits the search. However, uniqueness is still a matter of length of items and hashing algorithm and room for hash. Generally you expand your hash table to provide for uniqueness.
He was asking the fastest method, brute force searches guarentee correct results but are always the slowest operation. Thus, hashing provides a fast interface to a 3n access, hash+hash+test, where as a brute force search is done in powers, especially with unsorted. Sorted arrays generates sorting over-head, plus comparision overhead, reducing the speed. hash is a way to access sorted speed without a sort.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
I think you misunderstood what I was getting at (or I misunderstand your thoughts ... either way). What I was getting at is that if you just hash every element in both lists and then compare each hash element to see if it has 2 results, you run into a problem when the following scenario is played out:
Contents of list 1: X, X
Contents of list 2: Y, Y
After hashing the lists, your hash table will look something like:
Hash1: X, X
Hash2: Y, Y
You now have 2 elements in each hash, but the lists are obviously not the same. It is possible to get around this problem, but then you decrease the efficiency to the point where another algorithm would be a better option anyway.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: You now have 2 elements in each hash, but the lists are obviously not the same. It is possible to get around this problem, but then you decrease the efficiency to the point where another algorithm would be a better option anyway.
That is why I said you can have a different counting method. By counting in a high byte/low-byte format
Hash1: X,X will produce a count of 2 ==00000000 00000010
Hash2: Y,Y will produce a count of 512 ==00000010 00000000
a proper match, one from each, would produce a count of 257 == 00000001 00000001
What I was saying is you can adapt the count to produce a good result, bit math is still faster than sorting. providing a method for adapting to exception is sometimes faster than ignoring a method because it has an exception. In this case because the count is simply an adapted bit operation it is very efficient. A proper Hash algorithm produces a unique result about 98% of the time, so the 2% exception is either adapted by a larger hash-storage destination, or in this case since the count can be adapted easily, by the resulting operation the hash uses.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|