Click here to Skip to main content
15,894,343 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Counting bricks from image Pin
Tim Craig15-May-08 17:31
Tim Craig15-May-08 17:31 
GeneralRe: Counting bricks from image Pin
asiv15-May-08 20:47
asiv15-May-08 20:47 
GeneralRe: Counting bricks from image Pin
MarkB77715-May-08 21:31
MarkB77715-May-08 21:31 
GeneralRe: Counting bricks from image Pin
Tim Craig15-May-08 22:43
Tim Craig15-May-08 22:43 
GeneralRe: Counting bricks from image Pin
Paul Conrad28-Jun-08 9:16
professionalPaul Conrad28-Jun-08 9:16 
AnswerRe: Counting bricks from image Pin
asiv29-May-08 9:53
asiv29-May-08 9:53 
QuestionVideo Data on Network at a Bitrate? Pin
Andy Rama13-May-08 20:19
Andy Rama13-May-08 20:19 
QuestionIterating and comparing two Dictionary objects [modified] Pin
invictus39-May-08 5:03
invictus39-May-08 5:03 
Hi
I work with some very large arrays (millions of items) in an algorithm, however, since most fields contains the value 0 I decided to use a Dictionary<int, int=""> to represent only the array's fields where the value is not 0.

Dictionary<int, int=""> means that the first int is the index of the array in which the value would appear, and the second int is the value of this index.

Now, I have two of these "arrays" that I need to compare. For each _existing_ index I need to find the difference between the arrays.

E.g. index i exists in dict1 (first dictionary) but not in dict2, thus the difference should be the value of dict1[i] alone. index i exists in both dictionaries thus the difference should be dict1[i] - dict2[i].

Now, in theory this should be possible to achieve with iterating each unique index in BOTH dictionaries only once (e.g. if an index occurs in both dictionaries it should only be iterated once)

My suggestion was that I start by getting the first item from each and compare the index of these.if they are equal I would increase both iterators.if one is higher than the other I would increase the iterator until they are equal or the other one is lower. This would be repeated until both are iterated through. Any ideas how I can do this with C# and Dictionary<int, int="">?

Any ideas? need to do this iteration as fast as possible. In C I could do some pointer magic to achieve this, but I am not familiar with C# dictionary iterators/enumerators so I have no idea whatsoever how to solve this.

modified on Friday, May 9, 2008 2:50 PM

AnswerRe: Iterating and comparing two Dictionary objects Pin
73Zeppelin9-May-08 7:52
73Zeppelin9-May-08 7:52 
AnswerRe: Iterating and comparing two Dictionary objects Pin
Alan Balkany9-May-08 10:33
Alan Balkany9-May-08 10:33 
AnswerRe: Iterating and comparing two Dictionary objects Pin
Mark Churchill18-May-08 4:40
Mark Churchill18-May-08 4:40 
GeneralRe: Iterating and comparing two Dictionary objects Pin
supercat924-May-08 15:12
supercat924-May-08 15:12 
Question(Possibly) Simple Maths Pin
Reelix9-May-08 0:51
Reelix9-May-08 0:51 
AnswerRe: (Possibly) Simple Maths Pin
Cedric Moonen9-May-08 1:08
Cedric Moonen9-May-08 1:08 
GeneralRe: (Possibly) Simple Maths Pin
Reelix9-May-08 2:14
Reelix9-May-08 2:14 
AnswerRe: (Possibly) Simple Maths Pin
Alan Balkany9-May-08 3:37
Alan Balkany9-May-08 3:37 
AnswerRe: (Possibly) Simple Maths Pin
CPallini9-May-08 4:20
mveCPallini9-May-08 4:20 
AnswerRe: (Possibly) Simple Maths Pin
73Zeppelin9-May-08 7:45
73Zeppelin9-May-08 7:45 
Questionneed similar to Excel's "Goal Seek" in C/C++ Pin
KimN6-May-08 9:04
KimN6-May-08 9:04 
AnswerRe: need similar to Excel's "Goal Seek" in C/C++ Pin
73Zeppelin6-May-08 9:17
73Zeppelin6-May-08 9:17 
GeneralRe: need similar to Excel's "Goal Seek" in C/C++ Pin
KimN6-May-08 10:06
KimN6-May-08 10:06 
GeneralRe: need similar to Excel's "Goal Seek" in C/C++ Pin
73Zeppelin6-May-08 10:29
73Zeppelin6-May-08 10:29 
AnswerRe: need similar to Excel's "Goal Seek" in C/C++ Pin
cp98766-May-08 15:57
cp98766-May-08 15:57 
GeneralRe: need similar to Excel's "Goal Seek" in C/C++ Pin
73Zeppelin6-May-08 19:19
73Zeppelin6-May-08 19:19 
QuestionSorting multiple lists so they are unique Pin
jrg20005-May-08 1:10
jrg20005-May-08 1:10 

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.