Question: Divide and conquer: You have an n x n grid of lines. (Such a grid is defined by placing a vertex at each point (x,y)
Divide and conquer: You have an n x n grid of lines. (Such a grid is defined by placing a vertex at each point (x,y) for each integer x and y between 1 and n. Two vertices (a,b) and (c,d) are connected by an edge if and only if
|ac|+|bd|=1.) Every vertex of the grid is labelled with a unique number. There is a routine labelOf(x,y) that takes a coordinate (x,y) and returns the label of the vertex at that coordinate. Write an efficient algorithm that finds a locally minimal vertex. That is, a vertex whose label is the smaller than the labels of each of the up to 4 neighbors of that vertex.
a-C a-C
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
