![subject](/tpl/images/cats/informatica.png)
Computers and Technology, 27.04.2021 15:10 clara384
You will reimplement the Quicksort given in textbook and lecture slides. The given example, the first (left-most) element of the given list is selected as the pivot. In this question, you will choose the last (right-most) element of the list as the pivot. In order to do so, you can implement a get last(L, E) and remove_last(L, Ls), as described below.[20 points]
2.1 Write a Prolog rule: get last(L, E), which return the last element of list L to E. Test case: ?- get last([a, b, c, x, y], E) It returns E
2.2 Write a Prolog rule: remove last(L, Ls), which return the sub-list without the last element [10] to Ls Test case: ?- remove last([a, b, c, x, y], Ls) It returns Ls [a, b, c, x]
2.3 Rewrite quicksort rule qsort(L, Sorted), which will return the sorted list to Sorted. You must use the get_last and remove last in your qsort rule, so that the qsort rule takes the last (right-most) element of the list L as the pivot. Test case: 1?- qsort([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](/tpl/images/cats/User.png)
Answers: 2
![](/tpl/images/ask_question.png)
![](/tpl/images/ask_question_mob.png)
Other questions on the subject: Computers and Technology
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 13:00, torresnoemi899
Which of the following statements is false? a. a class can directly inherit from class object. b. if the class you're inheriting from declares instance variables as private, the inherited class can access those instance variables directly. c. a class's instance variables are normally declared private to enforce good software engineering. d. it's often much more efficient to create a class by inheriting from a similar class than to create the class by writing every line of code the new class requires.
Answers: 3
You know the right answer?
You will reimplement the Quicksort given in textbook and lecture slides. The given example, the firs...
Questions in other subjects:
![Konu](/tpl/images/cats/mat.png)
![Konu](/tpl/images/cats/ekonomika.png)
![Konu](/tpl/images/cats/biologiya.png)
![Konu](/tpl/images/cats/en.png)
![Konu](/tpl/images/cats/fizika.png)
![Konu](/tpl/images/cats/mat.png)
Mathematics, 25.05.2021 23:40
![Konu](/tpl/images/cats/istoriya.png)
![Konu](/tpl/images/cats/mat.png)
Mathematics, 25.05.2021 23:40
![Konu](/tpl/images/cats/informatica.png)
Computers and Technology, 25.05.2021 23:40