Welcome to W3Courses
 Like Us on Facebook

QuickSort

QuickSort Function using Prolog Source Code

Quick Sort code:

gtq(X,Y) :- X @> Y.  

quicksort( [],[] ).

quicksort( [X | Tail], Sorted) :-
        split( X, Tail, Small, Big),
        quicksort( Small, SortedSmall),
        quicksort( Big, SortedBig),
        conc( SortedSmall, [X | SortedBig], Sorted).

split( _, [], [], []).

Share