Question: Question 2 A Domain Name System ( DNS ) translates domain ALL ( i ) names to IP addresses which are then used by browsers

Question 2
A Domain Name System (DNS) translates domain
ALL
(i) names to IP addresses which are then used by browsers to load internet resources. For quicker DNS lookups, browsers often store a number of recent DNS queries in a DNS cache. Retrieving data from the cache is often faster than retrieving it
1
from a DNS server. This task aims to simulate DNS resolution and determine the time taken to process different URLs.
2 Assume that the DNS cache can store a maximum of the cache_size most recent DNS requests, i.e., URL-IP mappings. The cache is intitilly empty. It takes cache_time units of time to ferch data from the DNS cache, and server_time units of time to fetch data from the DNS server.
Given a list of n URL s visited as an array of strings, urls, determine the minimum time taken to resolve each DNS request.
Note: New DNS requests are dynamically added to the cache, and the cache stores mappings according to the order in which the requests were made.
Example
suppose cache size =3, cache time =2
server_time =5, urls =
hackerrank.com/test/1osk(dhn772/questions//rbpgeetica
41mleft
(1)2. Question 2
Language Python 3
I!/bin/pytho
10 #
11 Complete
12 :
13 The funct
14 i The funct
151. INTEG
16$ 2. INTEC
17$3. INTEC
18:4. STRI
19
28
21 def gethin
22
23> if _
+2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!