Generation

generate functionTue, 30 May 2023

Elaborar dos aplicaciones utilizando la estructura de datos tipo LISTA ENLAZADA, debe comentar cada línea de código empleada.

public class ListaEnlazada { private Nodo head; private int tamaño; public ListaEnlazada() { head = new Nodo("head"); tamaño = 0; } public void insertarPrincipio(Object valor) { Nodo temp = new Nodo(valor); //Creacion de un nuevo nodo temp.setNext(head.getNext()); //El siguiente del nuevo nodo apunta a head.getNext() head.setNext(temp); //El siguiente de head apunta al nuevo nodo tamaño++; //Incremento en 1 el tamaño } public void insertarFinal(Object valor) { Nodo temp = new Nodo(valor); //Creacion de un nuevo nodo Nodo current = head; //Creamos un nodo auxiliar que apunta a head while (current.getNext() != null) { //Recorre la lista hast

Questions about programming?Chat with your personal AI assistant