I'm trying to implement following picture.
The logic this illustrates is as follows: compare the first entity and last entity of a block and if they are different, divide it into two blocks. Then, compare the first and last entity of the divided block. Repeat it until we find two entities that are the same.
I've newly started to program and I just learned recursive logic, stacks and queues. I'm trying to implement it with DFS but I'm not sure how I can divide it into two and repeat. Can you help me to find a keyword to Google it? Or is there any matching data structure I can use?
I wrote this code, but this doesn't seem to work.
def getBln(idx1, idx2):
pass
#DFS
def videoRcsv():
if getBln(idx1, idx2) == True:
break
else:
videoRcsv(idx1, idx2/2),videoRcsv(idx2/2, idx2)
def main():
pass
main():