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

Other questions on the subject: Engineering

image
Engineering, 03.07.2019 14:10, kayabwaller4589
When at a point two solid phase changes to one solid phase on cooling then it is known as a) eutectoid point b) eutectic point c) peritectic point d) peritectoid point
Answers: 3
image
Engineering, 04.07.2019 18:10, mm016281
What difference(s) did you notice using a pneumatic circuit over hydraulic circuit. explain why the pneumatic piston stumbles when it hits an obstacle.
Answers: 2
image
Engineering, 04.07.2019 18:10, danksans7011
The mass flow rate of the fluid remains constant in all steady flow process. a)- true b)- false
Answers: 1
image
Engineering, 04.07.2019 18:10, hadellolo8839
Acompressor receives the shaft work to decrease the pressure of the fluid. a)- true b)- false
Answers: 3
You know the right answer?
Quick sort code in prolog asort([],[]) : - ! % empty list is already sorted asort([pivot[tail], sor...

Questions in other subjects:

Konu
Mathematics, 24.03.2021 21:00
Konu
Computers and Technology, 24.03.2021 21:00