Problem 6.1 epi 1.6.1 - question about specific input

#1

This might be a silly one but i’d appreciate any advice.

i tried to run the code in DutchNationalFlagSlowInplace.java
on the input -
BRBWBRW with pivot=5 ®
and the output was
RRBBWWB
which is definitely not the desired output in this case.
Am I missing something ?

0 Likes

#2

Hey @abusufgi,

It makes sense since the element you choose is the smallest one ®. So the output array is correct as nothing is placed in front of R, the pivot you choose and which is the smallest. If you want something you expected, you shall choose W as the pivot.

0 Likes