135
questions
0
votes
1
answer
66
views
Sort an array with small numbers while having secondary array with initial indexes
I have a small array with 7 elements which can have values from 0 to around 6 (very small numbers). The counting sort is really very efficient with such configuration, but, I have another array to ...
0
votes
0
answers
23
views
Required type and Provided type are same but java provides an error
public static List<? extends Number> countSort(List<? extends Number> inputList, Number lenOfAdditionalArray){
List<? extends Number> outputArray = new ArrayList<>();
...
0
votes
1
answer
122
views
counting sort using c++ [closed]
#include<iostream>
#include <fstream>
#include <algorithm>
using namespace std;
void countsort(int a[], int b[], int n, int k, int& count) {
int *c = new int[k + 1];
...
0
votes
0
answers
26
views
Why does my method of using combinations not work for this counting so program?
This is my solution for a computing contest, question S3 from 2017. Attached below is a link to the website with the question, and also an image of the question. It seems like I'm not accounting for ...
0
votes
1
answer
19
views
The Reason Behind Employing an Additional Array and Counting Smaller Elements in the Counting Sort Algorithm
Is it feasible to streamline the counting sort algorithm by exclusively utilizing the counting array (C) after determining the frequency of each element in the input array? Instead of creating an ...
0
votes
1
answer
37
views
Can n different numbers be sorted using radix sort (and counting sort for digits) in Θ(n) time?
Can n different numbers be sorted using radix sort (and counting sort for digits) in Θ(n) time?
i would say yes. This is because radix sort processes the digits of the numbers in a fixed number of ...
0
votes
1
answer
75
views
Countsort causing segment fault
Im trying to implement a count sorting algorithm in C but I ran into a weird issue.
Basically with the input of
0 0 0 0 0 1 1 1 1 2 2 2 3 3 4 6 7 7 8 10 10 10 10 10 8 8 9 9 9 9
My code will cause a ...
0
votes
0
answers
212
views
Count_sort function in python3, not allowed to use built in functions, must be in O(n+k) complexity
the prompt:
Use the count sort algorithm to write a function that receives a StaticArray and returns a new StaticArray with the same content sorted in non-ascending order. The original array must not ...
0
votes
1
answer
52
views
munmap_chunk(): invalid pointer : Likely from copying a struct
The last line (the free) is returning a munmap_chunk(): invalid pointer error.
This is the code snippet (it's a first draft, so I'd ask you to excuse the rough-around-the-edges shape. It operates on a ...
0
votes
1
answer
33
views
What SAS function can I use to count variables and perform frequency distribution in order to calculate the number of options available?
Hellow, how the number of options available should be calculated in SAS?
My data:
Obs Density$ P1 P2 P3 P4
1 0500_0600 0 0 0 0
2 0500_0600 0 0 0 0
3 0500_0600 0 0 0 ...
0
votes
1
answer
127
views
Excel VBA - counting numbers resetting
Please pardon my English. I try to explain my needs in excel.
I am trying to write an excel VBA code for total number counts in a particular column. for example A:A columns are filled with specified ...
0
votes
1
answer
45
views
Radix sort with counting sort incorrectly sorts letters converted to binary
I'm having trouble understanding why my code for radix sort with counting sort doesn't correctly sort the input when I convert it to binary. I'm basically using the same code for letters represented ...
-1
votes
1
answer
75
views
My program for counting sort always shows this error- Index 9 out of bounds for length 9 [duplicate]
I have been writing the below mentioned code for the problem and it always shows me the error that my index is out of bounds for my length. I have tried printing the size and it is comparitively very ...
0
votes
2
answers
325
views
CountingSort with ArrayList
I'm trying to implement the Counting Sort algorithm with an ArrayList but I have some difficulties.
I in this piece of code I want to calculate the occurrence of each element in the ArrayList named l.
...
0
votes
1
answer
234
views
Why is the time complexity of counting sort O(n+k) instead of O(2*n)?
In counting sort we know that O(n+k) is the time compelxity where 'n' is the number of elements and 'k' is the range of elements given such as 1-100.
Now look at the code below for counting sort:
void ...