Rumus Array Dimensi 1

Posted: 7 April 2012 in Semester II, Struktur Data, The Faculty

@A[i] = B + (i – 1) * L

 

Keterangan :

@A[i] : Posisi Array yg dicari

B : Posisi awal index di memory komputer

i : Subkrip atau indeks array yg dicari

L : Ukuran / besar memory suatu type data

 

Contoh soal :

Suatu Array A dideklarasikan sebagai berikut :

int A[5]; dengan alamat awal index berada di 0011(H) dan ukuran memory type data integer = 2.

Tentukan berapa alamat array A[3] = ?

 

Diketahui :

@A[i] = A[3]

B = 0011 (H)

i = 3

L = 2

 

Penyelesaian :

A[3] = 0011(H) + (3 – 1) * 2

= 0011(H) + 4 (D)

= 0011(H) + 0004 (H)

= 0015(H)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s