Answered step by step
Verified Expert Solution
Question
1 Approved Answer
c++ X M obile A chatx+ tructure.com/courses/2656158/assignments/24348896 201 > Assignments > absolutely different absolutely different Write a program that reads a list of N numbers
c++
X M obile A chatx+ tructure.com/courses/2656158/assignments/24348896 201 > Assignments > absolutely different absolutely different Write a program that reads a list of N numbers from input, all on one line, then determines whether or not the absolute value of the differences between adjacent numbers in the list covers all of the values 1..N-1. You may assume that there are no more than 50 numbers on a line. For example, the list'[2,5,4,6) meets this condition, because the absolute value of the differences are 12-5-3, 15-41 = 1, 14-61 = 2. So we have four values in the initial list and the absolute differences (1,2,3). Note that the order in which the difference values appear does not matter. If the input list meets the condition, report "Good sequence."; If it does not meet the condition, indicate the smallest expected value that is missing. You may assume that data structures are available in p queue.h, p2stack.h, and p2priorityqueue.h. Several sample runs are shown below. Enter list: 1 1 15 Gedunce. This example has differences (1,2,3,4,5) Good sequence. This example has differences (1,2,4,3) Eater list: Good CE. Previous Next absolutely different Enter list: 28 Good sequence. A list with only one value should not produce any differences and so is not missing any Enter list: 25 47 Bad sequence: missing 2. This example has differences {3,1,3}, so 2 is the smallest missing value. Enter list: 7 5 3 8 11 Bad sequence: missing 1. This example has differences 2,2,5,3), so 1 is the smallest missing value Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started