Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

answer must be in racket *** ***** ; ** problem 4 ** (15 points) ; Write three procedures ; (sorted? compare? lst) ; (insert compare?

answer must be in racket

image text in transcribedimage text in transcribed

*** ***** ; ** problem 4 ** (15 points) ; Write three procedures ; (sorted? compare? lst) ; (insert compare? item lst) ; (merge compare? lst1 lst2) ; For each of these procedures, you may assume that ; compare? is a total order on the elements of lst, ; item and the elements of Ist, and the elements of lst1 and 1st2, ; respectively. ; (sorted? compare? lst)|| ; takes a list of items and returns #t or #f ; depending on whether the items of lst are ; sorted with respect to the comparison predicate ; compare? ; In other words, the result should be #f if and only if ; there are two consecutive elements of lst for ; which compare? returns #f. ; (insert compare? item lst) ; inserts an item into a list ist of items ; which is sorted with respect to the compare? ; predicate, so that the resulting list of ; items is also sorted with respect to the ; compare? predicate. ; (merge compare? lsti Ist2) ; takes two lists of elements Ist1 and ist2, each of which is sorted with ; respect to the compare? predicate, and produces as its result a list ; of all the items in Ist1 and 1st2 (preserving duplicates) that is ; sorted with respect to compare? ; Examples ;> (sorted? (sorted? >= '(10 9 4 7 6)) ;#f ;> (insert (insert string>=? "hello" (list "the" "best" "arrangement")) ;'("the" "hello" "best" "arrangement") ;> (merge >= '(10 7 4 2 1) '(22 9 5)) ;'(22 10 9 7 5 4 2 1) ;> (merge string (sorted? (sorted? >= '(10 9 4 7 6)) ;#f ;> (insert (insert string>=? "hello" (list "the" "best" "arrangement")) ;'("the" "hello" "best" "arrangement") ;> (merge >= '(10 7 4 2 1) '(22 9 5)) ;'(22 10 9 7 5 4 2 1) ;> (merge string

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions

Question

accounts

Answered: 1 week ago