code is here:
combine_set = set()
total_num = k # A constant variable
save_idx = 0
while save_idx < total_num:
main_txt = random.choice(main_text) # using python random module select a txt from list
minor_txt = random.choice(minor_text)
if (main_txt, minor_txt) in combine_set:
continue
else:
save_idx += 1
combine_set.add((main_txt, minor_txt))
res = Combiner(main_txt, minor_txt)
I want to figure out the time complexity of this while loop. The Combiner operation's time complexity is O(n), and from here I know the time complexity of random.choice(list)
in python is O(logn).
Now, my main problem is that I don't know how to handle the continue
statement inside the if
statement. Can anyone help me?
Aucun commentaire:
Enregistrer un commentaire