Skip to main content
  1. About
  2. For Teams
Filter by
Sorted by
Tagged with
2 votes
1 answer
61 views

SML Quicksort Recursive Calls

I have a question regarding the following code I found on github: fun quicksort nil = nil | quicksort (pivot :: rest) = let fun split(nil) = (nil,nil) | split(x :: xs) = ...
dvk512's user avatar
  • 59
-3 votes
1 answer
113 views

Array passed as an argument does not seem to be changing [closed]

I was tasked to write up a C program to sort an array using quicksort, without using recursion. Original array: -25, 87, 12, -6, 91, 3, -48, 70, 19, -33, 55, 2, -18, 99, 41, -72, 63, 15, -90, 27, 8, -...
Thunder's user avatar
  • 11
1 vote
2 answers
101 views

How do I use quicksort in C with a multi-dimensional array? I am getting an incorrect result

I am trying to sort the tuples in the 2D array based on a single column value similar to Javascript's sort function. arr.sort((a,b) => a[0] - b[0]) C Code : #include<stdio.h> #...
Bittu970's user avatar
  • 107
1 vote
1 answer
106 views

Why can't two algorithms with the same time complexity pass the Kth Largest Element problem on LeetCode?

I am trying to solve the "Kth Largest Element in an Array" problem on LeetCode. I have two different approaches that both theoretically have the same time complexity (O(n) on average), but ...
459zyt's user avatar
  • 115
0 votes
1 answer
61 views

Stack Overflow on Quicksort with a first element pivot in Java

For this assignment I'm supposed to test my quicksort class using a variety of different pivots and a variety of ArrayLists in different arrangements. The class works fine with a random pivot, or a ...
Drake's user avatar
  • 19
0 votes
1 answer
103 views

Why does the partition function in QuickSort work even when the inner while loop seems to cause an infinite loop?

I'm implementing the partition function for QuickSort, and I've come across behavior that seems confusing. Specifically, in the partition logic: int partition(int A[], int low, int high) { int ...
Omm's user avatar
  • 37
0 votes
1 answer
80 views

Why is the cutoff value to insertion sort for small sub-arrays in optimizing quicksort algorithm is system-dependent?

In pp.296 Sedgewick & et al.'s Algorithm, 4rd edition, the author wrote: The optimum value of the cutoff M is system-dependent, but any value between 5 and 15 is likely to work well in most ...
Kt Student's user avatar
2 votes
1 answer
166 views

Can Hoare's partition method be used for partitioning around a specific pivot?

Studying quicksort , I discovered some weird behaviours of the partitioning algorithm (taught by our instructor) when testing it out for random pivots . After quite some research, I found out I was ...
MkB's user avatar
  • 21
1 vote
1 answer
125 views

Cannot access memory at address error in gdb

I am trying to the run the following quick sort algorithm and get the following error when I debug it with gdb: Program received signal SIGSEGV, Segmentation fault. 0x000055555555530a in partition (...
skm's user avatar
  • 43
0 votes
0 answers
51 views

Endless quicksort recursive function (academic assignment)

I have a few functions here that are taking strings from an array and sorting them alphabetically. SortList is the main function, which calls functions CompareString, LastName, and FirstName. ...
Antonio 1113's user avatar
0 votes
1 answer
68 views

When writing quicksort in python, is it possible to simultaneously have a method signature of quicksort(arr) -> void, and have quicksort be recursive?

I have written an assignment for a data structures class and am having trouble figuring out how to "Implement the main quicksort function that recursively sorts the subarrays formed by ...
Gabriel Denney-Martell's user avatar
-2 votes
1 answer
154 views

Why is the "If statement" getting skipped?

I am trying to do a QuickSort assignment for my Algorithms course and for some reason that I don't know, I can't figure out why my code is skipping the QuickSort portion (surrounded by "//") ...
Alexander Reams's user avatar
2 votes
0 answers
134 views

How to construct an array to make qsort() having n^2 time complexity?

I heard a long time ago that the implementation of the qsort function is the quick sorting algorithm and has a worst-case time complexity of n^2. But recently when I was trying to construct a set of ...
Sihan Lv's user avatar
2 votes
2 answers
151 views

Generic QuickSort implementation struggles with a lot of strings

I made this quicksort implementation in C for uni that is supposed to be able to receive any type of array and sort it. For a stress test I was provided a records.csv file with 20 million lines ...
Samuele Tonda Roc's user avatar
1 vote
0 answers
66 views

Sum of comparisons and exchange between two sorting methods and their comparison (shell and quicksort)

I'm trying to make a code that counts Shell and Merge comparisons and swaps, making a sum between the sum of the comps and swaps. The vectors are a subArray, such that, given: 4 (line break here) 3 6 ...
Poueeerr's user avatar

15 30 50 per page
1
2 3 4 5
217
Morty Proxy This is a proxified and sanitized view of the page, visit original site.