Quiz Struktur Data P6

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: 12 | Total Attempts: 4,691
Questions: 15 | Attempts: 471

SettingsSettingsSettings
Data Quizzes & Trivia

.


Questions and Answers
  • 1. 

    Stack dapat disajikan dalam program menggunakan

    • A.

      Array

    • B.

      Linked list

    • C.

      Queue

    • D.

      Tree

    Correct Answer(s)
    A. Array
    B. Linked list
    Explanation
    Stack dapat disajikan dalam program menggunakan Array dan Linked list. Array adalah struktur data yang dapat menyimpan elemen-elemen dalam urutan yang terdefinisi. Dalam implementasi stack menggunakan array, elemen-elemen stack disimpan dalam array dan operasi push dan pop dilakukan dengan memanipulasi indeks array. Linked list adalah struktur data yang terdiri dari node-node yang saling terhubung melalui pointer. Dalam implementasi stack menggunakan linked list, setiap elemen stack direpresentasikan sebagai node dan operasi push dan pop dilakukan dengan mengubah pointer yang menghubungkan node-node tersebut. Queue dan Tree bukanlah struktur data yang digunakan untuk merepresentasikan stack.

    Rate this question:

  • 2. 

    Prinsip dari stack

    • A.

      Last in first out

    • B.

      Last in last out

    • C.

      First ini first out

    • D.

      First in last out

    Correct Answer(s)
    A. Last in first out
    D. First in last out
    Explanation
    The principle of a stack is based on the concept of "last in, first out" (LIFO). This means that the last item added to the stack will be the first one to be removed. On the other hand, "first in, last out" (FILO) is the opposite principle, where the first item added to the stack will be the last one to be removed. Therefore, the correct answer is Last in first out, as it accurately describes the behavior of a stack.

    Rate this question:

  • 3. 

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

    • A.

      Yang dapat diambil terlebih dahulu adalah A

    • B.

      Yang dapat diambil terlebih dahulu adalah B

    • C.

      Yang dapat diambil terlebih dahulu adalah C

    • D.

      Elemen A terakhir diambil

    Correct Answer(s)
    C. Yang dapat diambil terlebih dahulu adalah C
    D. Elemen A terakhir diambil
    Explanation
    The given correct answer states that the element that can be taken first is C, and the last element to be taken is A. This is because in a stack, the last element that is added is the first one to be removed (LIFO - Last In First Out). Since A was the first element to be added, it will be the last one to be removed. Therefore, C can be taken first before A.

    Rate this question:

  • 4. 

    Operasi stack yang harus disiapkan jika diimplementasikan dalam array

    • A.

      Push

    • B.

      Pop

    • C.

      Enqueue

    • D.

      Dequeue

    Correct Answer(s)
    A. Push
    B. Pop
    Explanation
    The correct answer is "Push, Pop" because these operations are commonly used in a stack data structure. Push is used to add an element to the top of the stack, while Pop is used to remove the top element from the stack. These operations can be easily implemented using an array by keeping track of the index of the top element and updating it accordingly when performing push and pop operations.

    Rate this question:

  • 5. 

    Operasi push yaitu

    • A.

      Menginisialisasi stack

    • B.

      Operasi menambah elemen ke tumpukan

    • C.

      Operasi menghapus elememen pada tumpukan

    • D.

      Dalam python dapat menggunakan fungsi append

    Correct Answer(s)
    B. Operasi menambah elemen ke tumpukan
    D. Dalam python dapat menggunakan fungsi append
    Explanation
    The correct answer is "operasi menambah elemen ke tumpukan, Dalam python dapat menggunakan fungsi append". This is because the operation of pushing refers to adding elements to a stack. In Python, the append() function can be used to add elements to a stack.

    Rate this question:

  • 6. 

    Operasi pop yaitu

    • A.

      Menambah elemen ke dalam tumpukan

    • B.

      Menghapus elemen pada tumpukan

    • C.

      Dalam python menggunakan fungsi pop

    • D.

      Dilakukan dengan memberikan nilai top = -1

    Correct Answer(s)
    B. Menghapus elemen pada tumpukan
    C. Dalam python menggunakan fungsi pop
    Explanation
    The given answer is correct because it accurately explains that the operation of "pop" in Python is used to remove an element from the stack. The explanation also mentions that this operation is performed by assigning the value of "top" to -1.

    Rate this question:

  • 7. 

    Operasi isempty dalam stack adalah

    • A.

      Untuk memeriksa apakah stack kosong atau tidak

    • B.

      Untuk memeriksa apakah stack penuh atau tidak

    • C.

      Jika kosong maka isempty = false

    • D.

      Jika kosong maka isempty = true

    Correct Answer(s)
    A. Untuk memeriksa apakah stack kosong atau tidak
    D. Jika kosong maka isempty = true
    Explanation
    The correct answer is "untuk memeriksa apakah stack kosong atau tidak, Jika kosong maka isempty = true". This is because the operation "isempty" in a stack is used to check whether the stack is empty or not. If the stack is empty, the value of "isempty" will be true.

    Rate this question:

  • 8. 

    Diberikan variabel untuk menumpuk data yaitu x = [ ] pernyataan yang benar terkait operasi stack yaitu

    • A.

      Perintah menambah data ke dalam tumpukan yaitu x.append('A')

    • B.

      Perintah menambah data ke dalam tumpukan yaitu push.append('A')

    • C.

      Perintah menambah data ke dalam tumpukan yaitu x.pop('P')

    • D.

      Perintah menambah data ke dalam tumpukan yaitu x.pop()

    Correct Answer(s)
    A. Perintah menambah data ke dalam tumpukan yaitu x.append('A')
    D. Perintah menambah data ke dalam tumpukan yaitu x.pop()
    Explanation
    The correct answer is "perintah menambah data ke dalam tumpukan yaitu x.append('A'), perintah menambah data ke dalam tumpukan yaitu x.pop()". This is because the append() function is used to add data to the top of the stack, while the pop() function is used to remove and return the topmost data from the stack. The statement "perintah menambah data ke dalam tumpukan yaitu push.append('A')" is incorrect because there is no variable named "push" mentioned in the given code. The statement "perintah menambah data ke dalam tumpukan yaitu x.pop('P')" is also incorrect because the pop() function does not take any arguments.

    Rate this question:

  • 9. 

    Diberikan tumpukan = [ ] def tambah(nilai):   tumpukan.append(nilai) def ambil():   tumpukan.pop() def tampil(..?..):   print(..?..) jika kita ingin menampilkan isi tumpukan maka titik-titik di atas diisi dengan

    • A.

      Tambah

    • B.

      Tumpukan

    • C.

      Pop

    • D.

      Deklarasi program tersebut menggunakan linked list

    Correct Answer
    B. Tumpukan
    Explanation
    The given program defines three functions: tambah, ambil, and tampil. The tambah function appends a value to the stack, the ambil function removes the top value from the stack, and the tampil function is used to display the contents of the stack. Therefore, if we want to display the contents of the stack, we need to fill in the blank with "tumpukan". This indicates that the correct answer is "tumpukan".

    Rate this question:

  • 10. 

    Diberikan program berikut tumpukan = [ ] def tambah(nilai):   tumpukan.append(nilai) def ambil():   tumpukan.pop() jika kita ingin menambah isi tumpukan dengan nilai/data 'A' maka perintahnya

    • A.

      Tambah.append('A')

    • B.

      Tumpukan.append('A')

    • C.

      Tambah('A')

    • D.

      Nilai = 'A'

    Correct Answer
    C. Tambah('A')
    Explanation
    The correct answer is "tambah('A')". This is because the function "tambah(nilai)" is defined to add a value to the stack, and the parameter "nilai" represents the value to be added. Therefore, to add the value 'A' to the stack, we need to call the function "tambah('A')". The other options are incorrect because "tambah" is a function, not a list, so we cannot use the dot notation to call it.

    Rate this question:

  • 11. 

    Jika top=len(tumpukan)-1 maka if top < 0 berarti

    • A.

      Stack kosong

    • B.

      Stack tidak kosong

    • C.

      Stack penuh

    • D.

      Stack tidak penuh

    Correct Answer
    A. Stack kosong
    Explanation
    If the top variable is equal to the length of the stack minus one, and if the top variable is less than zero, it means that the stack is empty.

    Rate this question:

  • 12. 

    Class stack():   def __init__(self):     self.tumpukan = [ ]   def tambah(self, data):     self.tumpukan.append(data)   def tampil(self):     print(self.tumpukan) membuat objek yang benar yaitu

    • A.

      Objek = stack

    • B.

      Objek = stack()

    • C.

      Objek = tumpukan

    • D.

      Objek = tumpukan

    Correct Answer
    B. Objek = stack()
    Explanation
    The correct answer is "objek = stack()". This is because the given code defines a class named "stack" and the correct way to create an object of that class is by using the syntax "objek = stack()". This will create a new instance of the "stack" class and assign it to the variable "objek".

    Rate this question:

  • 13. 

    Diketahui tumpukan = [ ] tumpukan.append('h') tumpukan.append('i') tumpukan.append('j') maka len(tumpukan) = ...

    • A.

      1

    • B.

      2

    • C.

      3

    • D.

      0

    Correct Answer
    C. 3
    Explanation
    The given code initializes an empty stack called "tumpukan" and then appends three elements ('h', 'i', 'j') to the stack. The len() function is used to find the length of the stack, which is the number of elements in it. Since there are three elements in the stack, the correct answer is 3.

    Rate this question:

  • 14. 

    Diberikan tumpukan = [ ] tumpukan.append('h') tumpukan.append('i') tumpukan.append('j') print(tumpukan[1]) akan menghasilkan output ...

    • A.

      H

    • B.

      I

    • C.

      J

    • D.

      H, i, j

    Correct Answer
    B. I
    Explanation
    The given code creates a list called "tumpukan" and appends the elements 'h', 'i', and 'j' to it. The line "print(tumpukan[1])" prints the element at index 1 of the list, which is 'i'. Therefore, the output of the code will be "i".

    Rate this question:

  • 15. 

    Pernyataan yang salah yaitu stack menggunakan python

    • A.

      Jumlah elemen dalam tumpukan dapat diketahui dengan perintah len(stack)

    • B.

      Elemen paling atas dalam tumpukan dapat diketahui dengan perintah len(stack)-1

    • C.

      Elemen paling bawah dalam tumpukan yaitu stack[1]

    • D.

      Menambah elemen ke dalam tumpukan menyebabkan len(stack)+1

    Correct Answer
    C. Elemen paling bawah dalam tumpukan yaitu stack[1]
    Explanation
    The given answer is incorrect because the statement "elemen paling bawah dalam tumpukan yaitu stack[1]" is wrong. In Python, the index of the first element in a list or stack is 0, not 1. Therefore, the correct statement should be "elemen paling bawah dalam tumpukan yaitu stack[0]".

    Rate this question:

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.