To predict cancer using k-NN, patient data such as age, tumor size, and genetic markers are first collected. This data is then plotted in a multi-dimensional space. For a new patient, the algorithm calculates the distance to all points in the dataset using a distance metric, often Euclidean distance. The 'k' nearest neighbors are identified, and the most common cancer type among them is chosen as the prediction. This method is useful for predicting various types of cancer, including breast cancer and lung cancer.