Introduction to Algorithms and Computer Science - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Introduction to Algorithms and Computer Science

Description:

Introduction to Algorithms and Computer Science CS in a nutshell Computer scientists are on Calvin s side: Do it once, then never again. – PowerPoint PPT presentation

Number of Views:212
Avg rating:3.0/5.0
Slides: 12
Provided by: Suzan123
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Algorithms and Computer Science


1
Introduction to Algorithms and Computer Science
2
CS in a nutshell
  • Computer scientists are on Calvins side
  • Do it once, then never again.
  • Can do more difficult versions of same task.
  • The technology could be adapted to other tasks.
  • Building a robot is just more fun!

3
CS Vocabulary
  • Algorithm A detailed, unambiguous set of
    instructions to carry out a given task.
  • Alphabet A set of characters.
  • Ex English alphabet, ASCII alphabet, binary
    alphabet (0,1), DNA alphabet (A,T,C,G), amino
    acid alphabet.
  • String A set of characters from an alphabet in a
    particular order.
  • Empty string A string containing no characters

4
CS Vocabulary
  • Identifier a string associated with a value. The
    value can be either constant or a variable.
  • Constant a value for something that remains the
    same throughout an algorithm.
  • Variable a value associated with an identifier
    that can change as we execute and algorithm.

5
CS Vocabulary
  • Substring A set of characters that appear in
    order and consecutively in another string.
  • Ex cat is a substring of concatenate
  • Subsequence A set of characters that appear in
    order but not necessarily consecutively in
    another string.
  • Ex cat is a subsequence of correlate but not
    a substring.

6
CS Vocabulary
  • Prefix A substring entirely at the beginning of
    a string.
  • Suffix A substring entirely at the end of a
    string.
  • Concatenate To combine two strings by attaching
    the end of one to the beginning of the other to
    create a third string.
  • Ex Concatenating cat and bird gives catbird

7
Building An Algorithm
  • Computers are dumb
  • Human instructions Pour me a cup of coffee.
  • Computer Instructions
  • Walk to the coffee pot.
  • Is there a cup? If not get a cup out of the
    cupboard.
  • Is the cup right side up? If not, turn it over.
  • Is the cup clean? If not, get another cup out of
    the cupboard and make sure it is right side up
    and clean.
  • Pour coffee into cup.
  • Return to me with cup containing coffee.

8
Flowcharts
  • A way of organizing an algorithm visualy
  • Rectangles are instructions
  • Diamonds are decisions
  • Ovals represent end points
  • Arrows move between different shapes
  • A rectangle has 1 arrow from it, a diamond has 2.
  • A shape can have any number of arrows leading to
    it.
  • To follow the algorithm, just follow the arrows

9
Flowchart for coffee algorithm
Walk to coffee pot.
Is it right-side up?
Y
Y
Is there a cup?
Is the cup clean?
Pour coffee into cup.
Y
N
N
N
Get out a cup.
Turn cup over.
Return to me.
Give me cup.
Done
10
Algorithm to Do a Punnett Square
  • Task Given maternal and paternal genotypes, give
    the resulting punnett square of genotypes for the
    offspring and calculate the phenotype ratio for
    the offspring.
  • We will be looking at pea plant height with T
    tall and t short, with T dominant.
  • Make an algorithm to allow a computer to do this,
    and write your algorithm in the form of a
    flowchart.

11
Algorithm to Do a Punnett Square
  • Our computer can do the following tasks
  • Give a name to a note card
  • Put 1 number or 1 string on a named card
  • Read the value off a named card
  • If value is a string, can read a single character
    if we are given the number of that character in
    the string
  • Change the value on a named card
  • Do anything involving the 4 basic math functions
  • Check all the comparisons , ?, lt, , gt,
Write a Comment
User Comments (0)
About PowerShow.com