سوال ۵۸ کنکور ارشد مهندسی کامپیوتر ۱۴۰۴
فرض کنید میخواهیم تمام زیردنبالههای یک دنباله دادهشده را با استفاده از روش عقبگرد بررسی کنیم. اگر طول دنباله n باشد، پیچیدگی زمانی این روش چیست؟
پاسخ صحیح: گزینهٔ A —
Each element of a sequence of length can be either included in a subsequence or left out — two independent binary choices per element.
Hence the total number of subsequences equals the size of the power set of the index positions:
A backtracking enumeration builds a binary recursion tree: at each of the levels it branches on "take / skip" the current element. The tree therefore has leaves, one per subsequence, so the algorithm performs work just to produce them all.
Therefore the time complexity is
The other options are wrong: and are far too small to even list outputs, and counts permutations / orderings of items, not subsets.
Exam trick: Subsequences (subsets) ; permutations (orderings) . Any algorithm that must output every member of such a family cannot beat the size of the family itself.