Cognizant interview question

How GC algorithm works?