>

>
pelan
cepat
go to beginning previous frame pause play next frame go to end

Hash Table is a data structure to map key to values (also called Table or Map Abstract Data Type/ADT). It uses a hash function to map large or even non-Integer keys into a small range of Integer indices (typically [0..hash_table_size-1]).


The probability of two distinct keys colliding into the same index is relatively high and each of this potential collision needs to be resolved to maintain data integrity.


There are several collision resolution strategies that will be highlighted in this visualization: Open Addressing (Linear Probing, Quadratic Probing, and Double Hashing) and Closed Addressing (Separate Chaining). Try clicking Search(8) for a sample animation of searching a value in a Hash Table using Separate Chaining technique.


Remarks: By default, we show e-Lecture Mode for first time (or non logged-in) visitor.
If you are an NUS student and a repeat visitor, please login.

🕑

Hashing adalah sebuah algoritma (lewat fungsi hash) yang memetakan set-set data besar dengan panjang variable, disebut kunci-kunci, tidak harus bilangan-bilangan bulat, ke set-set data bilangan bulat yang lebih kecil dengan panjang tertentu.


Sebuah Tabel Hash adalah struktur data yang menggunakan fungsi hash untuk memetakan secara efisien kunci-kunci ke nilai-nilai (ADT Tabel atau Map), untuk pencarian/pengambilan, pemasukkan, dan/atau penghapusan yang efisien.


Tabel Hash sering digunakan di berbagai perangkat lunak komputer, terutama untuk larik-larik asosiatif, indeks basis data, caches, dan sets.


Di Kuliah Maya ini, kita akan menyamping sebentar ke ADT Tabel, ide-ide dasar dari Hashing, diskusi dari Fungsi-fungsi Hash sebelum masuk ke detil-detil dari struktur data Tabel Hash itu sendiri.


Pro-tip 1: Since you are not logged-in, you may be a first time visitor (or not an NUS student) who are not aware of the following keyboard shortcuts to navigate this e-Lecture mode: [PageDown]/[PageUp] to go to the next/previous slide, respectively, (and if the drop-down box is highlighted, you can also use [→ or ↓/← or ↑] to do the same),and [Esc] to toggle between this e-Lecture mode and exploration mode.

🕑

A Table ADT must support at least the following three operations as efficient as possible:

  1. Search(v) — determine if v exists in the ADT or not,
  2. Insert(v) — insert v into the ADT,
  3. Remove(v) — remove v from the ADT.

Hash Table is one possible good implementation for this Table ADT (the other one is this).


PS1: For two weaker implementations of Table ADT, you can click the respective link: unsorted array or a sorted array to read the detailed discussions.


PS2: In live class, you may want to compare the requirements of Table ADT vs List ADT.


Pro-tip 2: We designed this visualization and this e-Lecture mode to look good on 1366x768 resolution or larger (typical modern laptop resolution in 2021). We recommend using Google Chrome to access VisuAlgo. Go to full screen mode (F11) to enjoy this setup. However, you can use zoom-in (Ctrl +) or zoom-out (Ctrl -) to calibrate this.

🕑

When the range of the Integer keys is small, e.g., [0..M-1], we can use an initially empty (Boolean) array A of size M and implement the following Table ADT operations directly:

  1. Search(v): Check if A[v] is true (filled) or false (empty),
  2. Insert(v): Set A[v] to be true (filled),
  3. Remove(v): Set A[v] to be false (empty).

That's it, we use the small Integer key itself to determine the address in array A, hence the name Direct Addressing. It is clear that all three major Table ADT operations are O(1).


PS: This idea is also used elsewhere, e.g., in Counting Sort.


Pro-tip 3: Other than using the typical media UI at the bottom of the page, you can also control the animation playback using keyboard shortcuts (in Exploration Mode): Spacebar to play/pause/replay the animation, / to step the animation backwards/forwards, respectively, and -/+ to decrease/increase the animation speed, respectively.

🕑

In Singapore (as of Sep 2021), bus routes are numbered from [2..991].


Not all integers between [2..991] are currently used, e.g., there is no bus route 989 — Search(989) should return false. A new bus route x may be introduced, i.e., Insert(x) or an existing bus route y may be discontinued, i.e., Remove(y).


As the range of possible bus routes is small, to record the data whether a bus route number exists or not, we can use a DAT with a Boolean array of size 1000.


Discussion: In real life class, we may discuss on why we use 1000 instead of 991 (or 992).

🕑

Notice that we can always add satellite data instead of just using a Boolean array to record the existence of the keys.


For example, we can use an associative String array A instead to map a bus route number to its operator name, e.g.,

A[2] = "Go-Ahead Singapore",
A[10] = "SBS Transit",
A[183] = "Tower Transit Singapore",
A[188] = "SMRT Buses", etc.

Discussion: Can you think of a few other real-life DAT examples?

🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.

🕑

The keys must be (or can be easily mapped to) non-negative Integer values. Note that basic DAT has problem in the full version of the example in the previous few slides as there are actually variations of bus route numbers in Singapore, e.g., 96B, 151A, NR10, etc.


The range of keys must be small.
The memory usage will be (insanely) large if we have (insanely) large range.


The keys must be dense, i.e., not many gaps in the key values.
DAT will contain too many empty (and wasted) cells otherwise.


We will overcome these restrictions with hashing.

🕑

Using hashing, we can:

  1. Map (some) non-Integer keys (e.g., Strings) to Integers keys,
  2. Map large Integers to smaller Integers,
🕑

For example, we have N = 400 Singapore phone numbers (Singapore phone number has 8 digits, so there are up to 10^8 = 100M possible phone numbers in Singapore).


Instead of using a DAT and use a gigantic array up to size M = 100 Million, we can use the following simple hash function h(v) = v%997.


This way, we map 8 digits phone numbers 6675 2378 and 6874 4483 into up to 3 digits h(6675 2378) = 237 and h(6874 4483) = 336, respectively. Therefore, we only need to prepare array of size M = 997 (or just simplify to 1000) instead of M = 100 Million.

