Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON You are using a browser to visit web pages. e.g. page1 -> page2 -> page3 -> page4 -> page5 (single thread page view) This

PYTHON

You are using a browser to visit web pages. e.g. page1 -> page2 -> page3 -> page4 -> page5 (single thread page view) This gives a list like so: [ [page1, page2], [page2, page3], [page3, page4], [page4, page5], ] Now we shuffle the list: [ [page2, page3], [page1, page2], [page4, page5], [page3, page4], ] Return a pair of strings indicating the first and last page you visited: ["page1", "page2"] FOLLOW UP: There are some cases where you cannot determine what page you started with: page1 -> page2 -> page3 -> page4 -> page5 -> page1 You could start at any of the pages But there are also cases where you can determine where you started page1 -> page2 -> page3 -> page4 -> page5 -> page1 -> page5 (single thread page view) Input: [ [page3, page4], [page4, page5], [page1, page2], [page2, page3], [page5, page1], [page1, page5], ] The only possible answer is ["page1", "page5"] (because the indegree of page 1 < outdegree of page1) (and the indegree of page 2 >= outdegree of page 2) Handle this case as well

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_2

Step: 3

blur-text-image_3

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

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions

Question

List out some inventory management techniques.

Answered: 1 week ago