diff options
| author | mo khan <mo.khan@gmail.com> | 2020-09-26 19:44:29 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-09-26 19:44:29 -0600 |
| commit | 5cb4ce51804e8bc60fef6f3e33ceaee0f05bacc6 (patch) | |
| tree | 58a88d84a8d826ae89a23d95d74404a1741bd3ba /src/03/04 | |
| parent | c93020800e852b17f4cf30fb867bccac88d61cbd (diff) | |
Collapse all questions into a single README
Diffstat (limited to 'src/03/04')
| -rw-r--r-- | src/03/04/README.md | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/src/03/04/README.md b/src/03/04/README.md deleted file mode 100644 index fb94660..0000000 --- a/src/03/04/README.md +++ /dev/null @@ -1,56 +0,0 @@ -Given sequence 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, sort the sequence using the -following algorithms, and illustrate the details of the execution of the -algorithms: - -a. merge-sort algorithm. - -```plaintext -[3,1,4,1,5,9,2,6,5,3,5,] -[3,1,4,1,5,9,] -[3,1,4,] -[3,1,] -[3,] -[3,1,] -[1,3,4,] -[1,3,4,1,5,9,] -[1,3,4,1,5,] -[1,3,4,1,] -[1,3,4,1,5,] -[1,3,4,1,5,9,] -[1,1,3,4,5,9,2,6,5,3,5,] -[1,1,3,4,5,9,2,6,5,] -[1,1,3,4,5,9,2,6,] -[1,1,3,4,5,9,2,] -[1,1,3,4,5,9,2,6,] -[1,1,3,4,5,9,2,6,5,] -[1,1,3,4,5,9,2,5,6,3,5,] -[1,1,3,4,5,9,2,5,6,3,] -[1,1,3,4,5,9,2,5,6,3,5,] -``` - -b. quick-sort algorithm. -* Choose a partitioning strategy you like to pick a pivot element from the sequence. -* Analyze how different portioning strategies may impact on the performance of the sorting algorithm. - -For choosing a pivot I chose to use the value in the last element of the sequence. -Alternative, strategies include choosing a random pivot in each sub-sequence. - -Using the last item in the sub-sequence as the pivot: - -```plaintext -[3,1,4,1,5,9,2,6,5,3,] -[3,1,4,1,2,] -[1,1,] -[1,] -[] -[1,] -[1,1,] -[1,1,2,3,4,] -[1,1,2,] -[1,1,2,3,3,] -[1,1,2,3,3,4,5,6,5,9,] -[1,1,2,3,3,4,] -[1,1,2,3,3,4,5,5,5,9,] -[1,1,2,3,3,4,5,5,] -[1,1,2,3,3,4,5,5,5,6,] -``` |