🕑

Dengan hashing, kita sekarang dapat mengimplementasikan operasi-operasi ADT Tabel berikut menggunakan larik bilangan bulat (daripada larik Boolean) sebagai berikut:

  1. Cari(v): Mengecek bila A[h(v)] != -1 (kita menggunakan -1 untuk sel yang kosong dengan asumsi v ≥ 0),
  2. Masukkan(v): Set A[h(v)] = v (kita hash v ke h(v) sehingga kita juga perlu menyimpan kunci v),
  3. Hapus(v): Set A[h(v)] = -1 — untuk dijelaskan lebih lanjut.
🕑

Jika kita memiliki kunci-kunci yang dipetakan ke data satelit dan kita mau menyimpan kunci-kunci aslinya juga, kita dapat mengimplementasikan Tabel Hash menggunakan larik pasangan (pair) (Bilangan bulat, tipe-data-satelit) sebagai berikut:

  1. Cari(v): Kembalikan A[h(v)], yang adalah pair (v, data-satelit), mungkin kosong,
  2. Masukkan(v, data-satelit): Set A[h(v)] = pair(v, data-satelit),
  3. Hapus(v): Set A[h(v)] = (pair kosong) — untuk dijelaskan lebih lanjut.

Tetapi, pada saat ini anda harusnya menyadari bahwa sesuatu tidak komplet...

🕑

A hash function may, and quite likely, map different keys (Integer or not) into the same Integer slot, i.e., a many-to-one mapping instead of one-to-one mapping.


For example, h(6675 2378) = 237 from three slides earlier and if we want to insert another phone number 6675 4372, we will have a problem as h(6675 4372) = 237 too.


This situation is called a collision, i.e., two (or more) keys have the same hash value.

🕑

The Birthday (von Mises) Paradox asks: 'How many people (number of keys) must be in a room (Hash Table) of size 365 seats (cells) before the probability that some person share a birthday (collision, two keys are hashed to the same cell), ignoring the leap years (i.e., all years have 365 days), becomes > 50 percent (i.e., more likely than not)?'


The answer, which maybe surprising for some of us, is Reveal.


Let's do some calculation.

🕑

Let Q(n) be the probability of unique birthday for n people in a room.
Q(n) = 365/365 × 364/365 × 363/365 × ... × (365-n+1)/365,
i.e., the first person's birthday can be any of the 365 days, the second person's birthday can be any of the 365 days except the first person's birthday, and so on.


Let P(n) be the probability of same birthday (collision) for n people in a room.
P(n) = 1-Q(n).


We compute that P(23) = 0.507 > 0.5 (50%).


Thus, we only need 23 people (a small amount of keys) in the room (Hash Table) of size 365 seats (cells) for a (more than) 50% chance collision to happen (the birthday of two different people in that room is one of 365 days/slots).

🕑

Isu 1: Kita telah melihat fungsi hash sederhana seperti h(v) = v%997 digunakan dalam contoh Nomor-nomor Telepon yang memetakan range besar dari kunci-kunci bilangan bulat ke range yang lebih kecil dari kunci-kunci bilangan bulat, tetapi bagaimana dengan kunci-kunci yang bukan bilangan bulat? Bagaimana caranya melakukan hashing dengan efisien untuk hal tersebut?


Isu 2: Kita telah melihat bahwa dengan hashing, atau pemetaan, range besar ke range yang lebih kecil, mungkin sekali akan ada tabrakan (collision). Bagaimana caranya mengatasi hal tersebut?

🕑

How to create a good hash function with these desirable properties?

  1. Fast to compute, i.e., in O(1),
  2. Uses as minimum slots/Hash Table size M as possible,
  3. Scatter the keys into different base addresses as uniformly as possible ∈ [0..M-1],
  4. Experience as minimum collisions as possible.
🕑

Misalkan kita mempunya tabel hash dengan ukuran M dimana kunci-kunci digunakan untuk mengidentifikasikan data satelit dan sebuah fungsi hash spesifik digunakan untuk menghitung nilai hash.


Sebuah nilai hash/kode hash dari kunci v dihitung dari kunci v dengan menggunakan sebuah fungsi hash untuk mendapatkan sebuah bilangan bulat dalam range 0 ke M-1. Nilai hash ini digunakan sebagai indeks/alamat dasar/rumah dari masukan Tabel Hash untuk data-satelit.

🕑

Menggunakan contoh Nomor-nomor Telepon, jika kita mendefinisikan h(v) = floor(v/1 000 000),
yaitu kita memilih dua digit pertama dari sebuah nomor telepon.

h(66 75 2378) = 66
h(68 74 4483) = 68

Diskusi: Apa yang terjadi jika anda menggunakan fungsi hash seperti itu? Petunjuk: Lihat ini.

🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.

🕑

Before discussing the reality, let's discuss the ideal case: perfect hash functions.


A perfect hash function is a one-to-one mapping between keys and hash values, i.e., no collision at all. It is possible if all keys are known beforehand. For example, a compiler/interpreter search for reserved keywords. However, such cases are rare.


A minimal perfect hash function is achieved when the table size is the same as the number of keywords supplied. This case is even rarer.


If you are interested, you can explore GNU gperf, a freely available perfect hash function generator written in C++ that automatically constructs perfect functions (a C++ program) from a user supplied list of keywords.

🕑

People has tried various ways to hash a large range of Integers into a smaller range of Integers as uniformly as possible. In this e-Lecture, we jump directly to one of the best and most popular version: h(v) = v%M, i.e., map v into Hash Table of size M slots. The (%) is a modulo operator that gives the remainder after division. This is clearly fast, i.e., O(1) assuming that v does not exceed the natural Integer data type limit.


The Hash Table size M is set to be a reasonably large prime not near a power of 2, about 2+ times larger than the expected number of keys N that will ever be used in the Hash Table. This way, the load factor α = N/M < 0.5 — we shall see later that having low load factor, thereby sacrificing empty spaces, help improving Hash Table performance.


