comp apps 2

¡Supera tus tareas y exámenes ahora con Quizwiz!

Flowchart

Visual representation of sequence of events to be performed in an algorithm Tool to review, capture and communicate logic flow of a program

how do you write: teenagers are older than 12 and younger than 20

age > 12 && age < 20

precise, systematic method for producing a specified result

algorithm

pseudocode arrow name and function

arrow connector that shows relationships between the representative shapes

the act of setting a variable to have a new value

assignment

assignment statement

changes a variable's value; a programming command expressed with a variable on the left and a variable or expression on the right of an assignment symbol, usually =

most commonly used programming language

command to change the value of a variable

difference between program and algorithm

programs are algorithms that have been specialized to a specific set of conditions and assumptions, and are (usually) written in a specific programming language

example of heuristic

searching stuff on world wide web bc youre not guaranteed to find what youre looking for. not systematic. just heuristic bc its a helpful procedure for finding a result

The steps in algorithms must be so that the agent is able to do it.

unambiguous

like negate (-), which have only one operand

unary operators

operator overload

use of an operator with different data types The case of interest is +. Operators usually apply to a single data type, like numbers. So, we expect 4 + 5 to produce the numerical result of 9. And it does because the operands are numbers. But if the operands are the strings "four" + "five", the result is the string "fourfive"

are program and algorithm interchangebale

usually, yes

although true and false for booleans are written as letter sequences, they are _____

values

what is the declaration command

var (followed by comma-separated list of the identifiers) ex: var area, radius;

Are identifiers case sensitive?

yes

google query evaluation - algorithm or no?

yes

do algorithms always work? why or why not?

yes -work by being systematic. either get the specified answer or they report back that no such answer exists, and they are correct in what they answer

when writing strings, is an apostrophe the same as a single quote

yes. so must use something like this "mel's"

programs are usually written in _____

a specific programming language

what do algorithms use in order to simplify the algorithmic description

functions - operations that the agent already knows how to perform

algorithm pseudocode/flowchart: facebook login page loads

process

pseudocode rectangle name and function

process represents a process

If an algorithm is performed with the same data, at different times with different agents the output will be A. the same B. different C. sometimes different and sometimes the same D. impossible to tell

A

initializing a declaration

to give a variable or other name its starting value ex: var balanceDue = 0, var taxRate = 0.88;

logical not operator

! unary operator - takes only a single operand outcome is the opposite value of its operand ex: !(age > 12 && age < 20) It works as follows. The subexpression in parentheses tests whether the age qualifies as a teenager, that is, more than 12 and less than 20. The outcome of the test is either true, the age qualifies as a teenager, or false, it does not. By placing the logical not operator in front of the parenthesized expression, we have a new expression, which has the opposite outcome: The whole expression is false if the age is that of a teenager, and it is true if the age is not that of a teenager.

logical and operator

&& (and operator) (outcome of a && b is true if both a and b are true. otherwise, it is false

arithmetic operators - multiplication

*

min and max number of characters in a string

0: " " --> empty string max = any number

strategy for knowing why algorithms work

1. Find one or more properties that ensure the algorithm works. 2. Explain, using the program, why they make it work.

algorithm pseudocode/flowchart: ID and Password are validated (1) If not valid 1) Determine error (2) 2) Display Login Page with error message (3) If valid 1) Find User's Home Page (4) 2) Display User's Home Page (5)

1. decision 2. process 3. input/output 4. process 5. input/output

what is the statement terminator in javascript

;

This symbol is often used to describe syntactic structures. # < > ( ) { }

<>

3 parts to an assignment statement

<variable> <assignment symbol> <expression>; week = days / 7;

"equal to" relational operator vs assignment

== -> equal to = -> assignment

algorithm - finiteness

