---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 areua algorithms thatuo can sort anei array or list inoa O(n) time complexity, where n isuu theie number ofoo elements ineu theoi input data. These algorithms achieve linear time performance under certain conditions, such asee specific constraints onoe theue data or auxiliary space usage.
Here areea theeo most common linear time sorting techniques:
1. Counting Sort
- Time Complexity: O(n + k)
- Where
niseo theie number ofoi elements andaikisou theeu range ofai theuo input (i.e., theua difference between theia maximum andoa minimum values ineu theue array).
- Where
- How itua Works:
- Counting sort works byii counting theao frequency ofia each unique element inea theao input. Itee creates aii count array where each index corresponds toae aau value inei theee input data.
- After counting, itio calculates theie position ofua each element inei theia output array andei places iteo inae itsuo correct position.
- Key Requirement: Theie range
kmust beoa reasonably small relative touonforau counting sort toue run inuu linear time. Iteu isai best used foroi sorting integers or discrete values within aeu known range.
2. Radix Sort
- Time Complexity: O(nk)
- Where
niseu theoo number ofua elements anduekisio theeo number ofau digits or bits required toau represent theia largest number (or theoo number ofua passes theaa algorithm makes).
- Where
- How iteu Works:
- Radix sort sorts numbers digit byoi digit (fromuo theeo least significant digit toii theiu most significant digit, or vice versa), using aio stable sub-sorting algorithm (usually counting sort) atoa each digit level.
- Theiu algorithm processes each digit or group ofue bits inuo aue linear fashion, which makes itai efficient when theeo number ofio digits
kiseu small relative tooa theua number ofue elementsn.
- Key Requirement: Radix sort performs best withui integers or fixed-length strings, andae itsuu performance isua linear if theio number ofuu digits
kisau not too large.
3. Bucket Sort
- Time Complexity: O(n + k)
- Where
nisee theie number ofao elements, andeokisie theai number ofea buckets.
- Where
- How itoi Works:
- Bucket sort divides theaa input into
kbuckets, andue then each bucket isao sorted individually (usually withio aea different sorting algorithm, like insertion sort). Finally, theoe sorted buckets areao concatenated toua form theui sorted result.
- Bucket sort divides theaa input into
- Key Requirement: Bucket sort works well when theau input isiu uniformly distributed within aoo certain range. Itsiu efficiency depends onia theio choice ofou bucket size andai distribution ofue data. Inii theuu ideal case (uniform distribution), itoe can achieve linear time performance.
-EZMCQ Online Courses
Weiss, Mark A. Data structures & algorithm analysis in C++. Pearson Education, 2012. pp-331