I want to practice my problem-solving skills that involve the usage of a tree data structure (e.g.
Binary Search Tree,
Fenwick Tree, etc.)
The problem should make me search for the right tree data structure and apply it in solving the problem, but not manipulate the tree itself. Hence, problems like the lowest common ancestor, inorder traversal, etc. do not count.
One nice problem that I know is as follows:
N pixels in a row are originally coloured as white: WWWWWWWWWWWWWWW // N=15 in this case We now keep recolouring all pixels between position i and position j with a different colour c for T times: T = 1: WWWBBBBBWWWWWWW // i = 4, j = 8, c = B T = 2: WWWBBGGGGWWWWWW // i = 6, j = 9, c = G T = 3: YYYBBGGGGWWWWWW // i = 1, j = 3, c = Y T = 4: YBBBBBGGGWWWWWW // i = 2, j = 5, c = B ... At the end, you are asked to print the colour of each pixel.
Since N and T can be large, one requires a tree data structure to efficiently update the colour pattern of the pixels.
Can anyone suggest good programming problems of this nature?