The second-best MST is the MST with the smallest total weight that is strictly larger than the minimum MST weight. You can find it by replacing one edge in the MST with another edge. For each edge in the MST, remove it and find the minimum-weight edge that reconnects the two components.
The smallest such replacement gives you the second-best MST. This takes attempts, each requiring work. Total: .
Space complexity is for the data structures used.