search for: quicksort

Displaying 20 results from an estimated 42 matches for "quicksort".

2011 Sep 04
2
what is wrong with my quicksort?
Hey guys, I tried to program quicksort like this but somethings wrong. please help >partition <- function(x, links, rechts){ > > i <- links > j <- rechts > t <- 0 > pivot <- sample(x[i:j],1) > > while(i <= j){ > > while(x[i] <= pivot){ > i = i+1} > > whil...
2012 Oct 03
3
[LLVMdev] Does LLVM optimize recursive call?
...ry. > > Deep recursion will blow up your stack (AKA "segmentation fault" :-( ) > if the compiler could not optimize it (tail recursion optimization). Only if the recursion is very deep. In practice, a recursive descent parser isn't going to run out of stack space, nor will a quicksort or binary-tree walker, You're distracting this man from his job of learning how to program. Yes, it's a mistake to have a set of mutually recursive routines that chew up all your stack space; but it's a mistake to reply on a compiler optimization to avoid such problems. Write an expli...
2013 Jan 30
2
[LLVMdev] Edge Profiling
...-o sort_prof then I run the program and display the profiling information using llvm-prof sort_prof.bc, and the result is: ===-------------------------------------------------------------------------=== Function execution frequencies: ## Frequency 1. 4.3e+05/708539 main 2. 2.8e+05/708539 quickSort NOTE: 2 functions were never executed! ..... My question is regarding the execution frequencies. Does make any sense main executing 4.3e+05 times? Why so? The code I'm compiling is below. ###################### sort.c ######################## #include <stdio.h> #include <stdlib....
2012 Oct 03
0
[LLVMdev] Does LLVM optimize recursive call?
> Only if the recursion is very deep. In practice, a recursive descent > parser isn't going to run out of stack space, nor will a quicksort or > binary-tree walker, The recursive-descent parser case has happened in practice: http://my.opera.com/hallvors/blog/2012/07/17/twitter-crashes-itself-with-commas?1 Also, I've seen some recursion-related PR's in Clang, although I think that they are usually related to templates and n...
2006 Mar 11
1
Quicker quantiles?
Motivated by Deepayan's recent inquiries about the efficiency of the R 'quantile' function: http://tolstoy.newcastle.edu.au/R/devel/05/11/3305.html http://tolstoy.newcastle.edu.au/R/devel/06/03/4358.html I decided to try to revive an old project to implement a version of the Floyd and Rivest (1975) algorithm for finding quantiles with O(n) comparisons. I used
2023 Oct 16
1
Create new data frame with conditional sums
If one makes the reasonable assumption that Pct is much larger than Cutoff, sorting Cutoff is the expensive part e.g O(nlog2(n) for Quicksort (n = length Cutoff). I believe looping is O(n^2). Jeff's approach using findInterval may be faster. Of course implementation details matter. -- Bert On Mon, Oct 16, 2023 at 4:41?AM Leonard Mada <leo.mada at syonic.eu> wrote: > > Dear Jason, > > The code could look something...
1997 Sep 04
1
R-alpha: Sorting Efficiency
...is because the internal R code attempts to deal with missing observations. This is no longer needed because this is dealt with in the interpreted front end. An overall fix of the code should see us nearly match the performance of Splus. I say nearly because I think I will use heapsort instead of quicksort because I want to avoid worst-case performance rather than seek good average performance. I don't yet have an explanation of the behavior which Martin uncovered. Ross =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- r-devel mailing list -- Read http://www.ci.tuwi...
2016 Nov 15
9
Non-determinism in LLVM codegen
...Release vs Release+Asserts toolchains 3. Between Linux vs Windows toolchains The main reasons for the non-determinism in codegen are: 1. Iteration of unordered containers (like SmallPtrSet, DenseMap, etc) where the iteration order is undefined 2. Use of non-stable sorts (like std:sort which uses quicksort) where the relative order of elements with the same key is undefined I wanted a way to uncover instances where iteration of unordered containers results in different codegen. So I have written the following patch: *https://reviews.llvm.org/D26703* Given a flag (-mllvm -reverse-iterate) this pat...
2016 Nov 16
2
Non-determinism in LLVM codegen
...x vs Windows toolchains >> >> The main reasons for the non-determinism in codegen are: >> >> 1. Iteration of unordered containers (like SmallPtrSet, DenseMap, >> etc) where the iteration order is undefined >> 2. Use of non-stable sorts (like std:sort which uses quicksort) where >> the relative order of elements with the same key is undefined >> >> I wanted a way to uncover instances where iteration of unordered >> containers results in different codegen. >> So I have written the following patch: >> https://reviews.llvm.org/D2670...
2016 Dec 14
0
Non-determinism in LLVM codegen
...ains > 3. Between Linux vs Windows toolchains > > The main reasons for the non-determinism in codegen are: > > 1. Iteration of unordered containers (like SmallPtrSet, DenseMap, etc) > where the iteration order is undefined > 2. Use of non-stable sorts (like std:sort which uses quicksort) where > the relative order of elements with the same key is undefined > > I wanted a way to uncover instances where iteration of unordered > containers results in different codegen. > So I have written the following patch: > *https://reviews.llvm.org/D26703* > > Given a f...
2012 Oct 03
2
[LLVMdev] Does LLVM optimize recursive call?
> From: "Journeyer J. Joh" <oosaprogrammer at gmail.com> > I have a simple question about LLVM. > > I learned that we need to use iterations than recursions in C programming. > That is because recursion is expensive. It can easily consume out all > the stack given to a program. And the call/return consumes time much > more. > > But I've read a
2012 Oct 03
0
[LLVMdev] Does LLVM optimize recursive call?
Preston Briggs <preston.briggs at gmail.com> writes: > Think about costs asymptotically; that's what matters. Calls and > returns require constant time, just like addition and multiplication. Constant time, but not necessarily constant memory. Deep recursion will blow up your stack (AKA "segmentation fault" :-( ) if the compiler could not optimize it (tail recursion
1997 Sep 03
1
R-alpha: speed of sort(.) and order(.)
sort() and order() are not quite the same, as "one knows": o order allows breaking ties by more than one argument; o sort allows a 'partial' and 'na.last' argument Still, the following timing (on a `simple' UltraSparc I) suggest that actually two different algorithms are used > N <- 10000 > typeof(x0 <- 1:N) # --- x0 : already sorted --- [1]
2008 Feb 01
0
rsync Digest, Vol 62, Issue 1
...at came with fink on Mac > OS X (if the error has been fixed in the meantime, I will upgrade). Duh. I realize now that it's perfectly reasonable for you to be able to reproduce the problem while I can't. Versions 2.6.9 and earlier of rsync sort the file-list using the C library's quicksort, an unstable sort, ???so the results in case of duplicate files are highly sensitive to both the C library implementation and the order of directory entries in the source (which in turn is sensitive to the filesystem implementation). You probably have both a different C library and a different fil...
2023 Oct 16
1
Create new data frame with conditional sums
Dear Jason, The code could look something like: dummyData = data.frame(Tract=seq(1, 10, by=1), ?? ?Pct = c(0.05,0.03,0.01,0.12,0.21,0.04,0.07,0.09,0.06,0.03), ?? ?Totpop = c(4000,3500,4500,4100,3900,4250,5100,4700,4950,4800)) # Define the cutoffs # - allow for duplicate entries; by = 0.03; # by = 0.01; cutoffs <- seq(0, 0.20, by = by) # Create a new column with cutoffs dummyData$Cutoff
2015 Feb 05
5
[LLVMdev] RFC: Recursive inlining
...I see > > (qualitatively, poorly) 3 reasons for recursion in code that should > > go fast: > > > > > > 1. A fibonnacci function in a microbenchmark or compiler shootout. I > > think we can safely ignore this usecase... > > 2. Divide and conquer algorithms. Quicksort, FFT butterflies, etc. > > 3. Traversing a data structure, where the recursion is simply to get > > to the leaves which is where all the fun stuff happens. > > > > > > Points 2 and 3 both share a trait that they're dividing/fanning out > > at each step: >...
2015 Feb 05
5
[LLVMdev] RFC: Recursive inlining
...this is the most interesting case for recursion in real programs. I see (qualitatively, poorly) 3 reasons for recursion in code that should go fast: 1. A fibonnacci function in a microbenchmark or compiler shootout. I think we can safely ignore this usecase... 2. Divide and conquer algorithms. Quicksort, FFT butterflies, etc. 3. Traversing a data structure, where the recursion is simply to get to the leaves which is where all the fun stuff happens. Points 2 and 3 both share a trait that they're dividing/fanning out at each step: void ex3(i) { if (is_base(i)) { f();...
2010 Dec 15
6
Mysql query optimization for order condition
Hello everyone! I''ve a question that I hope someone in here would be able to answer. Today I was writing a simple test for a method that takes the last "n" (where n is an integer) users that signed up on my web app. I know it''s a simple method, but then I started to think about the optimal way to query the DB, and I tried different options. The first thing I did
2001 Apr 27
2
Benchmarking R, why sort() is so slow?
Hello everybody, I am making a modified version of "Stephan Steinhaus' benchmark test for number crunching, v. 2, (see http://www.scinetificweb.com/ncrunch/ncrunch.pdf for the original version), comparing several functions of some math/stat software. R is not performing bad at all... except for the sorting of a 1,100,000 random vector (test #3) which is the worst of all (see cell F3 in
2001 Apr 27
2
Benchmarking R, why sort() is so slow?
Hello everybody, I am making a modified version of "Stephan Steinhaus' benchmark test for number crunching, v. 2, (see http://www.scinetificweb.com/ncrunch/ncrunch.pdf for the original version), comparing several functions of some math/stat software. R is not performing bad at all... except for the sorting of a 1,100,000 random vector (test #3) which is the worst of all (see cell F3 in