tags:

views:

254

answers:

3

I need a collection of items in which I can perform selection sort in Smalltalk.

What's the best thing to use? List, set, linkedlist, etc.?

+1  A: 

First things first: You realize, of course, that selection sort is O(n^2), which means it'll be inefficient for large collections regardless of implementation.

The semantics of list and linked list should be the same from your point of view. Both allow duplicates, while set does not. Choose either list or set depending on which one is correct for your data.

Last, if list is array-backed and linked list simply swaps pointers, I would go with linked list for sorting because swapping is so key to sorting.

All of these comments are generic; none are specific to Smalltalk. You can make better choices if you study algorithms and data structures.

duffymo
A: 

Why isn't an array good enough?

Damien Cassou
A: 

Since the length of your List will never change(selection sort works in-place), use an Array. Otherwise OrderedCollection would also be of interest.

Richard.Durr