NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Mengimpor kedua file dan menyimpannya dalam dua variabel terpisah, misalnya "file1" dan "file2".

Menginisialisasi variabel "i" dan "j" dengan nilai awal 0, yang akan digunakan untuk menyimpan indeks saat kita memproses kedua file.

Buat sebuah variabel kosong untuk menyimpan data hasil penggabungan.

Lakukan loop sampai salah satu file habis diproses (misalnya file1) dengan menggabungkan data dengan cara membandingkan kode buku dari kedua file:

Jika kode buku di file1 lebih kecil dari kode buku di file2, maka tambahkan data di file1 ke dalam variabel hasil penggabungan, dan tambahkan nilai variabel i dengan 1.

Jika kode buku di file2 lebih kecil dari kode buku di file1, maka tambahkan data di file2 ke dalam variabel hasil penggabungan, dan tambahkan nilai variabel j dengan 1.

Jika kode buku di kedua file sama, maka tambahkan data dari kedua file ke dalam variabel hasil penggabungan, dan tambahkan nilai variabel i dan j dengan 1.

Setelah loop selesai, cek apakah ada data yang masih tersisa di salah satu file.

Jika ada data yang tersisa di file1, tambahkan data tersebut ke dalam variabel hasil penggabungan.

Jika ada data yang tersisa di file2, tambahkan data tersebut ke dalam variabel hasil penggabungan.

Variabel hasil penggabungan sekarang berisi data yang terurut berdasarkan kode buku. Jika menggunakan metode AND, hanya data yang ada di kedua file yang akan ditampilkan, sedangkan jika menggunakan metode OR, data dari kedua file akan digabungkan tanpa menghilangkan duplikat.

Berikut adalah contoh pseudocode algoritma penggabungan dua file dengan metode AND:
file1 = import("file1.txt")
file2 = import("file2.txt")
i = 0
j = 0
result = []

while i < len(file1) and j < len(file2):
if file1[i].kode_buku < file2[j].kode_buku:
i += 1
elif file1[i].kode_buku > file2[j].kode_buku:
j += 1
else:
result.append(file1[i])
i += 1
j += 1

Berikut adalah contoh pseudocode algoritma penggabungan dua file dengan metode OR:
file1 = import("file1.txt")
file2 = import("file2.txt")
i = 0
j = 0
result = []

while i < len(file1) and j < len(file2):
if file1[i].kode_buku < file2[j].kode_buku:
result.append(file1[i])
i += 1
elif file1[i].kode_buku > file2[j].kode_buku:
result.append(file2[j])
j += 1

     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.