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

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

View Full Document Right Arrow Icon
An Introduction to Programming Using Alice The Logical Structure of Algorithms
Image of page 1

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

View Full Document Right Arrow Icon
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.
Image of page 2
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.
Image of page 3

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

View Full Document Right Arrow Icon
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.
Image of page 4
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.
Image of page 5

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

View Full Document Right Arrow Icon
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.
Image of page 6
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
Image of page 7

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

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern