ch 4 Structure of Algorithms

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

Info iconThis 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
Background image of page 1

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

View Full DocumentRight 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.
Background 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.
Background image of page 3

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

View Full DocumentRight 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.
Background 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 { Some algorithms can be long and complex, such as this C++ code for performing matrix algebra.
Background image of page 5

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

View Full DocumentRight 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.
Background 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
Background image of page 7

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

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

This note was uploaded on 10/17/2011 for the course CIS 106 taught by Professor Alice during the Spring '11 term at Community College of Philadelphia.

Page1 / 31

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

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online