Language:EN
Pages: 3
Words: 359
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
col row row rows col col cols visited pipe returnv

Col row row rows col col cols visited pipe returnvisited true explore neighbors

Depth First Search Assignment Answers

Question:

Coding Exercise: Connected Sinks in a Pipe System

Depth First Search Answer and Explanation

rows = len(pipe_system)

cols = len(pipe_system[0])

return

if visited[row][col] or pipe_system[row][col] == '0':

dfs(row + 1, col) # down

dfs(row, col - 1) # left

# Found an unvisited sink, start DFS

connected_sinks_count += 1

['1', '0', '0', '1', '0'],

['1', '1', '0', '1', '0'],

print("Number of connected sinks:", find_connected_sinks(pipe_system))

In this:

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : vedika rana

PageId: DOC5D9ED58