levo

Exchanging Data

Hashing

  • 3 things to know
  • Component 01

Overview

Recall questions on hash functions and why hashing is not encryption, collisions, hash tables and collision handling, storing passwords as salted hashes, checksums for downloads, and hashing a message before signing it.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

What is a hash function?

Key term

What is a collision?

Key term

How is a hash table used to store and retrieve data?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What is a hash function?

    Model answer

    A hash function is an algorithm that takes an input of any size and produces an output, called the hash or digest, of a fixed size. The same input always produces the same output, but the process is one way: there is no practical way to work backwards from the hash to recover the original input.

  2. 2

    Explain why hashing is not a form of encryption.

    Model answer

    Encryption is reversible by design: it exists so that the holder of the correct key can decrypt the ciphertext and recover the original data exactly. Hashing is deliberately one way and has no key that reverses it; the output is a fixed size regardless of input size, so information is lost and the original cannot be reconstructed from the digest. Hashing is used to check or index data, not to hide data that must later be read back.

  3. 3

    What properties make a hash function a good one?

    Model answer

    It should be quick to compute; it should be deterministic, always giving the same output for the same input; it should distribute outputs evenly across the available range so that values do not cluster; it should therefore produce as few collisions as possible; and for security uses it should be infeasible to reverse and should produce a wildly different digest for even a tiny change in the input.

  4. 4

    What is a collision?

    Model answer

    A collision occurs when two different inputs produce the same hash value. Collisions are unavoidable in principle because there are more possible inputs than there are possible fixed-size outputs, so a good hash function aims to make them rare and hard to engineer rather than impossible.

  5. 5

    How is a hash table used to store and retrieve data?

    Model answer

    The key of each item is passed through a hash function, which produces an index into an array of buckets, and the item is stored at that index. To retrieve an item the same key is hashed again, giving the same index directly, so the item is found without searching through the other entries.

  6. 6

    A student writes that lookup in a hash table is O(1). Under what conditions is that true, and when does it break down?

    Model answer

    It is O(1) on average, when the table is not too full and the hash function spreads keys evenly, so most buckets hold at most one item and the index calculation leads straight to it. It breaks down when collisions become common, for instance when the load factor gets high or the hash function distributes poorly: many items then share buckets and must be searched through, and in the worst case, where every key hashes to the same bucket, lookup degrades to O(n).

Other ways to work this

The same content, four other ways.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

Processors: Structure, Performance and Types
Input, Output and Storage
Systems Software
Applications Generation

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

If it matches, the search .
succeedsfailsrestarts

Blank Blitz makes facts automatic

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

A0 + 0 gives 0.
B0 + 1 gives 1.
C1 + 1 gives 0 carry 1.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

A global variable means a variable reachable from anywhere in the program.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Exchanging Data, on a schedule.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.