apply_majority_rule function

Apply the majority rule algorithm