Discuss: What if we set M to be a power of 10 (decimal) or power of 2 (binary)?

🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.

🕑

People has also tried various ways to hash Strings into a small range of Integers as uniformly as possible. In this e-Lecture, we jump directly to one of the best and most popular version, shown below:

int hash_function(string v) { // assumption 1: v uses ['A'..'Z'] only
int sum = 0; // assumption 2: v is a short string
for (auto& c : v) // for each character c in v
sum = ((sum*26)%M + (c-'A'+1))%M; // M is table size
return sum;
}

Discussion: In real life class, discuss the components of the hash function above, e.g., why loop through all characters?, will that be slower than O(1)?, why multiply with 26?, what if the string v uses more than just UPPERCASE chars?, etc.

🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.

🕑

Ada dua ide-ide utama: Metode Pengalamatan Terbuka (Open Addressing) dibandingkan dengan Pengalamatan Tertutup (Closed Addressing).


Dalam Open Addressing, semua kunci-kunci yang di-hash terletak di sebuah larik tunggal. Kode hash dari sebuah kunci adalah alamat dasarnya. Tabrakan (Collision) diselesaikan dengan mengecek/menyelidiki (probing) berbagai alamat-alamat alternatif (sehingga dinamai terbuka (open)) di dalam tabel berdasarkan aturan tertentu.


Dalam Closed Addressing, Table Hash nya terlihat seperti Daftar Adjacency (Adjacency List) (sebuah struktur data graf). Kode hash dari sebuah kunci memberikan alamat dasar yang tetap/tertutup (closed). Tabrakan (Collision) diselesaikan dengan menambahkan kunci-kunci yang bertabrakan tersebut didalam sebuah Senarai Berantai (Ganda) yang diidentifikasikan oleh alamat dasarnya.

🕑

Ada tiga teknik-teknik resolusi tabrakan Open Addressing (OA) yang dibahas di visualisasi ini: Linear Probing (LP), Quadratic Probing (QP), dan Double Hashing (DH).


Untuk berpindah diantara ketiga mode, silahkan klik tajuk (header) yang bersangkutan.


Biarlah:
M = HT.length = ukuran sekarang dari tabel hash,
base = (key%HT.length),
step = langkah probing sekarang,
secondary = smaller_prime - key%smaller_prime (untuk menghindari angka nol — akan dibahas segera)

Kita akan segera melihat bahwa urutan-urutan penyelidikan (probing) di ketiga mode adalah:
Linear Probing: i=(base+step*1) % M,
Quadratic Probing: i=(base+step*step) % M, dan
Double Hashing: i=(base+step*secondary) % M.

🕑

Separate Chaining (SC) collision resolution technique is simple. We use M copies of auxiliary data structures, usually Doubly Linked Lists. If two keys a and b both have the same hash value i, both will be appended to the (front/back) of Doubly Linked List i (in this visualization, we append to the back in O(1) with help of tail pointer). That's it, where the keys will be slotted in is completely dependent on the hash function itself, hence we also call Separate Chaining as Closed Addressing collision resolution technique.


If we use Separate Chaining, the load factor α = N/M describes the average length of the M lists and it will determine the performance of Search(v) as we may have to explore α elements on average. As Remove(v) — also requires Search(v), its performance will be similar as Search(v). Insert(v) is clearly O(1).


If we can bound α to be a small constant (true if we know the expected largest N in our Hash Table application so that we can set up M accordingly), then all Search(v), Insert(v), and Remove(v) operations using Separate Chaining will be O(1).

🕑

View the visualisation of Hash Table above.


In this visualization, we prevent insertion of duplicate keys.


Due to limited screen space, we limit the maximum Hash Table size to be M = 19.


The Hash Table is visualized horizontally like an array where index 0 is placed leftmost and index M-1 is placed rightmost but the details are different when we are visualizing Open Addressing versus Separate Chaining collision resolution techniques.


Discuss: What to modify in order to allow duplicate keys?

🕑

There are three Open Addressing collision resolution techniques discussed in this visualization: Linear Probing (LP), Quadratic Probing (QP), and Double Hashing (DH).


For all three techniques, each Hash Table cell is displayed as a vertex with cell value of [0..99] displayed as the vertex label. Without loss of generality, we do not show any satellite data in this visualization as we concentrate only on the arrangement of the keys. We reserve value -1 to indicate an 'EMPTY cell' (visualized as a blank vertex) and -2 to indicate a 'DELETED cell' (visualized as a vertex with abbreviated label "DEL"). The cell indices ranging from [0..M-1] are shown as red label below each vertex.

🕑

Untuk teknik resolusi tabrakan Separate Chaining (SC), baris pertama berisikan M penunjuk-penunjuk "H" (Head/kepala) dari M Senarai Berantai Ganda.


Lalu, setiap Senarai Berantai Ganda i berisikan semua kunci-kunci yang semuanya ter-hash ke i dalam urutan apapun. Secara matematis, semua kunci-kunci yang bisa diekspresikan sebagai i (mod M) ter-hash ke DLL i. Lagi-lagi, kami tidak menaruh data satelit di visualisasi ini.

🕑

Dalam teknik resolusi tabrakan Linear Probing, kita menelusuri kedepan satu indeks setiap saat untuk slot kosong/terhapus berikutnya (kembali kedepan ketika kita telah mencapai slot terakhir) bilamana terjadi tabrakan.


Contohnya, mari asumsikan bahwa kita memulai dengan Tabel Hash kosong HT dengan ukuran tabel M = HT.length = 7 seperti yang ditunjukkan diatas yang menggunakan indeks 0 ke M-1 = 7-1 = 6. Sadri bahwa 7 adalah bilangan prima. Fungsi hash (primer) sederhana saja, h(v) = v%M.


Walk-through ini akan menunjukkan anda langkah-langkah yang diambil oleh operasi-operasi Masukkan(v), Cari(v), dan Hapus(v) ketika menggunakan Linear Probing sebagai teknik resolusi tabrakan.

🕑

Now click Insert([18,14,21]) — three individual insertions in one command.


