LargestTwo problem: Based upon the pseudocode code below,implement in C++ a divide-and-conquer algorithm that finds thelargest and second largest value from a vector of ints.
void LargestTwo (vector l, int left, int right, int &largest, int & secondLargest)
• Please write comment for your functions, similar to the one inthe pseudocode, to include both pre- and post-conditions.
• Comment on the logic of your code, e.g., what is true afterthe two recursive calls?
• Answer the three questions in the comment of your code. •
Test the function in main(), by calling the function to find outlargest and second largest values in a vector of length 2, 3 and 4,and make sure you include cases where the largest and secondlargest values are the same, e.g., for vector {3,4,4}, the top twolargest values are both 4.
Pseudocode
/* return largest and second largest element in listl[left...right] precondition: left+1<=right, i.e., the listcontains at least two elements postcondition: the largest andsecondLargest will be set to the largest element and second largestelement respectively */
LargestTwo (l[], left, right, largest, secondLargest)
{ //Write base case(s) and solutions here if (left+1==right)//i.e., there are two elements in the list
//Fill in the blank else
if (left+2==right) //i.e., there are three elements in thelist
//Fill in the blank, i.e., try to set largest, secondLargest
// to the largest and secondLargest values inl[left...right]
mid = (left+right)/2
LargestTwo (l, left, mid, leftL, leftSL)
LargestTwo (l, mid+1, right, rightL, rightSL)
//Fill in the rest of the code
// Note that based upon the postcondition of LargestTwo, wehave
// leftL and leftSL are largest and secondLargest value froml[left...mid] // rightL and rightSL are largest and secondLargestvalue from l[mid+1...right] }