
Enviado em 02/06/2022 - 03:23h
Olá, eu tenho essa função recursiva abaixo e gostaria de saber a notação de complexidade dela:bool combina(float porcAtual, float porcAlvo, int maxCombs, int currentStack, int tryingSorts, int saiuMin, int alvo, std::vector<int> ids, std::vector<int> & idsCombs, std::vector<std::vector<int>> & sorteios, std::vector<std::vector<int>> &combsBase, std::vector<std::vector<int>> &out) {
if (currentStack > maxCombs)
return 2;
std::vector<int> logic;
for (int i =0; i < 100; i++)
logic.push_back(i);
for (int i = 0; i < tryingSorts; i++) {
int p = combsBase.size() * RandNum();
if (combsBase.size() && !hasNum(idsCombs, p)) {
idsCombs.push_back(p);
auto &v = combsBase[p];
float currentPorc = 0;
int c = 0;
if (ids.size() == 0 && currentStack == 0) {
for (int j = 0; j < alvo - 1; j++) {
if ((saiuMin >= 0 && countSort(v, sorteios[j]) >= saiuMin) || (saiuMin < 0 && countSort(v, sorteios[j]) <= abs(saiuMin))) {
c++;
ids.push_back(j);
}
}
currentPorc += c / float(alvo - 1);
}
else if (ids.size()) {
if (ids.size() == 1) {
return 0;
}
for (auto &j: ids) {
if ((saiuMin >= 0 && countSort(v, sorteios[j]) >= saiuMin) || (saiuMin < 0 && countSort(v, sorteios[j]) <= abs(saiuMin))) {
c++;
}
}
currentPorc = (float(c) / float(ids.size()));
}
if (combina(porcAtual + (porcAlvo == 0)? 0: currentPorc, porcAlvo, maxCombs, currentStack + 1, tryingSorts, saiuMin, alvo, ids, idsCombs, sorteios, combsBase, out) == 1) {
if (currentStack > 0)
out.push_back(v);
return 1;
}
}
}
return 0;
} Como rodar o Folding@home no Linux
Criando um painel de controle (Dashboard) para seu servidor com o Homepage
O Abismo entre o Código e o Chão: Saltos Tecnológicos e a Exclusão Estrutural no Brasil
Instalar e Configurar a santíssima trindade (PAP) no Void Linux
NixOS + NVIDIA antiga: como sobreviver ao driver 595 (GTX 750 Ti / Maxwell)
Conhecendo o tmux: Multiplexador de Terminal
Acessando página do Syncthing fora da máquina local
[Resolvido] Meu monitor suporta 100fps. Por que o máximo é 60fps nos jogos?
SystemD e mais polêmicas. (10)
OpenClaude - toda IA joga mais que neymar (4)
Novos requisitos de sistema para a versão 26.04 (4)









