Question
Problem 8. Partition around median. Given a vector A of distinct integers and given k, the median of A (the median might be a decimal
Problem 8. Partition around median. Given a vector A of distinct integers and given k, the median of A (the median might be a decimal number, e.g. 3.2). Partition items of A so that all items in the first half of A are less than or equal to k and a items in the second half of A are greater than k. Write a function that partitions integers of A in place (do not use any additional data structure) and does the fewest number of operations (such as comparisons, assignments) You need to write the following function with the exact header as shown: int partitionAround(vectorcint> &A, double k); (Note that vector A is passed by reference, but not const, because this function will change A)
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