Sorting seven numbers: Write a program which reads an array of 7 integers then represents them in an increasing order....
Sorting using merge-sort algorithm: Sort the elements of an array A in ascending order.
Condition Merge 2 arrays (each of 1 element)
Divide the non sorted array until the condition is verified and sort the divided parts into pairs.
Precisely:
Recursively divide the non sorted array in...
Sorting using heap-sort algorithm: Sort the elements of an array A in ascending order.
Heapsort algorithm inserts all elements into a heap, then removes them from the root of a heap until the heap is empty.
Sort can be done in place with the array to be sorted.Instead of deleting an e...
Sorting using quick-sort algorithm: Sort the elements of an array A in ascending order.
Quick-sort uses recursive calls for sorting the elements.
Is an example for divide-and-conquer algorithmic technique.Divide: the array A[low … high] is partitioned into two non-empty sub arrays
A[...
Sorting using the counting sort algorithm: Sort the elements of an array A in ascending order.
According to wikipedia, the counting sort is an algorithm for sorting a collection of objects according to keys that are small integers; that is, it is an integer sorting algorithm. It operates by ...
Sorting using the radix sort algorithm: Sort the elements of an array A in ascending order.
According to wikipedia, the radix sort is a non-comparative integer sorting algorithm that sorts data with integer keys by grouping keys by the individual digits which share the same significant po...
Heapsort complexity: What is the asymptotic running time of the $$\texttt{heapsort}$$ algorithm on an array of length $$n$$ that is already sorted in ascending order? What about if the array is sorted in decreasing order? In both cases, justify your answer....
Trace of MergeSort: Consider the following array:
$$\begin{array}{|c|c|c|c|c|c|c|c|c|c|c|c|c|} \hline 5 & 8 & 1 & 9& -2 & 10 & 3 & 2 & 6 & 2 & 0 & 7 & -4 \\\hline\end{array}$$
Trace MergeSort using the above table to sort ...
Tracing QuickSort and Heapsort: Consider the following table:
$$\begin{array}{|c|c|c|c|c|c|c|c|c|}\hline 9 & 15& 5 &7 &11 &4 &10 &13 &8\\\hline \end{array}$$
Trace $$\texttt{QuickSort}$$ using the above table to sort its entries.
Trace $$\texttt{Heap...
Kth smallest element in an array using QuickSort: Implement the following function $$\texttt{find_k}$$ :
$$\texttt{int find_k(int A[], int N, int k);}$$
where $$\texttt{A}$$ is an array of distinct positive numbers, $$\texttt{N}$$ the dimension of the array, and $$\texttt{k} > 0$$. The function c...