1 / 3

MODUL KULIAH STRUKTUR DATA

MODUL KULIAH STRUKTUR DATA. TANGGAL REVISI TANGGAL BERLAKU KODE DOKUMEN. : : :. ---- 04 September 2006 ----. BAB V LINIER SINGLY LINKED LIST - Pengelolaan memory secara dinamis artinya tidak perlu mengalokasikan memori lebih awal secara tetap (fixed).

caron
Télécharger la présentation

MODUL KULIAH STRUKTUR DATA

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MODUL KULIAH STRUKTUR DATA TANGGAL REVISI TANGGAL BERLAKU KODE DOKUMEN : : : ---- 04 September 2006 ---- BAB V LINIER SINGLY LINKED LIST - Pengelolaan memory secara dinamis artinya tidak perlu mengalokasikan memori lebih awal secara tetap (fixed). - Satu elemen terdiri dari 2 elemen : a. Elemen yang menyimpan data b. Elemen yang menyimpan alamat record ILUSTRASI FIRST LAST INFO LINK INFO LINK INFO LINK INFO LINK 25 (1) 12 ( 2) 17 ( 3) 10 ( 4 ) Keterangan dari ilustrasi Linked List : - Ada 4 Simpul : simpul 1 s/d simpul 4 - Setiap simpul(record) terdiri 2 elemen yaitu : Field INFO misal bertipe Integer Field LINK bertipe Pointer Contoh simpul no. 1 Field INFO berisi nilai 25 Field LINK berisi alamat record no. 2 Simpul No. 3 Field INFO berisi nilai 17 Field LINK berisi alamat record no. 4 Session 6 Edited By Al-Bahra. L.B, S. Kom, M. Kom http://www.mercubuana.ac.id Pertemuan Ke : 6 / Page 1 - 10

  2. MODUL KULIAH STRUKTUR DATA TANGGAL REVISI TANGGAL BERLAKU KODE DOKUMEN : : : ---- 04 September 2006 ---- Struct SIMPUL { int INFO; struct SIMPUL *LINK; }; struct SIMPUL *P, *FIRST, *LAST; disiapkan 3 buah pointer yaitu P, FIRST, LAST yang semuanya terkait dengan simpul atau record . a. Pembuatan Simpul Awal Instruksi untuk membuat sebuah simpul (record) baru adalah : P=(struct SIMPUL*) malloc(sizeof(struct SIMPUL*)); Malloc : Maksudnya mengalokasikan memory Sebesar atau seukuran (sizeof) yang diperlukan Untuk simpul. Contoh sederhana (lengkap) program membuat Simpul Awal: #include <iostream.h> #include <conio.h> #include <stdlib.h> #include <ctype.h> struct SIMPUL { int INFO; struct SIMPUL *LINK; }; struct SIMPUL *P, *FIRST, *LAST; Session 6 Edited By Al-Bahra. L.B, S. Kom, M. Kom http://www.mercubuana.ac.id Pertemuan Ke : 6 / Page 3 - 10

  3. MODUL KULIAH STRUKTUR DATA TANGGAL REVISI TANGGAL BERLAKU KODE DOKUMEN : : : ---- 04 September 2006 ---- b. INSERT KANAN (INSERT AKHIR) sudah dibuat Simpul awal sebagai berikut : FIRST LAST P INFO LINK 25 ( 1 ) Akan diinsert disebelah kanan seperti berikut FIRST LAST INFO 25 ( 1 ) LINK INFO 12 ( 2) LINK Fungsiuntuk Insert Kanansebagaiberikut : void InsertKanan(void) { int X; cout<<”MASUKKAN SIMPUL KANAN : “; cin>>X; P=(struct SIMPUL*) malloc(sizeof(struct SIMPUL*)); P->INFO=X; LAST->LINK=P; LAST=P; P->LINK=NULL; } Session 6 Edited By Al-Bahra. L.B, S. Kom, M. Kom http://www.mercubuana.ac.id Pertemuan Ke : 6 / Page 5 - 10

More Related