Clase sobre la utilización del tipo de dato abstracto Cola realizando implementaciones en el lenguaje Java. Utilizada en la carrera Ingeniería en Ciencias Informáticas en el curso 2019-2020.
Andreas Schleicher presents at the launch of What does child empowerment mean...
Clase práctica 8: Uso del TDA Cola
1. Programación II
Clase práctica 8: Uso del TDA Cola
M. Sc. Leandro Tabares Martín, P. As.
https://www.slideshare.net/LeandroTabaresMartn, ltmartin@uci.cu
3. Bibliografía
Heileman, G.; Estructuras de datos,
algoritmos y programación orientada a
objetos. Capítulo 6.
Aho, V., Hopcroft, J., Ullman, J.;
Estructuras de datos y algoritmos.
Capítulo 2, epígrafes 2.3 y 2.4.
4. Revisión del estudio
independiente
Write a method splitStack that takes a stack of integers as
a parameter and splits it into negatives and non-negatives.
The numbers in the stack should be rearranged so that all
the negatives appear on the bottom of the stack and all the
non-negatives appear on the top. In other words, if after
this method is called you were to pop numbers off the
stack, you would first get all the nonnegative numbers and
then get all the negative numbers. It does not matter what
order the numbers appear in as long as all the negatives
appear lower in the stack than all the non-negatives. You
may use a single queue as auxiliary storage.
7. Ejercicio 1
1- Abrir la siguiente URL:
https://practiceit.cs.washington.edu/
problem/view/bjp3/chapter14/s15-
stackQueueUsage3
2- Autenticarse.
3- Introducir la respuesta del ejercicio.
4- Oprimir “Submit”.
8. Ejercicio 2
Abrir la URL:
https://practiceit.cs.washington.edu/
problem/view/bjp3/chapter14/s16-
stackQueueMystery1
9.
10. Ejercicio 3
Write a method rearrange that takes
a queue of integers as a parameter
and rearranges the order of the
values so that all of the even values
appear before the odd values and
that otherwise preserves the original
order of the list.
11. Ejercicio 3
For example, suppose a queue called q stores this
sequence of values:
front [3, 5, 4, 17, 6, 83, 1, 84, 16, 37] back
Then the call of rearrange(q); should rearrange the
queue to store the following sequence of values:
front [4, 6, 84, 16, 3, 5, 17, 83, 1, 37] back
12. Ejercicio 3
Notice that all of the evens appear
at the front of the queue followed by
the odds and that the order of the
evens is the same as in the original
list and the order of the odds is the
same as in the original list. You may
use one stack as auxiliary storage.
13. Ejercicio 3
1- Abrir la URL:
https://practiceit.cs.washington.edu/
problem/view/bjp3/chapter14/e6-rearrange
2- Autenticarse
3- Introducir la solución del ejercicio
4- Oprimir “Submit”
14. Estudio independiente
Resolver el ejercicio en la URL
https://practiceit.cs.washington.edu/
problem/view/bjp3/chapter14/e7-
reverseHalf
15. Estudio independiente
Write a method reverseHalf that
reverses the order of half of the
elements of a Queue of integers. Your
method should reverse the order of all
the elements in odd-numbered positions
(position 1, 3, 5, etc.) assuming that the
first value in the queue has position 0.
16. Estudio independiente
For example, if the queue originally stores this
sequence of numbers when the method is called:
●
- it should store the following values after the method
finishes executing:
index 0 1 2 3 4 5 6 7
front 1 8 7 2 9 18 12 0 back
index 0 1 2 3 4 5 6 7
front 1 0 7 18 9 2 12 8 back
17. Estudio independiente
Notice that numbers in even positions
(positions 0, 2, 4, 6) have not moved. That
sub-sequence of numbers is still: (1, 7, 9,
12). But notice that the numbers in odd
positions (positions 1, 3, 5, 7) are now in
reverse order relative to the original. In other
words, the original sub-sequence: (8, 2, 18,
0) - has become: (0, 18, 2, 8). You may use a
single stack as auxiliary storage.
18. Programación II
Clase práctica 8: Uso del TDA Cola
M. Sc. Leandro Tabares Martín, P. As.
https://www.slideshare.net/LeandroTabaresMartn, ltmartin@uci.cu