Recap (to be shown after you click the button above).


Formally, we describe Linear Probing index i as i = (base+step*1) % M where base is the (primary) hash value of key v, i.e., h(v) and step is the Linear Probing step starting from 1.


Tips: To do a quick mental calculation of a (small) Integer V modulo M, we simply subtract V with the largest multiple of MV, e.g., 18%7 = 18-14 = 4, as 14 is the largest multiple of 7 that is ≤ 18.

🕑

Sekarang klik Insert([1,35]) (selain dari tiga nilai-nilai pertama yang sudah dimasukkan di slide sebelumnya).


Rekap (akan ditunjukkan setelah anda mengklik tombol diatas)

🕑

Now we illustrate Search(v) operation while using Linear Probing as collision resolution technique. The steps taken are very similar as with Insert(v) operation, i.e., we start from the (primary) hash key value and check if we have found v, otherwise we move one index forward at a time (wrapping around if necessary) and recheck on whether we have found v. We stop when we encounter an empty cell which implies that v is not in Hash Table at all (as earlier Insert(v) operation would have placed v there otherwise).


Now click Search(35) — you should see probing sequence [0,1,2,3 (key 35 found)].


Now click Search(8) — [1,2,3,4, 5 (empty cell, so key 8 is not found in the Hash Table)].

🕑

Sekarang mari diskusikan operasi Hapus(v).


Jika kita baru saja mengeset sel HT[i] = KOSONG langsung dimana i adalah indeks yang mengandung v (setelah probing linear jika diperlukan), apakah anda menyadari bahwa kita akan menyebabkan sebuah masalah? Kenapa?


Petunjuk: Ulas tiga slide-slide terakhir tentang bagaimana Masukkan(v) dan Cari(v) bekerja.

🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.

🕑

Sekarang mari lihat Hapus(v) yang lengkap. Jika kita menemukan v pada indeks i (setelah Linear Probing jika diperlukan), kita harus mengeset HT[i] = TERHAPUS (disingkat sebagai DEL dalam visualisasi ini) dimana DEL adalah simbol spesial (secara umum anda harus hanya menggunakan simbol yang tidak dipakai di aplikasi anda) untuk mengindikasikan bahwa sel tersebut bisa di-lewati jika perlu oleh Cari(v) di masa mendatang, tetapi bisa ditimpa oleh Masukkan(w) di masa mendatang. Strategi ini desebut sebagai Penghapusan Malas (Lazy Deletion).


Sekarang klik Remove(21) — [0,1 (kunci 21 ditemukan dan kita set H[1] = DEL)].


Setelah itu, silahkan lanjutkan diskusi di slide berikuktnya.

🕑

Sekarang klik Search(35) — [0,1 (melewati sel yang TERHAPUS), 2,3 (menemukan kunci 35)].


Bayangkan apa yang akan terjadi jika kita salah mengeset H[1] = KOSONG.

🕑

Sekarang klik Insert(28) — anda harusnya melihat barisan probing [0,1 (menemukan sel dengan simbol DEL)], jadi sel ini sebenarnya bisa ditimpa dengan nilai baru tanpa mempengaruhi kebenaran dari Cari(v) di masa mendatang. Jadi, kita taruh 28 di indeks 1.

🕑

Although we can resolve collision with Linear Probing, it is not the most effective way.


We define a cluster to be a collection of consecutive occupied slots. A cluster that covers the base address of a key is called the primary cluster of the key.


Now notice that Linear Probing can create large primary clusters that will increase the running time of Search(v)/Insert(v)/Remove(v) operations beyond the advertised O(1).


See an example above with M = 11 and we have inserted 8 keys that are all 6 (modulo 11), i.e., all have remainder 6 when divided by 11. Now see how 'slow' Insert(94) (the 9th key) is.

🕑

The probe sequence of Linear Probing can be formally described as follows:

 h(v) // base address
(h(v) + 1*1) % M // 1st probing step if there is a collision
(h(v) + 2*1) % M // 2nd probing step if there is still a collision
(h(v) + 3*1) % M // 3rd probing step if there is still a collision
...
(h(v) + k*1) % M // k-th probing step, etc...

During Insert(v), if there is a collision but there is an empty (or DEL) slot remains in the Hash Table, we are sure to find it after at most M Linear Probing steps, i.e., in O(M). And when we do, the collision will be resolved, but the primary cluster of the key v is expanded as a result and future Hash Table operations will get slower too. Try the slow Search(94) on the same Hash Table as in the previous slide but with many DEL markers.

🕑

In the previous slide (Primary Clustering, Part 1), we break the assumption that the hash function should uniformly distribute keys around [0..M-1]. In the next example, we will show that the problem of primary clustering can still happen even if the hash function distribute the keys somewhat uniformly around [0..M-1].


On screen, you see M = 11 where the first 4 keys have been inserted {11, 2, 4, 6}. If we then insert these next 4 keys {22, 24, 26, 28}, these keys will initially collide with the cells that already contain {11, 2, 4, 6}, have "short" one-step probes, then by doing so "plug" the empty cells and accidentally annex (or combine) those neighboring (but previously disjointed) clusters into a long primary cluster. So the next insertion of a key {33} that lands at (the beginning of) this long primary cluster will end up performing almost O(M) probing steps just to find an empty cell. Try Insert([22,24,26,28,33]).

🕑

Untuk mengurangi primary clustering, kita bisa memodifikasi urutan penyelidikan (probe) menjadi:

 h(v) // alamat dasar
(h(v) + 1*1) % M // langkah probing ke-1 jika terjadi tabrakan
(h(v) + 2*2) % M // langkah probing ke-2 jika masih terjadi tabrakan
(h(v) + 3*3) % M // langkah probing ke-3 jika masih terjadi tabrakan
...
(h(v) + k*k) % M // langkah probing ke-k, dsb...

Seperti itu, penyelidikannya (probe) meloncat secara kuadratik, kembali ke depan Tabel Hash seperlunya.


