You have problems, and we're glad to hear them. Explain the problem, what you have tried, and where you got stuck.
Feel free to share a little info on yourself and the course.
Forum rules
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.
by omarasl » Tue Dec 11, 2012 7:46 am
hello every body ,
I tried to sort a list by using the quick sort algorithm
I put this code but I can not get the result
(defun qsort (L)
(if (null L)
nil
(append
(qsort (list< (first L) (rest L)) )
(cons (first L) nil)
(qsort (list>= (first L) (rest L)) )
)
)
)
would some one help me please with this code or if there is another code to do that
-
omarasl
-
- Posts: 12
- Joined: Sun Nov 25, 2012 6:19 am
by Goheeca » Tue Dec 11, 2012 9:44 am
And how does the implementation of list< and list>= functions look?
-

Goheeca
-
- Posts: 271
- Joined: Thu May 10, 2012 12:54 pm
-
by sylwester » Tue Dec 11, 2012 5:15 pm
I haven't changed your code, just put it in code-tags. I tested it and it works.
- Code: Select all
(defun qsort (L)
(if (null L)
nil
(append
(qsort (list< (first L) (rest L)))
(cons (first L) nil)
(qsort (list>= (first L) (rest L))))))
You need to define list< and list>= as well since it's a large part that's obviously missing but if they return lists lower and higher than the first element you have (numeric) quick sort

-
sylwester
-
- Posts: 130
- Joined: Mon Jul 11, 2011 2:53 pm
Return to Homework
Who is online
Users browsing this forum: No registered users and 1 guest