Mark As Completed Discussion

Let's test your knowledge. Could you figure out the right sequence for this list?

Dutch Nation Flag algorithm

Press the below buttons in the order in which they should occur. Click on them again to un-select.

Options:

  • If arr[mid] == 2, then swap arr[mid] and arr[high] and decrease `high` by 1
  • Initialize a `low` variable pointing to the start of the array and a `high` pointing at the end
  • Declare a `mid` pointer that iterates through each element starting at index 0
  • If arr[mid] == 0, then swap arr[mid] and arr[low] and increase `low` and `mid` by 1
  • If arr[mid] == 1, don't swap anything and just increase the mid pointer by 1