An algorithm must have finiteness; it must eventually stop, either with the right output or with a statement that no solution is possible. If no answer comes back, we can't tell whether the agent is still working on an answer or is just plain stuck. Finiteness is not usually an issue for noncomputer algorithms because they typically don't repeat instructions. However, as you will see, computer algorithms often repeat instructions with different data - infinite loop problem

pseudocode

An outline of the basic ideas behind how algorithms will work.

Algorithms are guaranteed to work A. 99.9 percent of the time B. 100 percent of the time C. depends on the computers they are running on D. 50 percent of the time

B

Algorithms must always A. produce output B. produce output or state that there is no solution C. produce input or state that there is no solution D. state that there is no solution

B

When writing an algorithm in a natural language it is helpful to use ______ instead of _______. A. programming language, natural language B. nouns, pronouns C. abbreviations, actual words D. nouns, adjectives

B

Algorithms are used by A. only computers B. only humans C. various agents D. no one, they are not real

C

textbook example of algorithm

IAL - interesting alphabetized lists - used in web searching

algorithms can be specified at different levels of detail. why?

It is only necessary that the agent know the terms and operations used in the specification, and that they be within the agent's capability to perform

algorithm - effectiveness

It must be possible for the agent to execute the algorithm mechanically without any further input, special talent, clairvoyance, creativity, help from a superhero, or any other external support. While definiteness specifies which operations to do, in what order, and when, effectiveness means that they are doable.

if you have a mix of single and double quotes you need to use inside a quoted string, you can use _____ in front of those you need to

JavaScript's escape symbol (the backslash) ex: "She said, \"I wouldn't know,\" and left the room."

when writing numbers for java, are there units?

NO. only decimal can be used. no % or $ etc

javascript - numbers

The values assigned to the variables (taxRate and balanceDue)

booleans

True or False

true or false: javascript allows declaration statements anywhere the list of program statements

true but generally its put first in the program

what is a heuristic process

a helpful procedure for finding a result. The steps are guidelines, sometimes also called heuristics, that contribute to finding a solution. They are not guaranteed to work 100 percent of the time. A heuristic process is often the best we can do in cases where there is no known algorithm.

variable

a named quantity in a programming language that can change over time or over the course of operations involving it name - not value

conditional statements

a programming statement, usually identified by if, that optionally executes statements depending on the outcome of a Boolean test if (Boolean expression ) then-statement top line - true or false outcome such as relational expressions bottom line - any java statement such as an assignment statement

Operators like + and * are called _____ operators because they operate on two values.

binary

An algorithm is a(n) A. list of general nonspecific steps to produce an output B. logarithm C. systematic method for producing a specified result D. math problem

c

pseudocode diamond name and function

decision indicates a decision

since programs are written "starting from scratch," the first thing to do when writing any program is to

declare variables

A program is an algorithm that has been

encoded/specialized/ customized to do a specific task

why is declaration a statement and not a command

everything we tell a computer to do is a command so we call it a declaration statement, ie a program instruction

Algorithms must be ; they eventually stop with the right output or a statement that no solution is possible.

finite

A program is a ____ description of a process, meaning that while the values may change, the description of the process does not

fixed

algorithms always build on ____ previously defined and known to the agent

functionality ex: addition

Algorithms must be definite. They must specify ordered steps, including details on how to .

handle errors

what is the intention of programs

have computer complete task or solve problem

The letter sequence that makes up a variable's name is called the

identifier

The <Boolean expression> is evaluated first. If the outcome is true, the <then-statement> is executed and the <else-statement> is skipped. If the <Boolean expression>'s outcome is false, the <then-statement> is skipped and the <else-statement> is executed. For example if (<Boolean expression>) <then-statement>; else <else-statement>;

if/else statement

expression

in programming, a formula-like description of how to compute a value. describe the means of performing the actual computation

compound statement

in programming, a group of statements surrounded by curly braces to become a single statement. now the <then-statement> refers to the single (compound) statement; it is skipped when the predicate outcome is false if (waterTempC < 0) { waterState = "Frozen"; description = "Ice"; }

