All Questions
9 questions
2
votes
1
answer
72
views
Merge Sort with Minimum Sufficient Variables, Verbosity and better Space Complexity
The majority of merge sort implementations searched online are provided with unnecessary variables and code lines. Here is an attempt to reduce that. However, does passing back the subArray as return ...
7
votes
5
answers
3k
views
Sort an array of 0s, 1s and 2s in Java
Write a program to sort an array of 0's,1's and 2's in ascending
order.
Input:
The first line contains an integer 'T' denoting the total number of
test cases. In each test cases, First line is number ...
0
votes
2
answers
612
views
Pancake sort inteview using java
Given an array of integers arr:
Write a function flip(arr, k) that reverses the order of the first k elements in the array <...
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:
<...
5
votes
1
answer
6k
views
Sort a given string in ascending order
This code sort the string below in ascending order.
I'd prefer it split-up in two or three smaller, simpler methods. I'm also wondering whether my algorithm has a decent time complexity.
Given string
...
4
votes
2
answers
7k
views
Sorting a Stack in ascending order
Here's my implementation of sorting a stack in ascending order. The problem statement is as follows :
Write a program to sort a stack in ascending order (with biggest items on top).
You may use at ...
1
vote
2
answers
377
views
Big O notation for quicksort implementation [closed]
I am trying to find out what would be the Big O notation of a quick sort implementation I wrote. If I can get some analysis on the code, that would be great.
...
1
vote
4
answers
384
views
Finding the second largest element of large input sets
I have a problem where I need to find the second maximum element of the user inputs. It's an online practice problem and I can't figure out why the server responds back with a Non-Zero Exit Code error ...
5
votes
1
answer
318
views
Is this an efficient merge sort implementation with regards to average time complexity in Big-O notation?
Is my below merge sort implementation in O(n log n)? I am trying to implement a solution to find k-th largest element in a given integer list with duplicates with O(N*log(N)) average time complexity ...