Graphs cospectral with starlike trees