It's been a long time since I've studied time complexity in school, but I've been tasked with finding the time complexity of an algorithm. Here is the algorithm in a pseudo-pseudocode (yes, two pseudos because I'm not good at creating pseudocode. Haha!).
main()
{
list = methodImportFromCSV(...) // Don't care about this line's complexity
tree = createRootNode() // O(1)
DO
count = tree.createChildren(list)
WHILE count > 0
}
createChildren(list) : returns integer
{
nodesCreated = 0
foreach (node in this.children)
{
nodesCreated += node.createChildren(list)
}
groups = separateIntoGroups(list) // O(n)
foreach (group in groups)
{
if (someMethodThatReturnsTrueOrFalse(group) = true) // Some method is O(n) of the group
{
this.children.Add(new child())
nodesCreated += 1
}
}
return nodesCreated
}
You can see that the method is recursive and just creates a tree structure. I remember a few things just as linear iteration is [O(n)]
, but I've never had to deal with recursion before. Is it permissible to state that the algorithm is running at O(n * t)
? Perhaps I am wrong? I thank you, all, for your assistance.