ChatterBank1 min ago
Discret Math
describe function mins that takes a non-empty of natural numbers for its argument, and has the smallest natural number in the set for its value.
i tried to use the function min which takes two integers as arguments and has the smaller of them for its value
but could not form it all together correctly :(
Help please??
i tried to use the function min which takes two integers as arguments and has the smaller of them for its value
but could not form it all together correctly :(
Help please??
Answers
If you have a set {a1, a2, ... , an} of n elements then there's probably a number of ways to describe a function that finds the minimum. I'd say the simplest one to design would work as follows: 1. Compare {a1, a2} using min (which presumably finds the sign of a1-a2, but at any rate is not a difficult comparison). Label the minimum b1. 2. Compare {b1,a3} in the same...
08:44 Mon 30th Mar 2015
If you have a set {a1, a2, ... , an} of n elements then there's probably a number of ways to describe a function that finds the minimum. I'd say the simplest one to design would work as follows:
1. Compare {a1, a2} using min (which presumably finds the sign of a1-a2, but at any rate is not a difficult comparison). Label the minimum b1.
2. Compare {b1,a3} in the same way -- the new minimum can be labelled as b2.
3. And so on, until finally one compares b_(n-2) with an, finds the minimum, and labels it b_(n-1) -- which ought to be the minimum of the whole set.
I think this is the most efficient way of finding the minimum and should always work, and has the advantage of being algorithmically easy to implement for any set size. I'm not 100% sure that this is what the question was after, but it seems right to me.
1. Compare {a1, a2} using min (which presumably finds the sign of a1-a2, but at any rate is not a difficult comparison). Label the minimum b1.
2. Compare {b1,a3} in the same way -- the new minimum can be labelled as b2.
3. And so on, until finally one compares b_(n-2) with an, finds the minimum, and labels it b_(n-1) -- which ought to be the minimum of the whole set.
I think this is the most efficient way of finding the minimum and should always work, and has the advantage of being algorithmically easy to implement for any set size. I'm not 100% sure that this is what the question was after, but it seems right to me.
If, at any point, two numbers being compared are equal, then the algorithm should arbitrarily choose the first number to enter the set {bi}.
If I've designed this algorithm correctly, then on the set {a}= {53,43,64,34,223,265,7,66,6,2} then the set {b}={43,43,34,34,34,7,7,6,2} which consists of progressively small members of the set as you go along and find new minima. Hope this helps.
If I've designed this algorithm correctly, then on the set {a}= {53,43,64,34,223,265,7,66,6,2} then the set {b}={43,43,34,34,34,7,7,6,2} which consists of progressively small members of the set as you go along and find new minima. Hope this helps.
Related Questions
Sorry, we can't find any related questions. Try using the search bar at the top of the page to search for some keywords, or choose a topic and submit your own question.