Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please complete in SML language. Please read entire document. Will Upvote! Problem The goal of this lab is to implement quicksort in SML. The idea

Please complete in SML language. Please read entire document. Will Upvote!

image text in transcribed

Problem The goal of this lab is to implement quicksort in SML. The idea of quicksort was to pick a pivot element p, partition the input in elements smaller than p and elements larger than p, and then recursively sort both parts. As pivot element, we will pick the median of the first, the middle, and the last element in a given list. To implement quicksort, implement the following functions. - A function last (1st) of type 'a list -> 'a which returns the last element of a given list. - A function middle(1st) of type 'a list -> 'a which returns the middle element of a given list. Hint: One way implement this functions is to create a helper function which recursively call itself with one list reduced by one item and the other reduced by two item until the smaller list is empty. - A function median(a, b, c) of type int * int * int -> int which returns the median of the given three elements. A function partition (1st, p) of type int list * int -> int list * int list that partitions the given list into a list containing all elements smaller than or equal to p and a list containing all elements larger than p. - A function quicksort(1st) of type int list -> int list which sorts a given list using quicksort and a pivot element as defined above. Do not use any pre-implemented functions of the form List.xyz(...)

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

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions

Question

=+7. What is progressive discipline?

Answered: 1 week ago

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago