counting-sort Questions

2

I need help with this following counting sort implementation. Is it because value of x can be too big? I am getting segmentation fault. This is what gdb says: Program received signal SIGSEGV, Segm...
Sufferable asked 9/8, 2016 at 5:25

3

Solved

I was looking at the code for Counting Sort on GeeksForGeeks and during the final stage of the algorithm where the elements from the original array are inserted into their final locations in the so...
Cinemascope asked 5/9, 2020 at 4:28

3

Solved

I encountered a question on hackerrank. https://www.hackerrank.com/challenges/countingsort4 My first attempt passed all the test cases except the last one, due to timeout. After failed to come up ...
Stratum asked 4/12, 2014 at 7:59

3

Solved

Design an algorithm that sorts n integers where there are duplicates. The total number of different numbers is k. Your algorithm should have time complexity O(n + k*log(k)). The expected time is en...
Richardo asked 1/4, 2020 at 22:51

1

Solved

I was reading about counting sort and one of the steps of algorithm is for(i = 1 to k) c[i] = c[i]+c[i-1]; Why do we need this step? Why can't we use this instead for(i = 0 to k) while(c...
Coronach asked 26/8, 2015 at 10:0

3

Counting sort is known with linear time if we know that all elements in the array are upper bounded by a given number. If we take a general array, cant we just scan the array in linear time, to fin...
Intyre asked 28/7, 2014 at 18:25

7

Solved

I am reading the definitions of radix, counting and bucket sorts and it seems that all of them are just the code below: public static void sort(int[] a, int maxVal){ int [] bucket=new int[maxVal+...
Centrifuge asked 16/1, 2013 at 21:41
1

© 2022 - 2024 — McMap. All rights reserved.