
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;
} Gentoo binário em 2026: UEFI, LUKS, Btrfs e Systemd
Trabalhando Nativamente com Logs no Linux
Jogando Daikatana (Steam) com Patch 1.3 via Luxtorpeda no Linux
LazyDocker – Interface de Usuário em Tempo Real para o Docker
Gentoo: Trocando wpa_supplicant pelo iwd no NetworkManager (Systemd)
OCS Inventory NG: Instalação de Agentes Linux e Windows + Autenticação HTTP
Recriar Links Simbólicos Quebrados
Usando dracut e dispensando genkernel no Gentoo + LUKS + Btrfs
Curso GRÁTIS: OCS Inventory NG - Do Deploy ao Hardening com foco em Segurança da Informação!
Removere linux-image-6... [RESOLVIDO] (2)
Quando vocês pararam de testar distros? (19)
O que houve com slackware ??? (6)









