All Questions
30 questions
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. ...
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 ...
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:
...
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 ...
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 ...
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 >...
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
...
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 ...
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 ...
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 ...
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:
<...
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 ...
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 ...
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 ...
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
...