With the rapid development of next-generation wireless communication technologies and the increasing demand of spectrum resources, it becomes necessary to introduce learning and reasoning capabilities in cognitive radio networks (CRN). In particular, our focus is on two fundamental applications in CRNs, namely spectrum sensing (SS) and spectrum sharing. The application of machine learning (ML) techniques has added new aspects to SS and spectrum sharing. This paper offers a survey on various ML-based algorithms in the cooperative spectrum sensing (CSS) and dynamic spectrum sharing (DSS) domain, with its emphasis on types of features extracted from primary user signal, types of ML algorithm, and performance metrics utilized for evaluation of ML algorithms. Starting with the basic principles and challenges of SS, this paper also justifies the applicability of supervised, unsupervised, and reinforcement ML algorithms in the CSS domain. The application of ML algorithms, to solve the DSS problem has also been reviewed. Finally, the survey paper is concluded with some suggested open research challenges and future directions for ML application in next-generation communication technologies.