Docsity

Techniques and Concepts Algorithms - Introduction to Computing - Lecture Slides, Slides of Introduction to Computing

Partial preview of the text

Download Techniques and Concepts Algorithms - Introduction to Computing - Lecture Slides and more Slides Introduction to Computing in PDF only on Docsity!

CS101 Introduction to Computing

Lecture 16

Algorithms I

Focus of the last lecture was on Word Processing

  • First among the four lectures that we plan to have on productivity software, a sub-category of application software
  • That first lecture was on WP
  • We learnt about what we mean by WP and also desktop publishing
  • We also discussed the usage of various functions provided by common WP’s (^2)

Solving Problems (1)

When faced with a problem:

  1. We first clearly define the problem
  2. Think of possible solutions
  3. Select the one that we think is the best under the prevailing circumstances
  4. And then apply that solution
  5. If the solution woks as desired, fine; else we go back to step 2

Solving Problems (2)

  • It is quite common to first solve a problem for a particular case
  • Then for another
  • And, possibly another
  • And watch for patterns and trends that emerge
  • And to use the knowledge form those patterns and trends in coming up with a general solution

al.go.rithm

Sequence of steps that can be taken to solve a given problem

7

steps

sequence

Examples

  • Addition
  • Conversion from decimal to binary
  • The process of boiling an egg
  • The process of mailing a letter
  • Sorting
  • Searching

Convert 75 to Binary

10

1001011

remainder

Algorithm for Decimal-to-Binary Conversion

  1. Write the decimal number
  2. Divide by 2; write quotient and remainder
  3. Repeat step 2 on the quotient; keep on repeating

until the quotient becomes zero

  1. Write all remainder digits in the reverse order (last

remainder first) to form the final result

Algorithm (Better Definition)

1 st^ Definition:

Sequence of steps that can be taken to solve a problem

Better Definition:

A precise sequence of a limited number of unambiguous, executable steps that terminates in the form of a solution

Three Requirements:

  1. Sequence is:

a. Precise b. Consists of a limited number of steps

  1. Each step is:

a. Unambiguous b. Executable

  1. The sequence of steps terminates in the

form of a solution (^) Docsity.com 14

Why Write an Algorithm Down?

  • For your own use in the future, so that you don’t

have spend the time for rethinking it

  • Written form is easier to modify and improve
  • Makes it easy when explaining the process to

others

Analysis of Algorithms

  • Analysis in the context of algorithms is concerned with predicting the resources that re requires: - Computational time - Memory - Bandwidth - Logic functions
  • However, Time – generally measured in terms of the number of steps required to execute an algorithm - is the resource of most interest
  • By analyzing several candidate algorithms, the most efficient one(s) can be identified

Early History: Search for a Generic Algorithm

  • The study of algorithms began with mathematicians

and was a significant area of work in the early years

  • The goal of those early studies was to find a single,

general algorithm that could solve all problems of a single type

Origin of the Term “Algorithm”

  • The name derives from the title of a Latin book: Algoritmi de numero Indorum
  • That book was a translation of an Arabic book: Al- Khwarizmi Concerning the Hindu Art of Reckoning
  • That book was written by the famous 9-th century Muslim mathematician, Muhammad ibn Musa al- Khwarizmi