Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

Sorting

Jojo was given a Math assignment by his teacher. Jojo's task is to sort a number of given then find the closest pair of numbers that has the maximum difference after sorted. Jojo was asked to write down a list of the pairs of numbers.

Input Format
The first line of input is an integer N i.e. the number of numbers
The second line is a series of numbers Ai as many as N

Output Format
Pairs of numbers separated by spaces

Constraints
2N105
-107Ai107

Sample Input
5
2 -8 3 1 -10

Sample Output
-8 1

Sample Input
10
45 9 3 -6 100 68 -57 23 -11 -25

Sample Output
-57 -25 68 100

In the sample above if the input is sorted then:
-10 -8 1 2 3 so that the difference between each number in sequence is 2, 9, 1, 1
-57 -25 -11 -6 3 9 23 45 68 100 so the difference is 32, 14, 5, 9, 6, 14, 22, 23, 32

Notes
Even though it wasn't stated in the problem, by now you should know that the advantages spaces or lines are considered WRONG ANSWER.

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education