We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Counting Sort 1
- Discussions
Counting Sort 1
Counting Sort 1
Sort by
recency
|
677 Discussions
|
Please Login in order to post a comment
!/bin/python3
import math import os import random import re import sys
def countingSort(arr, n): count = [0] * 100 # Fixed-size array of 100 elements
if name == 'main': fptr = open(os.environ['OUTPUT_PATH'], 'w')
its shows error what to do?
int* countingSort(int arr_count, int* arr, int* result_count) { for(int i=0;i<100;i++){ result_count[i]=0; } for(int i=0;i= 0 && arr[i] < 100) { result_count[arr[i]]++;} } return result_count;
}
c# solution:
public static List countingSort(List arr) { var zeroArray = new int[100];
I did not understand the problem, can someone explain it to me?
Create new array which size is 100 because maximum capacitiy can be 100 as written in document.
With for loop, check the every index of given input array. For example if first element is 23, it means go to index 23 of newly created array and increase one (+1).
Create new array which size is 100 because maximum capacitiy can be 100 as written in document.
With for loop, check the every index of given input array. For example if first element is 23, it means go to index 23 of newly created array and increase one (+1).