Radix Sort Using Couting Sort

Duration: 32 min

This video lesson is available to enrolled students.

Return to /learn/ZERO-TO-HERO/algorithms/sorting-algorithms/radix-sort/asset-radix-sort-using-couting-sort after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. Database Management System: Basics of DBMS, ER Diagram, Relational Model & Functional Dependencies, Keys & Integrity Constraints, Normalization (1NF - BCNF), Decomposition Properties & 4NF, File Organization & Indexing, Relational Algebra, SQL, Relational Calculus, Transaction Management, Concurrency Control
  2. Discrete Mathematics: Set Theory, Relations, Functions, Graph Theory, Group Theory, Propositional and Predicate Logic
  3. Digital Electronics: Digital Systems & Boolean Basics, Logic Gates & Hardware, Boolean Expression, Boolean Minimization, Combinational Circuit, Sequential Circuits, Number System, Number Representation, Registers and Counters, Boolean Algebra and Logic Gates, Microprocessors and Microcontrollers, Logic Families and CMOS Logic, Microprocessors, Logic Gates and Boolean Algebra, Number Systems and Codes, Minimization of Boolean Functions, Timing, Hazards and Testing, Logic Families, Combinational Logic Design, Arithmetic Circuits, Semiconductor Memories and Programmable Logic Devices, Combinational Logic Circuits, Sequential Circuits and State Machines, Latches and Flip-Flops, Finite State Machines, Minimization of Boolean Functions, Arithmetic Circuits, Registers and Counters, Latches and Flip-Flops, Number Systems and Codes
  4. Computer Architecture: Basics of COA, Floating Point Rep, Cache Memory Organization, Input Output Organisation, Pipelining, Instr Formats & Modes, Control Unit Design, Semiconductor Memories and Programmable Logic, Processor Organization and Instructions, Memory Hierarchy and Input/Output
  5. Operating System: Introduction to OS, Process Management, CPU Scheduling, Process Synchronization, Deadlock, Virtual Memory, Disc Scheduling, File Management, Memory Management, Threads & Process Creation
  6. Computer Networks: Introduction to CN, DLL: Access Control, DLL: Flow Control, DLL: Error Control, DLL: Framing, Data Link Layer - Ethernet, Net Layer: IPv4 & Proto, Net Layer: IP Addressing, Net Layer:Routing Protocol, Transport Layer Services, TL: Congestion & UDP, Application Layer, Network Security, Hardware Basics
  7. Data Structures: Introduction to DS, Array, Stack, Queue, Linked List, Tree, Graphs, Hashing
  8. Algorithms: Algorithm Analysis, Sorting Algorithms, Greedy Algorithms, Dynamic Programming, Minimum Spanning Trees, Shortest Path Algos, Time Complexity Analysis
  9. Theory Of Computation: Introduction to TOC, Deterministic FA (DFA), Non-Deterministic FA, Regular Expressions, Grammar, Regular Language Properties, Moore & Mealy Machines, Pushdown Automata & CFG, Turing Machines, Complexity Theory
  10. Compiler Design: Intro to Compilers, Lexical Analysis, Grammar & CFG, Syntax Analysis: Top-Down, Syntax Analysis: Bottom-Up, Semantic Analysis & SDT, Intermediate Code Gen, Code Optimization
  11. C language: C Fundamentals, Control Flow, Functions, Arrays & Pointers, Storage Classes, Structures & Enums
  12. Software Engineering: Fundamentals of Software Engineering, Software Requirements and Quality Assurance, Software Design, Estimation and Metrics, Software Testing, Software Maintenance and Configuration Management
  13. Emerging Trends & AI: Emerging Tech Trends, Artificial Intelligence, Cloud Computing, Internet of Things
  14. Computer Graphics: Basics of Computer Graphics, 2-D Geometrical Transforms and Viewing
  15. Aptitude: Percentage, Ratio and Proportion (Ratios), Logarithm, HCF LCM, Average, Sequence and Series (Series), Number System, Powers and Exponents (Surds and Indices), Algebra, Permutation and Combination, Probability, Profit and Loss, Simple Interest and Compound Interest, Pipe and Cistern, Speed Time and Distance, Mixture and Alligation, Mensuration and Geometry, Mental Ability, Age Problems, Partnership, Statistics, Data Interpretation, Arithmetic, Linear Algebra, Trigonometry, Percentages, Simplification and Approximation, Number System, Ratio and Proportion, Averages, Mixtures and Alligation, Permutations and Combinations, Profit, Loss and Discount, Sequences and Series, Vocabulary, Subject-Verb Agreement, Sentence Completion, Geometry, Reading Comprehension, Powers, Surds and Logarithms, Mathematical Operations, Alphabet and Word Tests, Transformation of Shapes, Signal Space and Optimum Detection, Constraint Puzzles, Mensuration, Patterns in Two-Dimensional Figures, Measurement and Quantity Take-Off, Three-Dimensional Patterns and Visualization, Numerical Reasoning, Sentence Structure and Correction, Critical Reasoning, Syllogisms and Venn Diagrams, Coding and Decoding, Series Completion, Order, Ranking and Sequence, Data Sufficiency, Differential Calculus, Wireless, Satellite and Optical Communication Systems, Complex Analysis, Vector Analysis, Trigonometry, Probability, Statistics, Differential Calculus, Algebra, Time and Work, Speed, Time and Distance, Data Interpretation, Combinatorics
  16. Reasoning: Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning), Series (Number and Letter Series) (Numerical Relations and Reasoning), Coding Decoding, Data Sufficiency, Syllogisms, Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning), Seating Arrangements, Blood Relations, Directions (Direction Test), Analytical Reasoning (Counting Figures Reasoning), Puzzle Solving (Puzzles), Calendar, Clock, Cubes & Dices, Selection Decision Table (Decision Making), Logical Sequence Of Words, Venn Diagram, Data Arrangement, Inequality, Analogy, Ranking, Order and Sequence, TCS NQT Advanced Reasoning Ability, Assembling and Grouping of Shapes, Cubes and Dice, Analogy and Classification, Direction Sense, Algebra, Logical Deduction and Induction, Speed, Time and Distance, Narrative Sequencing, Project Monitoring, Resources and Safety, Traverse Surveying, Time and Work, Clocks and Calendars, Data Interpretation, Blood Relations, Data Sufficiency
  17. English (Verbal Ability): Vocabulary, Noun, Pronoun, Adjectives, Preposition, Articles, Direct and Indirect Speech, Tenses, Conjunction, Subject Verb Agreement (Verb Noun Agreement), Modals, Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing), Sentence Correction (Error Correction), Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions), Cloze Test (Cloze Passage), Verbal Analogy (Word Based Analogy), Adverb, Verb, Prepositions and Conjunctions, Idioms and Phrases, Verb Forms and Verb Patterns, Sentence Basics, Nouns and Pronouns, Adjectives and Adverbs, Articles and Determiners, Voice and Reported Speech, Modals, Conditionals and Subjunctive, Blood Relations, Tenses, Vocabulary
  18. Engineering Mathematics: Calculus, Vectors
  19. GATE Live Class Recordings 2026: GATE 2026 Live Class
