Skip to main content

Questions tagged [sorting]

Use this tag when arranging items in order is the main focus of the code.

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 ...
fish_brain's user avatar
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: ...
Arjun Kumar's user avatar
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 ...
coderodde's user avatar
  • 28.9k
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: ...
coderodde's user avatar
  • 28.9k
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 ...
Peilonrayz's user avatar
  • 43.4k
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? ...
Kqehzo's user avatar
  • 41
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 ...
qxzsilver's user avatar
  • 123
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\$ ...
greybeard's user avatar
  • 6,519
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 , ...
IRP_HANDLER's user avatar
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 ...
Just Bucket's user avatar
8 votes
2 answers
405 views

Heap sort optimization

I tried to optimize heap sort algorithm. Instead of recursion, I used iteration: ...
iskander's user avatar
  • 121
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 ...
Lydia Yuan's user avatar
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 ...
Tobias Grothe's user avatar
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 ...
Preatorius's user avatar
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 ...
Глеб's user avatar
  • 183

15 30 50 per page
1
2 3 4 5
78