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
An air conditioning system consist of a 5 cm diameter pipe, operating at a pressure of 200 kpa. the air initially enters the pipe at 15°c with a velocity of 20 m/s and relative humidity of 80%. if the heat supply throughout the process is 960 w, determine the relative humidity and the temperature at the outlet
Answers: 3
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
Slip occurs via two partial dislocations because of (a) the shorter path of the partial dislocation lines; (b) the lower energy state through partial dislocations; (c) the charge balance.
Answers: 1
question
Engineering, 04.07.2019 18:10
The higher the astm grain size number, the finer the gran is. a)-true b)-false
Answers: 2
You know the right answer?
Quick sort code in prolog asort([],[]) : - ! % empty list is already sorted asort([pivot[tail], sor...
Questions
question
Biology, 07.12.2021 04:30
question
Mathematics, 07.12.2021 04:30
question
Mathematics, 07.12.2021 04:30
question
Mathematics, 07.12.2021 04:30
question
Mathematics, 07.12.2021 04:30
question
Mathematics, 07.12.2021 04:30
Questions on the website: 13722363