Top Banner
Complexit y 1 Mazes And Random Walks
23

Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Dec 21, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity1

MazesAnd Random Walks

Page 2: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity2

Can You Solve This Maze?

Page 3: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity3

The Solution

Page 4: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity4

What Will We Do?

• Our task is to show an algorithm for general mazes.

• We have memory which is logarithmic in the size of the maze.

Page 5: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity5

Introduction

• Objectives:– To explore the undirected connectivity

problem– To introduce randomized computations

• Overview:– Undirected Connectivity– Random Walks

Page 6: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity6

Undirected Connectivity

• Instance: An undirected graph G=(V,E) and two vertices s,tV

• Problem: To decide if there is a path from s to t in G

Page 7: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity7

What Do We Know?

Theorem: Directed Connectivity is NL-

Complete

Corollary: Undirected Connectivity is in NL.

Page 8: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity8

Undirected Connectivity is in NL: Revisit

Our non-deterministic algorithm:

At each node, non-

deterministically choose a

neighbor and jump to it

Page 9: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity9

What If We Don’t Have “Magic Coins”?

• Non-deterministic “algorithms” use “magic coins” to lead them to the right solution if one exists.

• In real life, these are unavailable…

Page 10: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity10

Idea!

• What if we have plain coins?• In other words, what if we

randomly choose a neighbor?

Page 11: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity11

Random Walks

Add a self loop to each vertex.• Start at s.

• Let di be the degree of the current node.

• Jump to each of the neighbors with probability 1/di.

• Stop if you get to t.s t

Page 12: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity12

Notations

• Let vt denote the node visited at time t (v0=s).

• Let pt(i) = Pr[vt=i]

p0(s)=1

p1(a)=0.5s ta

Page 13: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity13

Stationary Distribution

Lemma: If G=(V,E) is a connected graph, for any iV,

it

t

dlimp i

2 E i

tt

dlimp i

2 E

Page 14: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity14

Weaker Claim

We’ll prove a weaker result:

Lemma: If for some t, for any iV,

then for any iV,

it

dp i

2 E i

t

dp i

2 E

it 1

dp i

2 E it 1

dp i

2 E

Page 15: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity15

Proof

Proof: di=2|E|. If the ith node has weight di at time t, then it retains this weight at time t+1 (it’s reachable (only) from its di neighbors).

Page 16: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity16

Illustrated Proof

Page 17: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity17

Using the Asymptotic Estimate

Corollary: Starting from some node i, we will revisit i within expectedly 2|E|/di steps.

Proof: Since the walk has no “memory”, the expected return time is the same as the asymptotic estimate

Page 18: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity18

One-Sided Error

• Note that if the right answer is ‘NO’, we clearly answer ‘NO’.

• Thus, a random walk algorithm has one-sided error.

• Such algorithms are called “Monte-Carlo” algorithms.

Page 19: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity19

How Many Steps Are Needed?

If the right answer is ‘YES’, in how many steps do we expect to discover that?

s t

. . .

The probability we head in the right direction is 1/ds

But every time we get here, we get a

second chance!

Page 20: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity20

How Many Steps Are Needed?

• Since expectedly we return to each vertex after 2|E|/di steps,

• We expect to head in the right direction after |E| steps (w.p. ½).

• By the linearity of the expectation, we expect to encounter t in d(s,t)|E||V||E| steps.

Page 21: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity21

Randomized Algorithm for Undirected Connectivity

1. Run the random walk from s for 2|V||E| steps.

2. If node t is ever visited, answer “there is a path from s to t”.

3. Otherwise, reply “there is probably no path from s to t”.

Page 22: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity22

Main Theorem

Theorem: The above algorithm - uses logarithmic space- always right for ‘NO’ instances.- errs with probability at most ½ for

‘YES’ instances.

To maintain the current position we

only need log|V| space

Markov: Pr(X>2E[X])<½

PAP 401-404

Page 23: Complexity 1 Mazes And Random Walks. Complexity 2 Can You Solve This Maze?

Complexity23

Summary

• We explored the undirected connectivity problem.

• We saw a log-space randomized algorithm for this problem.

• We used an important technique called random walks.