Quiz Struktur Data P9

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Henilei
H
Henilei
Community Contributor
Quizzes Created: 11 | Total Attempts: 4,273
Questions: 15 | Attempts: 196

SettingsSettingsSettings
Quiz Struktur Data P9 - Quiz

.


Questions and Answers
  • 1. 

    Queue adalah

    • A.

      Bentuk khusus list linier

    • B.

      Khusus dari List Linier dengan operasi pe masukan data hanya diperbolehkan pada salah satu sisi, yang disebut

    • C.

      Stack

    • D.

      Tree

    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

    • A.

      Last in first out

    • B.

      First in last out

    • C.

      First ini first out

    • D.

      First come first serve

    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.

    Rate this question:

  • 3. 

    Jika terdapat antrian 3 elemen, elemen antrian pertama adalah A, kedua B, ketiga C

    • A.

      Yang dapat keluar dari antrian terlebih dahulu adalah A

    • B.

      Yang dapat keluar dari antrian terlebih dahulu adalah C

    • C.

      Elemen B dan C maju ke depan

    • D.

      Elemen C terakhir keluar

    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.

    Rate this question:

  • 4. 

    Operasi queue yang harus disiapkan jika diimplementasikan dalam array

    • A.

      Push

    • B.

      Pop

    • C.

      Enqueue

    • D.

      Dequeue

    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.

    Rate this question:

  • 5. 

    Pada operasi enqueue

    • A.

      Menginisialisasi antrian

    • B.

      Dapat menambah elemen ke antrian

    • C.

      Penambahan elemen selalu dilakukan pada elemen paling belakang

    • D.

      Penambahan elemen selalu dilakukan pada elemen paling depan

    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.

    Rate this question:

  • 6. 

    Operasi dequeue yaitu

    • A.

      Menambah elemen ke dalam antrian

    • B.

      Menghapus elemen dari antrian

    • C.

      Elemen di belakang antrian akan maju

    • D.

      Tail berkurang 1

    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.

    Rate this question:

  • 7. 

    Operasi Peek()

    • A.

      Digunakan untuk mendapatkan elemen yang terdapat pada posisi terakhir

    • B.

      Mengeluarkan elemen dari antrian

    • C.

      Menghapus element pada posisi terakhir

    • D.

      Tidak menghapus element pada posisi terakhir

    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.

    Rate this question:

  • 8. 

    Perhatikan perintah inisialisasi head berikut def __init__(self): self.head = Node("head") self.size = 0 pernyataan yang benar yaitu

    • A.

      Digunakan untuk membentuk dan menunjukan awal terbentuknya suatu Antrean Queue

    • B.

      Merupakan deklarasi antrian dengan C++

    • C.

      Head adalah tanda untuk kepala antrian (elemen pertama dalam antrian) yang tidak akan berubah ubah

    • D.

      Head adalah tanda untuk kepala antrian (elemen pertama dalam antrian) yang bisa berubah ubah

    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.

    Rate this question:

  • 9. 

    Pernyataan yang benar untuk kode berikut adalah def isEmpty(self): return self.size == 0

    • A.

      Banyak elemen yang antri bebas

    • B.

      Untuk memeriksa antrian penuh atau kosong

    • C.

       self.size == 0, nol sama artinya dengan false

    • D.

      Self.size == 0 artinya kosong

    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."

    Rate this question:

  • 10. 

    Def peek(self): if self.isEmpty(): raise Exception("Peeking from an empty stack") return self.head.next.value  

    • A.

      Perintah raise Exception("Peeking from an empty stack") akan dilakukan jika self.isEmpty() bernilai true 

    • B.

      Perintah raise Exception("Peeking from an empty stack") akan dilakukan jika self.isEmpty() bernilai false

    • C.

      Peek adalah nama fungsi

    • D.

      Peek adalah nama objek

    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.

    Rate this question:

  • 11. 

    Operasi SIZE() dalam queue

    • A.

      Untuk memeriksa apakah queue kosong atau tidak

    • B.

      Untuk memeriksa apakah queue penuh atau tidak

    • C.

      Mengembalikan jumlah item di dalam list.

    • D.

      Tidak memerlukan parameter dan mengembalikan suatu integer.

    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.

    Rate this question:

  • 12. 

    Pada inisialisasi head

    • A.

      Self.head = Node("tail")

    • B.

      Self.head = Node("head")

    • C.

      Self.size = 1

    • D.

      Self.size = 0

    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.

    Rate this question:

  • 13. 

    Pada fungsi enqueue

    • A.

      Penambahan elemen selalu menggerakan variabel Tail

    • B.

      Penambahan elemen selalu menggerakan variabel Head

    • C.

      Variabel digerakkan dengan cara menambahkan Headl terlebih dahulu

    • D.

      Variabel digerakkan dengan cara menambahkan Tail terlebih dahulu

    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.

    Rate this question:

  • 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

    • A.

      Self.size -= 1 artinya size berkurang 1

    • B.

      Isempty = 1

    • C.

      Isempty = 0

    • D.

      Return remove.value artinya mengisi parameter self dengan data yang dihapus

    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.

    Rate this question:

  • 15. 

    Jika elemen pada antrian bertambah maka

    • A.

      Self.size += 1

    • B.

      Self.size -= 1

    • C.

      Nilai self.size bertambah 1

    • D.

      Nilai self.size berkurang 1

    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.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Jan 04, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • May 20, 2020
    Quiz Created by
    Henilei
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.