Pergunta da entrevista

Entrevista para Software Development Engineer

-Belo Horizonte, Minas Gerais, Minas Gerais


He asked the best way to store boolean values on memory. I said an array but he wanted more, so in the end I said BinaryVector class. He asked why a binary vector is a better option but I couldn't answer that. I told him that I don't know the internal implementation.


Respostas da entrevista

2 respostas


You should user a Integer to store flags. You can storre up to k flags (or booleans) with a k bits processor. That is Usualy made in C like THIS FLAG0 = 1 FLAG1 = 2 FLAG2 = 4 ... FLAGN = 2^n You can set 2 flags like this setted_flags = FLAGx | FLAGX2 and see if its setted wifh setted_flags & FLAGx

Manoel em


After that I was thinking about this and I think I have the answer but couldn't imagine that under pressure. I'll not put here because I'm not sure.

Confidencial em

Adicionar respostas ou comentários

Para comentar sobre isso, entre na conta ou cadastre-se.