- 43 Views
- Uploaded on
- Presentation posted in: General

Chapter 9: Sample Applications

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

- Outline
- Spreadsheets
- Databases
- Numeric and Symbolic Computations
- Computer Networks

Social Issues

Applications

Software

Virtual Machine

Hardware

Algorithmic Foundations

- An electronic spreadsheet combines elements of:
- a calculator
- a word processor
- a database manager
- a graphing tool
- a modeling tool
- …

- Spreadsheet programs:
- Widely used
- Examples:
- VisiCalc
- MS Excel

- A spreadsheet is a 2-dimensional grid of cells:
- Rows: 1, 2, 3, …
- Columns: A, B, C, …

- Only a portion of the spreadsheet in visible on the screen
- window
- Window can be scrolled down/up

- Cell: specifies a row and a column:
- Activated using mouse or cursor
- Example:
- D2 means the cell at 2nd row and 4th column

- Information in each cell may be:
- Label
- Numeric value
- Mathematical formula

- Labels
- Text information that appear on the screen in a cell
- Any cell can contain a label (row numbers and columns letters are also labels)
- Format can be chosen: Font size, boldface, …
- Example
ABCDE

1 Item1Item2Total labels

2 3.255.759.00 numeric values

- Numeric values:
- Like labels can be formatted e.g.
- only 2 digits after the decimal point
- negative value in parentheses

- Like labels can be formatted e.g.
- Mathematical formulas
- Do not appear on the screen
- Entering a formula usually require some extra keystroke be done first
- Example:
- C2 = A2 + B2
- Total (C2) is computed automatically
- Error message if A2 or B2 are not numeric values

- Example: Payroll of a company

ABCDEFG

1IDNameAgeRateHoursPay

2101Janet K5116.6094

3 102Adam R188.50185

4 103Fred L4312.35250

5 104John A5317.80245

6 105Butch H176.7053

7

- Pay of Janet D2*E2 formula needed for Pay
- Entering the formulas:
- Enter D2*E2 in cell F2
- Copy (automatically supported) to other cells in column F

What you enter: (formulas entered)

ABCDEF

1IDNameAgeRateHoursPay

2 101Janet K5116.6094D2*E2

3 102Adam R188.50185 D3*E3

4 103Fred L4312.35250D4*E4

5 104John A5317.80245D5*E5

6 105Butch H176.7053D6*E6

What you see: (values computed)

ABCDEF

1IDNameAgeRateHoursPay

2 101Janet K5116.60941560.40

3 102Adam R188.501851572.50

4 103Fred L4312.352503087.50

5 104John A5317.802454361.00

6 105Butch H176.7053355.10

- Other Features
- Built-in functions for:
- Average
- Maximum
- Minimum
- User selects the desired cells and apply function

- Graphics:
- Data can be presented in graphical form
- Line graph
- Bar graph
- Pie graph
- etc.

- Multiple sheets can be handled at one time
- Formulas can be propagated to all sheets in use (if possible)
- Create 3-dimensional sheets

- Built-in functions for:

- Other Features (contd)
- User can write macros
- Macro:
- A series of instructions called by name
- “Like” a function …
- The name serves as a shortcut notation
- Use of macros saves time

- Example of a macro
- Select spreadsheet
- Select chart type
- Print sheet
- every time you call the macro the 3 tasks are done automatically

- Some database functions are also included in some spreadsheet programs

- Spreadsheet as a modeling tool
- Spreadsheet software does more than just:
- edit spreadsheets
- Perform simple calculations
- …

- Spreadsheets allow quick data modification and result presentation
- Suppose the owner of the payroll spreadsheet wants to give his/her employees a raise (in a good year)
- For example the increment should be 2% for each employee
- a new cell in the spreadsheet to hold the fixed increment: 2%
- a new column headed New Pay is also needed to store the incremented pay for each employee

- Spreadsheet software does more than just:

ABCDEFG

1IDNameAgeRateHoursPayNew Pay

2 101Janet K5116.60941560.401591.61

