
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;
} Cirurgia para acelerar o openSUSE em HD externo via USB
Void Server como Domain Control
Modo Simples de Baixar e Usar o bash-completion
Monitorando o Preço do Bitcoin ou sua Cripto Favorita em Tempo Real com um Widget Flutuante
[Resolvido] VirtualBox can't enable the AMD-V extension
Como verificar a saúde dos discos no Linux
Como instalar , particionar, formatar e montar um HD adicional no Linux?
Como automatizar sua instalação do Ubuntu para desenvolvimento de software.
systemd-resol... precisa ser reiniciado periodicamente [RESOLVIDO] (7)
Bridge - Rede - Ubuntu 24.04 (1)









