Question: **in C++** Part A-1: Implement the MergeSort and Merge methods in the HeroesDB class. Your code must follow the pseudo-code. NOTE: you must add a

**in C++** Part A-1: Implement the MergeSort and Merge methods in the HeroesDB class. Your code must follow the pseudo-code.

NOTE: you must add a parameter of type SortBy to both methods. You will get the user's sort by selection in part A-2 and pass it to MergeSort.

Part A-1: MergeSort Implement the MergeSort and Merge methods in the HeroesDB class. Your code must follow the pseudo-code. NOTE: you must add a parameter of type SortBy to both methods. You will get the user's sort by selection in part A-2 and pass it to MergeSort. function MergeSort (vector m) is // Base case. A vector of zero or one elements is sorted, by definition. if length of m $ 1 then return m Recursive case. First, divide the vector into equal-sized subvectors // consisting of the first half and second half of the vector. / / This assumes vectors start at index 0. var left := empty vector var right := empty vector for I = 0 to length (m) do if i hero2 function Merge (left, right) is var result := empty vector while left is not empty and right is not empty do if first (left) S first (right) then add first (left) to result remove first from left else add first (right) to result remove first from right // Either left or right may have elements left; consume them. // (Only one of the following loops will actually be entered. ) while left is not empty do add first (left) to result remove first from left while right is not empty do add first (right) to result remove first from right return result

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!