title: Check Whether Given Degrees Vertices Represent Graph Tree
signature: check_whether_given_degrees_vertices_represent_graph_tree <- function(degree, n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(degree, n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(degree, n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(2L, 3L, 1L, 1L, 1L), 5L, 
          TRUE
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(2L, 2L, 1L, 1L, 2L), 5L, 
          TRUE
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(2L, 2L, 1L, 1L, 1L), 5L, 
          FALSE
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(0L, 0L, 0L, 3L, 3L, 4L), 6L, 
          TRUE
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-10L, 12L, 2L), 3L, 
          TRUE
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 1L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 0L, 0L), 19L, 
          FALSE
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(1L, 6L, 10L, 13L, 15L, 17L, 18L, 23L, 26L, 28L, 30L, 32L, 32L, 33L, 36L, 39L, 39L, 41L, 43L, 50L, 50L, 51L, 53L, 54L, 59L, 59L, 63L, 63L, 63L, 66L, 66L, 71L, 71L, 74L, 78L, 89L, 89L, 93L), 30L, 
          FALSE
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(66L, -96L, -14L, 74L, -20L), 4L, 
          FALSE
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 31L, 
          FALSE
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(97L, 73L, 87L, 45L, 64L, 30L, 53L, 50L, 62L, 42L, 28L, 58L, 31L, 90L), 10L, 
          FALSE
      )))
  
  }
  
  main()
source_py: def check_whether_given_degrees_vertices_represent_graph_tree(degree, n):
      deg_sum = sum(degree)
      if ((2 * (n - 1)) == deg_sum):
          return True
      else:
          return False
source_cpp: bool check_whether_given_degrees_vertices_represent_graph_tree(vector<int> degree, int n) {
    int deg_sum = 0;
    for ( int i = 0;
    i < n;
    i ++ ) deg_sum += degree [ i ];
    return ( 2 * ( n - 1 ) == deg_sum );
  }