Pilas

Description

Creación y métodos para crear pilas
arual-168
Flashcards by arual-168, updated more than 1 year ago
arual-168
Created by arual-168 over 8 years ago
10
0

Resource summary

Question Answer
public class Pila{ } protected Nodo tope; // referencia al nodo en la cabeza protected int size; // número de elementos en la pila
Contructor Pila public Pila() { // construye una pila vacía tope = null; size = 0; }
size() { } public int size() { return size; }
isEmpty(){ esVacia() } public boolean isEmpty() { if (tope == null) return true; return false; }
push(){ meter() } public void push(int elem) { Nodo v = new Nodo(elem, tope); // crea y enlaza un nuevo nodo tope = v; size++; }
top(){ tope() } public int top(){ if (isEmpty()) { System.out.print("ERROR: La pila está vacía "); return -1; } return tope.getElem(); }
pop(){ sacar() } public int pop(){ if (isEmpty()) { System.out.print("ERROR: La pila está vacía "); return -1; } int temp = tope.getElem(); tope = tope.getSig(); // desenlaza el nodo que está en el tope size--; return temp; }
Show full summary Hide full summary

Similar

CONCEPTOS_ED
Jonathan Hernandez
Arreglos unidimensionales
Maricela Vizcarra
Estructura de datos
Joaquin Ordoñez Soliz
Pilas y electrolisis - Repaso para Selectividad
Diego Santos
PROGRAMACIÓN ORIENTADA A OBJETOS - TERCER CORTE
Jose Anacona Pira
EVENTOS EN JAVA
**CR 7**
Parcial Fundamento de Programación
ALBERTO MANUEL PATERNINA LEON
Java: Herencia y Polimorfismo
Ana Emilie
EVENTOS EN JAVA
LUIS NAKASIMA
Certificación Java 8 - Oracle Certified Associate - Tema 1 - Estructura de Clases
Miguel Gómez Cuesta
Interface en Java
tavoberry