Here is a pseudo code algorithm from an algorithm textbook by Goodrich for finding the dominating 2D points in a set of points, known as finding maxima sets:
Algorithm MaximaSet(S):
Input: A set,S,of n points in the plane
Output: The set, M, of maxima points in S
if n ≤ 1
then return S
Let p be the median point in S, by lexicographic (x,y)-coordinates
Let L be the set of points lexicographically less than p in S
Let G be the set of points lexicographically greater than or equal to p in S
M1 ←MaximaSet(L)
M2 ←MaximaSet(G)
Let q be the lexicographically smallest point in M2
for each point, r, in M1 do
if x(r) ≤ x(q) and y(r) ≤ y(q)
then Remove r from M1
return M1 ∪ M2
My question is in the two recursive calls at line 10,11. My understanding is that the first calls for M1 at line 10 will break the L side into another L and G set, and then the next L into another L and G set, until one set remains, the the next line will run and do the same thing to the G side for M2, but now how does it do the comparisons with q? Can someone help me trace the conquer part of this algorithm?
Given
(1,4) (2,6), ( 3,1) (4,5) (5,7) (6,9) (7,2), (8,6) (9,3)
I know the maxima set is (6,9) (8,6) (9,3) but I am stuck on how exactly that came to light using THIS algorithm. I solved it via brute force. This started as a HW question, and I technically can move on because I did find the answer, but I really need to get an understanding of this and I've tried 2 textbooks and google but I think I need a person this time. Thank you in advance and since this is my first time on stack please don't hesitate to (kindly, please) give me any corrections to how I asked my question or presented my p-code