Download presentation
Presentation is loading. Please wait.
Published byMillicent Park Modified over 9 years ago
1
CPS 001 1.1 Topics l Networks revisited l Java intro l Decision Trees l Problem solving and computing with numbers l Upcoming ä Numeric computation Course Notes: Chapter 3 Great Ideas : Chapter 3
2
CPS 001 1.2 Ethernet l Invented by Dr. Robert Metcalfe in 1970 at Xerox Palo Alto Research Center l Allows group of computers to communicate in Local Area Network
3
CPS 001 1.3 The Ethernet
4
CPS 001 1.4 An Internet Ethernet 2 Ethernet Ace Network Red
5
CPS 001 1.5 Number of networks needed? l Suppose you are dealing with Ethernets that can each only handle four computers. How many nets would you need to connect 100 such machines and tell how you would connect them. Assume that one machine can connect to no more than two networks simultaneously.
6
CPS 001 1.6 Network transfers l A network transfer is the passage of a message from one network to another through a gateway machine. l We wish to connect 100 machines having 2 network controllers each. l How many computers can a message reach without leaving the 2 networks the originating computer is attached to? l How many networks can a message reach in after 1 network transfer or 2 network transfers? l How many network transfers are necessary to reach 100 computers or 1024 computers?
7
CPS 001 1.7 Decision trees l If-Then statements if (logical expression) { “true” actions } l If-Then-Else statements if (logical expression) { “true” actions } else (logical expression 2) { “false” actions } l Logical expressions ä analogous to yes or no questions true or false Statements that are true ä (5 < 7) ä (100 == 100) ä (100 != 10) ä (10 <= 10) Statements that are false ä (-2 > -1) ä (10 != 10)
8
CPS 001 1.8 A decision tree He received the Physics Price in 1921. Try A. Solzhenitsyn, Literature 1970. Look up the Peace Prize in 1991. Try the Medicine Prize in 1962. Would you prefer a humanitarian? Would you like to read about a scientist? Would you like to read about Einstein? 0 1 2 6 5 4 3
9
CPS 001 1.9 More Java Syntax l Assignment statement variable = expression; l Method invocation ä Also called function or procedure ä Invoking also called “calling” a function ä Methods can take arguments button.setText(“This text is an argument”); init() l Variable declaration VariableType variableName; Button choice;
10
CPS 001 1.10 Problem Solving Programming is a strenuous exercise in problem solving G. Polya. How to Solve It, 2 nd ed., Princeton University Press, 1957. l Understand the problem ä What are its parts? unknown, data, condition ä Does the problem make sense? Is it feasible? ä Think about the problem, get a sense of what it needs l Make a plan ä Find the connection between givens and result ä What kind of problem is it? Is it familiar? ä Think about generalizations, specializations, variants l Carry out the plan ä Check each step l Examine the result ä Does it make sense?
11
CPS 001 1.11 Back of the envelope calculations Jon Bentley. Programming Pearls. 2 nd edition. Addison-Wesley, 2000. l Engineering technique to approximate and check answers ä Two answers are better than one ä Quick checks ä Rules of thumb ä Practice l Ad claims that salesperson drove 100,000 miles in a year. True? l Newspaper article states that a United States quarter dollar coin has “an average life of 30 years.” How can you check that claim?
12
CPS 001 1.12 Game l 10 coins ä You and a friend have a stack of 10 coins ä On each person’s turn, they remove either 1 or 2 coins from the stack ä The person who removes the last coin wins. ä Can you win? l 10 coins with a twist ä 10 coins, can now ALSO place 1 or 2 coins back on the stack ä Person who removes last coin wins ä Should you go first or second, and what’s your strategy
13
CPS 001 1.13 Puzzle: Pennies Heads Up From Car Talk! l You're sitting at a table with a bunch of pennies on it. Some are facing heads up and some are facing tails up. You're wearing a blindfold, and you're wearing mittens so that you can't actually feel the coins and tell which side is facing up. l I will tell you that a certain number of the pennies are facing heads up. Let's say 10 are facing heads up. l Is it possible to separate those pennies into two groups, so that each group has the same number of pennies facing heads up? How do you do it? ä Pennies can be flipped or moved as much as needed
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.