Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
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 ...
Thomas Mathew's user avatar
4 votes
1 answer
732 views

Performant Sort function for big arrays

In sort(arr), I want to sort an array. Children must be beneath their parent. And children of the same parent are sorted using ...
Helix112's user avatar
  • 143
7 votes
2 answers
170 views

Determine the complexity of sorting a binary array

The challenge is to sort an integer array containing only ones and zeros with the lowest complexity possible. As always, I am interested in any improvements suggested but in this question I am most ...
amalgamate's user avatar
2 votes
1 answer
78 views

In-Place Merging of Two Bubble Sorted Linked Lists (Python)

I'm following a tutorial on merging two bubble-sorted Single Linked Lists in Python. merge1 does the merging by creating a new list with maybe \$O(N+M)\$ memory ...
Emma Marcier's user avatar
  • 3,692
1 vote
1 answer
4k views

The quicksort algorithm in Haskell

I am learning Haskell programming language mainly from this source. And there I have encouraged with "an elegant" realization of the quicksort sorting algorithm (the Quick, sort! section). ...
LRDPRDX's user avatar
  • 941
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 ...
Anirudh Thatipelli's user avatar
1 vote
2 answers
209 views

Checking whether two lists contain the same elements

I have two lists of numbers: $$\{i_1, i_2, i_3,i_4\}$$ and $$\{j_1,j_2,j_3,j_4\}$$ The problem I want to solve is: Inside a loop, if the following two conditions are satisfied, then it will do ...
xjtan's user avatar
  • 119
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 <...
Anirudh Thatipelli's user avatar
5 votes
2 answers
902 views

Bottom-up singly linked list merge sort in C++

This is an implementation of a singly linked list merge sort I did on paper during a job interview recently, using a bottom-up approach. The requirement was simply "implement a merge sort for a ...
Fabio A.'s user avatar
  • 251
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
-5 votes
1 answer
246 views

Category of sorting algorithm and complexity [closed]

Just for fun, I wrote a sorting algorithm. I did not compare this with existing sorting algorithms.Can someone tell me what class of sorting algorithm this is and it's complexity? The algorithm ...
teeboy's user avatar
  • 101
3 votes
1 answer
5k views

Calculating the most profit from an array of stock prices

I'm a newbie learning how to code, and I am trying to find the most efficient way to calculate the most profit from an array of stock prices. For a given array,I have a list of stock prices over n ...
JohnnyTheJet's user avatar
5 votes
2 answers
2k views

Non-recursive implementation of MergeSort

I've been trying to internalize some of the basic sorting algorithms recently, and to do so I've been looking at their wikipedia pages to refresh myself with how they work, and then coding my own "...
dgamz's user avatar
  • 61
1 vote
1 answer
161 views

Merge sort C# time and space efficiency

Please comment on time and space efficiency. ...
Gilad's user avatar
  • 5,353
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 ...
Adam's user avatar
  • 405

15 30 50 per page