Computer Science
if x = [4,7,9,2] what is x[2]
9
indicate the data type of the expression: 5/2 == 5/2.0
Boolean
the person who popularized the term "debugging" was
Hopper
What is the run-time complexity of the following program? def findTarget(myList, target): count = 0 for item in myList: if (target == item): count = count + 1 return count
O(n)
range(0,n) creates a list of
[0,1,2,.....,n-1]
library
a collection of useful algorithms
if python 2.7, if x = 13 and y = 2, what is x/y a. 6 b.6.0 c.6.5 d. 7
a. 6
if x = 5.0 and y = 3, what is the data type of x*y a. integer b. float c. string d. list
b. float
fundamental building blocks of all computer systems
binary representation boolean logic gates circuits
A program in python prompts the user for input from the keyboard and will store the value as the variable myAnswer. The user types the value 3.0. At this point, the data type for myAnswer is:
string
a word with quotes
string
indicate the data type of the expression: str(2.6)
string
x = "3" what is type(x)?
string
string
the " " that enclose a phrase tell python its a string and treated as a single monolithic thing
in computer science terminology, the machine, robot person, or thing carrying out the steps of an algorithm is called
the computing agent
computer science
the study of algorithms, including their formal and mathematical properties their hardware realizations their linguistic realizations their applications
misconceptions: computer science is...
the study of computers the study of how to write computer programs the study of building/designing new machines
"doable"
there exists a computational process that allows the computing agent to complete the operation successfully. Formal term is effectively computable
period of the wave (T)
time it takes for the wave to make 1 complete cycle units: time(sec)
frequency f
total # of cycles per unit of time units: Hertz (Hz)
two's complement representation
total number of values that can be represented with n bits is 2^n
abstraction
use of high level instructions during the design process separation from the high level view of an entity or operation from the low level details of its implementation
virtual machine/environment
user oriented view of computer system
UNICODE
uses 16 bit representation for characters rather than the 8 bit rep of ASC II
digital representation
values for a given object are drawn from a finite set
a word without quotes
variable
top down design
viewing an operation at a high level abstraction
algorithm(formal)
well ordered collection of unambiguous and effectively computable operations that, when executed, produces a result and halts in a finite amount of time
primitive operation
when an operation is unambiguous (understood and carried out directly by the computing agent w/o further simplification or explanation)
3.3//2
1
if python 3.4, if x = 13 and y = 2, what is x/y a.6 b.6.0 c.6.5 d.7
c. 6.5
which of the following data types is mutable? a.float b.integer c.string d.list
d.list
read
evaluate-print cycle- infinite times
Given the following script in python, what will be printed? N = 0 if (N > 0): print("you entered a positive number") else: print("you are not feeling very positive") if (N == 0): print("you entered zero")
you are not feeling very positive you entered zero
Given the following program in python, what will be the value returned? N = 3 counter = 0 while (N > 0): counter = counter * N N = N - 1 return counter
0
Given the following script in python, What will be value of N when the program terminates? N = 4 counter = 1 while (N > 0): counter = counter * N N = N - 1 return counter
0
Rules
1. Direct Sequencing 2. Conditional Execution 3. Iterative Execution
3.3/2
1.65
sequential operations (3)
1.computation- evaluates the arithmetic expression, gets a result, and stores that result in the variable 2. input- provide computing agent with data values from the outside world 3. output- send results from computing agent to outside world
max number of binary digits that can be used to store an integer
16,32,64 bits
ENIAC
1st fully electronic general purpose programmable computer
FORTRAN and COBOL
1st high level programming languages
round(5/2)
2
def myFunction(a,b): return 2 * b + a what is myFunction(3, 10)?
23
What will be the value returned from this script? N = 4 counter = 1 while (N > 0): counter = counter * N N = N - 1 return counter
24
what is the final value of y when the following statements are entered in python? >>>x = 3 >>>y = x + 1 >>>x = 7
4
x =4 y= x x=7 what is y?
4
computer science is the study of
algorithms
a while statement is an example of
an iterative statement (looping instruction that doesn't say to go on but to go back and repeat)
iterative execution
applies to an iterative construct(loop, for, while) that will cause the execution of a subset of instructions to be repeated a specified number of times the trick is to understand how many times the instructions will be repeated
code mapping
assigning each printable letter or symbol in our alphabet to a unique number
Which of the following data types is mutable? a. integer b. float c. list d. string
c. list
which of the following statements describes the primitives of a computing agent? a. They are variables that can only store numerical values. b. They are written in pseudocode and form a basic outline of an algorithm. c.They are instructions that the computing agent understands and can execute without further explanation or simplification. d. They evaluate "true/false conditions" to determine if a loop body should be executed.
c. they are instructions that the computing agent understands and can execute without further explanation or simplification
control operations
conditional and iterative allow us to alter the normal flow of control in an algorithm
the question asking operations of an algorithm are called
conditional statements
Big O
constant run time O(1) logarithmic run time O(log n) linear run time O(n) linearithmic run time O(n log n ) quadratic run time O(n^2)
Gottfried Leibinitz
constructed a mechanical calculator called Lebnitz's Wheel. Also developed formal logic using binary system (-,+,*,/)
posttest loop
continuation condition at the end of each loop body
pretest loop
continuation condition tested at beginning of each loop
The list of numbers [6, 2, 3, 1, 5, 4] is to be sorted using BUBBLE SORT. The algorithm for this process involves nested "for" loops. Which of the following lists is an intermediate result after the first pass over the outer loop has been completed? a.[2, 6, 3, 1, 5, 4] b.[1, 2, 3, 6, 5, 4] c.[1, 2, 3, 4, 5, 6] d.[2, 3, 1, 5, 4, 6]
d. [2,3,1,5,4,6]
which of the following is NOT part of the formal definition of an algorithm? a. it produces a result b. it halts in a finite amount of time c. it consists of unambiguous operations d. it consists of step-by-step instructions
d. it consists of step by step instructions
Which of the following has the most optimal worst-case run-time complexity (in terms of the lowest order)? In other words, which of the following sorting algorithms is the most efficient (in the worst case)? a.bubble sort b.insertion sort c.selection sort d.they all have the same run-time complexity
d. they all have the same run-time complexity
Which of the following statements is CORRECT regarding Leibnitz's Wheel and the Pascaline a. They were programmable b. They are examples of early computers c. They had memory where information could be stored d. They were mechanical calculators
d. they were mechanical calculators
Blaise Pascal
designed and built one of the first mechanical calculators (named the Pascaline) (-,+)
Grace Hopper
developed first complier for a compare programming language credited with "debugging" for fixing computer glitches United States Navy seal admiral annual conference celebrating women in CS
string * non integer string * integer
error "hello" * 5 = hellohellohellohellohello
John von Neumann
father of computer virology designed a self reproducing computer program (virus) member of Manhattan Project produced different program design called stored program computer invented programming invented "merge sort"
Herman Hollerith
father of the modern automatic computation founded the Computer Tabulating Recording Company 1940- his tabulating machine company changed to IBM
Alan Turing
father of theoretical computer science wrote chess program defined standard for a machine to be called "intelligent"
algorithm discovery
finding a solution to a given problem
indicate the data type of the expression: 5/2
float
indicate the data type of the expression: 3 + 5.0
float
integer + float string + string string + integer string + float integer + integer float + float
float string error error integer float
conditional execution
for a conditional statement, the cost of execution is the maximum cost of evaluating the condition and the cost(s) of the alternate instruction sequences
direct sequencing
for a sequence of instructions, the cost of executing the sequence of instructions is, asymptotically speaking, the same as the maximum cost of the individual instructions
pass
give or pass info by enclosing it in parenthesis
primitives
instructions that computing agent understands
ASC II
internal standard for representing textual info in the majority of computers uses 8 bits to represent each character
John Napier
invented logarithms to simplify difficult math problems
4 data types
lists strings integers floats
Jacquard
made automative weaving process 1st programmable device
python interpreter
magic that underlies the evaluation part of shell. Responsible for translating commands you type into instructions
sampling rate
measure how many times per second we sample the amplitude of the sound wave
amplitude of the wave
measure of its loudness units: electrical voltage
variable
named storage location that holds data value
issues with using natural language to represent algorithms
natural language can be extremely verbose lack of structure makes it difficult to locate specific sections of the algorithm too rich in interpretation and meaning
pseuedocode
natural language:used to express algorithms, not sufficiently precise to represent algorithms used to design and represent algorithms a compromise between the two extremes of natural and formal language not unique
analog representation
objects can take on any value
sign/magnitude notation
one of a number of different techniques for representing positive and negative whole numbers 1- negative 0- positive
Charles Babbage
one of the "fathers of the computer" designed the Difference Engine (+,-<*,/ to 6 digits, solve polynomial equations), never completed designed the analytic engine, similar to modern computer, never actually built (mill,store, operator, output, input)
arithmetic overflow
operation that produces an unsigned value greater than 65,535
pattern matching
process of searching for a special pattern of symbols with a large collection of information
Ada Byron
regarded as history's 1st computer programmer Ada programming Her notes include what is recognized as first algorithm intended to be carried out by a machine
loop
repetition of a block of instructions while statement
infinite loop
runs forever
program/script
sequence of python instructions
operations used to construct algorithms
sequential conditional iterative
sequential algorithm
sometimes called straight line algorithm
sequential search
start at beginning and look at each one, one at a time, used for unordered lists
algorithm(unformal)
step by step instruction to accomplishing a task