Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Visual Studio, Please help! Show solutions and code, please. Please do Que

ID: 663884 • Letter: U

Question

Using Visual Studio, Please help!
Show solutions and code, please.

Please do Question 8
-You need to write a new sorting function which calls the quicksort function and insertion sort function in the right places.

7. Modify quicksort) to use insertion sort if the sublist has fewer than LOWER BOUND elements for some constant LOWER_BOUND and use quicksort otherwise 8. The preferred alternative to the approach in Exercise 7 suggested in the text was to ignore all sublists with fewer than LOWER BOUND elements, not splitting them further. When execution of the quicksort algorithm terminates, simply sort the list using insertion sort. Modify quicksortO to incorporate this modification.

Explanation / Answer

using Microsoft.VisualStudio.TestTools.UnitTesting; using PracticeExercises; using System; using System.Collections.Generic; namespace UnitTests { [TestClass] public class SortAlgorithmsTests { List originalList = new List(new int[] { 5, 4, 3, 1, 2 }); List sortedList = new List(new int[] { 1, 2, 3, 4, 5 }); [TestMethod] public void TestBubbleSort() { originalList = new List(new int[] { 5, 4, 3, 1, 2 }); SortAlgorithms.BubbleSort(originalList); CollectionAssert.AreEqual(sortedList, originalList); } [TestMethod] public void TestInsertionSort() { originalList = new List(new int[] { 5, 4, 3, 1, 2 }); originalList = SortAlgorithms.InsertionSort(originalList); CollectionAssert.AreEqual(sortedList, originalList); } [TestMethod] public void TestInsertionSortEmptyList() { originalList = new List(); originalList = SortAlgorithms.InsertionSort(originalList); CollectionAssert.AreEqual(new List(), originalList); } [TestMethod] public void TestInsertionSortInPlace() { originalList = new List(new int[] { 5, 4, 3, 1, 2 }); SortAlgorithms.InsertionSortInPlace(originalList); CollectionAssert.AreEqual(sortedList, originalList); } [TestMethod] public void TestSelectionSort() { originalList = new List(new int[] { 5, 4, 3, 1, 2 }); SortAlgorithms.SelectionSort(originalList); CollectionAssert.AreEqual(sortedList, originalList); } [TestMethod] public void TestMergeSort() { originalList = new List(new int[] { 5, 4, 3, 1, 2 }); originalList = SortAlgorithms.MergeSort(originalList); CollectionAssert.AreEqual(sortedList, originalList); } [TestMethod] public void TestMergeSortEmptyList() { originalList = new List(); originalList = SortAlgorithms.InsertionSort(originalList); CollectionAssert.AreEqual(new List(), originalList); } [TestMethod] public void TestQuickSort() { int[] originalList = new int[] { 5, 3, 4, 1, 2 }; SortAlgorithms.QuickSort(originalList,0,originalList.Length-1); CollectionAssert.AreEqual(sortedList.ToArray(), originalList); } } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote