Answered step by step
Verified Expert Solution
Link Copied!

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,

image text in transcribed

given code:

image text in transcribed

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 &A, int low, int high){ int pivot -A[high]; int i - low, j - high - 1; while(i - low && A[j] > pivot) f (1

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

Step: 3

blur-text-image

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

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

Students also viewed these Databases questions

Question

What are the APPROACHES TO HRM?

Answered: 1 week ago

Question

Understand the process of arbitration

Answered: 1 week ago

Question

Know the different variations of arbitration that are in use

Answered: 1 week ago