MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / threeWayPartition

Method threeWayPartition

ThreeWayPartitioning.java:10–30  ·  view source on GitHub ↗
(int array[], int a, int b)

Source from the content-addressed store, hash-verified

8 arr[b]=x;
9 }
10 public void threeWayPartition(int array[], int a, int b)
11 {
12 // code here
13 int l = 0;
14 int r = array.length-1;
15 int i=0;
16 for(i=0;i<=r;i++)
17 {
18 if(array[i]<a)
19 {
20 swap(array,l,i);
21 l++;
22 }
23 else if(array[i]>b)
24 {
25 swap(array,r,i);
26 r--;
27 i--;
28 }
29 }
30 }
31}

Callers

nothing calls this directly

Calls 1

swapMethod · 0.95

Tested by

no test coverage detected