Answered step by step
Verified Expert Solution
Question
1 Approved Answer
given code: Function partition that takes as parameters(1) string S of size n, passed constant by reference (2) vector indices of integers of size n,
given code:
Function partition that takes as parameters(1) string S of size n, passed constant by reference (2) vector indices of integers of size n, where each integer is the starting position of a suffix in S; indices are passed by reference (3) integers low and high, the start and the end indices of a given range; and (4) an integer pivotindex, which is an arbitrary index of the vector indices int partition(const string &S, vectorint> &indices, int low, int high, int pivotindex) First, this function swaps indices[pivotindex] and indices[high], where high is the last index in the range Then, this function will partition suffix indices (use code of Partition provided in lecture notes as an example) so that the first half contains positions of suffixes that are less than suffix pivot and the second contains indices of suffixes that are greater than suffix pivot. This function will call the functions lessThan to accomplish this task. INPUT: abracadabra 4 OUTPUT: 0 1 8 3 10 5 74 2 9 6 INPUT: abracadabra1 OUTPUT 0 10 8 3 7 5 1 4 2 9 6 INPUT: Life what happens while we are making other plans. 6 OUTPUT: 46 43 2 3 4 41 49 7 37 9 10 11 36 32 14 30 29 17 27 26 25 23 22 6 24 2 19 18 28 16 15 31 13 33 34 35 12 8 38 39 40 5 42 1 44 45 47 48 21 int partition(vector
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started