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
Determine whether or not it is possible to compress air adiabatically from k to 140 kpa and 400 k. what is the entropy change during this process?
Answers: 3
question
Engineering, 04.07.2019 18:10
Water at 55c flows across a flat plate whose surface temperature is held constant at 95c. if the temperature gradient at the plate's surface for a given value of x is 18 c/mm, find a) local heat transfer coefficient. b) heat flux
Answers: 3
question
Engineering, 04.07.2019 18:10
Burgers vector is generally parallel to the dislocation line. a)-true b)-false
Answers: 2
question
Engineering, 04.07.2019 18:20
Asolid cylinder is concentric with a straight pipe. the cylinder is 0.5 m long and has an outside diameter of 8 cm. the pipe has an inside diameter of 8.5 cm. the annulus between the cylinder ad the pipe contains stationary oil. the oil has a specific gravity of 0.92 and a kinematic viscosity of 5.57 x 10-4 m2/s. most nearly, what is the force needed to move the cylinder along the pipe at a constant velocity of 1 m/s?
Answers: 3
You know the right answer?
Quick sort code in prolog asort([],[]) : - ! % empty list is already sorted asort([pivot[tail], sor...
Questions
question
Mathematics, 20.08.2019 05:00
question
Mathematics, 20.08.2019 05:00
question
Mathematics, 20.08.2019 05:00
question
Social Studies, 20.08.2019 05:00