How to sort binary array in O(n).

How to sort binary array containing only 0 and 1? If we have array containing decimal number then it is easy.This is generally asked question in any C++ interview. Problem is to sort an array containing only 0 and 1 as an element in O(n). Following algorithm will sort the array in ascending order.Here you go for the detailed program. How to sort binary array…