HOMEWORK 5. 1. Write a predicate substitute(X,Y,Xs,Ys) that is true if the list Ys is the result of substituting Y for all occurrences of X in the list Xs. ======================================================= 2. Write a predicate without_doubles_1(Xs, Ys) that is true if Ys is the list of the elements appearing in Xs without duplication. The elements in Ys are in the same order as in Xs with the last duplicate values being kept. Sample run: ?- without_doubles_1([1,2,3,4,5,6,4,4],X). X = [1, 2, 3, 5, 6, 4]; No ======================================================= 3. Write a predicate without_doubles_2(Xs, Ys) that is true if Ys is the list of the elements appearing in Xs without duplication. The elements in Ys are in the reversed order of Xs with the first duplicate values being kept. Sumple run: ?- without_doubles_2([1,2,3,4,5,6,4,4],X). X = [6, 5, 4, 3, 2, 1]; No ======================================================= 4. Given a list of elements colored red, white, and blue, reorder the list so that all the red elements appear first, then all the white elements, followed by the blue elements. The reordering should preserve the original relative order of elements of the same color. Sample run: ?- reorder([red(1), white(2), blue(3), red(4), white(5)], Reordered). Reordered = [red(1), red(4), white(2), white(5), blue(3)]; no Write two versions of the reordering program: with and without difference lists. ============ 5. Implement two versions of the quicksort algorithm: with and without difference lists. ============