Click here to Skip to main content
15,891,184 members
Home / Discussions / C#
   

C#

 
QuestionSet Seperate Background Images of Dual Monitors Pin
aj.esler13-Oct-08 14:13
aj.esler13-Oct-08 14:13 
AnswerRe: Set Seperate Background Images of Dual Monitors Pin
Jakob Olsen14-Oct-08 1:00
Jakob Olsen14-Oct-08 1:00 
GeneralRe: Set Seperate Background Images of Dual Monitors Pin
aj.esler14-Oct-08 11:12
aj.esler14-Oct-08 11:12 
GeneralRe: Set Seperate Background Images of Dual Monitors Pin
Jakob Olsen14-Oct-08 21:10
Jakob Olsen14-Oct-08 21:10 
QuestionExternal sorting Pin
Diamonddrake13-Oct-08 13:37
Diamonddrake13-Oct-08 13:37 
AnswerRe: External sorting Pin
Simon P Stevens13-Oct-08 22:51
Simon P Stevens13-Oct-08 22:51 
GeneralRe: External sorting Pin
Diamonddrake14-Oct-08 10:08
Diamonddrake14-Oct-08 10:08 
GeneralRe: External sorting Pin
Simon P Stevens14-Oct-08 11:15
Simon P Stevens14-Oct-08 11:15 
Easiest thing is probably an example.

Take the numbers 0 to 9.

1 7 3 5 2 9 8 4 6 0

Lets assume you can only load 5 at a time into memory.
Load the first block of 5.
1 7 3 5 2 - Lets call this block A.
Now sort block A, using what ever method you want.
1 2 3 5 7.
Now save block A to disk.

Now load the next block.
9 8 4 6 0 - Lets call this block B.
Sort block B.
0 4 6 8 9.
Now save block B to disk.

A - 1 2 3 5 7
B - 0 4 6 8 9

Now you create an input buffer for each block, and 1 output buffer
In this case, we've already said we can manage 5 in memory at a time, so lets make our input buffers 1 item big, and our output buffer 3 items big.

Load the first items from blocks A & B into the input buffers.

InA: 1
InB: 0
Out: Nothing yet.

Now you take the lowest of all the input buffers. In this case buffer B. Move it to the output buffer.

InA: 1
InB: Empty
Out: 0

As buffer B is now empty, you load the next item from B into the buffer. (In this case 4)

InA: 1
InB: 4
Out: 0

Now you just repeat the process. So you move the lowest value to the output buffer.

InA: Empty
InB: 4
Out: 0 1

Then load the next item from A into the empty input buffer.

InA: 2
InB: 4
Out: 0 1

Then move the lowest to the output buffer

InA: Empty
InB: 4
Out: 0 1 2

Now the output buffer is full (remember we said the output buffer was 3 big). So you write the output buffer to disk.

InA: Empty
InB: 4
Out: Empty

Final sorted on disk: 0 1 2

Now you need to load the next value from block A (because InA has become empty)

InA: 3
InB: 4
Out: Empty

Then move the lowest to the output buffer

InA: Empty
InB: 4
Out: 3

Then load the next for any empty input buffers

InA: 5
InB: 4
Out: 3

Move lowest to the output buffer

InA: 5
InB: Empty
Out: 3 4

Load for any empty input buffers

InA: 5
InB: 6
Out: 3 4

Is it starting to be clear now?

1st, Divide into manageable blocks.
Sort each block and write back to disk.
Load the first bit of each block into an input buffer.
Process the input buffers, and move the lowest value into the output buffer.
Every time an input buffer runs empty, you load the next few data items from the associated block.
Every time the output buffer fills up, you write it to disk, and append it to the data already there.

Obviously, this is a simple example. You wouldn't really do this with a list of 10 numbers. And your block sizes and buffers would be much bigger.

Essentially, it's just a merge sort, but your not keeping each block in memory.

Good luck

Simon

GeneralRe: External sorting Pin
Diamonddrake14-Oct-08 14:37
Diamonddrake14-Oct-08 14:37 
GeneralRe: External sorting Pin
Simon P Stevens14-Oct-08 21:32
Simon P Stevens14-Oct-08 21:32 
Questioncrystal report viewer - treelist Pin
nelsonpaixao13-Oct-08 12:32
nelsonpaixao13-Oct-08 12:32 
QuestionCRYSTAL REPORTS - load image Pin
nelsonpaixao13-Oct-08 12:12
nelsonpaixao13-Oct-08 12:12 
AnswerRe: CRYSTAL REPORTS - load image Pin
teddddddddddd13-Oct-08 19:20
teddddddddddd13-Oct-08 19:20 
GeneralRe: CRYSTAL REPORTS - load image Pin
nelsonpaixao14-Oct-08 12:31
nelsonpaixao14-Oct-08 12:31 
GeneralRe: CRYSTAL REPORTS - load image Pin
nelsonpaixao15-Oct-08 13:21
nelsonpaixao15-Oct-08 13:21 
GeneralRe: CRYSTAL REPORTS - load image Pin
teddddddddddd15-Oct-08 19:41
teddddddddddd15-Oct-08 19:41 
QuestionWrite to Ms word document ??? Pin
TALHAKOSEN13-Oct-08 10:01
TALHAKOSEN13-Oct-08 10:01 
GeneralRe: Write to Ms word document ??? Pin
led mike13-Oct-08 10:10
led mike13-Oct-08 10:10 
AnswerRe: Write to Ms word document ??? Pin
#realJSOP13-Oct-08 10:53
mve#realJSOP13-Oct-08 10:53 
GeneralRe: Write to Ms word document ??? Pin
Pete O'Hanlon13-Oct-08 11:15
mvePete O'Hanlon13-Oct-08 11:15 
JokeRe: Write to Ms word document ??? Pin
Paul Conrad13-Oct-08 12:02
professionalPaul Conrad13-Oct-08 12:02 
AnswerRe: Write to Ms word document ??? Pin
Priya Prk13-Oct-08 12:11
Priya Prk13-Oct-08 12:11 
GeneralRe: Write to Ms word document ??? Pin
TALHAKOSEN13-Oct-08 20:16
TALHAKOSEN13-Oct-08 20:16 
GeneralSolution Pin
TALHAKOSEN14-Oct-08 0:51
TALHAKOSEN14-Oct-08 0:51 
GeneralRe: Solution Pin
nadinechemali19-Dec-10 21:52
nadinechemali19-Dec-10 21:52 

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.