Blossoming tree - painting by László Mednyánszky

"Joey," asked Ross of the new contractor, in a slow, careful voice, as though trying to calm a large predator. "Explain to me why the data tree has this read-only flag?"

"It's more secure that way. Obviously, if it's read-only, arbitrary people can't write to it."

Deep inside our Jar? Are we afraid of our own code? Ross wondered, but he dismissed his doubts. Sure, let him have that one. "Okay, but why is there a flag at every single node of the tree?"

"Well, obviously, if only the root's protected, people can still edit the leaves and branches. We want to protect the whole tree."

"Okay, but that means to edit the setting you have to visit every single node, which is O(n) at best."

"Price of security, man."

"Okay, but even so, why do you flip the flag before every insert, only to set it again after? Doesn't that make building the tree painful?"

"You can never be too careful."

"Okay, even if I buy all that, and even assuming that this is the best possible way to solve this problem- which it's not- Why do you visit every node twice?"

class treeNode {
	bool readOnly;
	treeNode child, sib;

	void setReadOnly(bool ro) {
		readOnly = ro;
		if (child != null) child.setReadOnly( ro );
		if(sib != null ) sib.setReadOnly( ro );

	void updateReadOnly(bool ro) {
		setReadOnly( ro );
		if (child != null) child.updateReadOnly( ro );
		if( sib != null ) sib.updateReadOnly( ro );

	// call on root node
	void insert(treeNode parent, treeNode fng) { 
		if (parent.child == null) parent.child = fng;
		else {
			treeNode k;
			for (k = parent.child; k.sib != null; k = k.sib);
			k.sib = fng;

Faced with this evidence, even Joey was silenced, though not for long. "It's.... doubly secure?"

"It's taking upwards of twenty minutes to build the tree!"

Joey's face lit up. "Ah! Right! I was just reading last week, it turns out, slower code is more secure, cryptographically speaking."

Faced with stupidity this blinding, all Ross could do was walk away. Hopefully Monica, the real security expert, would fare better setting him straight...

"Hi Ross!" she said, glancing up briefly before turning back to her computer. "Can't talk now. The new guy forgot to secure the data endpoint for our web service. The whole tree's publicly accessible!"

Ross smiled to himself as he headed back to his own desk. At this rate, Joey wasn't likely to last long anyway.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!