web page A containing a link to another one B is represented by a pair, (A B). Give a list L of such pairs, write two Lisp functions: (reached x L) where x is a web page, Lis a list of pairs representing linkage, and the function returns a list of all web pages that can be reached from x (x should not be part of the result). The order of the web pages in the resulting list s unimportant. The importance of a web page could be determined by how many other web pages refer to it. A web page A is said to refer another web page B iff A contains a (direct) link to B, andA and B are not the same web page i.e., a web page referring to itself doesn't count). Multiple links from (A,B) count as one for the importance web page B. Define a function (rank SL) where S is a list of atoms naming web pages, and Lis a list of pairs representing linkage. The function retuns a permutation of S such that the web pages are ordered according to the criterion above, i.e., the most referenced web page is the first in the list, and so on. If two web pages are equally important in terms of references, then it doesn't matter how they are ordered. Hint: Count the number of references to each atom in S to get a list, say ((Cmput325 23) (UofA 128) (CSD 68))

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

** Write in Lisp *** 

A web page A containing a link to another one Bis represented by a pair, (A B). Give a list L of such pairs, write two Lisp functions:
(reached x L)
where x is a web page, Lis a list of pairs representing linkage, and the function returns a list of all web pages that can be reached from x (x should not be part of the result). The order of the web pages in the resulting list
is unimportant.
The importance of a web page could be determined by how many other web pages refer to it. A web page A is said to refer to another web page B iff A contains a (direct) link to B, and A and B are not the same web page
(i.e., a web page referring to itself doesn't count). Multiple links from (A,B) count as one for the importance of web page B.
Define a function
(rank S L)
where S is a list of atoms naming web pages, and L is a list of pairs representing linkage. The function returms a permutation of S such that the web pages are ordered according to the criterion above, i.e., the most
referenced web page is the first in the list, and so on. If two web pages are equally important in terms
references, then it doesn't matter how they are ordered.
Hint: Count the number of references to each atom in S to get a list, say
((Cmput325 23) (UofA 128) (CSD 68))
Then, you can tailor the built-in function sort for your own needs, for example, by
defining
(defun mySort (L)
(sort L 'greaterThan)
(defun greaterThan (L1 L2)
(> (cadr L1) (cadr L2)))
This will give you, for the above example,
((UofA 128) (CSD 68) (Cmput325 23))
from which you can get the final result
(UofA CSD Cmput325)
Note: sort is destructive - it changes the argument list given. So sort is NOT pure functional in Lisp. If you want to save the input list, you can easily define a copy function that gives you a fresh copy of the input list.
Transcribed Image Text:A web page A containing a link to another one Bis represented by a pair, (A B). Give a list L of such pairs, write two Lisp functions: (reached x L) where x is a web page, Lis a list of pairs representing linkage, and the function returns a list of all web pages that can be reached from x (x should not be part of the result). The order of the web pages in the resulting list is unimportant. The importance of a web page could be determined by how many other web pages refer to it. A web page A is said to refer to another web page B iff A contains a (direct) link to B, and A and B are not the same web page (i.e., a web page referring to itself doesn't count). Multiple links from (A,B) count as one for the importance of web page B. Define a function (rank S L) where S is a list of atoms naming web pages, and L is a list of pairs representing linkage. The function returms a permutation of S such that the web pages are ordered according to the criterion above, i.e., the most referenced web page is the first in the list, and so on. If two web pages are equally important in terms references, then it doesn't matter how they are ordered. Hint: Count the number of references to each atom in S to get a list, say ((Cmput325 23) (UofA 128) (CSD 68)) Then, you can tailor the built-in function sort for your own needs, for example, by defining (defun mySort (L) (sort L 'greaterThan) (defun greaterThan (L1 L2) (> (cadr L1) (cadr L2))) This will give you, for the above example, ((UofA 128) (CSD 68) (Cmput325 23)) from which you can get the final result (UofA CSD Cmput325) Note: sort is destructive - it changes the argument list given. So sort is NOT pure functional in Lisp. If you want to save the input list, you can easily define a copy function that gives you a fresh copy of the input list.
Expert Solution
steps

Step by step

Solved in 2 steps with 8 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY