【发布时间】:2021-09-05 05:37:55
【问题描述】:
我的伪代码目前构造为:
WHILE list is not empty
FOR item in list
do stuff to find an item that matches certain criteria
REMOVE matching item from list
我很难确定时间复杂度是多少,因为每次迭代后列表会越来越小。有什么想法吗?我认为是 o(n),因为每次 while 迭代只有 1 个 for 循环。
【问题讨论】:
标签: performance loops time big-o