OCAML PROGRAMMING LANGUAGE ONLY Write a recursive function called partition that
ID: 3602723 • Letter: O
Question
OCAML PROGRAMMING LANGUAGE ONLY
Write a recursive function called partition that takes a pivot item and a list as arguments, and returns a tuple containing a list of items from the list that are less than the pivot and a list of items from the list that are greater than or equal to the pivot. If the original list contains duplicate items then the partitions should also contain duplicate items. If the original list is empty, both of the partitions should be empty. You may not use any built-in list functions.
Explanation / Answer
Ans
in this we can write a quick sort code in the OCAML recursive programming language
let recr quicksort = functon
[ ] -> [ ]
pivot element :: reset ->
let is_less a = a < pivot element in
let left , right = List.partition is_less reset in
quicksort left [ pivot ] pivot quicksort right
In this their is no built in function is use.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.