Q:

Trigger to be executed on DML?

There is two object Branch and Employee both are related to each other by a Branch_Lookup field on Employee field. Both are having a checkbox field named as External_Employee__c , as per req if parent is having 4 child record and , child record is having any of the checkbox true then it must be true in parent and if all are false in child then in parent it must be false.
note i have covered the first part but not able to make the second part. 
my code as follows
public class TH_Clr_Set_the_External_employee_true {
    public static void external() {

        integer count = 0;

        List < Employee__c > employeeList = new List < Employee__c > ();
        employeeList = [Select id, Name, Branch_Lookup__c, External_Employee__c FROM Employee__c Where External_Employee__c = true];

        List < Branch__c > branchList = new List < Branch__c > ();
        branchList = [Select id, Name, External_Employee__c FROM Branch__c];

        List < Employee__c > employeeList1 = new List < Employee__c > ();
        employeeList1 = [Select id, Name, Branch_Lookup__c, External_Employee__c FROM Employee__c];

        set < id > branchidwithemployee = new set < id > ();

        List < Branch__c > branchList1 = new List < Branch__c > ();
        List < Branch__c > branchList2 = new List < Branch__c > ();

        for (Branch__c branch2: branchList) {
            for (Employee__c employee2: employeeList1) {
                if ((branch2.External_Employee__c == true) && (employee2.External_Employee__c == true) && (employee2.Branch_Lookup__c == branch2.id)) {
                    branchidwithemployee.add(employee2.Id);
                    count = branchidwithemployee.size();
                }
            }
        }

        if (count == 0) {
            for (Branch__c branch: branchList)

            {
                for (Employee__c employee: employeeList) {
                    if ((employee.Branch_Lookup__c == branch.id) && (employee.External_Employee__c == true) && (branch.External_Employee__c != true)) {
                        system.debug('<<<<<Branch_Lookup__c>>>>' + employee.Branch_Lookup__c);
                        branch.External_Employee__c = true;
                        System.debug('##########External_Employee__c' + branch.External_Employee__c);
                        branchList1.add(branch);

                    }
                }
            }
            database.update(branchList1, false);
        } else {

            for (Branch__c branch1: branchList) {
                for (Employee__c employee1: employeeList) {

                    System.debug('##########em.Branch_Lookup__c' + employee1.Branch_Lookup__c);
                    System.debug('**********et.id' + branch1.Id);
                    System.debug('&&&&&&&&&&em.External_Employee__c' + employee1.External_Employee__c);
                    System.debug('^^^^^^^^^^^^^^^^^^' + branch1.External_Employee__c);
                    if ((employee1.Branch_Lookup__c == branch1.id) &&
                        (employee1.External_Employee__c == false) &&
                        (branch1.External_Employee__c == true)) {
                        branch1.External_Employee__c = false;
                        branchList2.add(branch1);

                    }
                }

            }

            database.update(branchList2, false);
        }
    }
}

A:

Try this block of code,you will get the result. If done select this as your answer.
trigger EmployeeTrigger on Employee__c (after insert,after update) {
    TH_Clr_Set_the_External_employee_true.external(Trigger.newMap);
}

public class TH_Clr_Set_the_External_employee_true {
    public static void external(Map<id,Employee__c> recentnewemp ) {
        set<id> branchid = new set<id>();
        for(Employee__c emp:recentnewemp.values()){
            branchid.add(emp.Branch_Lookup__c);
        }
        List<Branch__c> branchlist = [select id,(select id,External_Employee__c from Employees__r),External_Employee__c  from Branch__c where id in:(branchid)];
        List<Branch__c> branchlisttoupdate =new List<Branch__c>();
        for(Branch__c b:branchlist){
            Boolean check=b.External_Employee__c;
            boolean flag=true;
            b.External_Employee__c=false;
            for(Employee__c emp:b.Employees__r){
                if(flag==true && emp.External_Employee__c==true){
                    b.External_Employee__c=true;
                    flag=false;
                }
            }
            if(check!=b.External_Employee__c){
                branchlisttoupdate.add(b);
            }
        }
        update branchlisttoupdate;
    }
}

