From: BryanW Date: 2007-04-14T00:27:13+09:00 Subject: Re: Computer Science Math - For the Uninitiated ------=_Part_4720_6318783.1176478031641 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Don, Actually there is just a bit of math there, but none of it is complex at all, at least in the conceptual realm. What you are looking at is a bit of pseudo-code. It's not actually any specific language but borrows common bits from many such as: iteration (for loops in this case) indexing (that's the A[j] notation you see, as it refers to the jth element of an array called A, conditional statements (if (something is true) then (do something) comparison (in this case comparing adjacent array elements: A[j] and A[j-1]) function calls ( swap(Array element 1, Array element 2) is a particularly bad example but it communicates the idea of swapping the position of two elements in an array based on a comparison) As you get into your book you'd actually find out that from a design stand point you're most interested in the looping structure of that code, since being able to predict how many times the code has to do the comparison and swap operations will till you how expensive it is in computer cycles. My advice is: don't worry about the pseudo-code as long as you can understand how it uses the basic concepts such as those listed above. More important is being able to translate those concepts into your language of choice such as Ruby. Ruby would have many many ways of doing an insertion sort, and it might be worthwhile to code a couple just for practice. Also, while the Knuth work is the seminal standard, it's not at all easy to work with (His code snippets tend to resemble Assembly language), and a more basic text will give you a better introduction to the material your working with. Hope this helps, Bryan W On 4/12/07, Don Levan wrote: > > Hello all, > > A journey that has taken me from developing in Filemaker through the > self study of Ruby, Rails, and regular expressions has led me to > begin looking at algorithms and data structures. Though I don't have > a traditional computer science background, I am trying to educate > myself as best I can. > > I am begin stymied by what looks like math but is greek to me. For > example, on the first page of the book I am reading (The Algorithm > Design Manual, b Steven Skinea), there is this description of the > insertion sort algorithm: > > for i = 1 to n - 1 do > for j = i downto 2 do > if (A[j] < A[j-1]) then swap(A[j],A[j-1]) > > I can struggle through it, but I am wondering 1) what branch of math > is this? Is it algebra or something more complex? And 2) are there > any good (and accessible) books that will give me a basic > introduction to the language conventions? > > Thanks so much, > > Don Levan > Brooklyn, New York > > ------=_Part_4720_6318783.1176478031641--