In- place quick sort - Ruby [duplicate] - ruby

This question already has answers here:
Quick Sort in Ruby language
(6 answers)
Closed 7 years ago.
I'm having trouble wrapping my head around a in-place quick sort. I understand it using sub-arrays, but in-place is really throwing me.
Having an example in Ruby would really help, but I haven been able to find one. Could some one provide me with an example or point me in the right direction?

Rather than trying to understand it in code, there's a number of very elegant explanations of the quicksort algorithm out there. Here are a few of my favorite illustrations which may help your understanding.
With cups
With Hungarian Dance
As for a Ruby example, the answers to this question cover that.

Related

Python : Which Sort Method is used behind .sort()? [duplicate]

This question already has answers here:
What algorithm does Python's built-in sort() method use?
(2 answers)
Closed 7 years ago.
I have always heard that usually merge sort is used for in built functions. But I cannot understand why. Quicksort is faster obviously with exact time complexity of 1.39NlogN and also it is in place! then why not quick sort?
timesort algo is used in the inbuilt sort

Can someone explain the QR-Code image generation/encoding algorithm by example? [duplicate]

This question already has answers here:
Encode algorithm QR-code
(4 answers)
Closed 4 years ago.
Right now I am working for development of qrcode algorithm for past time project.
Can someone explain the main principle of this algorithm with example?
As an example, I'd like to convert the simple statement "I love StackOverflow" into a matrix representation of a qr-code.
If you really want to understand the encoding, you really need to buy the ISO specification (18004:2006). Nothing else will give you full detail enough to implement encoding.
Of course you can also look at source code implementing QR code encoding, if that's all you need. See zxing.

Algorithms/problems to solve while learning a new language [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
At some point in our lives we're put in the situation to learn a new language (either by job requirements or just passion). Personally, I'm trying to learn Objective-C coming from a background of several years coding php. My problem is that I'm bored with your average starting programs (most of them coming from maths; eg: Fibonacci).
What are your first algorithms and programs you write when learning a new language?
I'm thinking we could make a list of interesting problems to be solved and that would make the learning curve at least more entertaining.
Later edit:
My question is about fun things (and also useful), but not like Code Kata or other very boring math stuff (I've done many of those already)
Later edit [ 2 ]:
I found this today and the problems there seem fun to do.
Try to develop something proper, a project of some kind; solving algorithmic problems really only teaches you to apply the algorithm, not really a lot about the language your using.
Deciding on a useful project then deciding on a language and then 'doing it' will cover many of the bases you need to learn a new language.
I like this series of articles by Larry O'Brien.
http://www.knowing.net/index.php/2006/06/16/15-exercises-to-know-a-programming-language-part-1/
http://www.knowing.net/index.php/2006/06/16/15-exercises-to-know-a-programming-language-part-2-data-structures/
http://www.knowing.net/index.php/2006/06/16/15-exercises-to-know-a-programming-language-part-3-libraries-frameworks-and-mashups/
Have a look at these:
How do you find interesting problems to solve?
https://stackoverflow.com/questions/6327/what-are-your-programming-exercises
Just as an idea: Look at the problems of the The Computer Language Benchmarks Game.
When you've done a snippet, you can compare your solutution to the provided one.
Whenever I pick up a new language, I try using it to solve the problems at SPOJ. They basically support every mainstream language out there (as well as a few esolangs like Intercal and Whitespace). The problems are mostly from various ACM and similar format contests around the world and so can be quite hard, and perhaps be too CS/math for everyone's tastes. The tutorial problems are quite doable in any language.
I would also recommend adding that language's tag to your SO interested tags list. Many SO questions involve small snippets of code, and trying to answer them and looking at the other answers can be very enlightening.
But as soon as I've got the basics right, the strategy I choose is to try my hand at a very small project. Usually this a simple game, GUI app or a tiny webapp. This is valuable since there are some things you cannot learn by only doing small isolated blobs of code.
Try to solve these challenges using your new language. What's it all about:
In software we do our practicing on
the job, and that’s why we make
mistakes on the job. We need to find
ways of splitting the practice from
the profession. We need practice
sessions...
I sometimes use the exercises from the first few chapters of Structure and Interpretation of Computer Programs.
You can also try to understand or improve existing open source projects as suggested in this so question. Even though the answers are cocoa biased it should be a good starting point.
This way you can dive in to the level of your choice (understand, debug, improve) and in direction of your interest (UI, specific library, etc, etc...).
EDIT: When I said starting point, I meant that you can browse repositories for objective-c code, for example sourceforge

How can I get better at/learn more about Ruby? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I have recently started learning Ruby, as my first programming language. I feel comfortable with the syntax, and I've done numerous tutorials that just teach the same basics. I have written a few small programs (including my own method for sorting an array that I thought was pretty smart until someone told me to Google 'Bubble Sort'), but I feel I need to attempt something bigger and harder to understand more about Ruby. Any ideas as to how I can do this?
Ruby Resources
http://www.rubyist.net/~slagell/ruby/
http://web.njit.edu/all_topics/Prog_Lang_Docs/html/ruby/syntax.html
http://www.ruby-doc.org/core-1.8.7/index.html
http://en.wikipedia.org/wiki/Ruby_(programming_language)
http://pleac.sourceforge.net/pleac_ruby.html
http://www.zenspider.com/Languages/Ruby/QuickRef.html
http://www.ruby-doc.org/docs/ProgrammingRuby/
The "advanced" Ruby book is The Ruby Way by Hal Fulton. It wouldn't hurt to read some real Ruby code - most gem's will do for this.
Finally, you need a project. You could take a program you have already written and redo it in Ruby, or you could think of something new to write.
Rubylearning Blog is hosting a fortnightly contest. The first contest went live - http://rubylearning.com/blog/2009/09/24/rpcfn-shift-subtitle-1/
That should be a start :)
A few years back I worked through Dave Thomas' Code Kata as part of a similar exercise. Fairly simple, self-contained pieces that let me explore the language at my own speed.
The kata idea seems to be moderately popular with developers, particularly at the Agile end - Googling "code kata" with and without "ruby" ought to throw up some more ideas.
fellow newbie. :) I too have just recently started learning ruby.
Right now, I'm reading The Ruby Way. Although I'm not required to code at work, I try to find practical applications of ruby -- no matter how mundane. For instance, I prepared scripts when I needed to test something that required several files with 0 file size and when i needed to generate an xml file based on another xml file; and since there was a tennis meet at work, i tried to create a script for random pairing or grouping. (Little baby steps, i know)
My colleague has written a post listing out the resources that a Ruby newbie would find useful. It was primarily intended for members of our local Ruby User Group, but it should be useful to you too.
More importantly, a lot has changed in the last couple of years and this post is pretty up-to-date (as of September 2012).
Here's the link: http://www.jasimabasheer.com/posts/meta_introduction_to_ruby.html

Good refresher course on 'O(N)' type stuff? [duplicate]

This question already has answers here:
Closed 13 years ago.
Learned all about computing algorithm costs in College, but that was so long ago I forgot it all. Is there any sort of walkthrough that goes over the whole subject matter? I feel as though there was more than I currently remember. I want to refresh some of my core skills.
Check out Big-O for Eight Year Olds?
You should be able to find various tutorials by searching for complexity analysis.
Wikipedia (Analysis of algorithms) is always a good place to get a quick refresher.
This is a good resource with some tests:
Complexity and Big-O Notation

Resources