I'm currently learning how to program with Java, so I'm taking a class on Data Structures and whatnot. Recently, we've been covering the concepts of Sorting Algorithms, and from the start I've been very much confused about the concept as a whole.
We've been given an assignment recently on Sorting Algorithms, and one of the questions looks like this:
Closest 1d pair. Given a sequence of N real numbers, find the pair of integers that are closest in value. Give a O(N log N) algorithm. Describe your proposed algorithm in English.
Basically, what I'm trying to ask is this: Can someone explain to me the general idea of Sorting Algorithms and their purpose as a whole, as well as walk me through how I would go about answering this question? You don't have to give me an answer, I just am looking to acquire the knowledge necessary for answering this question.
Thank you.