AI summary & chapters

AI Summary

An AI-generated summary of this video lecture.

This lecture provides a comprehensive walkthrough of Radix Sort implemented using Counting Sort as the underlying subroutine. The instructor begins by defining Radix Sort as a non-comparison based sorting algorithm that processes elements digit by digit, specifically from the Least Significant Digit (LSD) to the Most Significant Digit (MSD). The core concept relies on the stability of Counting Sort, ensuring that elements with equal keys maintain their relative order during intermediate passes. The demonstration utilizes a sample array of eight integers, such as 178, 002, 169, and 314, to illustrate the mechanics of sorting. The radix is established as 10 for decimal numbers, meaning digits range from 0 to 9. The instructor visually constructs an auxiliary counting array 'C' initialized with zeros, which is then populated by iterating through the input array to count the frequency of each digit at the current position being processed. The lecture progresses through multiple passes, first sorting by the ones place (LSD), then the tens place, and finally the hundreds place. In each pass, the counting array is modified to store cumulative counts, which determines the correct position of elements in a temporary output array 'b'. The video concludes by deriving the time complexity as O(dn), where d is the number of digits and n is the array size, and space complexity as O(n+k), simplifying to O(n) when radix is treated as a constant.

Chapters

  1. 0:00 – 2:00 00:00-02:00

    The lecture opens with an introduction to Radix Sort using Counting Sort, explicitly labeled on screen as a 'Non Comparison Based Sorting Algorithm'. The instructor defines the sorting strategy as processing digits from the Least Significant Digit (LSD) to the Most Significant Digit (MSD). A sample array 'a' is displayed containing eight integers: 178, 002, 169, 314, 521, 738, 142, and 194. The digit range is identified as 0-9 with a radix of 10, setting the stage for the decimal sorting demonstration. The instructor emphasizes that Counting Sort serves as a stable subroutine at each digit position.

  2. 2:00 – 5:00 02:00-05:00

    The instructor begins the practical demonstration by initializing an auxiliary counting array 'C' with zeros. The focus shifts to processing the Least Significant Digit (LSD), which corresponds to the ones place of each number in array 'a'. The instructor underlines specific digits, such as the 8 in 178 and the 2 in 002, to indicate which position is currently being sorted. The counting array 'C' starts empty and begins to be populated with frequencies corresponding to the last digits of the numbers. The visual setup clearly distinguishes between the input array 'a' and the auxiliary counting structure required for the algorithm.

  3. 5:00 – 10:00 05:00-10:00

    The process of populating the counting array 'C' continues as the instructor iterates through every element in the input array. For each number, the last digit is extracted and used as an index to increment the value in array 'C'. For example, if a number ends in 2, the count at index 2 of 'C' is incremented. The on-screen text confirms that digits range from 0-9 and the radix remains 10. The instructor demonstrates how to map input numbers to their respective digit counts, building the frequency distribution necessary for the next step of determining positions. The array 'C' transitions from all zeros to a populated state reflecting the distribution of ones digits.

  4. 10:00 – 15:00 10:00-15:00

    The instructor modifies the counting array 'C' to store cumulative counts, a critical step for stable sorting. This transformation allows the algorithm to determine the final position of each element in the output array 'b'. The video shows arrows indicating the mapping from input numbers to their sorted positions based on the cumulative counts. Elements like 142 and 194 are placed into the output array 'b' based on their ones digit. The text on screen highlights that Counting Sort is used as a stable sorting algorithm at each digit position, ensuring the relative order of elements with identical digits is preserved during this pass.

  5. 15:00 – 20:00 15:00-20:00

    The first pass of sorting is completed, and the instructor prepares for the next iteration by processing the tens place. The data from the temporary output array 'b' is copied back into the source array 'a', effectively updating the input for the next digit position. The counting sort array 'c' is re-initialized to zeros, and the process repeats for the second least significant digit. The instructor demonstrates how the array evolves after sorting by the ones place, showing intermediate states where numbers are partially ordered. This step-by-step progression highlights the iterative nature of Radix Sort, moving systematically from LSD to MSD.

  6. 20:00 – 25:00 20:00-25:00

    The sorting process continues with the tens place digit. The instructor applies Counting Sort logic again, this time extracting the middle digit of each number (e.g., 7 from 178, 0 from 002). The counting array 'c' is populated with frequencies of these tens digits, and cumulative sums are calculated to determine positions in the output array. The visual evidence shows intermediate arrays labeled 'a', 'c', and a sorted version, illustrating the stability of the sort. The instructor tracks index positions 0-9 for digit buckets, ensuring that elements are placed correctly relative to their tens digit values.

  7. 25:00 – 30:00 25:00-30:00

    The final pass of the sorting algorithm is executed, focusing on the Most Significant Digit (MSD), which corresponds to the hundreds place. The instructor demonstrates how the array is sorted based on these leading digits, completing the Radix Sort process. The final output array 'b' is shown with numbers in fully ascending order, confirming the correctness of the algorithm. The visual progression from unsorted to sorted is clear, with intermediate arrays showing the state after each digit pass. The instructor emphasizes that this method works for any number of digits, provided the counting sort subroutine is applied correctly at each stage.

  8. 30:00 – 31:56 30:00-31:56

    The lecture concludes with an analysis of the time and space complexity. The instructor writes the formula O(dn) for time complexity, defining 'd' as the number of digits in each element and 'n' as the total number of elements. Space complexity is derived as O(n+k), where k represents the radix (10 in this case). The instructor notes that since the radix is a constant, the space complexity simplifies to O(n). The final frames show the sorted array 'a' with indices 1-8, alongside the counting array 'c', reinforcing the relationship between the algorithm's structure and its efficiency metrics.

The lecture effectively bridges theoretical concepts with practical implementation by using a concrete example of sorting eight integers. The key takeaway is the iterative application of Counting Sort, which acts as a stable subroutine to sort digits from LSD to MSD. The stability of Counting Sort is crucial; without it, the relative order established in previous passes would be lost. The visual aids, including underlined digits and evolving arrays 'a', 'b', and 'c', provide clear evidence of the algorithm's mechanics. The complexity analysis at the end solidifies understanding by quantifying performance in terms of digits and array size. This approach demonstrates why Radix Sort is efficient for large datasets with fixed-length keys, avoiding the O(n log n) lower bound of comparison-based sorts.

Loading lesson…