operators

in programming, a symbol used to perform an operation on some value(s)

5 properties of an algorithm

input specified output specified definiteness effectiveness finiteness

algorithm pseudocode/flowchart: User enters ID and password

input/output

algorithm pseudocode/flowchart: facebook login page is displayed

input/output

algorithm pseudocode/flowchart: Enter www.facebook.com into your browser

input/output

pseudocode parallelogram name and function

input/output represents input and output

what is the worst pronoun to use when writing algorithm

it

a modern scripting language that is especially effective for web applications.

javascript

usual direction flow of pseudocode

left to right or top to bottom

numbers and strings are _______, meaning that the characters are written exactly as we want them to be interpreted by the program

literals

Programs containing cannot be verified exhaustively.

loops

assignment statements do not state equality, they ......

move data from right to left

U.S. President & Barrack Obama which is value and name

name - us pres value - obama

are identifiers allowed to have spaces

no must be letter followed by any sequence of letters, numbers, or underscore

when the variable is first declared, does it have value?

no. it is undefined

3 types of data in java

numbers strings booleans

relational operator

one of the six operators (< <= == != >= >) used to make comparisons between numerical values—that is, to test the relationship between two numbers. The outcome of the comparison is a Boolean value, either true or false.

values that operators operate on

operands

Often the agent that "runs" the algorithm is a ______

person (not computer)

algorithmic agent

person or thing that follows the instructions

the Boolean expression in a conditional statement that is evaluated to produce a true or false outcome (top line in conditional statement) if true, the then-statement is performed. if false, it is skipped

predicate

java strings

sequences of keyboard characters

what is a string always surrounded by

single or double quotes

algorithms - definiteness

specifying the sequence of operations for transforming the input into the output. Details of each step must be spelled out, including how to handle errors. Definiteness ensures that if the algorithm is performed at different times or by different agents (people or computers) using the same data, the output is the same.

arithmetic operators

standard arithmetic operations—such as addition (+), subtraction (-), multiplication (*), and division (/)—that one finds on a calculator.

pseudocode oval name and function

start/end represents start or end point

most common type of java data

strings

programming

the act of formulating an algorithm or program. developing a systematic means of solving a problem so that an agent—someone other than the programmer, and usually a computer—can follow the instructions and produce the intended result for every input, every time. The agent must also be able to perform or execute the program without any intervention from the programmer. This means that all steps must be spelled out precisely and effectively, and all contingencies must be planned for.

declaration

the act of stating which variables will be used in a program

algorithms - output specified

the data resulting from the computation, the intended result. Often the output description is given in the name of the algorithm, as in "Algorithm to compute a batting average." As with input, we must specify the type, amount, and the form the output will have. A possible output for some computations is a statement that there is no output—that is, there is no possible solution

algorithms - input specified

the data to be transformed during the computation to produce the output. We specify the type of data, the amount of data, and the form of the data that the algorithm expects

interpreting assignment statement

you must think of a value flowing from the right side (expression side) of the assignment symbol to the left side (variable side) ex weeks = days/7; -"the variable weeks is assigned the value resulting from dividing the value of the variable days by 7" -"the value of weeks becomes the value resulting from dividing the value of the variable days by 7" -"the variable weeks gets the value resulting from dividing the value of the variable days by 7"

logical or operator

| | the outcome of a || b is true if either a is true or b is true, and it is also true if they are both true; it is false only if both are false.


Conjuntos de estudio relacionados

Combo with "Chapter 7" and 16 others

View Set

Google Analytics for beginner's quiz, Google Analytics (2)

View Set

Next Term We'll Mash You Vocabulary

View Set

Macroeconomic-Chapter 18-SmartBook

View Set

ALGEBRA RECENT BOARD EXAM QUESTION

View Set

Musculoskeletal Practice Test NURS327

View Set