Initialization is one of the fundamental tasks to set up an ad hoc network, which involves assigning each of the n MSs a distinct ID number from 1 to n, distributedly. In this paper, an algorithm for initializing an ad hoc network with carrier sense capability is described. A novel acknowledgement scheme is first proposed to notify a transmitting MS whether its transmission is successful during the initialization. A distributed initialization algorithm is then developed and analyzed under the assumptions of a known number of users in the network. The algorithm is obtained based on the optimized key parameter to minimize the total time required to complete the initialization. Theoretical analysis and simulation indicates that the proposed initialization algorithm outperforms the randomized initialization algorithm.