Question

Write just Algorithm for Given an array of n elements, write an algorithm to find a...

Write just Algorithm for Given an array of n elements, write an algorithm to find a number that has a duplicate.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Algorithm:

main:
Read array n-1 elements
call to duplicate()

called function:

dulicate(int arr[], int size) do

for i=0 through size of array do

    if (arr[abs(arr[i])] >= 0) do

    arr[abs(arr[i])] = -arr[abs(arr[i])];  

    else

Print duplicate element

Add a comment
Know the answer?
Add Answer to:
Write just Algorithm for Given an array of n elements, write an algorithm to find a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT