سؤال

My Professor uses the term key comparison when talking about quicksort, but didn't explain what exactly the key is. If we're sorting an array of numbers, is a key a number in the array?

هل كانت مفيدة؟

المحلول

The key is whatever you're sorting on.

If you're just doing a typical sort of an array of numbers, then the key is a number.

If you're sorting, for example, objects describing people, and you're sorting this by their surname, then the key would be the surname.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top