New answers tagged

0

What is the absolute minimum set of instructions required to build a Turing complete processor? Jörg W Mittag said, "one," but how about zero? Why do you assume that a "processor" has to have "instructions"? A Turing machine is a Turing-complete processor, and it does not operate on "instructions" as such. It has rules, but the rules are not ...


1

movfuscator compiles C code using only mov x86 instructions, showing in a very concrete way that a single instruction suffices. The Turing completeness seems to have been proven in a paper: https://www.cl.cam.ac.uk/~sd601/papers/mov.pdf See also: http://stackoverflow.com/questions/3711443/minimal-instruction-set-to-solve-any-problem-with-a-computer-program


1

To answer your actual question: Most higher level (or scripting) languages out there have data structures that can hold different types of data (like numbers, strings and even functions) in the same structure ... So how are these types of data structures found in higher level languages implemented in the lower level language they are written in? You ...


7

The closest thing I managed to write was a class in C++ which allocated a certain amount of memory and, when its size was filled, allocated a longer block of memory, copied the elements in that block and freed the first one, but that doesn't seem efficient at all and anyway only allows to add one specific type of item and only in a stack-like way (where you ...


0

Mixed types are accommodated by storing pointers to objects. The closest thing I managed to write was a class in C++ which allocated a certain amount of memory and, when its size was filled, allocated a longer block of memory, copied the elements in that block and freed the first one, but that doesn't seem efficient at all It's quite efficient in ...


8

I guess the kind of "lists" you had in mind are not the "linked lists" mentioned by Robert Harvey, but the kind of arrays which are called list in Python, List or ArrayList in C#, ArrayList in Java, or std::vector in C++. Another popular term for this kind of data structure is "dynamic array". These are indeed implemented internally exactly the way you ...


4

Arrays, like all data structures, trade one kind of efficiency for another. The efficiency that an array specializes in is that of rapidly looking up an element by its index. It does that, not by searching through the array for the correct element, but by performing a mathematical calculation. If an array has elements of size 8 bytes, and you want to look ...



Top 50 recent answers are included