Questions tagged [sorting]
Use this tag when arranging items in order is the main focus of the code.
1,159
questions
1
vote
1
answer
52
views
Advent of Code 2022 Day 13 Solution in C: Sorting and parsing nested list
Link to Original Problem: Advent of Code 2022 Day 13
Question Summary:
The task involves sorting and parsing nested lists, with two parts:
Determine pairs in the correct order and calculate the sum ...
3
votes
1
answer
115
views
Sorting the divisors of a given number
I am trying to sort all the divisors of a given number in the most efficient way.
Below is my code for sorting the divisors:
...
0
votes
0
answers
33
views
Efficient least-significant digit (LSD) radix sort for int and long keys in Java - iteration II
This post elaborates on Efficient least-significant digit (LSD) radix sort for int keys in Java. This time, I made mild corrections to my code and provided the radix sort for ...
3
votes
1
answer
127
views
Efficient least-significant digit (LSD) radix sort for int keys in Java
(This post has a continuation post.)
This one is my attempt at LSD radix sort:
Code
com.github.coderodde.util.LSDRadixsort.java:
...
3
votes
1
answer
95
views
Sorting songs with the ability to save and resume partial sorts
I listen to a lot of music (~4k h/y) and managing thousands of songs is a bit of a challenging.
To improve my listening experience I want to better organize my collection.
One thing I want to do is ...
4
votes
1
answer
311
views
c++ quicksort pivots
Is this code for quicksort using the first index as a pivot correct?
Also if I want to use the last or middle index as a pivot how would the whole code change?
...
2
votes
1
answer
80
views
Sort array of numbers using tree sort - Leetcode 912
Problem statement:
Sort integer array nums in O(N log N) time,
without relying on any library sort routine.
I am trying to use a tree sort method (using the ...
1
vote
0
answers
14
views
Determine top t values with few calls to order(), a given procedure to order k values, Java take 2
My 2nd take of the problem in Determine top t values with few calls to order(), a given procedure to order k values:
Given an array and a procedure to order \$k\$ ...
1
vote
1
answer
118
views
Fraudulent activity notifications problem from hackerrank
There's a problem on hackerrank called fraudulent activity notifications: given an array of integers and a value k, I'm supposed to increment a counter if the median of the numbers up until k , ...
2
votes
1
answer
58
views
Average Pair Sorting algorithm
I had to relax a bit, so I wrote this sorting algorithm. By any means it isn't fast, but I really started to get interested in it, since I haven't seen similar approach yet.
Disclaimer
I do not intend ...
8
votes
2
answers
405
views
Heap sort optimization
I tried to optimize heap sort algorithm. Instead of recursion, I used iteration:
...
3
votes
1
answer
82
views
Creating Worst-Case Scenario for QuickSort using Middle Pivot in Java
I've implemented a solution to generate the worst-case scenario for QuickSort using the middle pivot strategy in Java. The goal is to rearrange an input array to produce the worst performance during ...
5
votes
2
answers
148
views
Print the three most occurring chars in Java using streams
The three characters that occurs most in a given string should be printed by using streams/lambdas (functional programming). The order of characters that occur equally often should be preserved.
My ...
2
votes
1
answer
78
views
Implementing an improved merge sort that uses insertion sort, with "levels" - Would this work correctly?
We were asked to improve the merge sort algorithm by introducing insertion sort to the code. We have been tasked with doing this by utilising a "levels" logic. Here is the exact description ...
8
votes
3
answers
2k
views
Algorithm "sort except zero"
Task:
Sort the integers in sequence in sequence. But the position of zeros should not be changed.
Input: List of integers (int).
Output: List or another Iterable (tuple, generator, iterator) of ...