> 
for i in xrange (N-1):
    for j in xrange (i, N):
        if a[j] < a[i]:
            a[i], a[j] = a[j], a[i]
> It's what Wikipedia says a selection sort is: put the least element in [0], 
> the least of the remaining elements in [1], etc.

If your only requirement to match to selection sort is the end result, then 
every sort would be selection sort. If you meant "put the least element in [0] 
in the first pass" then that would indeed be selection sort, but that is not 
what the above code does. The above code is bubble sort.

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to