Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*** Write in Lisp *** A web page A containing a link to another one B is represented by a pair, (A B). Give a

*** Write in Lisp ***image text in transcribed

A 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 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 Biff 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 SL) where is a list of atoms naming web pages, and L is a list of pairs representing linkage. The function retums 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 Cmput 325) 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions