Achieving efficient spectrum usage is a major challenge in the management of a complex communication system. With multiple users having conflicting objectives who share a common spectrum, some of whom may be hostile, careful resource allocation is essential for the effective utilization of the available frequency. Conventionally, spectrum sharing is achieved via orthogonal transmission schemes whereby the available frequency band is divided into multiple tones (or bands) which are pre-assigned to all the users on a non-overlapping basis. However, such "static orthogonal spectrum sharing" approach can lead to low bandwidth utilization. In fact, various recent spectrum occupancy studies have demonstrated that a typical geographical region has wide swathes of frequencies (up to 2/3 of the allocated radio spectrum) that are not used at any given time. While the utilization of spectrum varies with time, a significant amount of spectrum is available for opportunistic wireless applications among secondary users. Spectrum-sensing cognitive radio technology allows devices to dynamically and automatically seek out and use the optimum frequencies and bandwidth. To take advantage of the unused spectrum capacity, the users dynamically adapt to the spectral environment and change transmission or reception parameters on the fly. This allows for more efficient wireless communication without causing harmful interference with legacy systems or other devices using the same frequency bands. In these systems all users are allowed to use all the tones simultaneously. In comparison with the static spectrum sharing policies, this setup offers significantly greater freedom in utilizing the spectrum. A major challenge in the development of opportunistic spectrum sharing technology is to devise efficient algorithms for the distributed management of frequency slots and transmit power. This tutorial will describe various optimization and game theoretic formulations of the dynamic spectrum management and present some recent results on its complexity, duality and approximation.