3 102Adam R188.501851572.501603.95

4 103Fred L4312.352503087.503149.25

5 104John A5317.802454361.004448.22

6 105Butch H176.7053355.10362.20

7

8Base Increase %2

9Totals$10936.50$11155.23

G: new column for increased pay

C8: stores the 2% value

F9 and G9: store the total pay

- Needed formulas:
- D2*(1 + $C$8/100)*E2 (entered in cell G2)
- G3 … G6: inserted automatically (by copying) after inserting G2
- same formula is used
- $C$ in order to prevent indexing the C column for G2 … G6 (constant value!)
- To compute the total in F9:
- SUM(F2:F6) (entered in cell F9)
- this means sum up all values in cells between F2 and F6
- By copying to cell G9, the corresponding formula SUM(G2:G6) is automatically generated

- The nice thing is now that if the owner wants to examine an increased pay using another percent, say 3%, only cell C8 needs to be modified!
- the new column G and the total pays are adjusted automatically

- The owner may also use another more realistic formula for increments:
- Each employee is given a “merit” percentage over a fixed base rate

- ABCDEFGH
- 1IDNameAgeRateHoursPayMeritNew Pay
- 2 101Janet K5116.60941560.40 31638.42
- 3 102Adam R188.501851572.50 21635.40
- 4 103Fred L4312.352503087.50 33241.87
- 5 104John A5317.802454361.00 24535.44
- 6 105Butch H176.7053355.10 1365.75
- 7
- 8Base Increase %2
- 9Totals$10936.50$11416.80

- Formulas needed to be typed in (for “merits” example):
- First, a column (we use G) is created to model the merits
- Now column H is for new pay
- D2*(1 + ($C$8 + G2)/100)*E2 (entered in H2)
- Formulas in H3…H6 are generated automatically after copying

- Moreover, some spreadsheet program can perform “goal seeking”
- Suppose the owner only knows:
- What merits each employee is worth
- The amount of money reserved for salaries (in the current year)

- Owner types in these values AND spreadsheet software seeks the amount of base increase percentage automatically
- For example:
- Suppose amount for this year is $12000.00
- Spreadsheet software will assign to cell C3 the value 7.33 automatically
- Owner is now happy to know what is the base increment in this year (that does not exceed his/her expectation)

- Suppose the owner only knows:

- Imagine more complicated examples:
- Company may vary the price of a product or the cost of supply and see immediately the effect on the profit
- A chemist can experiment with the amount of additives necessary to obtain a smooth flow of a liquid in a pipe
- An economist can track revenue impacts of a proposed tax increase
- …
- spreadsheet programs have become modeling and forecasting tools!

- However:
- Spreadsheets can only perform “numeric” modeling
- Time dependence of data is not directly supported (but can be achieved)

- Programming levels of spreadsheets:
- Macro programming ( highest level):
- Here a real programming language including (sequential, conditional, and interactive) instruction is provided in order to develop “programs” that simplify the work (of inputting formulas etc.)

- Visual programming ( intermediate level):
- Spreadsheet program acts like a (visual) language interpreter
- it waits for the user to change something, and then delivers new results
- “event-driven programming”
- Can be compared to an (interpreted) functional language, since only formulas (functions!) are used
- Formulas can:
- Explicitly use if (-statement): e.g. IF(A3 > B3, A3-B3, B3-A3)
- Implicitly use loops: e.g. when determining a base (input) value given a target one (like when we use target total pay 12000.00 to determine the base percentage)

- Formulas (programming) ( lowest level):
- Use of the basic arithmetic operations: e.g. A1*B1*C1
- Use of built-in functions: e.g. SUM(B2:B10), ABS(A1), etc.

- Macro programming ( highest level):

- Since Herman Hollerith demonstrated the advantages of mechanizing the processing of large amounts of data (in the US census of 1890), data processing emerged and evolved to a very common task at almost each desktop computer in the world
- Large amounts of data are stored in permanent storages (disks, tapes, …)
- Related data are organized in files in background storage:
- A file has a name and further attributes, and
- It includes the (user) data themselves

