Algorithms

Teaching students
Suitable
Teaching educators
Suitable

Preview slides with notes

We recommend previewing these slides on a larger screen to view the slides and speaker notes easily.

Algorithms

Key questions

  • What is an algorithm?
  • How is an algorithm different from a program?

As an algorithm


    set the maximum_so_far to the first number

    for each other number:
        if the next number is larger than maximum_so_far:
            set maximum_so_far to the number

    At the end, maximum_so_far contains the largest value

As an algorithm


    set the maximum_so_far to the first number

    for each other number:
        if the next number is larger than maximum_so_far:
            set maximum_so_far to the number

    At the end, maximum_so_far contains the largest value

As an algorithm


    set the maximum_so_far to the first number

    for each other number:
        if the next number is larger than maximum_so_far:
            set maximum_so_far to the number

    At the end, maximum_so_far contains the largest value

As an algorithm


    set the maximum_so_far to the first number

    for each other number:
        if the next number is larger than maximum_so_far:
            set maximum_so_far to the number

    At the end, maximum_so_far contains the largest value

As an algorithm


    set the maximum_so_far to the first number

    for each other number:
        if the next number is larger than maximum_so_far:
            set maximum_so_far to the number

    At the end, maximum_so_far contains the largest value

Scratch

whenclickedaskType in a scoreandwaitsetmax so fartoanswerrepeat4askType in a scoreandwaitifanswer>maxsofarthensetmax so fartoanswersayjoinHigh score wasmaxsofarfor10seconds

Scratch

whenclickedaskType in a scoreandwaitsetmax so fartoanswerrepeat4askType in a scoreandwaitifanswer>maxsofarthensetmax so fartoanswersayjoinHigh score wasmaxsofarfor10seconds

Scratch

whenclickedaskType in a scoreandwaitsetmax so fartoanswerrepeat4askType in a scoreandwaitifanswer>maxsofarthensetmax so fartoanswersayjoinHigh score wasmaxsofarfor10seconds

Scratch

whenclickedaskType in a scoreandwaitsetmax so fartoanswerrepeat4askType in a scoreandwaitifanswer>maxsofarthensetmax so fartoanswersayjoinHigh score wasmaxsofarfor10seconds

Python


            max_so_far = int(input("Type in a score: "))

            for i in range(4):
                score = int(input("Type in a score: "))
                if score > max_so_far:
                    max_so_far = score

            print("High score was", max_so_far)
        

Python


            max_so_far = int(input("Type in a score: "))

            for i in range(4):
                score = int(input("Type in a score: "))
                if score > max_so_far:
                    max_so_far = score

            print("High score was", max_so_far)
        

Python


            max_so_far = int(input("Type in a score: "))

            for i in range(4):
                score = int(input("Type in a score: "))
                if score > max_so_far:
                    max_so_far = score

            print("High score was", max_so_far)
        

Python


            max_so_far = int(input("Type in a score: "))

            for i in range(4):
                score = int(input("Type in a score: "))
                if score > max_so_far:
                    max_so_far = score

            print("High score was", max_so_far)
        

Python


            max_so_far = int(input("Type in a score: "))

            for i in range(4):
                score = int(input("Type in a score: "))
                if score > max_so_far:
                    max_so_far = score

            print("High score was", max_so_far)
        

Key questions

  • What is an algorithm?
  • How is an algorithm different from a program?

Supporting Resources