1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Transform a set into an ascending order sequence

  1. Oct 19, 2012 #1
    1. The problem statement, all variables and given/known data
    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?

    2. Relevant equations

    3. The attempt at a solution
    Googling without any luck.
  2. jcsd
  3. Oct 19, 2012 #2


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    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.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook