I am learning about Greedy Algorithms and we did an example on Huffman codes. To prove the correctness of our algorithm, we had to have the greedy choice property and the optimal substructure property.
Here is what my professor said about the optimal substructure property:
Let C be an alphabet and x and y characters with the lowest frequency.
Let C' = C-{x,y}U{z} where z.frequency = x.frequency + y.frequency
Let T' (a binary tree) be an optimal prefix code for C'
She then drew these pictures
Let T be constructed from T' by replacing z with an internal node with children x and y. Then T is an optimal prefix code for C
And I don't really understand what/how this proves anything. All I see that she is doing is like..working backwards. First she replaced x and y with z, and now she is replacing z with x and y. What exactly is this showing? I'm really bad with proofs sometimes so I am just completely lost as to how this showed me anything about anything