- Common file types:
- Text files: produced by e.g. a word processor
- Graphic files: produced by e.g. drawing program
- Program files: produced by e.g. a compiler (which is also stored in a program file)
- …

- File manager:
- Often part of the operating system

- Is a program that offers operations for:
- Creating a new file in a directory
- Reading information in a directory
- Updating information in a directory
- Deleting a file from a directory

- File name
- File size
- Time of last update
- Access rights
- …

- A file is for the file manager a black box
- File manager cannot even distinguish file types

- But file manager is indispensable, since access to background storage is always through it(s operations).

- Data organization
- Let us confine us to (simple) user data files (no program files)
- Data are based on bits and bytes
- but these are too small quantities in real life

- Data can be better organized in:
- Fields: a collection of bytes (e.g. employee name)
- Records: a collection of fields (e.g. employee information – name, phone#, …)
- Data files: a collection of records (e.g. all employees in a company)
- Database: a collection of data files (e.g. employees, inventory, …)

- Structure of a database (consisting of 1 file)
Field1 (e.g.ID) Field2 (e.g Name) Field3 (e.g. Age) Field4 (e.g. PayRate)

Record1

Record2

Record3

Record4

- Attention: A record is unlike an array, since it may include fields of different data types and those fields are not accessed via indexes!
- Database management system (DBMS)
- A program that manages files in a databases
- Codd E. F. observed records in a file as one entity: 2-dimensional table
- He introduced the relational database model:
- Now an employee file is not a collection of individual records but it is a 2 dimensional table
- He suggested new terminology (now widely used):
- Entity: is what the table represents e.g. employees file
- Tuple: represents one instance of this entity (the old record or a row in a table)
- Attribute: Heading (or name) of a column in a table (e.g. employee name, age, …)
- Primary key: An attribute (or a collection of attributes) that uniquely identifies a tuple (e.g. SSN of an employee)
- Relation: Same as entity from the point of view of “related” attributes

- A DBMS is more than a file manager:
- It works on the level of attributes and relations
- It knows how data are organized and how to access them the best (using primary keys)
- User data is a glass box for a DBMS (not a black box)

- A DBMS is really a complex program:
- It has its own data definition language (DDL)
- It has its own data manipulation language or query language (DML)

- After defining the data using DLL, the query language can be used to perform complex operations on the data
- SQL: Structured Query Language
- Examples of queries in SQL:
- Get all information about employee 123, the user poses the following query:
SELECTID, Name, Age, Payrate, Hours, Pay

FROM Employee

WHERE ID = 123;

- Get all information about employee 123, the user poses the following query:

- Get pays of a specific employee:
SELECT Name, Pay

FROM Employee

WHERE Name = ‘John Kay’;

- Get all information about employees ordered by their IDs:
SELECT *

FROM Employee

ORDERED BY ID;

- Get all information about employees older then 21 years:
SELECT *

FROM Employee

WHERE Age > 21;

- A query using two tables:
SELECT Employee.Name, Insurance.PanType

FROM Employee, Insurance

WHERE Employee.Name = ‘Fred James’ AND Employee.ID = Insurance.ID;

- Issues in databases:
- Transactions:
- All-or-nothing…

- Multimedia data:
- Audio
- Video
- …

- WWW
- Accessing databases using browsers (hypermedia)

- Distributed Databases
- Data distributed among nodes
- Replication and fault tolerance
- Security

- Transactions:

- Historically, the first application of computers is numeric computation:
- Baggage Analytic Engine for mathematical equations
- Hollerith solved statistical problems (US census
- 1940’s computers motivated by military-based mathematical problems

- Today: numeric computation still a challenging task
- Problems with up to 1015 mathematical operations are not uncommon
- Typical areas:
- Weather forecasting
- Molecular analysis
- Real-time imaging
- Simulation
- Natural language processing

- Mentioned challenges yielded to the development of supercomputers and highly parallel computers
- Machines with 1010 (and more) floating point operation per second have been constructed
- Example: virtual reality ( real-time imaging)
- Computer generates images in the same time frame and with the same orientation as when seen in real life
- Images are displayed on glasses and headsets are used to feel like in a real scene
- For example: as you are moving your arms, legs, and eyes, the computer may be generating and displaying simulated images of what you would see during a stroll through a forest.
- High demands on computation ability:
- about 24 images / sec
- each image = e.g. one million of pixels (picture elements)
- for each image: hundreds or thousands of mathematical operations

- Computer determines repeatedly:
- How far you have moved (since last image)
- How your eyes/head is positioned
- What is visible (what colors etc.) and what not from the current perspective

- 100 trillion (1014) of operations are needed for a single result!
- A regular computer (25 MIPS) would work 1.5 moths to generate result
- A supercomputer: 1 hour
- A teraflop machine: less than 2 minutes

- Even after the emergence of non-numeric applications (like word processing, databases, …), numeric computation are still very demanding, and in particular the field of symbolic computing
- Symbolic Computing
- Traditional numeric problems are based on “numeric values”:
e.g. 13.57/1.8897 *sin(1.2*p) – cos(1.34*p)*10-4

- Symbolic computing works on quantities that represent numbers (like unknown variables of high school mathematics)
- Examples:
- Spreadsheets formula: D2*E2
- Simplify: -x2 + 3x – 4 + 3x2– x + 1
- Solve: x3 + 2x2 + 10x - 13 = 0
- Factor: x3 + x2– 3x – 3
- Plot: sin(3x) for 0 <= x <= 2p

- Traditional numeric problems are based on “numeric values”:

- There is a variety of software tools for symbolic computation (e.g. Mathematica, Maple)
- Of course these tools are able to do numeric computations as well
- In general the tools are interactive:
- User: enters some request (here boldface)
- Program: displays result (here italic)

- Example: N[expr, i]
- Entered when a numeric computation is wanted
- Arithmetic expression expr is evaluated with the precision I
- N[((13.1842/1.976) Sin[2.1 Pi])^(1.0/3.0) + 0.0406893, 6]
1.31346

- Most symbolic systems work with ASCII representation of numbers and not with their binary representation:
- “10” = 1010 (4 bits)
- “10” = ‘1’’0’ (2 bytes)
- they can achieve high precision (but need more memory)
- Examples:
- Compute p with 250 precision:
- N[Pi, 250]
3.1415926535…52271201909

- N[Pi, 250]
- Compute the factorial of 200:
- 200!
78865786479050…737472000…00000

- 200!

- Compute p with 250 precision:

- However the strength of these systems is in symbolic computing
- Examples
- Simplify expression: Simplify[expr]
- Simplify[(x-1)^2 + (x+2) + (2x-3)^2 + x]
12 – 12 x + 5 x2

- Simplify[(x-1)^2 + (x+2) + (2x-3)^2 + x]
- Factor polynomial: Factor[polynomial]
- Factor[x^10 -1]
(-1 + x) (1 + x) (1 – x + x2 - x3 + x4) (1 + x + x2 + x3 + x4)

- Factor[x^10 -1]
- Expand expression: Expand[expr]
- Expand[(1 + x + 3y)^4]
1 + 4x + 6x2 + 4x3 + x4 + 12y + 36xy + 36x2y + 12x3y + 54y2 + 108xy2 + 54x2y2 + 108y3 + 108xy3 + 81y4

- Expand[(1 + x + 3y)^4]

- Simplify expression: Simplify[expr]

- Solve equations: Solve[equation, unknown]
- Solve[x^2 – 5x + 4 == 0, x] (Note: “==“ means equal)
{{x 4} { x 1}}

- Solve[x^2 – 5x + 4 == 0, x] (Note: “==“ means equal)
- Solve transcendental equations like ex – 1.5 == 0
- Solve[Exp[x]– 1.5 == 0, x]
{{x 0.405465}

- Solve[Exp[x]– 1.5 == 0, x]
- Solve system of linear equations:
- Solve[{2x + y == 11, 6x – 2y == 8}, {x, y}]
{{x 3, y 5}}

- Solve[{2x + y == 11, 6x – 2y == 8}, {x, y}]
- Solve system of linear equations:
- Solve[{2x + y == 11, 2x + y == 8}, {x, y}]
{ }

- Solve[{2x + y == 11, 2x + y == 8}, {x, y}]

- Calculus operations:
- Differentiation:
- D[x^3+6x-7, x]
6+ 3x2

- D[x^3+6x-7, x]
- Integration:
- Integrate[x^4 - 2, x]
1/5 x5 - 2x

- Integrate[x^4 - 2, x]
- Summation of (convergent) infinite series:
- N[Sum[1/2^i, {i, 1, Infinity}]]
1.0

- N[Sum[1/2^i, {i, 1, Infinity}]]
- Summation of (divergent) infinite series:
- N[Sum[1/k, {k, 2, Infinity}]]
Sum diverges

- N[Sum[1/k, {k, 2, Infinity}]]

- Differentiation:

- Plotting functions:
- Plot[x^2 + x – 2, {x, -3, +2}]

- Plot[5 Sin[3x], {x, 0, 2 Pi}]

- Various options for plots are available:
- Discrete: only some points
- 3-dimensional: e.g. Plot3D[Sin[x*y]. {x, 0, 3}, {y, 0, 3}]
- …

- Process of performing user requests:
- Get and analyze request
- Activate the appropriate program to handle the request
- Receive results
- Display results

- Issues:
- Algorithms for symbolic computation
- Exploiting parallelism
- Distribution in a network

- A computer network consists of:
- Computers
- Peripheral devices (printers, disks, …)
- An interconnection network

- Types of networks:
- local area network: LAN e.g. within buildings
- Wide area network: WAN e.g. across countries

- Benefits of networks:
- Share physical resources: e.g. one printer in a department
- Share logical resources: e.g. access to files, databases, …
- Fault tolerance: e.g. if one printer fails, another can be used
- Parallelism: e.g. print two documents on two different printers
- Communication: e.g. email

- Further benefits:
- Use of supercomputers in a WAN
- Groupware: Joint editing of documents
- Electronic data interchange: Data transfer from a program to a program; e.g. orders as output from a program at company X are transmitted to another program (that handles bills and shipping) at company Y ( no human intervention)
- Use of network-centric applications:
- WWW
- E-commerce
- Search engines
- …

- Internet
- One of the largest computer networks
- Outgrowth of ARPANET (US DoD)
- ARPANET was developed in 1970s
- Internet is a network of networks

- Advantages (of Internet)
- Voice mail
- Cellular phones
- Teleconferencing
- …

- Issues:
- Reliability of networks
- Efficiency
- Privacy and confidentiality

- More about the Internet
- Vision: “information superhighway”
- global information access from everywhere by everyone at every time
- Information should be a basic infrastructure good
- Information should flow like current/voltage flows from plugs

- Information is accessible through services
- Internet is a big WAN (actually a WAN of WANs/LANs)
- Internet is big collection of nodes connected by wire, each node is either a individual computer (e.g. mainframe) or a switching station

- Vision: “information superhighway”

- User connects to the internet using:
- Workstation
- PC
- Laptop
- …

- Connection:
- Direct: user connects by telephone line to a “host” (already connected to Internet)
- Over LAN: user machine is in a LAN that is connected to an internet host

- Email:
- In order to communicate with someone via email you must know his/her email address

- Addressing scheme is hierarchical:
- “jones” identifies an individual account on a host computer
- “ournode” identifies the host computer
- “ccc” identifies where the host is located (perhaps central computer center)
- “uleth” identifies the organization where this machine is located (U of L)
- “ca” specifies the country or organization sector (here Canada)

- Problems with Email:
- Is not protected (default)
- Informality of an email may be misinterpreted (by reader)
- Viruses in emails!

- Remote log-in
- The service is called “telnet”
- Used to log on to any computer in the Internet
- Login types:
- Anonymous
- Individual

- After logging in your are like a direct user of the machines
- Why?
- In order to access a database
- In order to use a special compiler
- In order to run a program on a supercomputer
- …

- Clearly, the user notices a delay when accessing remote machines

- File transfer:
- Service: FTP (file transfer protocol)
- This service allows a user to transfer files between two machines
- Files can be of arbitrary length and of any type
- Commands:
- Put: from your machine to remote computer
- Get: from remote computer to your machine
- …

- Anonymous ftp: open services for everyone
- Difference between telnet, ftp, and email:
- Telnet: you are a user of the remote machine
- FTP: you are not a user, you are only allowed to use commands of FTP
- Emails: only text files, you communicate with a user (not a machine)

- Browsing:
- Gopher:
- Allows to “jump” from one machine to another collecting information
- Menu-driven
- Menu contents e.g.
- Library entries
- General information
- Next gopher site(s)

- WAIS:
- Use keywords to retrieve information from directories in the Internet

- WWW:
- Hypertext-based navigation
- Any kind of information (text, audio, video, …)
- Browser software needed (e.g. Netscape, Internet Explorer, …)

- Gopher:

- Different services:
- Search engines
- Applications/Applets
- …

- E.g. newsgroups: discussion groups on a specific topic
- Hierarchal naming e.g. cs.comp.parallel
- In general moderated

- Some Internet statistics (rather old)
- 20,000 networks in the Internet
- A new network every 10 minutes
- 4 million hosts
- More than 50 million people have access to the Internet
- Over 5,000 news groups
- Over 4,000 Gopher servers
- Annual traffic growth of WWW is 341,634 percent!!!
- Internet services in use for more than 2 decades (by insiders)
- Based on current growth, by 2003 every person on the globe will have Internet access (???)

- Issues in networking
- Transmission is analog, but data are digital
- conversion is needed
- conversion: use of Fourier series to approximate digital signal by superposition of multiple analog ones
- Bandwidth: maximum transmission rate (medium-specific)
- Media:
- Twisted pair copper wire:
- Used in telephone networks
- Inexpensive
- Limited bandwidth
- Signal deteriorates at distances longer than 10 km (amplifiers needed, repeaters)

- Twisted pair copper wire:

- Coaxial cable:
- Used for cable TV
- More bandwidth but more expensive
- Signal deterioration also at about 10 km but is less subject to “noise”

- Fiber optic:
- Bundles of thin glass wire
- Signal are pulses of light
- High bandwidth
- Up to 100 km without deterioration
- More expensive

- In general a WAN is a switched network
- messages travel from one switch to another on the way to their destinations

- A message includes its destination address in order to help intermediate nodes to “switch in the right direction”
- Multiple paths from source to destination are possible (and usual)
- Why?
- Reliability: redundant connections
- Efficiency: more connections among nodes with higher traffic or parallel connections

- Why?
- What path is the best?
- Shortest ones?
- Less intermediate nodes or less distance?

- Path with highest bandwidth?
- Priorities for messages?
- High priority messages use high bandwidth paths
- Low priority messages use low bandwidth paths

- Shortest ones?

- Thus, answer is not trivial…
- After all, determining the “best” path is a prohibitively long task
- compare: bin-packing problem O(2n)
- A number of routing algorithms are in use

- Bus-based LANs (e.g. Ethernet)
- Broadcasting:
- Any message is sent to ALL nodes in the network
- Each node checks whether or not it is the message destination
- If yes, message is completely received and processed
- If not, message is ignored

- Collision is possible:
- “A” sends “m1” and before “m1” is received “A2” sends “m2”
- Since medium is shared, “m2” collides with “m1”
- Both are then useless for potential receivers

- Thus, collision must be detected and sending machines retry to send the message again
- In order not to collide another time the machines wait different “random” periods before sending