Sebuah kesalahan yang paling sering karena hal ini adalah Quadratic Probing tipe lain:
Melakukan h(v), (h(v)+1) % M, (h(v)+1+4) % M, (h(v)+1+4+9) % M, ...

🕑

Asumsikan bahwa kita telah memanggil Masukkan(18) dan Masukkan(10) ke Tabel Hash yang pada awalnya kosong dengan ukuran M = HT.length = 7. Karena 18%7 = 4 dan 10%7 = 3, 18 dan 3 tidak bertabrakan dan keduanya masing-masing berada di indeks 4 dan 3 seperti yang ditunjukkan diatas.


Sekarang, mari klik Insert(38).


Ulangan (akan ditunjukkan setelah anda mengklik tombol diatas).

🕑

Operasi-operasi Hapus(x) dan Cari(y) didefinisikan dengan mirip. Hanya saja kali ini kita menggunakan Quadratic Probing dan bukan Linear Probing.


Contohnya, asumsikan bahwa kita telah memanggil Hapus(18) setelah slide sebelumnya dan kita menandai HT[4] = TERHAPUS. Jika kita lalu memanggil Search(38), kita akan menggunakan urutan Quadratic Probing yang sama seperti slide sebelumnya, tetapi menembus HT[4] yang sudah di tandai sebagai TERHAPUS.

🕑

Sekilasi, Quadratic Probing yang meloncat +1, +4, +9, +16, ... secara kuadratik sepertinya bisa menyelesaikan isu primary clustering yang kita hadapi dengan Linear Probing sebelumnya, tetapi akah ini adalah teknik resolusi tabrakan yang sempurna?


Cobalah Insert([12,17]).


Apakah anda menyadari apa yang baru saja terjadi?

🕑

Kita bisa memasukkan 12 dengan mudah karena h(12) = 12%7 = 5 sebelumnya kosong (lihat diatas).


Tetapi kita akan memiliki masalah mayor dalam memasukkan kunci 17 bahkan ketika kita masih memiliki 3 slot kosong karena:
h(17) = 17%7 = 3 sudah terisi oleh kunci 10,
(3+1*1) % 7 = 4 sudah terisi oleh kunci 18,
(3+2*2) % 7 = 0 sudah terisi oleh kunci 38,
(3+3*3) % 7 = 5 sudah terisi oleh kunci 12,
(3+4*4) % 7 = 5 lagi sudah terisi oleh kunci 12,
(3+5*5) % 7 = 0 lagi sudah terisi oleh kunci 38,
(3+6*6) % 7 = 4 lagi sudah terisi oleh kunci 18,
(3+7*7) % 7 = 3 lagi sudah terisi oleh kunci 10,
Akan terjadi siklus selamanya jika kita melanjutkan Quadratic Probing ini...


Meskipun kita masih memiliki beberapa (3) sel-sel kosong, kita tidak bisa memasukkan nilai baru 17 ini kedalam Tabel Hash...

🕑

Jika α < 0.5 dan M adalah sebuah bilangan prima (> 3), maka kita bisa selalu mendapatkan slot kosong menggunakan Quadratic Probing. Ingat: α adalah load factor dan M adalah ukuran Tabel Hash (HT.length).


Jika kedua persyaratan diatas terpenuhi, kita bisa membuktikan bahwa M/2 indeks-indeks Quadratic Probing pertama, diluar alamat dasar h(v) adalah berbeda dan unik.


Tetapi tidak ada garansi setelah itu. Sehingga jika kita mau menggunakan Quadratic Probing, kita perlu menjamin bahwa α < 0.5 (tidak dipaksakan dalam visualisasi ini tetapi kita keluar dari loop setelah M langkah untuk menghindari infinite loop).

🕑

Kita akan menggunakan pembuktian dengan kontradiksi. Kita pertama berasumsi bahwa dua langkah Quadratic Probing:
x dan y, x != y (misalkan x < y), bisa menghasilkan alamat yang sama modulo M.

h(v) + x*x = h(v) + y*y (mod M)
x*x = y*y (mod M) // hapus h(v) dari kedua sisi
x*x - y*y = 0 (mod M) // pindahkan y*y ke sisi kiri
(x-y)*(x+y) = 0 (mod M) // atur ulang formula

Sekarang, antara (x-y) atau (x+y) harus sama dengan nol.
Karena asumsi kita bilang bahwa x != y, maka (x-y) tidak bisa 0.
Karena 0 ≤ x < y ≤ (M/2) dan M adalah bilangan prima > 3 (sebuah bilangan bulat ganjil),
maka (x+y) juga tidak mungkin bisa 0 modulo M.


Kontradiksi!


Jadi M/2 langkah-langkah pertama dari Quadratic Probing tidak bisa menghasilkan alamat yang sama modulo M

(jika kita mengeset M sebagai bilangan prima lebih besar dari 3).


Diskusi: Bisakah kita membuat Quadratic Probing menggunakan ~50% sel-sel tabel yang lainnya?

🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.

🕑

In Quadratic Probing, clusters are formed along the path of probing, instead of around the base address like in Linear Probing. These clusters are called Secondary Clusters and it is 'less visible' compared to the Primary Clusters that plagued the Linear Probing.


Secondary clusters are formed as a result of using the same pattern in probing by colliding keys, i.e., if two distinct keys have the same base address, their Quadratic Probing sequences are going to be the same.


To illustrate this, see the screen with M = 19. We have populated this Hash Table with only 7 keys (so load factor α = 7/19 ≥ 0.5) and the Hash Table looks 'sparse enough' (no visibly big primary cluster). However, if we then insert Insert(38), despite the fact that there are many (19-7 = 12) empty cells and 19 != 38 (different keys that ends up hashed into index 0), we end up doing 7 probing steps along this 'less visible' secondary cluster.


Secondary clustering in Quadratic Probing is not as bad as primary clustering in Linear Probing as a good hash function should theoretically disperse the keys into different base addresses ∈ [0..M-1] in the first place.

🕑

Untuk mengurangi clustering tipe primary dan secondary, kita dapat memodifikasi urutan probe ke:

 h(v) // alamat dasar
