Peeking into Computer Science 1 Reading Assignment Mandatory Chapter 1 Optional None 2 Problems amp Solutions Computer Science perspective 3 Objectives At the end of this section you will be able to ID: 362518
Download Presentation The PPT/PDF document "Introduction" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Introduction
Peeking into Computer Science
1Slide2
Reading Assignment
Mandatory: Chapter 1Optional: None2Slide3
Problems & SolutionsComputer Science perspective
3Slide4
ObjectivesAt the end of this section, you will be able to:
Define a (computational) problemUnderstand the terms algorithm and program
Start working with Microsoft Excel SpreadsheetsSlide5
Computer Science
Studying computers and utilizing them to solve problemsComputational problems are solved by computersComputer scientists use methodological thinking when approaching problems
5Slide6
Problems
Any problem has input and outputExamples: laundry, cooking, buildingThe problem specifies what
needs to be done
It specifies the relationship between
input
and
output
The problem is not concerned with
how
6Slide7
Example: Searching the WebSearching the Web is a computational problem
Input: A collection of keywordsOutput: A ranked list of Web documents that are relevant to the input keywords
7Slide8
Solution: Search EngineCollects and records information about Web documents in a
databaseWeb crawlers or spiders collect informationYou can use a search engine through a Web browser
All are
programs
8Slide9
ProgramsSolutions to computational problems are represented as programs
Program = sequence of computer instructions Written in a programming languageAlgorithm = A program that is not written in a programming language
It is the specification of a program
9Slide10
Web Crawler Algorithmto-visit = a non-empty list of initial URLs to be visited
For each URL in to-visit:Open that URL document dRecord information about d in the databaseScan d for hyperlinksFor each hyperlink in d:Add the hyperlink to
to
-visit
10Slide11
General-Purpose ProgramsBrowsers and crawlers are specialized programs
General-purpose programs can be used to solve variety of problemsExample: Microsoft Excel program
11Slide12
SpreadsheetsGird of cells
Cell = intersection of a column and rowColumns are referenced by lettersRows are referenced by numbersExample cell: B1 contains 124
12Slide13
FormulasAllow us to perform calculations
Formulas start with == is an instruction to perform calculations13
=C7*D7Slide14
Functions Allow us to perform group calculations
Some example functions: sum, average, minimum, and maximum14
=SUM(E7:E9)Slide15
ChartsA picture is worth thousand words!
15Slide16
Divide and Conquer
The power to solve16Slide17
ObjectivesAt the end of this section, you will be able to:
Understand and use the Divide & Conquer techniqueApply Divide & Conquer to a spreadsheet exampleSlide18
Divide & Conquer Approach
Divide and Conquer:Divide the problem into smaller easier to solve problemsSolve the sub-problemsCombine the sub-solutions
18Slide19
Divide & Conquer
Start with an overview of the solutionSpecify the components
Overview
Component 1
Component 2
Component n
19Slide20
Divide & Conquer
Repeat for the components, specify subcomponents
Overview
1
2
n
20Slide21
Divide and Conquer
Making a tableEasier: Make the legsMake the topCombine them
21Slide22
Making a Table
Can go further down the tree if need be
Table
Legs
Top
22Slide23
Making a Table
Table
Legs
Top
23Slide24
Design Example
Spreadsheets24Slide25
The Problem
I would like to move to a US state that:Has a warm climateHas a low crime rateIs close to Ottawa
Dividing the problem:
Collect the
avg
high temperature per state
Collect homicide rates from US states
Measure the time it takes to drive from each state to Ottawa
25Slide26
1. Collecting avg high temperatures
www.netstate.comAvg high temperature is recorded in Fahrenheit
Use Google calculator to convert to Celsius
Record the data in a spreadsheet
26Slide27
The spreadsheet
27Slide28
2. Collecting Homicide Rates
Find some source and record the rates in the spreadsheet.My source is: "graphic Discovery" by Howard Wainer.
28Slide29
The spreadsheet
29Slide30
3. Time to Ottawa
This needs to be further divided into sub-problems:Find a point in the stateMeasure the distance from that point to Ottawa
For 2, we can simply use Google maps
For 1, the geographic center, the capital city, or something else?
We choose the capital city
30Slide31
http://www.usacitiesonline.com/
31Slide32
Google Maps
32Slide33
The Spreadsheet
33Slide34
Combining Sub-Solutions
Since we have more than one factor, we need to weigh the factors based on preferenceOne way is to use a weighted averageMy preferences are:Warmer: 30%Fewer homicide: 50%
Closer to Ottawa: 20%
34Slide35
The Spreadsheet
35Slide36
The Solution
36