Device to Device communication (D2D) for the cellular networks enables direct communication between the mobile devices that are in close proximity of each other. However, the scarce cellular spectrum for D2D in-band overlay communication must be intelligently assigned in order to optimize the overall network spectral and energy efficiency. With the help of graph theory, we demonstrate that the joint power and spectrum allocation optimization problem has an exponential time complexity that increases with the number of D2D nodes and frequency resources. We then propose an algorithm that solves the aforementioned optimization problem in two phases. The first phase performs admission control for the nodes that meet the power feasibility requirement along with the resource block assignment based on frequency reuse strategies with the aim to minimize the required frequency resources, whereas, the next phase minimizes the required transmission power of the nodes scheduled on those resource blocks while meeting the Quality of Service (QoS) requirements. We also propose several dynamic frequency reuse strategies and highlight the trade-off between spectrum and energy efficiency within an outage constraint for a given network with different service requirements and applications. The proposed strategies outperform other state-of-the-art strategies effectiveness of which is evaluated using extensive network level simulations.