Imagem de fundo

O programa declara dois métodos mutuamente recursivos.

Código I – para os itens de 51 a 63


01 public class Estrutura {

02___private class No {

03_____int valor: int qtd; No filhoE, filhoD;

04_____No(int valor) {this.valor = valor; qtd = 1;}

05_____No insere(int valor) {

06_______if (this.valor > valor) {

07_________if (filhoE == null) ( filhoE = new NHo(valor); return filhoE;

08__________} else ( return filhoE.insere(valor);

09__________}

10________} else if (this.valor < valor) {

11__________if (filhoD == null) ( filhoD = new Ho(valor); return filhoD;

12__________} else { return filhoD.insere(valor);

13_________}

14________} else {

15__________qtd++; return this;

16________}

17_____}

18_____void atravessa() {

19________if (filhoD != null) filhoD.atravessa();

20________System.out.print("("+valor+","+gtd+")");

21________if (filhoE != null) filhoE.atravessa();

22_____}

23___}

24___String nome; No raiz;

25___Estrutura(String nome) (this.nome = nome;raiz = null;)

26___No insere(int valor) {

27_____if (raiz == null) (raiz = new No(valor) ;return raiz;

28_____} else return raiz.insere(valor);

29___}

30___void atravessa() {

31_____if (raiz == null) return;

32_____System.out .print(nome+"={") ;raiz.atravessa() ;System.out.print("}");

33___}

34___public static void main(String[] args) {

35_____Estrutura e = new Estrutura(args[0]);

36_____for (int i = 1; i < args.length; i++) {

37_______e.insere(Integer.parseInt(args[i]));

38_____}

39_____e.atravessa();

40___}

41 }


O código I representa um programa Java plenamente funcional. Julgue os itens de 51 a 59, acerca das informações apresentadas no código e dos conceitos de construção de algoritmos, estrutura de dados, orientação a objetos e linguagem de programação Java.

O programa declara dois métodos mutuamente recursivos.


C

Certo


E

Errado