Serving the Quantitative Finance Community

 
User avatar
Athletico
Posts: 14
Joined: January 7th, 2002, 4:17 pm

Design/implement a sorting algorithm with a special constrained language.

March 11th, 2012, 10:23 pm

QuoteOriginally posted by: CuchulainnQuoteL.tail() only returns one element located at the tail of the list L.I think Athletico's point is that it is _not_ that (it corresponds to cdr == everything except the first element).Exactly Cuch. A list type that supports primitives head() and tail() provides for iteration via recursion, and the "no random access" condition is not violated.
 
User avatar
Etuka
Posts: 1
Joined: January 1st, 2002, 7:40 pm

Design/implement a sorting algorithm with a special constrained language.

March 14th, 2012, 1:48 pm

Agreed Athletico.Jack, the problem is simple if tail returns all elements except the first. You will need another command as well to implement your list if tail only returns the last element.
 
User avatar
dd3
Posts: 4
Joined: June 8th, 2010, 9:02 am

Design/implement a sorting algorithm with a special constrained language.

March 14th, 2012, 7:41 pm

QuoteOriginally posted by: JackBryanThis is an exam question. The exam has been done. Given a specific language including a list of unsorted integers, the list does not support random access. It has functions of head(), tail(), concatenate(), define, return , compare operator < , > , size() , if .. then ? . It does not support random access.Design/Implement a sorting algorithm with this language so that a sorted list is returned. Any C/C++ or other language library functions, library algorithms or data containers are not allowed to be used. I have no idea about how to handle it without random access functions.What will be the result of head() after a concatenate(tail(), head()) operation; the item after the original head() used in the concatenate() or do you now have a circular list?
Last edited by dd3 on March 13th, 2012, 11:00 pm, edited 1 time in total.