def print_tree_rec(self, node_ind): if SC.is_leaf(node_ind, self.left_child): return SP.str_(self.mean[node_ind]) else: left_child = self.left_child[node_ind] right_child = self.right_child[node_ind] return '(' + self.print_tree_rec(left_child) + ','\ + self.print_tree_rec(right_child) + ')'
def string_comp(input): str = list(input) output = "" i = 0 while i < len(input): count = 1 while (i + count < len(input)) and (str[i + count] == str[i]): count = count + 1 output += str[i] output += str_(count) i = i + count if len(output) < len(input): return output else: return input