அல்கோரிதம்time complexity optimization
Time Complexity Optimization (attack the dominant term) — நேரச் சிக்கல் மேம்பாடு
TT
Testlaa Team
May 14, 2026•1 min read
நேர மேம்பாடு — முதன்மை சொல் மாற்றம்; n² → n log n / n / log n.
உண்மை உலகில் இது ஏன் முக்கியம்?
தேடல் — inverted index. routing — trie.
மையக் கருத்து (மாணவர்களுக்கான விளக்கம்)
உட்வளையம்/மீண்டும் sort — hash/தன்னியக்க அமைப்பு.
Pythonில் முயற்சி செய்வோம்
def two_sum_sorted(a: list[int], t: int) -> bool:
a.sort()
i, j = 0, len(a) - 1
while i < j:
s = a[i] + a[j]
if s == t:
return True
if s < t:
i += 1
else:
j -= 1
return False
print(two_sum_sorted([3, 1, 4, 5], 9))
அடிக்கடி நேரும் தவறுகள்
- heap+log காரணி பெருக்கம்.
- amortized தவறான கூட்டு.
முக்கியச் சுருக்கக் குறிப்புகள்
- T(n) சுருக்கம்.
- timeout மாதிரி சோதனை.
Tags:
Algorithms & complexityPythonமாணவர்கள்
