You are Here: Home >< A-levels

# CompSci Hash Tables?!?! watch

1. Hey all, I'm self studying A level computer science, but this is one topic I'm struggling to get my head around, hash tables. Here is the question I am on:

Q) Using the hashing function k(k+3) mod m, where k is the key field and m is the bucket size, if m is 251, calculate the addresses for the key fields:
a) 101
b)52

Now I understand you substitute the key field into k and 251 into m e.g. for a) 101((101+3) = 104) mod 251
=10504 mod 251
But from here I'm not sure on what I'm doing. I've done my best to try to understand the use of modular arithmetic, but I don't know how to do these questions. Can anyone help me out? Thank you in advance (the answers are 213 for a) and 99 for b) btw)
2. the mod operator shows you the remainder of number you divide. for example: 7 mod 3 = 1 (7-3-3, remainder is 1) or 5 mod 2 = 1(5-2-2, remainder is 1), but 15 mod 3 = 0 (remainder equals 0: 15-3-3-3-3-3).

in your case, you put the numbers 101 and 53 instead of 'k' and find the remainder by dividing on 251. so its ( 101*(101+3)) mod 251.

you can also Google any number and find the remainder. just type "number mod number". try to predict the result and then you shall get how it works
the mod operator which shows you the remainder of number you divide. for example: 7 mod 3 = 1 (7-3-3, remainder is 1) or 5 mod 2 = 1(5-2-2, remainder is 1), but 15 mod 3 = 0 (remainder is equals 0: 15-3-3-3-3-3).

in your case you put the numbers 101 and 53 instead of 'k' and find the remainder by dividing on 251. so its ( 101*(101+3)) mod 251.

you can also Google any number and find the remainder. just type "number mod number". try to predict the result and the you shall get how it works
Thank you Vladon, I think I understand the concept better now. Is there a reputation or something I can give to you?
4. (Original post by AR12)
Thank you Vladon, I think I understand the concept better now. Is there a reputation or something I can give to you?
no worries, i dont need anything

TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

This forum is supported by:
Updated: October 26, 2017
Today on TSR

### He lied about his age

Thought he was 19... really he's 14

### University open days

Wed, 25 Jul '18
2. University of Buckingham
Wed, 25 Jul '18
3. Bournemouth University
Wed, 1 Aug '18
Poll

## All the essentials

### Student life: what to expect

What it's really like going to uni

### Essay expert

Learn to write like a pro with our ultimate essay guide.

### Create a study plan

Get your head around what you need to do and when with the study planner tool.

### Resources by subject

Everything from mind maps to class notes.

### Study tips from A* students

Students who got top grades in their A-levels share their secrets

## Groups associated with this forum:

View associated groups

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE