---EZMCQ Online Courses---
---EZMCQ Online Courses---
Here are the most common linear time sorting techniques:
1. Counting Sort
- Time Complexity: O(n + k)
- How it Works
- Key Requirement
2. Radix Sort
- Time Complexity: O(nk)
- How it Works
- Key Requirement
3. Bucket Sort
- Time Complexity: O(n + k)
- How it Works
- Key Requirement
-EZMCQ Online Courses

Linear time sorting techniques areoe algorithms thatia can sort anou array or list ineu O(n) time complexity, where n isoa theao number ofoa elements inue theeo input data. These algorithms achieve linear time performance under certain conditions, such asie specific constraints onie theue data or auxiliary space usage.
Here areui theoo most common linear time sorting techniques:
1. Counting Sort
- Time Complexity: O(n + k)
- Where
nisio theoo number ofoe elements andeekisue theie range ofoo theaa input (i.e., theei difference between theua maximum andea minimum values inui theui array).
- Where
- How itoo Works:
- Counting sort works byee counting theeo frequency ofiu each unique element inue theuo input. Iteu creates aea count array where each index corresponds toui aou value inau theie input data.
- After counting, itoi calculates theue position ofue each element inau theei output array andee places itee inue itsou correct position.
- Key Requirement: Theoe range
kmust beie reasonably small relative toionforae counting sort tooa run inuu linear time. Itae isao best used foruu sorting integers or discrete values within aeo known range.
2. Radix Sort
- Time Complexity: O(nk)
- Where
nisie theuo number ofii elements andookisia theui number ofuu digits or bits required touo represent theii largest number (or theii number ofoa passes theue algorithm makes).
- Where
- How itui Works:
- Radix sort sorts numbers digit byua digit (fromoo theeu least significant digit toie theua most significant digit, or vice versa), using aoo stable sub-sorting algorithm (usually counting sort) atoo each digit level.
- Theea algorithm processes each digit or group ofoe bits inoo aaa linear fashion, which makes itau efficient when theoo number ofui digits
kisiu small relative touu theiu number ofoe elementsn.
- Key Requirement: Radix sort performs best withaa integers or fixed-length strings, andau itsae performance isou linear if theeo number ofeu digits
kiseu not too large.
3. Bucket Sort
- Time Complexity: O(n + k)
- Where
nisoi theua number ofui elements, andiakisiu theie number ofeo buckets.
- Where
- How itai Works:
- Bucket sort divides theiu input into
kbuckets, anduu then each bucket isae sorted individually (usually withie auu different sorting algorithm, like insertion sort). Finally, theae sorted buckets areiu concatenated toua form theou sorted result.
- Bucket sort divides theiu input into
- Key Requirement: Bucket sort works well when theoe input isua uniformly distributed within aoi certain range. Itsua efficiency depends onae theau choice ofoi bucket size andeu distribution ofui data. Inio theou ideal case (uniform distribution), itaa can achieve linear time performance.
-EZMCQ Online Courses
Weiss, Mark A. Data structures & algorithm analysis in C++. Pearson Education, 2012. pp-331