Delirium is an acute and fluctuating change in cognitive function, characterized by poor attention and disorganized thinking. Recent studies show that patients with obstructive sleep apnea (OSA) - a sleep disorder characterized by repeated episodes of complete or partial blockage of the upper airway - are at greater risk to develop delirium. It is estimated that 43% of men and 27% of women aged 50-70 years old have OSA. Elderly individuals with this condition are often undiagnosed. Unrecognized OSA may be a treatable cause of postoperative delirium. However, timely access to polysomnography is usually not possible prior to surgery. This multi-centre randomized controlled trial will enroll elderly patients scheduled for elective hip/knee replacement surgery. All participants who have given the consent to participate will be assessed risks of OSA and comorbidity by 3 basic questionnaires- STOP-Bang, Epworth Sleepiness Scale and Charlson Comorbidity index, Cognitive level assess by Mini-Cog and baseline delirium assessment by CAM. STOP-Bang questionnaire is the validated questionnaire to screen the patients for OSA. Score of 3 or higher has sensitivity of detecting OSA of 93% and 100% for moderate and severe OSA respectively. If participant has STOP-Bang score 3 or higher will have a home sleep study with the ApneaLink Air and overnight oximetry. Patients identified to have OSA(AHI ≥10/h) will be randomized to 1) Auto-titrating continuous positive airway pressure (CPAP) applied 1-3 nights before surgery (if possible) and during day/night sleep for 72 hrs after surgery or 2) Control group - routine care. All patients will be evaluated for delirium for 72h after surgery.