You are given a list of sampling profiler snapshots (Samples), each containing a float timestamp and an ordered list of function names representing the current call stack at that moment. The samples are ordered by timestamp. Implement convertToTrace(samples) (also called convertSamplesToEvents) that converts this list of samples into a chronological…