theory

Can garbage collection coexist with explicit memory management?

For example, say one was to include a 'delete' keyword in C# 4. Would it be possible to guarantee that you'd never have wild pointers, but still be able to rely on the garbage collecter, due to the reference-based system? The only way I could see it possibly happening is if instead of references to memory locations, a reference would be...

Stagnation as a computer scientist

Hello, Entering my fourth year of university, I feel that I've stagnated as a computer scientist. I'm a fairly decent programmer as is - I've taken an array of courses on algorithms, formal languages, formal logic and the like (as well as a ton of math), but I feel like I'm not learning anything anymore. I'm certainly much more enamored...

Flatten a recordset in SQL Server?

Say you get a recordset like the following: | ID | Foo | Bar | Red | |-----|------|------|------| | 1 | 100 | NULL | NULL | | 1 | NULL | 200 | NULL | | 1 | NULL | NULL | 300 | | 2 | 400 | NULL | NULL | | ... | ... | ... | ... | -- etc. And you want: | ID | Foo | Bar | Red | |-----|-----|-----|-----| | 1 | 100 | ...

Is it possible to write code to write code?

I've heard that there are some things one cannot do as a computer programmer, but I don't know what they are. One thing that occurred to me recently was: wouldn't it be nice to have a class that could make a copy of the source of the program it runs, modify that program and add a method to the class that it is, and then run the copy of t...

comparison sort problem

Does a comparison sort have to compare the A[i] largest and A[i+1] largest values? I think any comparison sort must, but I'm not sure. I've checked out mergesort, insertion sort, and quicksort and in each of them the A[i] largest and A[i+1] largest values have to be compared. ...

What is the difference between a Functor and the Command pattern?

I am very familiar with the Command pattern, but I don't yet understand the difference in theory between a Functor and a command. In particular, I am thinking of Java implementations. Both are basically programming "verbs" represented as objects. However, in the case of functors, as I have seen from some examples anonymous inner class im...

Is writing code out still considered an algorithmic representation?

I just lost 50% of my answer on a test because I wrote the code out instead of an algorithm on my midterm, bumping me from an A to a C. Is writing code out still considered an algorithmic representation? Wikipedia: Algorithm Representation (since programming style is pretty much consensus-based) EDIT: Ok, so let me make a few points cl...

What are your favorite metaphors for technical concepts?

At the risk of getting downvoted I'm going to ask this anyway. What are your favorite metaphors for technical concepts? My most recent one I used was when a customer didn't understand why we would have to charge them for switching out one mapping api for another. My metaphor was: If you had a heat pump at your house and then boug...

How do you set strings to uppercase / lowercase in Unicode?

This is mostly a theoretical question I'm just very curious about. (I'm not trying to do this by coding it myself or anything, I'm not reinventing wheels.) My question is how the uppercase/lowercase table of equivalence works for Unicode. For example, if I had to do this in ASCII, I'd take a character, and if it falls withing the [a-z]...

Alternative Entropy Sources

Okay, I guess this is entirely subjective and whatnot, but I was thinking about entropy sources for random number generators. It goes that most generators are seeded with the current time, correct? Well, I was curious as to what other sources could be used to generate perfectly valid, random (The loose definition) numbers. Would using m...

Is there any formal definition for "refactoring"?

Anyone knows a way to define refactoring in a more formal way? UPDATE. A refactoring is a pair R = (pre; T) where pre is the precondition that the program must satisfy, and T is the program transformation. ...

Wolfram's Rule 34 in XKCD

The hover "joke" in #505 xkcd touts "I call rule 34 on Wolfram's Rule 34". I know what rule 34 is in Internet terms and I've googled up who Wolfram is but I'm having a hard time figuring out what Wolfram's Rule 34 is. So what exactly is this "Rule 34"? Here's the comic: http://xkcd.com/505/. ...

Explaining computational complexity theory

It is said that true mastery of a subject is achieved when you can explain it simply. Unfortunately as an Electronics Engineer I lack some of the more formal aspects of computer science. Taking into consideration that there is some background in math, how would you explain computational complexity theory to the naïve? Where to start ...

Running time of set union operation

Given two sets A and B, what is the common algorithm used to find their union, and what is it's running time? My intuition: a = set((1, 2, 3)) b = set((2, 3, 5)) union = set() for el in a: union.add(el) for el in b: union.add(el) Add checks for a collision, which is O(1), and then adds the element, which is (??). This is do...

Exiting functions using return / exit sub statements

Back in the day when I was learning programming theory at the university, I was always told that it was bad practice, taboo if you will, to have more than one exit point for a function. As I have programmed more an more in the real world, I have come to the conclusion that not only is this not always the case, but in many instances it h...

Theoretical Material about Clusters

I'm writting a paper about clusters, so... What books or articles have a good theoretical material about clusters? For the ones that may show interest in this paper, it is related to a project I'm working on called L2LB, online @ http://l2lb.googlecode.com/ ...

What are some good computer science resources for a blind programmer?

I'm a totally blind individual who would like to learn more of the theory aspect of computer science. I've had an intro data structures class and the general intro programming but would like to learn more on things such as software design, advanced data structures, and compiler design. I want to do this as a self study course not as part...

What is the Zipper data structure and should I be using it?

The question is simple: I cannot understand the Zipper data structure. My question is related to its uses with a Tree. I want to understand how can I change the tree node using zipper. And how not to copy the whole tree (or the most part of it). Please, clarify if I'm wrong with zipper. Maybe it cannot help with the tree update? Or, m...

Why can Conway’s Game of Life be classified as a universal machine?

I was recently reading about artificial life and came across the statement, "Conway’s Game of Life demonstrates enough complexity to be classified as a universal machine." I only had a rough understanding of what a universal machine is, and Wikipedia only brought me as close to understanding as Wikipedia ever does. I wonder if anyone cou...

Do custom HTML Helper Classes violate the ASP.Net MVC model?

On a related post I mentioned that I have found custom HTML helpers to be just that, helpful, when developing. For instance, when I need paging for a "grid" I have a custom helper that I can call --> Html.Pager() Some have made a point that HTML helpers are a violation of the MVC model. Personally, I don't see it being any different t...