Solved

Algorithm to find the repeated number

Posted on 2004-04-18
2
784 Views
Last Modified: 2006-11-17
Suppose you have an array of 1001 integers. The integers are in random order, but you know each of the integers is between 1 and 1000 (inclusive). In addition, each number appears only once in the array, except for one number, which occurs twice. Assume that you can access each element of the array only once. Describe an algorithm to find the repeated number. If you used auxiliary storage in your algorithm, can you find an algorithm that does not require it?


I will place my program very soon. But that has multipl access to array and has auxillary array to store. I have two more steps to be taken t reach goal. So please help...

M
0
Comment
Question by:Mamata_gd
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
ID: 10855143
Find the sum of all the integers in the array, and compare it to the sum of the integers between 1 and 1000
0
 

Author Comment

by:Mamata_gd
ID: 10855216
Great.. How can you think like this??? We were using big sledgehammers to kill this fly. -:)

BTW, how did you think in this direction?

Please let me know..

M
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now