News for hackers. Stuff that matters.
Re:Summoning Cthulhu by Parsing HTML with Regular Expression... by yeputons on Saturday April 16, 2022 @05:23AM (#31050939)
That's not O(1), that's O(log n) memory, where `n` is the size of your string. You need `log n` bits to store the pointer. Granted, it's very limited for practical purposes, but you have to account for it in theoretical applications.

UPD: you can also say that you're actually writing a code for a Turing machine with two heads, and that would be ok. So, yeah, this is why the "you cannot write a constant-memory algorithm" definition is very hand-waving, one has to be extra careful with the model they're working in.

Re:Summoning Cthulhu by Parsing HTML with Regular Expression... by tgv on Saturday April 16, 2022 @05:44AM (#31051039)
If you have a symbol that cannot be in the input (an EOT token), I think you can write it in O(1). You just change the input when you're done checking the outer symbols. Takes extra time, though.