You are given n movies labeled 0..n-1 and a list of undirected pairs (a, b) meaning movies a and b are similar. Group all movies into categories where each category is a maximal set of movies connected via similarity links (i.e., connected components). Return the categories as lists of movie IDs, each list sorted, and the collection sorted by the smallest ID in each category. Implement solutions using both BFS and DFS, explain their time/space complexity, and compare iterative vs. recursive DFS. Then discuss an alternative Union-Find approach and when it would be preferable. Dry-run on n=8 with pairs: (0, 1),(1, 2),(3, 4),(5, 6),(6, 7).