subject
Engineering, 12.12.2019 05:31 dexterwilliams161

Quick sort code in prolog asort([],[]) : - ! % empty list is already sorted asort([pivot[tail], sorted): - % take first number as pivot split(pivot, tail, l1, l2), asort(l1, sorted1), % sort first part qsort(l2, sorted2), % sort second part append(sorted1,[pivot|sorted2], sorted). ,[],[]). split(pivot,[x|t],[x|le], gt): - x= pivot, split(pivot. t.le, gt). % stopping condition % take first from tail % and put it into le % take first from tail % and put it into gtchs 11/19/2002 you will reimplement the quicksort given in textbook and lecture slides. in the given example, the first (left-most) element of the given list is selected as the pivot. in this question, you must choose the second element of the list as the pivot. hint: you can represent the input list into pairs: [first | [pivot | tail]]. you must write comments to indicate the size-n problem, stopping condition and its return value, size m-problems, and construction of the size-n problem from size-m problems. [20 points] test case: | ? - qsort2([8, 3, 4, 12, 25, 4, 6, 1, 9, 22, 6], sorted). it returns: sorted = [1,3,4,4,6,6,8,9,12,22,25]

ansver
Answers: 3

Another question on Engineering

question
Engineering, 04.07.2019 18:10
Ajournal bearing has a journal diameter of 3.250 in with a unilateral tolerance of 20.003 in. the bushing bore has a diameter of 3.256 in and a unilateral tolerance of 0.004 in. the bushing is 2.8 in long and supports a 700-lbf load. the journal speed is 900 rev/min. find the minimum oil film thickness and the maximum film pressure for both sae 20 and sae 20w-30 lubricants, for the tightest assembly if the operating film temperature is 160°f. a computer code is appropriate for solving this problem.
Answers: 3
question
Engineering, 04.07.2019 18:20
A2-m rigid tank initially contains saturated water vapor at 100 kpa. the tank is connected to a supply line through a valve. steam is flowing in the supply line at 600 kpa and 300 c. the valve is opened, and steam is allowed to enter the tank until the pressure in the tank reaches the line pressure, at which point the valve is closed. a thermometer placed in the tank indicates that the temperature at the final state is 200°c. determine (a) the mass of steam that has entered the tank (b) the amount of heat transfer.
Answers: 3
question
Engineering, 04.07.2019 18:20
For each of the following process: a) sketch the p-v diagram, b)sketch t-s diagram, c) sketch t-v diagram, d) sketch the boundary work on one of the diagrams (a, b or c) and e) sketch the reversible heat transfer on one of the diagrams (a, b or c): 1- isobaric process from compressed liquid to superheated vapor 2- isothermal process from compressed liquid to superheated vapor 3- isentropic process from compressed liquid to superheated vapor
Answers: 3
question
Engineering, 04.07.2019 19:10
What is the major difference between thermoplastics and thermosetting plastics from the polymerization structure point of view?
Answers: 2
You know the right answer?
Quick sort code in prolog asort([],[]) : - ! % empty list is already sorted asort([pivot[tail], sor...
Questions
question
Mathematics, 22.08.2019 20:00
Questions on the website: 13722362