Skip to main content
The 2025 Developer Survey results are in. Explore insights into technology and tools, careers, community and more. View results.

All Questions

Tagged with
Filter by
Sorted by
Tagged with
3 votes
0 answers
112 views

Comparing two Tree sort algorithm variations implemented in Java

I have this repository. It contains three variations of a simple sorting algorithm for integer keys. The idea is that we keep a balanced BST in which each node holds the integer key and its frequency. ...
coderodde's user avatar
  • 31k
2 votes
1 answer
87 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
3 votes
2 answers
222 views

Counting duplicate elements in two sorted arrays

I've been working on an assignment that involves optimizing a duplicate finding algorithm for sorted arrays, and I'd like to get your thoughts on the implementation. Here's the code I've come up with: ...
Bryan C's user avatar
  • 31
2 votes
2 answers
208 views

Quick Sort Program

Quick sort is a sorting algorithm in which we select any random element as pivot from the array and we do the partition of the array around that pivot. Basically we place all the elements smaller than ...
Strange Alchemist's user avatar
1 vote
1 answer
270 views

Find Kth Element in the merged two sorted arrays?

We have been given two sorted arrays and a number K . We have to merge the two sorted arrays in the sorted manner and return the element at the Kth position. My approach is to use two variables ...
Aryaman 's user avatar
5 votes
1 answer
364 views

ZigZag array implementation

I have implemented a zigzag array which will sort smaller greater smaller and goes on... For example : 3 7 4 8 2 6 1 is a valid ordering. The relationship between numbers is 3 < 7 > 4 < 8 >...
Neslihan Bozer's user avatar
2 votes
1 answer
234 views

Efficient counting sort for large byte arrays in Java

I have this counting sort for byte values running in linear time with respect to array length: Arrays.java ...
coderodde's user avatar
  • 31k
0 votes
2 answers
149 views

ContactsList implementation in Java

I created a ContactsList class in Java that holds Person objects. I consider this is a side project for my GitHub profile. Any ...
Hamidur Rahman's user avatar
3 votes
2 answers
393 views

Check whether array is sorted recursively

I'm trying to implement isSorted method checking whether given array is sorted recursively. I've written two types, one is similar to merge sort logic, the another ...
Soner from The Ottoman Empire's user avatar
1 vote
2 answers
100 views

Mergesort, instrumented for counting reads and writes

I have just finished an implementation of mergesort, and I was wondering if I can further reduce the amount of reads and writes. I have looked at it for a while, and to my eyes, I cannot see anything ...
joeyvanlierop's user avatar
0 votes
1 answer
1k views

Sort multidimensional array based of the difference in the value

Sort multidimensional array based of the difference in the value, if value is same sort on first column. Constrains: No of rows can be any but fixed no of column ie 2. Example: <...
Sandesh Wani's user avatar
4 votes
1 answer
1k views

Repeated comparison of sorted subarrays

This question is from a recently concluded competition on Codechef. You are given an array A of size n, and there are ...
Ravi Chandra's user avatar
3 votes
2 answers
310 views

Segregate an array of 0s and 1s

I think that my code contains a lot of if and else statements that are probably not required.I suppose that this code could be condensed to a shorter form where the logic applied would look clearer ...
Mayank Gupta's user avatar
3 votes
3 answers
9k views

Sorting integers in descending order

So, I coded a program which asks you the number of integers and the integers the user wants to sort in descending order. The program works but I feel like it is very inefficient. If I were to receive ...
Huzo's user avatar
  • 287
4 votes
1 answer
2k views

Find distinct combinations of four elements in an array that have a certain sum

The task is: Given an array A of size N, find all combinations of four elements in the array whose sum is equal to a given value K. The specific requirements are: The combinations must be distinct ...
umop apisdn's user avatar

15 30 50 per page