ch 4 Structure of Algorithms

# ch 4 Structure of Algorithms - The Logical Structure of...

This preview shows pages 1–8. Sign up to view the full content.

An Introduction to Programming Using Alice The Logical Structure of Algorithms

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
An Introduction to Programming Using Alice Algorithms Algorithms contain the steps necessary to complete a particular task. A recipe for baking a cake has a list of the cake’s ingredients, as well as step-by-step instructions on what to do. The recipe provides an algorithm for baking a cake.
An Introduction to Programming Using Alice Algorithms When children learn long division, they are learning an algorithm. Algorithms are an important part of everyday life.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
An Introduction to Programming Using Alice Algorithms Professionals, such as engineers, architects, and doctors, apply many different algorithms in the course of their daily work.
An Introduction to Programming Using Alice for ( ; d < diag.end(); X+=incx, d++, Y+=incy) { *Y += alpha * *d * *X; } } void mult_conj_diag(const T& alpha, const T* x, int incx, T* y, int incy) const { const T* X = x; T* Y = y; typename vector<T>::const_iterator d= diag.begin(); for ( ; d < diag.end(); X+=incx, d++, Y+=incy) { *Y += alpha * conj(*d) * *X; } } void nondiag_mult_vec(const T& alpha, const T* x, int incx, T* y, int incy) const { int M = num_rows(); if (incy == 1) { for (int i=0; i<M; i++) y[i] += alpha * sp_dot_product(S[i], x, incx); } else { for (int i=0; i<M; i++) Some algorithms can be long and complex, such as this C++ code for performing matrix algebra.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
An Introduction to Programming Using Alice Algorithms Algorithms are sequential in nature. They form a kind of sequential logic. There are certain patterns in sequential logic that can be understood as elements of logical structure . The elements of logical structure are the building blocks of algorithms.
An Introduction to Programming Using Alice Elements of Logical Structure In the 1960’s two Italian mathematicians, Corrado Böhm and Giuseppe Jacopini, showed that algorithms are composed of three major structures: linear sequences selection sequences repetition sequences

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern