DSA Lab II semester 2017-18

Lab -7

Aim: To implement DNS using hash table implementation of Dictionaries

Introduction: The Domain name system (DNS) is a distributed database which provides a mapping from hostname to IP addresses. Hostnames are strings of characters like www.google.com. An IP4 address is a 32-bit quantity that is divided into 4 groups of 8 bits each. Each group is then converted into an integer number in the range 0 to 255. The aim of the experiment is to simulate a simple DNS that allows us to insert DNS records and also provide mapping from hostname to IP4 address using hash table.

Tasks:

Write a C/JAVA program to construct a dictionary using hash table using chaining with the following methods

a. Insert (hostname, ip_address)

b. Find(hostname)

Let table size be N = 53

Example: insert (google.com, 10.1.34.56)

a. Compute the polynomial hash code

= ASCII(g) + ASCII(o) * a + ASCII(o) * a2 + ASCII(g) * a3 + ASCII(l) * a4 + ASCII(e) * a5 + ASCII(c) * a6 + ASCII(o) * a7 + ASCII(m) * a8. Use a as 33.

b. Apply compression map as

c. Insert the pair (hostname, ip_address) in the list present at the index

Example: Find (google.com)

a. Compute the polynomial hash code

= ASCII(g) + ASCII(o) * a + ASCII(o) * a2 + ASCII(g) * a3 + ASCII(l) * a4 + ASCII(e) * a5 + ASCII(c) * a6 + ASCII(o) * a7 + ASCII(m) * a8. Use a as 33.

b. Apply compression map as

c. Display the IP4 address if the hostname is present in the list present at the index . Otherwise display no such element found.

Sample hostname, IP address pairs:

# News

bbc.co.uk 212.58.241.131

aljazeera.com 198.78.201.252

# Social media

reddit.com 72.247.244.88

imgur.com 173.231.140.219

google.com 172.217.11.174

youtube.com 74.125.65.91

yahoo.com 98.137.149.56

hotmail.com 65.55.72.135

bing.com 65.55.175.254

digg.com 64.191.203.30

theonion.com 97.107.137.164

hush.com 65.39.178.43

gamespot.com 216.239.113.172

ign.com 69.10.25.46

cracked.com 98.124.248.77

sidereel.com 144.198.29.112

github.com 207.97.227.239

# Torrent sites

thepiratebay.org 194.71.107.15

mininova.com 80.94.76.5

btjunkie.com 93.158.65.211

demonoid.com 62.149.24.66

demonoid.me 62.149.24.67

# Social networking

facebook.com 31.13.77.36

twitter.com 199.59.149.230

tumblr.com 174.121.194.34

livejournal.com 209.200.154.225

dreamwidth.org 69.174.244.50

# Live Streaming Content

stickam.com 67.201.54.151

blogtv.com 84.22.170.149

justin.tv 199.9.249.21

chatroulette.com 184.173.141.231

omegle.com 97.107.132.144

own3d.tv 208.94.146.80

megavideo.com 174.140.154.32

# Television

gorillavid.com 178.17.165.74

videoweed.com 91.220.176.248

novamov.com 91.220.176.248

tvlinks.com 208.223.219.206

1channel.com 208.87.33.151

# Shopping

amazon.com 72.21.211.176

newegg.com 216.52.208.187

frys.com 209.31.22.39

# File Sharing

mediafire.com 205.196.120.13

megaupload.com 174.140.154.20

fileshare.com 208.87.33.151

multiupload.com 95.211.149.7

uploading.com 195.191.207.40

warez-bb.org 31.7.57.13

hotfile.com 199.7.177.218

gamespy.com 69.10.25.46

what.cd 67.21.232.223

warez.ag 178.162.238.136

putlocker.com 89.238.130.247

uploaded.to 95.211.143.200

dropbox.com 199.47.217.179

pastebin.com 69.65.13.216

Lab-6

CSF211 Lab, 7-3-2018

--------------------

Write a C/JAVA program to read a set of student records (at least 20) from a file.

Assume that each student record contains Student name, ID no., enrollment year and Grade Point Average (GPA).

Sort the records based on Student name using quick sort and display the result.