Transform a set into an ascending order sequence

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 1K views
Cinitiator
Messages
66
Reaction score
0

Homework Statement


Let's say that I have a set called M, which is a subset of real numbers. Let's say that I want to create a sequence {[itex]s_1, s_2, ..., s_3[/itex]} with all of the members of M, which would be ordered in an ascending (increasing) order. For example, if M = {4, 5, 1, 3, 2}, then [itex]s_0 = 1 ; s_1 = 2; s_2 = 3[/itex] etc.

How does one do that?

Homework Equations


-


The Attempt at a Solution


Googling without any luck.
 
Physics news on Phys.org
Cinitiator said:

Homework Statement


Let's say that I have a set called M, which is a subset of real numbers. Let's say that I want to create a sequence {[itex]s_1, s_2, ..., s_3[/itex]} with all of the members of M, which would be ordered in an ascending (increasing) order. For example, if M = {4, 5, 1, 3, 2}, then [itex]s_0 = 1 ; s_1 = 2; s_2 = 3[/itex] etc.

How does one do that?

Homework Equations


-

The Attempt at a Solution


Googling without any luck.

This is not possible in general.

If M is uncountably infinite, then there isn't even a way to enumerate its elements in a sequence.

If M is countably infinite, then you can enumerate the elements in a sequence (indeed, this is the definition of countable), but in general it won't be possible to sort this sequence. Consider [itex]M = \mathbb{Q}^+[/itex], the set of positive rational numbers. This set has no smallest element, so it's impossible even to choose [itex]s_0[/itex] in the way that you want to do.

However, in some particular cases it may be possible when M is countably infinite. For example, if [itex]M = \mathbb{N}[/itex], the set of natural numbers, just choose [itex]s_0 = 1, s_1 = 2, s_2 = 3, \ldots[/itex].

Of course, if M is finite, then this will always be possible. If you want a concrete algorithm to do it, look into various sorting algorithms: bubble sort, insertion sort, quick sort, etc.