language-agnostic

Difference between a LinkedList and a Binary Search Tree

What are the main differences between a Linked List and a BinarySearchTree? Is BST just a way of maintaining a LinkedList? My instructor talked about LinkedList and then BST but did't compare them or didn't say when to prefer one over another. This is probably a dumb question but I'm really confused. I would appreciate if someone can cla...

How do you draw kanji using Mac OS X 10.5

I want to be able to draw in Kanji like you can with IME in Windows. Anyone know how? ...

Buildfarms : Options

Hi all, We use Incredibuild here to compile our code in a distributed fashion. I was wondering if there are any open source (or free) alternatives to use on a home network? Failing that, are there any other simple solutions with good integration with Visual Studio out there? EDIT: I should say that I am quite happy to get my hands d...

What are some tricks that a processor does to optimize code?

I am looking for things like reordering of code that could even break the code in the case of a multiple processor. ...

Techniques for adding Achievements to business class software

I was thinking of adding some Achievements to our internal bug-tracking and time logging system. It's connected to an SQL Server back-end. At first I thought that the system could be run on the database, using triggers to, for example, know when: you've logged 1000 hours created 1000 tickets closed your own ticket worked on a ticket t...

Use of else after a return or break from a function or loop

This is a matter of style I've considered for a while, and I'm curious of others thoughts. The two pieces of code below are logically equivalent, which in your opinion is better style and why?: // no else some_function(): if ( my_var == 0 ) then: return true print "hello: " + my_var return false // with else some_...

Secret santa algorithm.

Every Christmas we draw names for gift exchanges in my family. This usually involves mulitple redraws until no one has pulled their spouse. So this year I coded up my own name drawing app that takes in a bunch of names, a bunch of disallowed pairings, and sends off an email to everyone with their chosen giftee. Right now, the algorith...

What is a bubble sort good for?

Do bubble sorts have any real world use? Every time I see one mentioned, it's always either: A sorting algorithm to learn with. An example of a sorting algorithm not to use. ...

Classic programming exercises

I was looking for some good programming exercises for some mentoring. Something like: projecteuler.net: good for the mathematical side but somewhat abstract DNS client: good exercise + concrete technology understanding Sorry for asking this again. I did find this thread but I was hoping for something concrete. Preferably something sm...

List of de facto standard keyboard shortcuts for Windows apps?

Let's say I'm developing a new desktop application for Windows. Is there a list somewhere that I can consult (either from Microsoft or a 3rd party) of keyboard shortcuts that all Windows applications should support? (Note: When I say "all Windows applications" here, I really mean "all Windows applications where a particular keyboard sh...

What is the most interesting bug you have fixed?

On a recent round of interviews, one interviewer at "a leading brand technology company" asked - as an ice breaker - this question. I thought it was a good question, worth asking (and warning) others. Interesting can mean a multitude of things, so there a few more suggested constraints to make this a valid question: minor cause, majo...

Puzzle: Find the most common entry in an array

You are given a 32-bit unsigned integer array with length up to 232, with the property that more than half of the entries in the array are equal to N, for some 32-bit unsigned integer N. Find N looking at each number in the array only once and using at most 2 kB of memory. Your solution must be deterministic, and guaranteed to find N. ...

The use of config file is it equivalent to use of globals?

I've read many times and agree with avoiding the use of globals to keep code orthogonal. Does the use of the config file to keep read only information that your program uses similar to using Globals? ...

What is a somewhat secure way of generating a 64 bit signature?

I would like to sign a device, and I have 64 bits to store my signature in the device. This device has a MAC address and some other details (about 30 bytes worth) I can mangle to create my signature. If possible, I would like the method to be one-way, so that I can verify that the signature is valid without knowing how to create a vali...

What is your favorite educational programming pearl?

A pearl is an elegant, instructive and fun example of programming, which teaches important techniques and fundamental design principles. For example, I really enjoyed the programming pearl Automata via Macros. It shows how to build a construct for finite state machines using Scheme macros, while touching upon the importance of tail-cal...

What are five things you hate about your favorite language?

There's been a cluster of Perl-hate on Stack Overflow lately, so I thought I'd bring my "Five things you hate about your favorite language" question to Stack Overflow. Take your favorite language and tell me five things you hate about it. Those might be things that just annoy you, admitted design flaws, recognized performance problems, o...

Which books have really interesting source code and explain it well?

I am looking for books that present interesting software system at the source code level. One such book which I loved is Building Problem Solvers. It presents a series of truth-maintenance systems written in Common Lisp. The book reads like an insightful and well-presented commentary of the code. Can you recommend any other books in this...

Computing a mean confidence interval without storing all the data points.

For large n (see below for how to determine what's large enough), it's safe to treat, by the central limit theorem, the distribution of the sample mean as normal (gaussian) but I'd like a procedure that gives a confidence interval for any n. The way to do that is to use a Student T distribution with n-1 degrees of freedom. So the quest...

Evenly shuffling a list of mail address by domain

Hi, I have a list of email address which I want to distribute evenly by domain. For example: let the list be, [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] The output should be [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] The source list is not sorted by domain as in example, but can be sorted by domain, if that can help...

Where to wrap a line of code, especially long argument lists?

What's your preferred way of wrapping lines of code, especially when it comes to long argument lists? There has been several questions relating to wrapping lines (such as When writing code do you wrap text or not? and Line width formatting standard), but I haven't been able to find one which covers where to wrap a line of code. Let's s...