(h(v) + 1*h2(v)) % M // langkah probing ke-1 jika terjadi tabrakan
(h(v) + 2*h2(v)) % M // langkah probing ke-2 jika masih terjadi tabrakan
(h(v) + 3*h2(v)) % M // langkah probing ke-3 jika masih terjadi tabrakan
...
(h(v) + k*h2(v)) % M // langkah probing ke-k, dsb...

Seperti itu, probe nya meloncat sesuai nilai dari fungsi hash kedua h2(v), wrapping around Table Hash seperlunya.

🕑

Jika h2(v) = 1, maka Double Hashing bekerja sama persis seperti Linear Probing.
Jadi secara umum kita mau h2(v) > 1 untuk menghindari primary clustering.


Jika h2(v) = 0, maka Double Hashing tidak bekerja karena alasan yang sangat jelas karena langkah penyelidikan (probing) apapun dikalikan dengan 0 tetaplah 0, yaitu kita tetap di alamat dasar selamanya pada setiap tabrakan. Kita perlu menghindari hal ini.


Biasanya (untuk kunci-kunci bilangan bulat), h2(v) = M' - v%M' dimana M' adalah bilangan prima yang lebih kecil dari M.
Ini membuat h2(v) ∈ [1..M'], yang adalah cukup beragam untuk menghindari secondary clustering.


Penggunaan fungsi hash sekunder membuat Double Hashing secara teori susah untuk mengalami isu clustering primary ataupun secondary.

🕑

Klik Insert([35,42]) untuk memasukkan 35 dan lalu 42 ke Table Hash saat ini diatas.


Rekap (akan ditunjukkan setelah anda mengklik tombol diatas).

🕑

Operasi-operasi Hapus(x) dan Cari(y) didefinisikan dengan mirip. Hanya saja kali ini kita menggunakan Double Hashing dan bukan Linear Probing atau Quadratic Probing.


Contohnya, asumsikan bahwa kita telah memanggil Hapus(17) setelah slide sebelumnya dan kita menandai HT[3] = TERHAPUS. Jika kita lalu memanggil Search(35), kita akan menggunakan urutan Double Hashing yang sama seperti slide sebelumnya, tetapi menembus HT[3] yang sudah ditandai sebagai TERHAPUS.

🕑

In summary, a good Open Addressing collision resolution technique needs to:

  1. Always find an empty slot if it exists,
  2. Minimize clustering (of any kind),
  3. Give different probe sequences when 2 different keys collide,
  4. Fast, O(1).

Now, let's see the same test case that plagues Quadratic Probing earlier. Now try Insert(38) again. Although h(19) = h(38) = 0 and their collide, their probing steps are not the same: h2(19) = 17-19%17 = 15 is not the same as h2(38) = 17-38%17 = 13.


Discussion: Double Hashing seems to fit the bill. But... Is Double Hashing strategy flexible enough to be used as the default library implementation of a Hash Table? Let's see...

🕑

Try Insert([9,16,23,30,37,44]) to see how Insert(v) operation works if we use Separate Chaining as collision resolution technique. On such random insertions, the performance is good and each insertion is clearly O(1).


However if we try Insert([79,68,90]), notice that all Integers {79,68,90} are 2 (modulo 11) so all of them will be appended into the (back of) Doubly Linked List 2. We will have a long chain in that list. Note that due to the screen limitation, we limit the length of each Doubly Linked List to be 6.

🕑

Try Search(35) to see that Search(v) can be made to run in O(1+α).


Try Remove(7) to see that Remove(v) can be made to run in O(1+α) too.


If α is large, Separate Chaining performance is not really O(1). However, if we roughly know the potential maximum number of keys N that our application will ever use, then we can set table size M accordingly such that α = N/M is a very low positive (floating-point) number, thereby making Separate Chaining performances to be expected O(1).

🕑
Diskusi: Setelah semua penjelasan-penjelasan ini, mana dari kedua teknik collision resolution yang lebih baik?
🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.

🕑

Anda telah mencapai akhir dari materi-materi dasar dari struktur data Table Hash ini dan kami mendorong anda untuk mengeksplorasi lebih jauh di Mode Eksplorasi.


Tetapi, kami masih mempunyai beberapa tantangan-tantangan Table Hash untuk anda yang diuraikan di bagian ini.

🕑

Performa dari Tabel Hash menurun ketika load factor α menjadi lebih tinggi. Untuk teknik resolusi tabrakan Quadratic Probing (standar), pemasukkan bisa gagal jika Tabel Hash memiliki α > 0.5.


JIka itu terjadi, kita bisa melakukan hash ulang. Kita buat Tabel Hash lain sekitar dua kali lebih besar dengan fungsi hash yang baru. Kita lalui semuai kunci-kunci di Tabel Hash asli, hitung ulang nilai-nilai hash baru, dan memasukkan ulang kunci-kunci (dan dengan data satelitnya) ke Tabel Hash yang baru dan lebih besar, sebelum pada akhirnya kita menghapus Tabel Hash yang lama dan lebih kecil.


Sebuah aturan praktis adalah untuk melakukan hash ulang ketika α ≥ 0.5 jika kita menggunakan Pengalamatan Terbuka (Open Addressing) dan ketika α > konstanta kecil (dekat dengan 1.0, sesuai kebutuhan) jika kita menggunakan Separate Chaining.


Jika kita mengetahui nilai maksimum dari total kunci-kunci yang mungkin dipakai, kita bisa selalu mempengaruhi α menjadi angka kecil.

🕑

However, if you ever need to implement a Hash Table in C++, Python, or Java, and your keys are either Integers or Strings, you can use the built-in C++ STL, Python standard library, or Java API, respectively. They already have good built-in implementation of default hash functions for Integers or Strings.


See C++ STL std::unordered_map, std::unordered_set, Python dict, set, or Java HashMap, HashSet.


For C++, note that the std::multimap/std::multiset implementations are also exist where duplicate keys are allowed.


For OCaml, we can use Hashtbl.


However, here is our take of a simple Separate Chaining implementation: HashTableDemo.cpp | py | java.

🕑

The content of this interesting slide (the answer of the usually intriguing discussion point from the earlier slide) is hidden and only available for legitimate CS lecturer worldwide. This mechanism is used in the various flipped classrooms in NUS.


If you are really a CS lecturer (or an IT teacher) (outside of NUS) and are interested to know the answers, please drop an email to stevenhalim at gmail dot com (show your University staff profile/relevant proof to Steven) for Steven to manually activate this CS lecturer-only feature for you.


FAQ: This feature will NOT be given to anyone else who is not a CS lecturer.

🕑

Tabel Hash adalah struktur data yang sangat baik untuk mengimplementasikan ADT Tabel jika kunci-kunci (Integer atau String) hanya perlu dipetakan ke data-satelit, dengan performa O(1) untuk operasi-operasi Cari(v), Masukkan(v), dan Hapus(v) jika Tabel Hash disetup dengan benar.


Tetapi, jika kita perlu melakukan lebih banyak hal dengan kunci-kunci, kita mungkin perlu menggunakan struktur data alternatif.

🕑

Untuk beberapa pertanyaan yang lebih menarik tentang struktur data ini, silahkan latihan pada modul latihan Table Hash (tidak perlu login).


Tetapi untuk pengguna yang teregistrasi, anda harus login dan pergi ke Halaman Latihan Umum untuk secara resmi menyelesaikan modul ini dan prestasi tersebut akan disimpan dalam akun pengguna anda.

🕑

Cobalah selesaikan beberapa masalah-masalah pemrograman dasar yang agak membutuhkan penggunaan Tabel Hash (terutama jika ukuran masukkan jauh lebih besar):

  1. Kattis - cd (masukannya sudah terurut jadi solusi alternatif yang bukan menggunakan Tabel Hash ada; jika masukannya tidak terurut, masalah irisan himpunan ini baik diselesaikan dengan bantuan sebuah Tabel Hash),
  2. Kattis - oddmanout (kita bisa memetakan kode-kode undangan yang besar ke range bilangan bulat yang lebih kecil; ini adalah latihan untuk meng-hash bilangan bulat (dengan range besar)),
  3. Kattis - whatdoesthefoxsay (kita menaruk suara-suara yang bukan rubah (fox) ke set yang tidak terurut; ini adalah latihan untuk meng-hash string).

You have reached the last slide. Return to 'Exploration Mode' to start exploring!

Note that if you notice any bug in this visualization or if you want to request for a new visualization feature, do not hesitate to drop an email to the project leader: Dr Steven Halim via his email address: stevenhalim at gmail dot com.

🕑

Buat

Masukkan

Hapus

>

Buat Tabel Hash kosong dengan u

size =

Lakukan

v =

Lakukan

v =

Lakukan

We use cookies to improve our website.
By clicking ACCEPT, you agree to our use of Google Analytics for analysing user behaviour and improving user experience as described in our Privacy Policy.
By clicking reject, only cookies necessary for site functions will be used.

ACCEPT REJECT
Tentang Tim Syarat Guna Kebijakan Privasi

Tentang

VisuAlgo was conceptualised in 2011 by Dr Steven Halim as a tool to help his students better understand data structures and algorithms, by allowing them to learn the basics on their own and at their own pace.

VisuAlgo contains many advanced algorithms that are discussed in Dr Steven Halim's book ('Competitive Programming', co-authored with his brother Dr Felix Halim) and beyond. Today, a few of these advanced algorithms visualization/animation can only be found in VisuAlgo.

Though specifically designed for National University of Singapore (NUS) students taking various data structure and algorithm classes (e.g., CS1010/equivalent, CS2040/equivalent, CS3230, CS3233, and CS4234), as advocators of online learning, we hope that curious minds around the world will find these visualizations useful too.

VisuAlgo is not designed to work well on small touch screens (e.g., smartphones) from the outset due to the need to cater for many complex algorithm visualizations that require lots of pixels and click-and-drag gestures for interaction. The minimum screen resolution for a respectable user experience is 1024x768 and only the landing page is relatively mobile-friendly. However, we are currently experimenting with a mobile (lite) version of VisuAlgo to be ready by April 2022.

VisuAlgo is an ongoing project and more complex visualizations are still being developed.

The most exciting development is the automated question generator and verifier (the online quiz system) that allows students to test their knowledge of basic data structures and algorithms. The questions are randomly generated via some rules and students' answers are instantly and automatically graded upon submission to our grading server. This online quiz system, when it is adopted by more CS instructors worldwide, should technically eliminate manual basic data structure and algorithm questions from typical Computer Science examinations in many Universities. By setting a small (but non-zero) weightage on passing the online quiz, a CS instructor can (significantly) increase his/her students mastery on these basic questions as the students have virtually infinite number of training questions that can be verified instantly before they take the online quiz. The training mode currently contains questions for 12 visualization modules. We will soon add the remaining 12 visualization modules so that every visualization module in VisuAlgo have online quiz component.

We have translated VisuAlgo pages into three main languages: English, Chinese, and Indonesian. Currently, we have also written public notes about VisuAlgo in various languages:

id, kr, vn, th.

Tim

Pemimpin & Penasihat Proyek (Jul 2011-sekarang)
Dr Steven Halim, Senior Lecturer, School of Computing (SoC), National University of Singapore (NUS)
Dr Felix Halim, Senior Software Engineer, Google (Mountain View)

Murid-Murid S1 Peniliti 1 (Jul 2011-Apr 2012)
Koh Zi Chun, Victor Loh Bo Huai

Murid-Murid Proyek Tahun Terakhir/UROP 1 (Jul 2012-Dec 2013)
Phan Thi Quynh Trang, Peter Phandi, Albert Millardo Tjindradinata, Nguyen Hoang Duy

Murid-Murid Proyek Tahun Terakhir/UROP 2 (Jun 2013-Apr 2014)
Rose Marie Tan Zhao Yun, Ivan Reinaldo

Murid-Murid S1 Peniliti 2 (May 2014-Jul 2014)
Jonathan Irvin Gunawan, Nathan Azaria, Ian Leow Tze Wei, Nguyen Viet Dung, Nguyen Khac Tung, Steven Kester Yuwono, Cao Shengze, Mohan Jishnu

Murid-Murid Proyek Tahun Terakhir/UROP 3 (Jun 2014-Apr 2015)
Erin Teo Yi Ling, Wang Zi

Murid-Murid Proyek Tahun Terakhir/UROP 4 (Jun 2016-Dec 2017)
Truong Ngoc Khanh, John Kevin Tjahjadi, Gabriella Michelle, Muhammad Rais Fathin Mudzakir

Murid-Murid Proyek Tahun Terakhir/UROP 5 (Aug 2021-Apr 2022)
Liu Guangyuan, Manas Vegi, Sha Long

List of translators who have contributed ≥100 translations can be found at statistics page.

Ucapan Terima Kasih
Proyek ini dimungkinkan karena Hibah Pengembangan Pengajaran dari NUS Centre for Development of Teaching and Learning (CDTL).

Syarat Guna

VisuAlgo bebas biaya untuk komunitas Ilmu Komputer di dunia. Jika anda menyukai VisuAlgo, satu-satunya "pembayaran" yang kami minta dari anda adalah agar anda menceritakan keberadaan VisuAlgo kepada murid-murid/dosen-dosen Ilmu Komputer yang anda tahu =) lewat postingan Facebook/Twitter/Instagram/TikTok, situs mata kuliah, ulasan di blog, email-email, dsb.


