IGCSE 6 Cambridge Effectiveness of algorithms Computer Science

Slides:



Advertisements
Similar presentations
CPSC 171 Introduction to Computer Science Efficiency of Algorithms.
Advertisements

Topic 7 Standard Algorithms Learning Objectives Describe and exemplify the following standard algorithms in pseudocode and an appropriate high level.
Sorting CMSC 201. Sorting In computer science, there is often more than one way to do something. Sorting is a good example of this!
8 Algorithms Foundations of Computer Science ã Cengage Learning.
Learning Objectives Explain similarities and differences among algorithms, programs, and heuristic solutions List the five essential properties of an algorithm.
Scott Grissom, copyright 2004 Chapter 5 Slide 1 Analysis of Algorithms (Ch 5) Chapter 5 focuses on: algorithm analysis searching algorithms sorting algorithms.
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (3) Recurrence Relation 11/11 ~ 11/14/2008 Yang Song.
Chapter 3: The Efficiency of Algorithms
Illuminating Computer Science CCIT 4-6Sep
计算机科学概述 Introduction to Computer Science 陆嘉恒 中国人民大学 信息学院
Chapter 10 Strings, Searches, Sorts, and Modifications Midterm Review By Ben Razon AP Computer Science Period 3.
ดร.สุรศักดิ์ มังสิงห์ SPU, Computer Science Dept.
Searching and Sorting Chapter Sorting Arrays.
Chapter 11Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 11 l Basics of Recursion l Programming with Recursion Recursion.
ALGORITHMS.
Course Code #IDCGRF001-A 5.1: Searching and sorting concepts Programming Techniques.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Technical Writing with Taste How to write Directions/Procedures for Middle School Science
Binary & Normalization What is Normalization? We discussed this the other day (special review session slides, near the end) Can someone tell us.
1 The Role of Algorithms in Computing. 2 Computational problems A computational problem specifies an input-output relationship  What does the.
Lists and Sorting Algorithms
OCR A Level F453: Data structures and data manipulation Data structures and data manipulation a. explain how static data structures may be.
Recursion Riley Chapter 14 Sections 14.1 – 14.5 (14.6 optional)
Component 1.6.
Sort Algorithm.
CSE15 Discrete Mathematics 03/06/17
Searching and Sorting Algorithms
Sort & Search Algorithms
Growth of Functions & Algorithms
Applied Discrete Mathematics Week 2: Functions and Sequences
Outline lecture Revise arrays Entering into an array
Week 9 - Monday CS 113.
Week 13: Searching and Sorting
May 17th – Comparison Sorts
Formatting Output.
Lesson Objectives Aims Understand the following “standard algorithms”:
COMP 103 SORTING Lindsay Groves 2016-T2 Lecture 26
Algorithm Analysis CSE 2011 Winter September 2018.
Enough Mathematical Appetizers!
Last Class We Covered Data representation Binary numbers ASCII values
Algorithms Chapter 3 With Question/Answer Animations
Lower Bound Theory.
Data Structures and Organization (p.2 – Arrays)
Computational Thinking
Lesson 15: Processing Arrays
Scratch Where Are You Now?
MSIS 655 Advanced Business Applications Programming
Applied Discrete Mathematics Week 6: Computation
Sorting … and Insertion Sort.
Discrete Mathematics CMP-101 Lecture 12 Sorting, Bubble Sort, Insertion Sort, Greedy Algorithms Abdul Hameed
Algorithm Discovery and Design
IT 4043 Data Structures and Algorithms
Data Structures (CS212D) Week # 2: Arrays.
Chapter 11 Limitations of Algorithm Power
Sorting "There's nothing in your head the sorting hat can't see. So try me on and I will tell you where you ought to be." -The Sorting Hat, Harry Potter.
Basics of Recursion Programming with Recursion
Arrays Week 2.
Introduction to Data Structures
Algorithms Step-by-step instructions that tell a computing agent how to solve some problem using only finite resources Resources Memory CPU cycles Time/Space.
PYTHON: BUILDING BLOCKS Sequencing & Selection
Algorithms Step-by-step instructions that tell a computing agent how to solve some problem using only finite resources Resources Memory CPU cycles Time/Space.
COMPUTATIONAL THINKING COMPUTATIONAL THINKING IN PROGRAMMING
Converting to Base-n from Base-10
Principles of Computing – UFCFA3-30-1
Multiplying Decimals and Whole Numbers
Discrete Mathematics CS 2610
Divide and Conquer Merge sort and quick sort Binary search
Multiplying Decimals Multiply and divide decimals and fractions, using efficient and generalizing procedures, including standard algorithms.
Algorithms Tutorial 27th Sept, 2019.
Presentation transcript:

