Question: Replace the text * FILLINHERE * with the correct code in Prolog to make each function work. / * swap the first two elements if
Replace the text FILLINHERE with the correct code in Prolog to make each function work.
swap the first two elements if they are not in order
swapX YTY X T:
Y X
swap elements in the tail
swapHTHT:
swapT T
Comment describing bubbleSort
bubbleSortLSL:
swapL L at least one swap is needed
bubbleSortL FILLINHERE
bubbleSortL L here, the list is already sorted
Comment describing ordered
ordered
orderedX
orderedH HT:
H H
orderedHT
Comment describing insertE SL SLE
Comment describing the st clause of insert
insertXX
insertEHTEHT:
orderedT
FILLINHEREE H
Comment describing the nd clause of insert
insertEHTHT:
orderedT
insertE T FILLINHERE
Comment describing insertionSort
insertionSort
insertionSortHT SORTED :
insertionSortT T
insertH T FILLINHERE
Comment to describe meregeSort...
mergeSort The empty list is sorted
mergeSortXX:
mergeSortL SL:
splitinhalfL L L
mergeSortL FILLINHERE
mergeSortL S
mergeS FILLINHERE, SL
Comment to describe splitinhalf...
intDivNN R: R is divNN
splitinhalf: fail.
splitinhalfXX
splitinhalfL L L:
lengthLN
intDivNN
lengthL FILLINHERE
appendL L L
Comment describing mergeS S S
merge L L comment
mergeLL comment
mergeHTHTH FILLINHERE:
H FILLINHERE H
mergeTHTT
mergeHTHTHT:
FILLINHERE FILLINHERE
mergeHT T FILLINHERE
Comment describing split for quickSort
split
splitXHTHSMALL BIG:
H X
splitX T SMALL, FILLINHERE
splitXHT SMALL, HBIG:
X H
splitX T FILLINHERE, BIG
Comment describing quickSort
quickSort
quickSortHT LS:
splitH T SMALL, FILLINHERE
quickSortSMALL S
quickSortBIG B
appendSHB FILLINHERE
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
