Check if every node can me made accessible from a node of a Tree by at most N/2 given operations

import java.io.*;import java.util.HashMap;  class GFG {                  public static void    findNode(HashMap map,             int n)    {                          int[] a = new int[n];          for (int i = 0; i < n; i++) {            a[i] = map.getOrDefault(i + 1, 0);        }                          int count0 = 0;                  for (int i = 0; i < n; i++) {                                      if (a[i] == 0) {                                  count0++;            }        }          count0 -= 1;                          if (count0