Click here to Skip to main content
15,889,462 members
Home / Discussions / Algorithms
   

Algorithms

 
QuestionQuestion from my Phone Interview Pin
BobInNJ15-Dec-08 10:17
BobInNJ15-Dec-08 10:17 
GeneralSum Pin
Luc Pattyn15-Dec-08 11:19
sitebuilderLuc Pattyn15-Dec-08 11:19 
AnswerRe: Question from my Phone Interview Pin
Member 419459315-Dec-08 11:47
Member 419459315-Dec-08 11:47 
AnswerRe: Question from my Phone Interview Pin
Member 419459315-Dec-08 11:49
Member 419459315-Dec-08 11:49 
GeneralRe: Question from my Phone Interview Pin
BobInNJ15-Dec-08 12:43
BobInNJ15-Dec-08 12:43 
GeneralRe: Question from my Phone Interview Pin
Luc Pattyn15-Dec-08 12:52
sitebuilderLuc Pattyn15-Dec-08 12:52 
GeneralRe: Question from my Phone Interview Pin
Member 419459315-Dec-08 13:05
Member 419459315-Dec-08 13:05 
Generalsum <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Pin
Luc Pattyn15-Dec-08 13:20
sitebuilderLuc Pattyn15-Dec-08 13:20 
Right, summing all the numbers is the cheapest and fastest way to identify the duplicate number.
The sum trick only works because you know the range of valid numbers; if the problem was: we have 100 different numbers and 1 got duplicated, then you would need a bitmap. Hence, use all available information. BTW: In order to sum the numbers 1..N you don't need an accumulator, the sum equals N*(N+1)/2 = 5050.

As for the cards, the punch cards I used a long time ago used to have 80 columns; columns 73-80 were not relevant to the program; they typically got used for numbering the cards. And sorting machines were available, so dropping a tray only did cost a few passes through the sorting machine to get everything back in order. IIRC they had around 100 output bins, so for decimal digits, they could handle two digits at a time.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

Fixturized forever. Confused | :confused:


GeneralRe: sum <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Pin
Member 419459315-Dec-08 14:43
Member 419459315-Dec-08 14:43 
GeneralRe: sum <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Pin
riced18-Dec-08 12:47
riced18-Dec-08 12:47 
GeneralNot Cobol Pin
Luc Pattyn18-Dec-08 12:59
sitebuilderLuc Pattyn18-Dec-08 12:59 
GeneralRe: Not Cobol Pin
riced18-Dec-08 13:27
riced18-Dec-08 13:27 
GeneralRe: Not Cobol Pin
Luc Pattyn18-Dec-08 13:39
sitebuilderLuc Pattyn18-Dec-08 13:39 
GeneralRe: Question from my Phone Interview Pin
leonej_dt15-Dec-08 13:33
leonej_dt15-Dec-08 13:33 
AnswerFinding an extra/missing number Pin
supercat918-Dec-08 9:56
supercat918-Dec-08 9:56 
GeneralRe: Question from my Phone Interview Pin
Luc Pattyn18-Dec-08 13:15
sitebuilderLuc Pattyn18-Dec-08 13:15 
GeneralRe: Finding several extra/missing numbers Pin
Luc Pattyn19-Dec-08 1:28
sitebuilderLuc Pattyn19-Dec-08 1:28 
GeneralRe: Finding several extra/missing numbers Pin
supercat919-Dec-08 7:00
supercat919-Dec-08 7:00 
GeneralRe: Finding several extra/missing numbers Pin
Luc Pattyn19-Dec-08 7:25
sitebuilderLuc Pattyn19-Dec-08 7:25 
GeneralRe: Finding several extra/missing numbers Pin
supercat919-Dec-08 8:56
supercat919-Dec-08 8:56 
GeneralRe: Finding several extra/missing numbers Pin
Luc Pattyn19-Dec-08 9:36
sitebuilderLuc Pattyn19-Dec-08 9:36 
GeneralRe: Finding several extra/missing numbers Pin
supercat921-Dec-08 12:28
supercat921-Dec-08 12:28 
GeneralRe: Finding an extra/missing number Pin
cp987619-Dec-08 11:46
cp987619-Dec-08 11:46 
GeneralRe: Finding an extra/missing number Pin
Luc Pattyn19-Dec-08 12:48
sitebuilderLuc Pattyn19-Dec-08 12:48 
GeneralRe: Finding an extra/missing number Pin
supercat920-Dec-08 15:57
supercat920-Dec-08 15:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.