Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. EJERCICIO 7- COLA CON LISTA
  2.  
  3. public class ColaConLista <E> implements Queue <E>{
  4.  
  5. protected Position <E> L;
  6.  
  7. public ColaConLista ......... (ni la mas puta idea como hacer el constructor) jajajajaja
  8.  
  9. public void enqueue(E e){
  10.  
  11. addLast(e);}
  12. public E dequeue() throws EmptyQueueException{
  13.  
  14. if(L.isEmpty())
  15. throw new EmptyQueueException;
  16. return remove(L.first());
  17. }
  18.  
  19. public E front() throws EmptyQueueException{
  20.  
  21. if(L.isEmpty())
  22. throw new EmptyQueueException;
  23.  
  24. return (L.first());
  25. }
  26. public boolean isEmpty(){
  27. return(L.isEmpty());
  28. }
  29.  
  30. public int size(){
  31. return L.size();}
  32. }
  33.  
  34. -----------------------------------------------------------------------------------------------------------------------------------
  35. EJERCICIO 10 COLAS DE PILAS, ES DE ORDEN N??????????????????????????????
  36.  
  37. public Queue COrdenado (Queue <Character> cin1, Queue<Character> cin2) throws EmptyQueueException{
  38.  
  39. Queue<Character> salida=new ColaConArregloCircular<Character>(cin1.size()+cin2.size());
  40.  
  41. if((cin1.isEmpty())&&(cin2.isEmpty())
  42. throw new EmptyQueueException("Cola Vacia");
  43.  
  44. while((!cin1.isEmpty())&&(!cin2.isEmpty()){
  45. if(c1.front()=>c2.front()){
  46. salida.enqueue(c2.front())
  47. cin2.dequeue();}
  48. else{
  49. salida.enqueue(c1.front());
  50. c1.dequeue();}
  51. }
  52.  
  53. if(cin1.isEmpty()){
  54. while(!cin2.isEmpty()){
  55. salida.enqueue(cin2.front());
  56. cin2.enqueue();}
  57. }
  58. if(cin2.isEmpty()){
  59. while(!cin1.isEmpty()){
  60. salida.enqueue(cin1.front());
  61. cin1.dequeue();}
  62. }
  63. return salida;
  64. }
  65. ---------------------------------------------------------------------------------------------------------------------------
  66. EJERCICIO 11- PILA DE PILASSSSS (SI NO SE ENTENDIO LA IDEA TE MANDO MI SUPER TRAZA JAJAJA )
  67.  
  68. public Stack PilaDeEnteros(Stack<Integer>PPE) throws EmptyStackException{ (tengo duda en el parametro como poner que es pila de pila de enteros porque asi como lo puse yo seria pila de enteros nomas)
  69.  
  70. Stack<Integer> aux= new PilaArreglo<Integer>(PPE.size());
  71. Stack<Integer> salida= new PilaArreglo<Integer>(PPE.size());
  72.  
  73. if(PPE.isEmpty())
  74. throw new EmptyStackException("Pila Vacia");
  75.  
  76. while(!PPE.isEmpty()){
  77.  
  78. Stack<Integer> pila=PPE.pop();
  79.  
  80. while(!pila.isEmpty()){
  81. aux.push(pila.pop());
  82. }
  83.  
  84. }
  85.  
  86. while(!aux.isEmpty()){
  87.  
  88. salida.push(aux.pop());}
  89.  
  90. return salida;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement