1.
Queue adalah
Correct Answer(s)
A. Bentuk khusus list linier
B. Khusus dari List Linier dengan operasi pe masukan data
hanya diperbolehkan pada salah satu sisi, yang disebut
2.
Prinsip dari queue
Correct Answer(s)
C. First ini first out
D. First come first serve
Explanation
The correct answer is "First come first serve". This principle of a queue means that the items or entities that enter the queue first will be served or processed first, while the ones that enter later will have to wait in line. It follows a fair and chronological order, ensuring that no entity is given priority over others based on any other factor. This principle is commonly used in various scenarios, such as waiting in line at a store or processing tasks in a computer system.
3.
Jika terdapat antrian 3 elemen, elemen antrian pertama adalah A, kedua B, ketiga C
Correct Answer(s)
A. Yang dapat keluar dari antrian terlebih dahulu adalah A
C. Elemen B dan C maju ke depan
D. Elemen C terakhir keluar
Explanation
Based on the given information, the element at the front of the queue is A. Therefore, A is the element that can be dequeued first. Additionally, it is mentioned that elements B and C move forward in the queue. This means that after A is dequeued, B becomes the element at the front of the queue, and C moves to the second position. Finally, it is stated that C is the last element to be dequeued, indicating that it is the element that comes out of the queue last.
4.
Operasi queue yang harus disiapkan jika diimplementasikan dalam array
Correct Answer(s)
C. Enqueue
D. Dequeue
Explanation
The operations that need to be prepared for implementation in an array are Enqueue and Dequeue. Enqueue is used to add an element to the end of the queue, while Dequeue is used to remove an element from the front of the queue. These two operations are essential for maintaining the order and structure of the queue in an array-based implementation.
5.
Pada operasi enqueue
Correct Answer(s)
B. Dapat menambah elemen ke antrian
C. Penambahan elemen selalu dilakukan pada elemen paling belakang
Explanation
The correct answer is "dapat menambah elemen ke antrian, penambahan elemen selalu dilakukan pada elemen paling belakang." This answer explains that during the enqueue operation, elements can be added to the queue and the addition of elements always takes place at the back of the queue.
6.
Operasi dequeue yaitu
Correct Answer(s)
B. Menghapus elemen dari antrian
C. Elemen di belakang antrian akan maju
Explanation
The correct answer is "menghapus elemen dari antrian, elemen di belakang antrian akan maju". This answer accurately describes the operation of dequeue, which is the process of removing an element from the queue. When an element is dequeued, the element behind it in the queue will move forward, and the tail of the queue will decrease by 1.
7.
Operasi Peek()
Correct Answer(s)
A. Digunakan untuk mendapatkan elemen yang terdapat pada
posisi terakhir
D. Tidak menghapus element pada posisi terakhir
Explanation
The operation Peek() is used to retrieve the element that is present at the last position of the queue, without removing it. It allows us to access the element at the last position without altering the queue's structure.
8.
Perhatikan perintah inisialisasi head berikut
def __init__(self):
self.head = Node("head")
self.size = 0
pernyataan yang benar yaitu
Correct Answer(s)
A. Digunakan untuk membentuk dan menunjukan awal terbentuknya suatu Antrean Queue
C. Head adalah tanda untuk kepala antrian (elemen pertama dalam antrian) yang tidak akan berubah ubah
Explanation
The correct answer is "Digunakan untuk membentuk dan menunjukan awal terbentuknya suatu Antrean Queue,Head adalah tanda untuk kepala antrian (elemen pertama dalam antrian) yang tidak akan berubah ubah." This is because the given code initializes the head of the queue as a node with the value "head" and sets the size of the queue to 0. The head of the queue represents the first element in the queue and it will remain unchanged throughout the execution of the program.
9.
Pernyataan yang benar untuk kode berikut adalah
def isEmpty(self):
return self.size == 0
Correct Answer(s)
B. Untuk memeriksa antrian penuh atau kosong
C. self.size == 0, nol sama artinya dengan false
D. Self.size == 0 artinya kosong
Explanation
The correct answer explains that the given code is used to check if the queue is empty or not. It states that "self.size == 0" is equivalent to false, meaning that the queue is not empty. Therefore, the correct statement for the given code is "to check if the queue is full or empty, self.size == 0, zero is equivalent to false, self.size == 0 means empty."
10.
Def peek(self):
if self.isEmpty():
raise Exception("Peeking from an empty stack")
return self.head.next.value
Correct Answer(s)
A. Perintah raise Exception("Peeking from an empty stack") akan dilakukan jika self.isEmpty() bernilai true
C. Peek adalah nama fungsi
Explanation
The correct answer is that the command "raise Exception("Peeking from an empty stack") will be executed if self.isEmpty() evaluates to true. This means that if the stack is empty, an exception will be raised to indicate that peeking from an empty stack is not allowed. The other options are incorrect as they do not accurately describe the behavior of the code.
11.
Operasi SIZE() dalam queue
Correct Answer(s)
C. Mengembalikan jumlah item di dalam list.
D. Tidak memerlukan parameter dan mengembalikan suatu integer.
Explanation
Operasi SIZE() dalam queue digunakan untuk mengembalikan jumlah item yang ada di dalam list. Operasi ini tidak memerlukan parameter dan akan mengembalikan suatu integer. Dengan menggunakan operasi SIZE(), kita dapat memeriksa berapa banyak elemen yang ada dalam queue. Dengan demikian, kita dapat mengetahui apakah queue kosong atau tidak. Jika hasil dari operasi SIZE() adalah 0, maka dapat disimpulkan bahwa queue kosong.
12.
Pada inisialisasi head
Correct Answer(s)
B. Self.head = Node("head")
D. Self.size = 0
Explanation
The correct answer is self.head = Node("head"), self.size = 0. This is because in the given code snippet, the head of the linked list is being initialized with a node containing the value "head". Additionally, the size of the linked list is being set to 0.
13.
Pada fungsi enqueue
Correct Answer(s)
A. Penambahan elemen selalu menggerakan variabel Tail
D. Variabel digerakkan dengan cara menambahkan Tail terlebih dahulu
Explanation
The correct answer is "Penambahan elemen selalu menggerakan variabel Tail, variabel digerakkan dengan cara menambahkan Tail terlebih dahulu". This means that when adding an element to the queue, the variable Tail is always moved first. This suggests that the enqueue operation adds elements to the end of the queue, as the Tail represents the end of the queue. By moving the Tail first, new elements are added at the end, maintaining the order of the queue.
14.
Def dequeue(self):
if self.isEmpty():
raise Exception(“dequeue from an empty stack")
remove = self.head.next
self.head.next = self.head.next.next
self.size -= 1
return remove.value
pada fungsi dequeue di atas
Correct Answer(s)
A. Self.size -= 1 artinya size berkurang 1
D. Return remove.value artinya mengisi parameter self dengan data yang dihapus
Explanation
The correct answer is "self.size -= 1" means that the size of the stack is decreased by 1. This is because when an element is removed from the stack, the size of the stack should be updated to reflect the change.
Additionally, "return remove.value" means that the value of the removed element is returned. This is important because the caller of the dequeue function may need to access the value of the removed element for further processing or analysis.
15.
Jika elemen pada antrian bertambah maka
Correct Answer(s)
A. Self.size += 1
C. Nilai self.size bertambah 1
Explanation
When an element is added to the queue, the size of the queue should increase by 1. So, the statement "self.size += 1" correctly represents this behavior. It means that the value of "self.size" is incremented by 1, indicating that the size of the queue has increased by 1.