manipulating an abstraction iteration
play

Manipulating an Abstraction (Iteration) CT @ VT An algorithm with - PowerPoint PPT Presentation

Introduction to Computational Thinking Manipulating an Abstraction (Iteration) CT @ VT An algorithm with iteration START BOOK LIST = get all books TOTAL = 0 for each BOOK grab next book in BOOK LIST no more books TOTAL = TOTAL + current


  1. Introduction to Computational Thinking Manipulating an Abstraction (Iteration)

  2. CT @ VT An algorithm with iteration START BOOK LIST = get all books TOTAL = 0 for each BOOK grab next book in BOOK LIST no more books TOTAL = TOTAL + current BOOK’s price print TOTAL END Fall 201 2015 Slide 2

  3. CT @ VT Combining iteration and decision START BOOK LIST = get all books TOTAL = 0 for each BOOK in grab next book BOOK LIST true no more books BOOK’s price > $40 false print TOTAL TOTAL = TOTAL + current BOOK’s price END Fall 201 2015 Slide 3

  4. CT @ VT Abstraction and Big Data  Abstraction identifies the properties of interest of some kind of artifact (books, people, …)  We are not interested in the abstraction of a single instance (one book, one person,…) but a large number of instances of that kind  Examples: Big Data set … each instance has… All Books on Amazon Author, title, price All Movies on NetFlix Title, rating, length All Stocks on NYSE Name, price, date, time All Temperatures in US City, state, temperature Fall 201 2015 Slide 4

  5. CT @ VT Iteration and Big Data  Definition  repeatedly executing a set of statements  where some data is different on each execution  until a condition changes  If it works for a few items it will work for millions of items!! AKA: looping, repetition Fall 201 2015 Slide 5

  6. CT @ VT Example City:  Temperature abstraction State: Temperature:  Temperature data set City: Miami City: New York City: Blacksburg City: Los Angeles City: Ames State: FL State: NY State: VA State: CA State: IA Temperature: 89 Temperature: 86 Temperature: 77 Temperature: 100 Temperature: 65  Iteration can be used to process a data set  Each element is processed once  Each iteration applies the statements to the “current” element  The iteration continues as long as there are more elements remaining that have not been processed Fall 201 2015 Slide 6

  7. CT @ VT Flowchart City: Miami City: New York City: Blacksburg State: FL State: NY State: VA Temperature: 89 Temperature: 86 Temperature: 77 for each element statements Fall 201 2015 Slide 7

  8. CT @ VT Example City: Miami City: New York City: Blacksburg City: Los Angeles City: Ames State: FL State: NY State: VA State: CA State: IA Temperature: 89 Temperature: 86 Temperature: 77 Temperature: 100 Temperature: 65 Find the total of all of the temperatures Fall 201 2015 Slide 8

  9. CT @ VT Example City: Miami City: New York City: Blacksburg City: Los Angeles City: Ames State: FL State: NY State: VA State: CA State: IA Temperature: 89 Temperature: 86 Temperature: 77 Temperature: 100 Temperature: 65 Find the total number of temperatures Fall 201 2015 Slide 9

  10. CT @ VT Combining iterations Find the average temperature: average = total/number Iterate to find total Iterate to find number Fall 201 2015 Slide 10

  11. CT @ VT Combining iterations Find the average temperature: average = total/number combine steps one iteration Fall 201 2015 Slide 11

  12. CT @ VT Iteration and Decision Find the maximum temperature. set current-max 0 for each city [ if temp > current-max [ set current-max temp ] ] Fall 201 2015 Slide 12

  13. CT @ VT Next steps today  Work on the iteration problems in your cohort  Exchange algorithms for problem 2  Cohort feedback/reports  Discussion Fall 201 2015 Slide 13

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend