1 / 27

Computational Thinking, Problem-Solving and Programming

Topic 4. Computational Thinking, Problem-Solving and Programming. Assessment Objectives. Assessment objective 1 : classify, define, draw, label, list, state Assessment objective 2 : annotate, apply, calculate, describe, design, distinguish, estimate, identify, outline , present, trace

maree
Download Presentation

Computational Thinking, Problem-Solving and Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Topic 4 Computational Thinking, Problem-Solving and Programming

  2. Assessment Objectives • Assessment objective 1: classify, define, draw, label, list, state • Assessment objective 2: annotate, apply, calculate, describe, design, distinguish, estimate, identify, outline, present, trace • Assessment objective 3: analyse, comment, compare, compare and contrast, construct, contrast, deduce, demonstrate, derive, determine, discuss, evaluate, examine, explain, formulate, interpret, investigate, justify, predict, sketch, suggest, to what extent

  3. Computational Thinking • Five different types of computational thinking • Find out what they are • Examples of each

  4. Example • You have decided to invite your friends over to watch the big basketball game. You are going to make food for everyone. • How will you use computational thinking to make sure your day goes well? • Give examples of where you can apply each of the five types of computational thinking to this situation.

  5. Thinking Ahead • Think back to the basketball game task • In what ways did you need to think ahead? • What examples of thinking ahead do you know of from the world of computing?

  6. Pre-conditions and post-conditions • A method of specifying what a procedure accomplishes without going into the details of how it works Go and write me a function. I don't care how you do it, just make sure these requirements are met.

  7. Example void print_sqrt(double d) { // pre-condition: d>=0 // post-condtion: sqrt(d) written // to standard output } You should add these comments to every non-trivial method that you write in your Java IA

  8. Working in teams Your job is to write the function. When I call it, I will ensure that the pre-conditions are met. But just to be on the safe side my function will checkif a pre-condition has been violated, and reportan error if it has. Well as long as you meet the pre-conditions, I guarantee it will work.

  9. Conditions to Decisions • IB documentation wants you to realise that pre- and post-conditions affect the decisions that will be made in the implementation of the function • Think back to the sqrt() function • Give an example of an if… then…block that will follow from the preconditions

  10. Your turn • Consider a function that tells you how many times a particular letter occurs within a word • What pre- and post-conditions will there be? • Write the function in Java, and link the decisions in the function to the conditions outside it

  11. Decomposition in subtasks. Thinking procedurally, thinking ahead, thinking concurrently. Gantt charts

  12. Review • What are the five types of computational thinking?

  13. Concurrent thinking in everyday life • Things to do: • Put the clothes into the washing machine and turn it on • Take the clothes out of the washing machine and hang them up • Put the food into the oven • Take the food out of the oven • What order is best?

  14. Thinking concurrently • What examples of concurrent thinking can you think of from the world of computer science? • Multi-tasking OS • time-slicing • scheduling • interrupts • RDBMS (database) • transactions

  15. Dining Philosophers • Philosophers like to think a bit, eat a bit, think a bit, etc. • Need two chopsticks to eat • Have to pick them up one at a time • Can't steal them from someone else! DEADLOCK

  16. Thinking Abstractly • a publication • a newspaper • The San Francisco Chronicle • the May 18 edition of the The San Francisco Chronicle • my copy of the May 18 edition of the The San Francisco Chronicle • my copy of the May 18 edition of the The San Francisco Chronicle as it was when I first picked it up (as contrasted with my copy as it was a few days later: in my fireplace, burning)

  17. Abstraction • Considering the same object from different viewpoints • Different aspects of the object are important to different audiences • Describe a car from the viewpoint of: • A driver • A mechanic • A physicist • What are the benefits of abstraction? How does it help us?

  18. The best example of abstraction in the world ever

  19. Different names for different types of packet Some abstractions HTTP Packet IP Datagram TCP Segment Ethernet Frame

  20. Task: The OSI Model and abstraction • Write a brief outline of how the OSI Model uses abstraction. • How does it make complex tasks simple? • What does each layer know about the one below? • What does each packet know about its payload? • Imagine you are Mr Brown and you want to send a letter to the head of ISKL. What layers of abstraction exist to facilitate this process? Describe them and explain why they are useful.

  21. Flowcharts

  22. This algorithm finds the index of TARGET within an ARRAY of N elements. Check that you understand how the algorithm works by explaining how you could tell whether or not TARGET was found. START I = 0 I = N? yes STOP no ARRAY[I]=TARGET? yes STOP no I = I + 1

  23. Tasks • Flowchart for finding a given value in an array • Flowchart for BubbleSort • Trace tables • Read chapter from the blog • Do exercises

  24. Task: Produce a trace table int a = 2, b = 4, c; int x = 20, y = 20; for (inti = 0; i < 3; i ++) { System.out.print(" i = " + i); for ( int j = 0; j < 3; j ++) { c = a * b; System.out.print(" c = " + c); a ++; b ++; x += 20; } // end inner loop x = 20; y += 20; } // end outer loop

  25. Do this exercise quietly, on your own. Don't shout out the answers. Let other people work. START • Trace this flowchart for B = 26, N = 7 • State what the algorithm does and note preconditions and postconditions • Write the algorithm in pseudocode • Write the algorithm as a method in Java. (B and N should be passed into the method as parameters. A and B should be returned by the method.) INPUT B, N A = 0 B – N < 1? yes no OUTPUT A, B A = A + 1 B = B - N STOP

  26. Practice on these Do this exercise quietly, on your own. Don't shout out the answers. Let other people work. An algorithm that takes an integer input N and prints the sum of all numbers from one up to N An algorithm that takes an integer array input A[] and prints out the largest number in A[] An algorithm that takes an integer array input A[] and output true if it is sorted (ascending or descending) and false otherwise An algorithm that takes an integer input N and prints out all the integer factors of N An algorithm that takes an integer input N and prints out the Nth triangular number An algorithm that takes an integer argument N and outputs its position in linked list LIST, or -1 if it is not found An algorithm that takes an integer input N and prints the Fibonacci sequence up to N An algorithm that takes an integer array input A[] and prints out true if it is palindromic and false otherwise An algorithm that takes integer arguments N and B and prints N out in base B (assuming that N is denary to start with) An algorithm that takes a 2d integer array argument A[][] and outputs the sum of each column An algorithm takes takes an integer N and a sorted array A[] and inserts N in the right place in A An algorithm that takes string input A and B and outputs true if A is a substring of B and false if not

  27. Assembly Tutorial • http://skilldrick.github.io/easy6502/

More Related