{"id":34000,"date":"2024-11-01T09:22:54","date_gmt":"2024-11-01T09:22:54","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=34000"},"modified":"2024-11-01T10:54:22","modified_gmt":"2024-11-01T10:54:22","slug":"c-coding-test-course-radix-sort","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/34000\/","title":{"rendered":"C# Coding Test Course, Radix Sort"},"content":{"rendered":"<p><body><\/p>\n<p>Hello! Today we will explore the concept of Radix Sort and how to implement it using C#. Radix Sort is one of the efficient ways to sort unsorted data, particularly useful when the range of integers is limited.<\/p>\n<h2>1. What is Radix Sort?<\/h2>\n<p>Radix Sort is a method of sorting numbers based on the position of their digits, typically divided into LSD (Least Significant Digit) and MSD (Most Significant Digit) methods. Using L starts the sorting from the lowest digit, while starting with M sorts from the highest digit.<\/p>\n<h2>2. How Radix Sort Works<\/h2>\n<p>The mechanism of Radix Sort works as follows:<\/p>\n<ol>\n<li>Starting from the least significant digit, sort the data based on each digit.<\/li>\n<li>Repeat the sorting process up to the most significant digit.<\/li>\n<li>In this process, a stable sorting algorithm, such as Counting Sort, is used to sort based on each digit.<\/li>\n<\/ol>\n<h2>3. Time Complexity of Radix Sort<\/h2>\n<p>The time complexity of Radix Sort is <code>O(d * (n + k))<\/code>, where <code>d<\/code> is the number of digits in the numbers, <code>n<\/code> is the number of integers to sort, and <code>k<\/code> is the range of digits from 0 to the maximum digit. One of the biggest advantages is that Radix Sort is stable.<\/p>\n<h2>4. Example Problem Solving with Radix Sort<\/h2>\n<p>Now, let&#8217;s solve a problem by sorting a specific list of numbers using Radix Sort.<\/p>\n<h3>Problem Description<\/h3>\n<p>Sort the given list of integers in ascending order using Radix Sort.<br \/>\nInput: [170, 45, 75, 90, 802, 24, 2, 66] <br \/>\nOutput: [2, 24, 45, 66, 75, 90, 170, 802]<\/p>\n<h3>Problem Solving Process<\/h3>\n<ol>\n<li>Start from the least significant digit. Sort using the first digit in the units place.<\/li>\n<\/ol>\n<pre><code>C#\npublic static void LSDRadixSort(int[] array)\n{\n    \/\/ Find the largest number.\n    int max = array.Max();\n    \/\/ Find the number of digits.\n    for (int exp = 1; max \/ exp &gt; 0; exp *= 10)\n    {\n        CountingSort(array, exp);\n    }\n}\n\nprivate static void CountingSort(int[] array, int exp)\n{\n    int n = array.Length;\n    int[] output = new int[n]; \/\/ Sorted array\n    int[] count = new int[10]; \/\/ Count for digits 0-9\n\n    \/\/ Count the number of elements corresponding to the digit.\n    for (int i = 0; i &lt; n; i++)\n    {\n        count[(array[i] \/ exp) % 10]++;\n    }\n\n    \/\/ Calculate cumulative count.\n    for (int i = 1; i &lt; 10; i++)\n    {\n        count[i] += count[i - 1];\n    }\n\n    \/\/ Create the sorted array.\n    for (int i = n - 1; i &gt;= 0; i--)\n    {\n        output[count[(array[i] \/ exp) % 10] - 1] = array[i];\n        count[(array[i] \/ exp) % 10]--;\n    }\n\n    \/\/ Update the original array.\n    for (int i = 0; i &lt; n; i++)\n    {\n        array[i] = output[i];\n    }\n}\n<\/code><\/pre>\n<p>In the above code, we define the <code>LSDRadixSort<\/code> method. This method sorts using <code>CountingSort<\/code> for each digit.<\/p>\n<h2>5. Implementation and Execution<\/h2>\n<p>Now, we will run the entire program using the above functions. Below is the complete code for the program:<\/p>\n<pre><code>C#\nusing System;\nusing System.Linq;\n\nclass Program\n{\n    public static void Main(string[] args)\n    {\n        int[] array = {170, 45, 75, 90, 802, 24, 2, 66};\n        LSDRadixSort(array);\n\n        Console.WriteLine(\"Sorted array:\");\n        Console.WriteLine(string.Join(\", \", array));\n    }\n  \n    public static void LSDRadixSort(int[] array)\n    {\n        int max = array.Max();\n        for (int exp = 1; max \/ exp &gt; 0; exp *= 10)\n        {\n            CountingSort(array, exp);\n        }\n    }\n\n    private static void CountingSort(int[] array, int exp)\n    {\n        int n = array.Length;\n        int[] output = new int[n];\n        int[] count = new int[10];\n\n        for (int i = 0; i &lt; n; i++)\n        {\n            count[(array[i] \/ exp) % 10]++;\n        }\n\n        for (int i = 1; i &lt; 10; i++)\n        {\n            count[i] += count[i - 1];\n        }\n\n        for (int i = n - 1; i &gt;= 0; i--)\n        {\n            output[count[(array[i] \/ exp) % 10] - 1] = array[i];\n            count[(array[i] \/ exp) % 10]--;\n        }\n\n        for (int i = 0; i &lt; n; i++)\n        {\n            array[i] = output[i];\n        }\n    }\n}\n<\/code><\/pre>\n<p>When executing the above code, the following results can be obtained:<\/p>\n<pre><code>\nSorted array:\n2, 24, 45, 66, 75, 90, 170, 802\n<\/code><\/pre>\n<h2>6. Advantages and Disadvantages of Radix Sort<\/h2>\n<p>The advantages of Radix Sort are as follows:<\/p>\n<ul>\n<li><strong>Fast speed:<\/strong> Excellent performance under certain conditions. (i.e., when the range is limited)<\/li>\n<li><strong>Stable sort:<\/strong> Maintains relative order of equivalent values.<\/li>\n<\/ul>\n<p>However, there are also disadvantages:<\/p>\n<ul>\n<li><strong>Memory usage:<\/strong> Requires additional memory.<\/li>\n<li><strong>Limited data:<\/strong> Difficult to use for data types other than integers.<\/li>\n<\/ul>\n<h2>7. Conclusion<\/h2>\n<p>Today, we examined the basic concept of Radix Sort, its operation principle, time complexity, and problem examples. This algorithm is very useful for efficiently handling collections that contain integers. It is also good to try Radix Sort during actual coding tests.<\/p>\n<p>See you in the next lecture! Good luck with your coding test preparation!<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello! Today we will explore the concept of Radix Sort and how to implement it using C#. Radix Sort is one of the efficient ways to sort unsorted data, particularly useful when the range of integers is limited. 1. What is Radix Sort? Radix Sort is a method of sorting numbers based on the position &hellip; <a href=\"https:\/\/atmokpo.com\/w\/34000\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;C# Coding Test Course, Radix Sort&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[90],"tags":[],"class_list":["post-34000","post","type-post","status-publish","format-standard","hentry","category-c-coding-test-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C# Coding Test Course, Radix Sort - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/34000\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C# Coding Test Course, Radix Sort - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Hello! Today we will explore the concept of Radix Sort and how to implement it using C#. Radix Sort is one of the efficient ways to sort unsorted data, particularly useful when the range of integers is limited. 1. What is Radix Sort? Radix Sort is a method of sorting numbers based on the position &hellip; \ub354 \ubcf4\uae30 &quot;C# Coding Test Course, Radix Sort&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/34000\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:22:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T10:54:22+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"3\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/34000\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/34000\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"C# Coding Test Course, Radix Sort\",\"datePublished\":\"2024-11-01T09:22:54+00:00\",\"dateModified\":\"2024-11-01T10:54:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/34000\/\"},\"wordCount\":414,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"C# Coding Test Tutorials\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/34000\/\",\"url\":\"https:\/\/atmokpo.com\/w\/34000\/\",\"name\":\"C# Coding Test Course, Radix Sort - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:22:54+00:00\",\"dateModified\":\"2024-11-01T10:54:22+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/34000\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/34000\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/34000\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C# Coding Test Course, Radix Sort\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C# Coding Test Course, Radix Sort - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/34000\/","og_locale":"ko_KR","og_type":"article","og_title":"C# Coding Test Course, Radix Sort - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Hello! Today we will explore the concept of Radix Sort and how to implement it using C#. Radix Sort is one of the efficient ways to sort unsorted data, particularly useful when the range of integers is limited. 1. What is Radix Sort? Radix Sort is a method of sorting numbers based on the position &hellip; \ub354 \ubcf4\uae30 \"C# Coding Test Course, Radix Sort\"","og_url":"https:\/\/atmokpo.com\/w\/34000\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:22:54+00:00","article_modified_time":"2024-11-01T10:54:22+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"3\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/34000\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/34000\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"C# Coding Test Course, Radix Sort","datePublished":"2024-11-01T09:22:54+00:00","dateModified":"2024-11-01T10:54:22+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/34000\/"},"wordCount":414,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["C# Coding Test Tutorials"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/34000\/","url":"https:\/\/atmokpo.com\/w\/34000\/","name":"C# Coding Test Course, Radix Sort - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:22:54+00:00","dateModified":"2024-11-01T10:54:22+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/34000\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/34000\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/34000\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"C# Coding Test Course, Radix Sort"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/34000","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=34000"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/34000\/revisions"}],"predecessor-version":[{"id":34001,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/34000\/revisions\/34001"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=34000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=34000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=34000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}