SWI-PROLOG ONLY PLEASE. Q. Create a predicate that performs the insertion sort algorithm to organise a list of numbers in ascending order.
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
SWI-PROLOG ONLY PLEASE. Q. Create a predicate that performs the insertion sort algorithm to organise a list of numbers (in ascending order):
Data Structure and Algorithm in Java Q. Rewrite the INSERTION-SORT method to sort into descending order instead of ascending order.
I'm using SWI-Prolog for the project. Define a predicate segregate/3 that takes a list of integers as an argument and generates two lists, the first containing containing the even numbers from the original list and the second sublist containing the odd numbers from the original list. Your predicate should have the signature segregate(List, Even, Odd). Examples: ?- segregate([8,7,6,5,4,3], Even, Odd). Even = [8,6,4] Odd = [7,5,3] ?- segregate([7,2,3,5,8], Even, Odd). Even = [2,8] Odd = [7,3,5] ?- segregate([-4,11,-7,9,0], Even, Odd)....
Using C++ Create a program that performs the Bubble Sort, the Insertion Sort, and the Selection Sort with arrays of varying lengths. You will time each algorithm. The algorithms' time complexities should allow us to predict how these algorithms will perform. Program needs Four separate arrays, each with the same length and filled with the same sequence of randomly chosen numbers. Four separate functions, one for each of the four algorithms. All four functions will need to be timed. Be...
Implement MERGE-SORT() algorithm that reads from a file named “inputHW02.txt” a list of double numbers (max = 3,000,000 numbers), sorts those numbers and indicates time consumption. This programming question will address the advantage of using iteration loops over recursive calls as well as using INSERTION-SORT() as a procedure in MERGESORT(). Your program must perform the following actions: 1. Opens the given file name and reads all double numbers. For simplicity, we assume this file only contains numbers and nothing else....
Implement MERGE-SORT() algorithm that reads from a file named “inputHW02.txt” a list of double numbers (max = 3,000,000 numbers), sorts those numbers and indicates time consumption. This programming question will address the advantage of using iteration loops over recursive calls as well as using INSERTION-SORT() as a procedure in MERGESORT(). Your program must perform the following actions: 1. Opens the given file name and reads all double numbers. For simplicity, we assume this file only contains numbers and nothing else....
4. [201 Use Prolog (e.g., SWI-Prolog) to create a knowledge base for the family tree of Figure 1 and then ask queries about the family tree. Assume the intended interpretation of all predicates of the form p(x.y) is that "x is the p of y" George eMum r-Kydd Elizabeth Philip Margaret Diana-Charles Anne-Mark Andrew Sarah E William Harry Peter Zara Beatrice Eugenie Figure 1. A typical family tree. The symbol-connects spouses and arrows point to children. Enter the information from...
Implement MERGE-SORT() algorithm that reads from a file named “inputHW02.txt” a list of double numbers (max = 3,000,000 numbers), sorts those numbers and indicates time consumption. This programming question will address the advantage of using iteration loops over recursive calls as well as using INSERTION-SORT() as a procedure in MERGESORT(). Your program must perform the following actions: 1. Opens the given file name and reads all double numbers. For simplicity, we assume this file only contains numbers and nothing else....
Please create a method or class to test my Insertion Sort algorithm by providing a complete test with n = 2, 4, … , up to 2^16 . public static void insertionSort(int a[]) { int n = a.length; for (int i = 1; i < n; i++) { int target = a[i]; int j = i - 1; while (j >= 0 && target < a[j]) { a[j +...
Consider the following python code that will sort the list of numbers using the Bubble Sort algorithm def bubbleSort(alist): print(alist) for j in range (len(alist) - 1, 8, -1): for i in range(): if alist[i] > alist[i + 1]: temp = alist[i] alist[i] = alist[i+1] alist[i+1] = temp print(alist) alist = [52, 25, 94, 17, 25, 52] bubbleSort (alist) print(alist) Sort the following series of values into ascending order using the Bubble Sort algorithm. Write out the complete row of...
please help with python Write a well-documented, Python program, hmwk305.py that implements the Selection-Sort algorithm. Selection Sort segments the list into sorted and unsorted elements. The algorithm continues to remove the smallest element of the unsorted list and adds it to the sorted segment. Implement the algorithm that accepts an unsorted list and returns a sorted one - in ascending order. 5 3 8 4 6 Initial List Minimum Swaps Position: Sorted List Length 1 Minimum Swaps Position: Sorted List...