Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

project to be done in C only ( Duplicate Elimination ) Use a one - dimensional array to solve the following problem. Read 2 0

project to be done in C only
(Duplicate Elimination) Use a one-dimensional array to solve the following
problem. Read 20 numbers, each of which is between 10 and 100, inclusive. As each
number is read, print it only if its not a duplicate of a number already read. Provide
for the worst case in which all 20 numbers are different. Use the smallest possible
array to solve this problem.
If the following 22 numbers are entered as input to the program (note that the numbers 9 and 101 are not valid, and are thus not counted towards the 20 valid inputs required):
25,25,50,23,95,55,50,9,85,45,25,97,56,56,33,75,95,35,101,86,100,25
Only the following 14 numbers will be output at the end (the remainder are either invalid numbers or duplicate numbers):
25,50,23,95,55,85,45,97,56,33,75,35,86,100
You should attempt to implement an algorithm that is reasonably efficient in regards to calculating whether a number was previously entered. A hint is that this algorithm does _NOT_ require you to sort the numbers input, which would _NOT_ be efficient for such a small number of inputs. A hashing algorithm is also _NOT_ appropriate here.
Your solution must include a function called isUnique() that returns 1(true) if the number input is unique and 0(false) otherwise . I will leave it to YOUR BEST JUDGEMENT to decide what parameters to pass to this function. The implementation of this function must follow AFTER the implementation of main() in your .c file.
HINT: When you have completed inputting the numbers, there is no requirement that the array contain all of the numbers input by the user. Only the unique numbers are required to be stored in the array.
NOTE: So as to help you narrow down possible acceptable algorithms, I will be looking for your solution to use only a single one dimensional array and the array should have exactly 20 elements.
Note: You should not have any non const global variables as part of your solution.
NOTE: The output your solution produces must emulate the .exes output AS CLOSELY AS POSSIBLE.
NOTE: I have supplied sample test output with 3 different sets of inputs. Your test output that you submit with your solution should use the identical 3 test data sets.
below is an sample output
Enter # 1 : 10
The number: 10 is unique
Enter # 2 : 20
The number: 20 is unique
Enter # 3 : 30
The number: 30 is unique
Enter # 4 : 9
The number entered is not in the valid range of 10 to 100
Enter # 4 : 101
The number entered is not in the valid range of 10 to 100
Enter # 4 : 40
The number: 40 is unique
Enter # 5 : 50
The number: 50 is unique
Enter # 6 : 60
The number: 60 is unique
Enter # 7 : 70
The number: 70 is unique
Enter # 8 : 80
The number: 80 is unique
Enter # 9 : 90
The number: 90 is unique
Enter # 10 : 100
The number: 100 is unique
Enter # 11 : 95
The number: 95 is unique
Enter # 12 : 85
The number: 85 is unique
Enter # 13 : 75
The number: 75 is unique
Enter # 14 : 65
The number: 65 is unique
Enter # 15 : 55
The number: 55 is unique
Enter # 16 : 45
The number: 45 is unique
Enter # 17 : 35
The number: 35 is unique
Enter # 18 : 25
The number: 25 is unique
Enter # 19 : 15
The number: 15 is unique
Enter # 20 : 11
The number: 11 is unique
All of the unique numbers found are:
1020304050
60708090100
9585756555
4535251511

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

Cite common obstacles to reaching your goals.

Answered: 1 week ago

Question

=+b. Who would the brand be as a famous person?

Answered: 1 week ago