Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a code in C++ that will produce the following answer. The answer that needs to be produced... Test swapListValues() swapListValuesO test 1, suap 2

Write a code in C++ that will produce the following answer.

The answer that needs to be produced...

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Test swapListValues() swapListValuesO test 1, suap 2 values expected: List length: 2 [10, 51 actual List length: 2 010, 51 swapListValues) test 2, same index expected: List length: 2 8, 61 actual List length: 2 [8, 6] swapListValues ) test 3, suap 2 values from inside of list expected: List length: 12 [2, 7, 6, 3, 8, 4, 2, 9, 5, 8, 9, 11 actual List length: 12 [2, 7, 6, 3, 8, 4, 2, 9, 5, 8, 9, 11 swapListValues ) test 4, reverse the previous swap expected: List length: 12 12, 7, 9, 3, 8, 4, 2, 9, 5, 8, 6, 11 actual: List length: 12 12, 7, 9, 3, 8, 4, 2, 9, 5, 8, 6, 1] swapListValuesO test 5, swap with index 0 expected: List length: 12 4, 7, 9, 3, 8, 2, 2, 9, 5, 8, 6, 11 actual List length: 12 [4, 7, 9, 3, 8, 2, 2, 9, 5, 8, 6, 1] suapListValues) test 6, swap with last index expected: List length: 12 [4, 7, 9, 3, 8, 2, 1, 9, 5, 8, 6, 2] actual List length: 12 4, 7, 9, 3, 8, 2, 1, 9, 5, 8, 6, 21 test findAndSwapPivot) -- findAndSwapPivot) test 1, basic test expected: List length: 3 [5, 8, 3] expected pivot: 3 actual: List length: 3 [5, 8, 3] actual pivot: 3 findAndSwapPivot O test 2, test list size 1 expected: List length: 1 [51 expected pivot: 5 actual: List length: 1 [51 actual pivot: 5 findAndSwapPivot ) test 3, bigger list with even number of values expected: List length: 10 [5, 2, 8, 7, 8, 9, 1, 4, 5, 31 expected pivot: 3 actual: List length: 10 [5, 2, 8, 7, 8, 9, 1, 4, 5, 3] actual pivot: 3 findAndSuapPivotO test 4, bigger list with odd number of values expected: List length: 15 [5, 2, 8, 7, 3, 9, 1, 18, 5, 8, 10, 11, 15, 22, 421 expected pivot: 42 actual: List length: 15 [5, 2, 8, 7, 3, 9, 1, 18, 5, 8, 10, 11, 15, 22, 421 actual pivot: 42 Test partitionListO - partitionList) test 1, basic test expected: List length: 10 [1, 3, 4, 2, 9, 6, 7, 8, 8, 51 expected pivot: 4 actual: List length 10 [1, 3, 4, 2, 9, 6, 7, 8, 8, 51 actual pivot: 4 partitionList) test 2, bigger test and some duplicates of the pivot expected: List length: 15 [4, 7, 6, 6, 19, 18, 12, 15, 10, 10, 12, 13, 11, 17, expected pivot: 4 actual: List length: 15 [4, 7, 6, 6, 19, 18, 12, 15, 10, 10, 12, 13, 11, 17, actual pivot: 4 partitionList) test 3, everything is smaller than pivot value expected: List length: 6 [4, 3, 7, 6, 5, 10] expected pivot: 5 actual: List length: 6 [4, 3, 7, 6, 5, 10] actual pivot: 5 partitionList) test 4, everything is bigger than pivot value expected: List length: 6 [4, 3, 7, 6, 5, 21 expected pivot: 0 actual: List length: 6 [4, 3, 7, 6, 5, 21 actual pivot: 0 partitionList) test 5, small list that needs a swap expected: List length: 3 [2, 8, 41 expected pivot: 1 actual: List length: 3 [2, 8, 41 actual pivot: 1 6 partitionList) test 6, list of size 1 Cand pivot value) expected: List length: 2 8, 41 expected pivot: 0 actual: List length: 2 [8, 41 actual pivot: 0 partitionList) test 7, list of size 1, pivot value is larger expected pivot: 1 expected: List length: 2 [8, 12] actual: List length: 2 8, 121 partitionList) test 8 (sort by hand) after first partition: List length: 5 [5, 3, 6, 7, 81 after second partition (left): List length: 5 [3, 5, 6, 7, 81 after third partition (right) List length: 5 [3, 5, 6, 7, 8] expected: List length: 5 [3, 5, 6, 7, 81 actual: List length: 5 [3, 5, 6, 7, 81 Test quickSort)- quickSort) test 1, sort list of size 1 expected: List length: 1 [8] actual: List length: 1 81 quickSort) test 2, sort list of size 2 already ordered expected: List length: 2 3, 9] actual: List length: 2 [3, 9] quickSort) test 3, sort list of size 2 out of order expected: List length: 2 [3, 91 actual: List length: 2 [3, 9] quickSort) test 4, sort odd sized list expected: List length: 9 [2, 3, 4, 5, 5, 6, 7, 8, 91 actual: List length: 9 L2, 3, 4, 5, 5, 6, 7, 8, 91 quickSort) test 5, sort even sized list expected: List length: 14 [2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 8, 9, 10, 111 actual: List length: 14 [2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 8, 9, 10, 111 quickSort test 6, sort already sorted list expected: List length 17 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1 actual: List length: 17 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1 quicksort() tet 7' sort a reversed list expected: List length: 17 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1 actual: List length: 17 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1 quickSort ) test 7, sort a reversed list expected: List length: 14 [4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 81 actual: List length: 14 [4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 81 Test swapListValues() swapListValuesO test 1, suap 2 values expected: List length: 2 [10, 51 actual List length: 2 010, 51 swapListValues) test 2, same index expected: List length: 2 8, 61 actual List length: 2 [8, 6] swapListValues ) test 3, suap 2 values from inside of list expected: List length: 12 [2, 7, 6, 3, 8, 4, 2, 9, 5, 8, 9, 11 actual List length: 12 [2, 7, 6, 3, 8, 4, 2, 9, 5, 8, 9, 11 swapListValues ) test 4, reverse the previous swap expected: List length: 12 12, 7, 9, 3, 8, 4, 2, 9, 5, 8, 6, 11 actual: List length: 12 12, 7, 9, 3, 8, 4, 2, 9, 5, 8, 6, 1] swapListValuesO test 5, swap with index 0 expected: List length: 12 4, 7, 9, 3, 8, 2, 2, 9, 5, 8, 6, 11 actual List length: 12 [4, 7, 9, 3, 8, 2, 2, 9, 5, 8, 6, 1] suapListValues) test 6, swap with last index expected: List length: 12 [4, 7, 9, 3, 8, 2, 1, 9, 5, 8, 6, 2] actual List length: 12 4, 7, 9, 3, 8, 2, 1, 9, 5, 8, 6, 21 test findAndSwapPivot) -- findAndSwapPivot) test 1, basic test expected: List length: 3 [5, 8, 3] expected pivot: 3 actual: List length: 3 [5, 8, 3] actual pivot: 3 findAndSwapPivot O test 2, test list size 1 expected: List length: 1 [51 expected pivot: 5 actual: List length: 1 [51 actual pivot: 5 findAndSwapPivot ) test 3, bigger list with even number of values expected: List length: 10 [5, 2, 8, 7, 8, 9, 1, 4, 5, 31 expected pivot: 3 actual: List length: 10 [5, 2, 8, 7, 8, 9, 1, 4, 5, 3] actual pivot: 3 findAndSuapPivotO test 4, bigger list with odd number of values expected: List length: 15 [5, 2, 8, 7, 3, 9, 1, 18, 5, 8, 10, 11, 15, 22, 421 expected pivot: 42 actual: List length: 15 [5, 2, 8, 7, 3, 9, 1, 18, 5, 8, 10, 11, 15, 22, 421 actual pivot: 42 Test partitionListO - partitionList) test 1, basic test expected: List length: 10 [1, 3, 4, 2, 9, 6, 7, 8, 8, 51 expected pivot: 4 actual: List length 10 [1, 3, 4, 2, 9, 6, 7, 8, 8, 51 actual pivot: 4 partitionList) test 2, bigger test and some duplicates of the pivot expected: List length: 15 [4, 7, 6, 6, 19, 18, 12, 15, 10, 10, 12, 13, 11, 17, expected pivot: 4 actual: List length: 15 [4, 7, 6, 6, 19, 18, 12, 15, 10, 10, 12, 13, 11, 17, actual pivot: 4 partitionList) test 3, everything is smaller than pivot value expected: List length: 6 [4, 3, 7, 6, 5, 10] expected pivot: 5 actual: List length: 6 [4, 3, 7, 6, 5, 10] actual pivot: 5 partitionList) test 4, everything is bigger than pivot value expected: List length: 6 [4, 3, 7, 6, 5, 21 expected pivot: 0 actual: List length: 6 [4, 3, 7, 6, 5, 21 actual pivot: 0 partitionList) test 5, small list that needs a swap expected: List length: 3 [2, 8, 41 expected pivot: 1 actual: List length: 3 [2, 8, 41 actual pivot: 1 6 partitionList) test 6, list of size 1 Cand pivot value) expected: List length: 2 8, 41 expected pivot: 0 actual: List length: 2 [8, 41 actual pivot: 0 partitionList) test 7, list of size 1, pivot value is larger expected pivot: 1 expected: List length: 2 [8, 12] actual: List length: 2 8, 121 partitionList) test 8 (sort by hand) after first partition: List length: 5 [5, 3, 6, 7, 81 after second partition (left): List length: 5 [3, 5, 6, 7, 81 after third partition (right) List length: 5 [3, 5, 6, 7, 8] expected: List length: 5 [3, 5, 6, 7, 81 actual: List length: 5 [3, 5, 6, 7, 81 Test quickSort)- quickSort) test 1, sort list of size 1 expected: List length: 1 [8] actual: List length: 1 81 quickSort) test 2, sort list of size 2 already ordered expected: List length: 2 3, 9] actual: List length: 2 [3, 9] quickSort) test 3, sort list of size 2 out of order expected: List length: 2 [3, 91 actual: List length: 2 [3, 9] quickSort) test 4, sort odd sized list expected: List length: 9 [2, 3, 4, 5, 5, 6, 7, 8, 91 actual: List length: 9 L2, 3, 4, 5, 5, 6, 7, 8, 91 quickSort) test 5, sort even sized list expected: List length: 14 [2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 8, 9, 10, 111 actual: List length: 14 [2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 8, 9, 10, 111 quickSort test 6, sort already sorted list expected: List length 17 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1 actual: List length: 17 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1 quicksort() tet 7' sort a reversed list expected: List length: 17 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1 actual: List length: 17 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1 quickSort ) test 7, sort a reversed list expected: List length: 14 [4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 81 actual: List length: 14 [4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 81

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions