Data Structures: Linked Lists and Array Implementations in Java

Singly Linked List Implementation

The following code demonstrates a singly linked list implementation in Java:


public class ListaUnNexo {
    private Nodo first;
    private Nodo last;

    public ListaUnNexo() {
        first = null;
        last = null;
    }

    public void ingresar(int d) {
        Nodo curr = new Nodo(d);
        curr.setNext(first);
        first = curr;
    }

    public void ingresarOrdenado(int d) {
        Nodo nuevo = new Nodo(d);
        Nodo previo = null;
        
Read More