  Femtosecond electron bunches with complex temporal structures play a crucial
role in THz generation, free-electron lasers and plasma wakefield accelerators.
The ultrashort electron pulse duration can be reconstructed from the coherent
transition radiation (CTR) spectrum based on prior knowledge. A weighted greedy
sparse phase retrieval (WGESPAR) algorithm is developed to reduce the
ambiguities for reconstructing the distribution of the beam current. This
algorithm achieves better performance than iterative algorithms, especially for
truncated noisy spectra of multibunch structures. Based on the WGESPAR
algorithm, the complex temporal structures of femtosecond electron bunches
generated from laser wakefield accelerators can be successfully reconstructed.
