views:

1490

answers:

3

which data structure to use to sort n numbers in dr scheme i m not allowed to use vector and structure ..if i use list i cant edit the list values .so how can i sort n numbers . the language i use is textual mzscheme rsr5

A: 

Here are some vector sorting utilities for MzScheme.

Eli Bendersky
is there a way to sort using lists or other data structures rather than using vectors and structures
Arunachalam
Like this one: http://www.engin.umd.umich.edu/CIS/course.des/cis400/scheme/sorts.html ?? I think you should specify exactly what you're looking for - it's not very clear so far!
Eli Bendersky
+3  A: 

If you cannot edit the list values ... return a new list! :-)

Simon Groenewolt
A: 

Not sure if you are supposed to be writing your own bubblesort for homework, but otherwise this is built in:

(sort (list 1 2 4 3) <) (1 2 3 4)

Ben
how to include library in our program
Arunachalam
Actually, sort is *not* built in to R5RS Scheme. (http://schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-15.html#%_index_start). Bubble sort is also a bad choice for Scheme; it is very hard to write compared to insertion sort, for example.
Nathan Sanders
Hi Nathan - thanks didn't know that was not in the standard. Just started to learn scheme.
Ben