IGCSE 6 Cambridge Effectiveness of algorithms Computer Science Section 2 Effectiveness of algorithms Unit 7 Algorithm design and problem-solving 6

Objectives Produce an algorithm for a given problem Explain standard methods of solution Comment on the effectiveness of a given solution Use a trace table to find the value of variables at each step in an algorithm

Designing an algorithm Designing an algorithm involves developing a set of instructions to solve a problem The instructions need to work for any instance of the problem Sometimes it helps to figure out a solution to one particular instance, and from that, understand how to solve the general problem

Multiplying by ten How do you multiply an integer by 10? Why is this easier than multiplying by 9 or by 11? What is special about the number 10? 4623 x 10 = 46230

Multiplying by the number base Decimal numbers use 10 digits 0..9 They are base 10 numbers Binary digits use two digits 0 and 1. They are base 2 numbers What do you get when you multiply the binary number 1001101 by 2? (Remember that 2 converts to 10 in binary) From this instance you can work out a general solution to the problem of multiplying a number by its “base”!

Evaluating an algorithm When designing an algorithm, you need to consider whether it is the best solution, or even a good solution Does it always give the correct answer? Is it fast enough? Is it economical in terms of resources (e.g. memory, disk space or computational power)? Is it easy for someone to use?

Efficiency of an algorithm When designing an algorithm, you need to consider whether it is the best solution, or even a good solution An algorithm which works well for a few items may not be suitable for a large number of items! Could you use this algorithm to add the numbers 1 to 1000? total = 1 + 2 + 3 Output total

A better algorithm What goes in the blank decision box? total = 0 Output total total = 0 count = 0 count = count + 1 total = total + count No Yes

An even better solution 1 + 2 + 3 + ……1000 + 1000 + 999 + 998 + ….. 1 = 1001 + 1001 + 1001 + …… 1001 = 1000 * 1001 Total = n * (n + 1) / 2 Output Total n = 1000 Output Total

A search algorithm Ask a friend to think of an integer between 1 and 20 Each time they guess, tell them whether the guess was too high, too low or spot on How many guesses did it take to get the right number? What algorithm were they using to solve the problem?

See Binary video

The binary search algorithm This is a very efficient algorithm for finding a particular item in a sorted array or file Think of how you might search for a name in a telephone directory If you’re searching for Richards, you might open the page and find Smith Then you try a few pages back and find Patel What next?

The binary search algorithm Can be applied to guessing a number x between 1 and n Compare x with the middle element m of the set of numbers If x = guess, then the item is found Otherwise, if x < m, repeat the search on the subset to the left of the middle element Or, if x > m, repeat the search on the subset to the right of the middle element For example, suppose your partner thought of the number 6 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 3 Guess 1 too high Guess 4 – found it!

Worksheet 6 Try Tasks 1 and 2 on the worksheet

Extension - Sorting Sorting is a very common operation in data processing applications Why would you need to sort data? There are many sorting algorithms and they vary wildly in their efficiency The merge sort is 200 times faster than a bubble sort for sorting 10,000 items

The bubble sort The bubble sort is not efficient for a large number of items, but it is a simple algorithm to follow Each item in a list is compared to the one next to it, and if it is greater, they swap places At the end of one pass through the list, the largest item is at the end of the list This is repeated until the items are sorted

Worksheet 6 Try Task 3 on the worksheet

Plenary You’ve had lots of practice at constructing and testing algorithms You’ve learned how to use a trace table to find out what’s going on in an algorithm You’ve learned something about the effectiveness of different solutions to problems You’re ready for the final assessment test!