Three way partitioning Python
PROGRAM TO PARTITION AN ARRAY AROUND A GIVEN RANGE
Given an array and a range [lowVal, highVal], partition the array around the range such that array is divided in three parts.
1) All elements smaller than lowVal come first.
2) All elements in range lowVal to highVVal come next.
3) All elements greater than highVVal appear in the end.
The individual elements of three sets can appear in any order.
1) All elements smaller than lowVal come first.
2) All elements in range lowVal to highVVal come next.
3) All elements greater than highVVal appear in the end.
The individual elements of three sets can appear in any order.
OUTPUT
Modified array 1 5 4 2 1 3 14 20 20 98 87 32 54
Comments
Post a Comment