15 Stack Queue-In - Class v.1.03
15 Stack Queue-In - Class v.1.03
15 Stack Queue-In - Class v.1.03
YA R S I
Content by:
Andreas F., Herika H., M. Faturrachman, and Nova E.D.
Image(s):
unsplash.com
http://unsplash.com/ Desain by Arksnet – Desain Modified by Andreas F.
UNIVERSITAS
YA R S I 15’ Review
REVIEW
Image(s):
http://unsplash.com/ 2
UNIVERSITAS
YA R S I Soal 1
3
UNIVERSITAS
YA R S I Soal 2
?
java.util.LinkedList<String> text = Apa keluaran dari
new java.util.LinkedList<>(); potongan program
berikut
text.add("will");
text.add("best");
text.add("of me");
text.add(1, "be");
text.addFirst("I");
text.add(3, "the");
text.add(5, "version");
text.add(text.getLast().substring(3));
text.set(text.size() - 2, "of");
System.out.println(text);
4
UNIVERSITAS
YA R S I Soal 3
4 newData
1 3 7 9
current
5
UNIVERSITAS
YA R S I Soal 4
4 newData
1 3 7 9
current
6
UNIVERSITAS
YA R S I Soal 5
…
Kesalahan apa yang
ada pada potongan
kode berikut
// asumsikan list merupakan sebuah LinkedList yang
?
// didefinisikan pada kode sebelum ini
NodeSDA current = list.getFirst().next.next;
7
UNIVERSITAS
YA R S I Soal 6
8
UNIVERSITAS
YA R S I
Image(s):
https://pixabay.com/ 9
UNIVERSITAS
YA R S I
Image(s):
https://www.fotolia.com/ 10
UNIVERSITAS
YA R S I
Image(s):
https://pixabay.com/ 11
UNIVERSITAS
YA R S I
Image(s):
https://www.fotolia.com/ 12
UNIVERSITAS
YA R S I
- Dekan FTI -
Image(s):
https://www.fotolia.com/ 13
UNIVERSITAS
YA R S I
- Dekan FTI -
Image(s):
https://www.fotolia.com/ 14
UNIVERSITAS
YA R S I Topik
Review ArrayList
LinkedList
15
Tugas 4
UNIVERSITAS
YA R S I
Image(s):
http://priyanka2787.blogspot.com/ 16
UNIVERSITAS
YA R S I Tugas 4
17
UNIVERSITAS
YA R S I
Pengumuman
18
UNIVERSITAS
YA R S I Nilai Bonus Penuh
19
UNIVERSITAS
YA R S I Transfer Bonus
Image(s):
https://www.fotolia.com/ 20
UNIVERSITAS
YA R S I Ujian 1
Image(s):
https://www.fotolia.com/ 21
UNIVERSITAS
YA R S I Ujian 2 & 3
Image(s):
https://www.fotolia.com/ 22
Image(s):
http://unsplash.com/
Stack
UNIVERSITAS
YA R S I
23
UNIVERSITAS
YA R S I Stack
https://docs.oracle.com/javase/10/docs/api/java/util/Stack.html
meaaw?
Image(s):
https://id.pinterest.com/ 24
UNIVERSITAS
YA R S I Soal 7
25
UNIVERSITAS
YA R S I Import Stack
import java.util.Stack;
26
UNIVERSITAS
YA R S I Prilaku Stack
Stack<String> stack = new Stack<>();
stack.push("I");
stack.push("will"); stack cheat
will
not
I
stack.push("not"); will
not
I
stack.push("cheat"); will
I
System.out.println(stack);
I
System.out.print(stack.pop() + " ");
System.out.print(stack.pop() + " - ");
System.out.println(stack);
28
UNIVERSITAS
YA R S I Soal 9
?
java.util.Stack<String> stack = Apa keluaran dari
new java.util.Stack<>(); potongan program
berikut
stack.push("IT");
stack.push("can do");
stack.push("you");
System.out.println(stack);
29
UNIVERSITAS
YA R S I Soal 10
?
java.util.Stack<String> stack = Apa keluaran dari
new java.util.Stack<>(); potongan program
stack.push("I"); berikut
stack.push("will");
stack.push("love you");
java.util.Stack<String> stack2 =
new java.util.Stack<>();
stack2.push(stack.pop());
stack2.push(",");
stack2.push(stack.pop());
stack2.push(stack.pop());
System.out.println(stack2);
30
UNIVERSITAS
YA R S I Soal 11
?
java.util.Stack<Integer> stack = Apa keluaran dari
new java.util.Stack<>(); potongan program
berikut
stack.push(2);
stack.push(4);
stack.push(3);
stack.push(stack.pop() * stack.pop());
stack.push(stack.pop() + stack.pop());
System.out.println(stack.pop());
31
UNIVERSITAS
YA R S I Method Stack
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Stack.html
32
UNIVERSITAS
YA R S I Soal 12
?
java.util.Stack<String> stack = Apa keluaran dari
new java.util.Stack<>(); potongan program
berikut
System.out.println(stack.empty());
stack.push(null);
System.out.println(stack.pop());
33
UNIVERSITAS
YA R S I Soal 13
java.util.Stack<String> stack =
new java.util.Stack<>();
stack.push("something");
Apakah error yang
ada pada potongan
program berikut ?
System.out.println(stack.empty());
System.out.println(stack.pop());
System.out.println(stack.pop());
34
UNIVERSITAS
YA R S I
Any
Question(s)?
Image(s):
https://www.animaker.com/ 35
Image(s):
http://unsplash.com/
Queue
UNIVERSITAS
YA R S I
36
UNIVERSITAS
YA R S I Queue
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/
java/util/Queue.html
meaaw?
Image(s):
https://id.pinterest.com/ 37
UNIVERSITAS
YA R S I Soal 14
38
UNIVERSITAS
YA R S I Java Queue
Image(s):
https://www.fotolia.com/ 39
UNIVERSITAS
YA R S I Prilaku Queue
LinkedList<String> queue = new LinkedList<>();
queue.add("I");
queue will
not
I
queue.add("will");
queue.add("not"); cheat
will
not
queue.add("cheat"); cheat
not
System.out.println(queue); cheat
41
UNIVERSITAS
YA R S I Soal 16
42
UNIVERSITAS
YA R S I Soal 17
?
java.util.LinkedList<String> queue = Apa keluaran dari
new java.util.LinkedList<>(); potongan program
berikut
queue.add("Yesterday");
queue.add("is");
queue.add("not");
queue.add("today");
System.out.println(queue);
System.out.println(queue);
43
UNIVERSITAS
YA R S I Method Queue
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Queue.html
44
UNIVERSITAS
YA R S I
Image(s):
https://www.dreamstime.com/ 45
UNIVERSITAS
YA R S I Soal 18
?
java.util.LinkedList<String> queue = Apa keluaran dari
new java.util.LinkedList<>(); potongan program
berikut
String text = "I am smart and I know IT";
queue.add("great");
queue.add(queue.getFirst().substring(3));
queue.addFirst(text.substring(0, 4));
queue.add(text.substring(text.length() - 2));
System.out.println(queue);
46
UNIVERSITAS
YA R S I
Image(s):
https://www.dreamstime.com/ 47
UNIVERSITAS
YA R S I Soal 19
?
java.util.LinkedList<String> list = Apa keluaran dari
new java.util.LinkedList<>(); potongan program
berikut
list.add("myself");
list.add("me");
list.add(2, "!");
list.poll();
list.addFirst("fantastic");
list.push("the");
list.push("the");
list.pop();
System.out.println(list);
48
UNIVERSITAS
YA R S I
Any
Question(s)?
Image(s):
https://www.animaker.com/ 49
UNIVERSITAS
YA R S I Soal 20
50
UNIVERSITAS
YA R S I Soal 21
51
UNIVERSITAS
YA R S I
Image(s):
https://www.istockphoto.com/ 52