Problem Description( Refer to Exercise 6 on Page 116) Write a quick sort function of type...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Problem Description( Refer to Exercise 6 on Page 116) Write a quick sort function of type int list -> int list. Here is a review for quick sort algorithm. First pick an element and call it pivot. (The head of the list is an easy choice for the pivot.) Partition the rest of the list into two sublists, one with all the elements less than the pivot and another one with all the elements not less than the pivot. Recursively sort the sublists. Combine two sublists and pivot into final sorted list. Requirement: The solution must follow the style of function merge sort on page 114. The help functions must be made inside let. Sample Run: Please see the screen shot below to see the sample run Project - run.x86-darwin - 80x24 Last login: Sat Jan 2 15:13:23 on ttys000 MACS-H-ZENG-MBA: ~ h_zeng $ cd Documents/CSCI461VA/Project MACS-H-ZENG-MBA: Project h_zeng$ sml Standard ML of New Jersey v110.79 [built: Sun Oct 4 14:45:06 2015] - use "CSCI461ProjTwo.sml"; [opening CSCI461Proj Two.sml] val partition = fn : int * int list -> int list * int list val quickSort = fn : int list -> int list val newQuickSort = fn: int list -> int list val it (): unit - val x = [3, 1, 4, 8, 9, 5, 7, 6, 2, 0]; val x = [3,1,4,8,9,5,7,6,2,0]: int list - quickSort x; val it = [0,1,2,3,4,5,6,7,8,9] int list Problem Description( Refer to Exercise 6 on Page 116) Write a quick sort function of type int list -> int list. Here is a review for quick sort algorithm. First pick an element and call it pivot. (The head of the list is an easy choice for the pivot.) Partition the rest of the list into two sublists, one with all the elements less than the pivot and another one with all the elements not less than the pivot. Recursively sort the sublists. Combine two sublists and pivot into final sorted list. Requirement: The solution must follow the style of function merge sort on page 114. The help functions must be made inside let. Sample Run: Please see the screen shot below to see the sample run Project - run.x86-darwin - 80x24 Last login: Sat Jan 2 15:13:23 on ttys000 MACS-H-ZENG-MBA: ~ h_zeng $ cd Documents/CSCI461VA/Project MACS-H-ZENG-MBA: Project h_zeng$ sml Standard ML of New Jersey v110.79 [built: Sun Oct 4 14:45:06 2015] - use "CSCI461ProjTwo.sml"; [opening CSCI461Proj Two.sml] val partition = fn : int * int list -> int list * int list val quickSort = fn : int list -> int list val newQuickSort = fn: int list -> int list val it (): unit - val x = [3, 1, 4, 8, 9, 5, 7, 6, 2, 0]; val x = [3,1,4,8,9,5,7,6,2,0]: int list - quickSort x; val it = [0,1,2,3,4,5,6,7,8,9] int list
Expert Answer:
Answer rating: 100% (QA)
Here is a quicksort function in SML that follows the style of the merge sort ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Why is it difficult to addresses a variety of readers who have different perspectives from those of the writer? What specific actions should you take to lessen or eliminate this issue?
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Refer to Exercise 6 on page 119 for a description of a study about walking speed. Exercise 6 In a double-blind study, 50 older adults who had difficulty keeping their balance and/or were slow walkers...
-
In Exercises find the vertex, focus, and directrix of the parabola, and sketch its graph. x 2 + = 0
-
List two disadvantages of ULTs compared to KLTs.
-
Does each of the following describe a physical change or a chemical change? (a) The helium gas inside a balloon tends to leak out after a few hours. (b) A flashlight beam slowly gets dimmer and...
-
The tall vertical pump example was successfully brought down to acceptable vibration levels by placing a long 2- 4-inch beam between the top of the motor and a cinder block wall. What else could...
-
McLaughlin borrowed $1,000 from Adler, who, apprehensive about McLaughlins ability to pay, demanded security. McLaughlin indorsed and delivered to Adler a negotiable promissory note executed by...
-
Suppose that each kilowatt-hour (kwh) of electricity produced using natural gas results in 0.2kgs of carbon dioxide emissions. If each ton of carbon dioxide emissions results in environmental costs...
-
You are meeting with a client and they tell you data observability is not a priority right now. You ask them if they are scaling their data platform, and they say yes. What question should you follow...
-
XYZ was formed as a calendar-year S corporation with Xavier, Yolinda, and Zach as equal shareholders. On September 15, 2020, XYZ's S election was terminated after Zach sold his XYZ shares (one-third...
-
How do theories of globalization and transnationalism reconfigure conventional understandings of social boundaries, community, and identity in an increasingly interconnected world ?
-
How do classical and contemporary social theorists conceptualize the relationship between agency and structure in shaping social phenomena, and what implications does this have for understanding...
-
What are the advantages and disadvantages of studying abroad? Explain briefly
-
How can you apply what you learned about communication and relationship building to your personal, professional, and academic life? Throughout this course, you've had a chance to view multiple PLAY...
-
1. Select five companies you do business with. Does each one need to engage their customers, ? Explain why or why not. 2. What are the next big tech trends? 3. Under what conditions does cloud...
-
The following information relates to Acco Co.: a. Beginning cash balance on July 1: $35,000. b. Cash receipts from sales: 27% is collected in the month of sale, 50% in the next month, and 23% in the...
-
F.(3e* -2x 3 sin(2x)) is equal to 2 3 Cos 8. IT 3, t (4+@ 2 3, 1+o 1 4 Cos 4 4 1 3. 1 +4cos V7 (1+o 4 1 4 Cos 4 1+0 4-
-
a. Wilson filed his individual tax return on the original due date, but failed to pay $700 in taxes that were due with the return. If Wilson pays the taxes exactly 2 months late, calculate the amount...
-
For each of the following cases, indicate the filing status for the taxpayer(s) for 2012 using the following legend: A - Single B - Married, filing a joint return C - Married, filing separate returns...
-
Greg died on July 1, 2012, and left Lea, his wife, a $50,000 life insurance policy which she elects to receive at $5,000 per year plus interest for 10 years. In the current year, Lea receives $6,200....
-
Diana Corporation provides the following information for 2017: Calculate the total manufacturing costs incurred in 2017. Beginning inventory of direct materials, 1/1/2017 Purchases of direct...
-
Pepsi Corporation uses trucks to transport bottles from the warehouse to different retail outlets. Gasoline costs are $0.15 per mile driven. Insurance costs are $6,000 per year. Calculate the total...
-
What are the three key features of cost accounting and cost management?
Study smarter with the SolutionInn App