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
Afour cylinder four-stroke in-line engine has a stroke of 160mm, connecting rod length of 150mm, a reciprocating mass of 3kg and its firing order is 1-3-4-2. the spacing between cylinders is 100mm. i. show that the engine is in balance with regard to the primary inertia forces and primary 3. a and secondary inertia couples. li determine the out of balance secondary inertia force ii. propose ways of balancing this out of balance force and discuss the challenges that will arise
Answers: 3
question
Engineering, 04.07.2019 18:10
Afluid flows with a velocity field given by v=(x/t)i.. determine the local and convective accelerations when x=3 and t=1.
Answers: 2
question
Engineering, 04.07.2019 18:10
The higher the astm grain-size number, the coarser the grain is. a)-true b)-false
Answers: 3
question
Engineering, 04.07.2019 18:10
Which of the following refers to refers to how well the control system responds to sudden changes in the system. a)-transient regulation b)- distributed regulation c)-constant regulation d)-steady-state regulation
Answers: 1
You know the right answer?
Quick sort code in prolog asort([],[]) : - ! % empty list is already sorted asort([pivot[tail], sor...
Questions
question
Mathematics, 18.06.2021 05:30
question
Social Studies, 18.06.2021 05:30
question
Mathematics, 18.06.2021 05:30
question
Mathematics, 18.06.2021 05:30
Questions on the website: 13722361