TheAlgorithms / MATLAB-Octave

This repository contains algorithms written in MATLAB/Octave. Developing algorithms in the MATLAB environment empowers you to explore and refine ideas, and enables you test and verify your algorithm.
MIT License
373 stars 176 forks source link

Improve counting sort #81

Closed MaximSmolskiy closed 3 years ago

MaximSmolskiy commented 3 years ago
  1. Preallocate ans
  2. Decrease memory consumption for C creation
    >> k = 100000;
    >> counting_sort(1:k, k)
    error: out of memory or dimension too large for Octave's index type
    error: called from
    counting_sort at line 9 column 5
  3. Remove unnecessary if statement