Jika anda adalah seorang murid/dosen struktur data dan algoritma, anda diijinkan untuk menggunakan situs ini secara langsung di kelas-kelas anda. Jika anda mengambil screen shots (video-video) dari situs ini, anda dapat menggunakan screen shots (video-video) tersebut ditempat lain asalkan anda menyebut URL dari situs ini (https://visualgo.net) dan/atau daftar publikasi dibawah ini sebagai referensi. Tetapi, anda TIDAK diijinkan untuk mengunduh berkas-berkas VisuAlgo (sisi-klien) dan memasangnya di situs anda sendiri karena itu dikategorikan sebagai plagiat. Saat ini, kami TIDAK mengijinkan orang lain untuk membuat cabang/varian dari proyek VisuAlgo ini. Menggunakan kopi offline (sisi-klien) dari VisuAlgo untuk kepentingan pribadi diijinkan.


Ingat bahwa komponen kuis online dari VisuAlgo secara natur membutuhkan sisi-server dan tidak ada cara mudah untuk menyimpan skrip-skrip sisi-server dan basis-basis data secara lokal. Saat ini, publik hanya bisa menggunkaan 'mode latihan' untuk mengakses sistem kuis online. Saat ini, 'mode ujian' adalah sistem yang lebih terkontrol untuk menggunakan pertanyaan-pertanyaan yang dibuat secara acak serta verifikasi jawaban otomatis untuk ujian-ujian resmi di NUS.


Daftar Publikasi


Karya ini telah dipresentasikan singkat pada CLI Workshop sewaktu ACM ICPC World Finals 2012 (Poland, Warsaw) dan pada IOI Conference di IOI 2012 (Sirmione-Montichiari, Italy). Anda bisa mengklik link ini untuk membaca makalah kami tahun 2012 tentang sistem ini (yang belum disebut sebagai VisuAlgo pada tahun 2012 tersebut).


Karya ini dibuat denbgan bantuan bekas murid-murid saya.


Laporan Bug atau Permintaan Fitur Baru


VisuAlgo bukanlah proyek yang sudah selesai. Dr Steven Halim masih aktif dalam mengembangkan VisuAlgo. Jika anda adalah pengguna VisuAlgo dan menemukan bug di halaman visualisasi/sistem kuis online atau jika anda mau meminta fitur baru, silahkan hubungi Dr Steven Halim. Alamat emailnya adalah gabungan dari namanya dan tambahkan gmail titik com.

Kebijakan Privasi

Version 1.1 (Updated Fri, 14 Jan 2022).

Disclosure to all visitors: We currently use Google Analytics to get an overview understanding of our site visitors. We now give option for user to Accept or Reject this tracker.

Since Wed, 22 Dec 2021, only National University of Singapore (NUS) staffs/students and approved CS lecturers outside of NUS who have written a request to Steven can login to VisuAlgo, anyone else in the world will have to use VisuAlgo as an anonymous user that is not really trackable other than what are tracked by Google Analytics.

For NUS students enrolled in modules that uses VisuAlgo: By using a VisuAlgo account (a tuple of NUS official email address, NUS official student name as in the class roster, and a password that is encrypted on the server side — no other personal data is stored), you are giving a consent for your module lecturer to keep track of your e-lecture slides reading and online quiz training progresses that is needed to run the module smoothly. Your VisuAlgo account will also be needed for taking NUS official VisuAlgo Online Quizzes and thus passing your account credentials to another person to do the Online Quiz on your behalf constitutes an academic offense. Your user account will be purged after the conclusion of the module unless you choose to keep your account (OPT-IN). Access to the full VisuAlgo database (with encrypted passwords) is limited to Steven himself.

For other NUS students, you can self-register a VisuAlgo account by yourself (OPT-IN).

For other CS lecturers worldwide who have written to Steven, a VisuAlgo account (your (non-NUS) email address, you can use any display name, and encrypted password) is needed to distinguish your online credential versus the rest of the world. Your account will be tracked similarly as a normal NUS student account above but it will have CS lecturer specific features, namely the ability to see the hidden slides that contain (interesting) answers to the questions presented in the preceding slides before the hidden slides. You can also access Hard setting of the VisuAlgo Online Quizzes. You can freely use the material to enhance your data structures and algorithm classes. Note that there can be other CS lecturer specific features in the future.

For anyone with VisuAlgo account, you can remove your own account by yourself should you wish to no longer be associated with VisuAlgo tool.