Click here to Skip to main content
16,011,475 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: java or C# , which better? Pin
Luc Pattyn11-Mar-11 5:17
sitebuilderLuc Pattyn11-Mar-11 5:17 
GeneralRe: java or C# , which better? Pin
Anwar Isaed23-Mar-11 23:15
Anwar Isaed23-Mar-11 23:15 
GeneralRe: java or C# , which better? Pin
R. Erasmus24-Mar-11 21:18
R. Erasmus24-Mar-11 21:18 
AnswerRe: java or C# , which better? Pin
R. Erasmus24-Mar-11 21:16
R. Erasmus24-Mar-11 21:16 
Questioncompression Pin
khomeyni1-Mar-11 5:32
khomeyni1-Mar-11 5:32 
AnswerRe: compression Pin
Luc Pattyn1-Mar-11 6:03
sitebuilderLuc Pattyn1-Mar-11 6:03 
GeneralRe: compression Pin
Bernhard Hiller2-Mar-11 3:14
Bernhard Hiller2-Mar-11 3:14 
AnswerRe: compression PinPopular
Luc Pattyn2-Mar-11 5:31
sitebuilderLuc Pattyn2-Mar-11 5:31 
Incorrect. You either believe in magic, or you didn't understand my suggestion.

So I created a little proof:
public void generateFiles() {
	using (TextWriter tw=File.CreateText("test.txt")) {
		using (BinaryWriter bw=new BinaryWriter(File.Create("test.dat"))) {
			int DIM=100*1000;
			Random r=new Random();
			for (int i=0; i<DIM; i++) {
				ulong n=0;
				for (int j=0; j<19; j++) {
					int d=r.Next(10);
					tw.Write("01234567890".Substring(d,1));
					n=10*n+(ulong)d;
				}
				bw.Write(n);
			}
		}
	}
}

and I WinZipped the txt file; the resulting sizes were:
.txt = 1,856 KB
.dat =   782 KB (that is a compression factor of 2.37 indeed)
.zip =   872 KB (that is 2.13)

which tells me WinZip is wasting around 10%.
While ZIP normally achieves around a factor of 10, that simply can not be achieved when the data is really random and has log2(10) significant bits in each 8-bit byte (if it could, it would store a digit in less than one bit which is clearly impossible)

Smile | :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

GeneralRe: compression Pin
Bernhard Hiller2-Mar-11 22:49
Bernhard Hiller2-Mar-11 22:49 
AnswerRe: compression Pin
Luc Pattyn3-Mar-11 0:50
sitebuilderLuc Pattyn3-Mar-11 0:50 
QuestionBackup Algorithm Pin
Richard Andrew x6422-Feb-11 14:04
professionalRichard Andrew x6422-Feb-11 14:04 
AnswerRe: Backup Algorithm Pin
Richard MacCutchan22-Feb-11 23:12
mveRichard MacCutchan22-Feb-11 23:12 
QuestionRe: Backup Algorithm Pin
Tadeusz Westawic27-Feb-11 3:13
Tadeusz Westawic27-Feb-11 3:13 
AnswerRe: Backup Algorithm Pin
Richard Andrew x6427-Feb-11 6:20
professionalRichard Andrew x6427-Feb-11 6:20 
QuestionBasic Aging Algorithm for Insurance Premiums Pin
Brady Kelly18-Feb-11 6:18
Brady Kelly18-Feb-11 6:18 
AnswerRe: Basic Aging Algorithm for Insurance Premiums Pin
Roger Wright18-Feb-11 7:00
professionalRoger Wright18-Feb-11 7:00 
AnswerRe: Basic Aging Algorithm for Insurance Premiums Pin
Yusuf18-Feb-11 11:03
Yusuf18-Feb-11 11:03 
GeneralRe: Basic Aging Algorithm for Insurance Premiums Pin
Brady Kelly18-Feb-11 21:43
Brady Kelly18-Feb-11 21:43 
GeneralRe: Basic Aging Algorithm for Insurance Premiums Pin
riced19-Feb-11 0:51
riced19-Feb-11 0:51 
GeneralRe: Basic Aging Algorithm for Insurance Premiums Pin
Brady Kelly19-Feb-11 1:55
Brady Kelly19-Feb-11 1:55 
GeneralRe: Basic Aging Algorithm for Insurance Premiums Pin
Yusuf19-Feb-11 2:05
Yusuf19-Feb-11 2:05 
GeneralRe: Basic Aging Algorithm for Insurance Premiums Pin
Brady Kelly19-Feb-11 2:17
Brady Kelly19-Feb-11 2:17 
GeneralRe: Basic Aging Algorithm for Insurance Premiums Pin
Roger Wright19-Feb-11 4:35
professionalRoger Wright19-Feb-11 4:35 
GeneralRe: Basic Aging Algorithm for Insurance Premiums Pin
Brady Kelly19-Feb-11 4:40
Brady Kelly19-Feb-11 4:40 
GeneralRe: Basic Aging Algorithm for Insurance Premiums Pin
Roger Wright19-Feb-11 5:25
professionalRoger Wright19-Feb-11 5:25 

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.