Unit 2 | Abstraction | Shared

Ace your homework & exams now with Quizwiz!

Defined inputs

used to test a program should demonstrate the different expected outcomes that are at or just beyond the extremes (minimum and maximum) of input data.

modularity

The subdivision of a computer program into separate subprograms

substring

part of an existing string.

String parsing

process of taking a string from a file or the network or the user, and processing it to extract the information the user wants.

REMOVE(aList, i)

removes the item at index i in aList and shifts to the left any values at indices greater than i. The length of aList is decreased by 1.

filtering list

removing unwanted elements of a list, such as keeping only the positive numbers from a list, or keeping only students who signed up for band from a record of all the student

Existing code

segments can come from internal or external sources, such as libraries or previously written code.

INSERT(aList, i, value)

shifts to the right any values in aList at indices greater than or equal to i. The length of the list is increased by 1, and value is placed at index i in aList.

test cases

specification of the inputs, execution conditions, testing procedure, and expected results that define a single test to be executed to achieve a particular algorithm testing

Application program interfaces (APIs)

specifications for how the procedures in a library behave and can be used.

testing

testing uses defined inputs to ensure that an algorithm or program is producing the expected outcomes. Programmers use the results from testing to revise their algorithms or programs.

index values 1

the index of the first element in a list.

Strings - manipulation

the process of changing, parsing, pasting, or analyzing strings

syntax

the set of rules that defines the combinations of symbols that are considered to be a correctly structured document or fragment in that language.

complete traversal

where all elements in the list are accessed

partial traversal

where only a portion of elements are accessed.

Iteration

~a repeating portion of an algorithm. ~repeats a specified number of times or until a given condition is met.

traversal

~accessing elements of a list. ~Iteration statements can be used to traverse a list.

list

~an ordered sequence of elements. For example, [value1, value2, value3, ...] describes a list where value1 is the first element, value2 is the second element, value3 is the third element, and so on. ~Allows multiple related items to be treated as a single value.

Proceedural Abstraction Manages Complexity

~by breaking problems down into interacting pieces, each with their own purpose, makes writing complex programs easier. ~which provides a name for a process and allows a procedure to be used only knowing what it does, not how it does it. ~by extract shared features to generalize functionality instead of duplicating code. This allows for program code reuse.

software library

~contains procedures that may be used in creating new programs. ~simplifies the task of creating complex programs.

Data abstraction

~provides a separation between the abstract properties of a data type and the concrete details of its representation. ~manage complexity in programs by giving a collection of data a name without referencing the specific details of the representation. ~can be created using lists.

Proceedural Abstraction

~which provides a name for a process and allows a procedure to be used only knowing what it does, not how it does it. ~helps improve code readability. ~allows programmers to change the internals of the procedure (to make it faster, more efficient, use less storage, etc.) without needing to notify users of the change as long as what the procedure does is reserved.

Data vs. Information

Data are raw facts; information is data converted into a meaningful & useful context for decision making

binary search requirement

Data must be in sorted order to use the binary search algorithm.

extreme data

Test data that checks the program works with data at the limits of validity

index

a common technique for referencing the elements in a list or string using natural numbers.

adding extra output statement(s)

a debugging process to show a checkpoint outputing the state of a program

algorithm

a finite set of instructions that accomplish a specific task.

logic error

a mistake in the algorithm or program that causes it to behave incorrectly or unexpectedly.

run-time error

a mistake in the program that occurs during the execution of a program. Programming languages define their own run-time errors.

syntax error

a mistake in the program where the rules of the programming language are not followed.

debuggers

a software tool used by programmers to help find and fix errors in computer code

visualizations

a software tool used by programmers to help see execution of computer code for error detection.

Validity of inputs

bounds or limits on data inputs example cheking for an @ in email address or that a zip code is 5 or 9 digits.

[value1, value2, value3, ...]

create a list with those values as the first, second, third, and so on items.

aList ← [ ]

creates a new empty list and assigns it to aList.

aList ← [value1, value2, value3,...]

creates a new list that contains the values value1, value2, value3, and ... at indices 1, 2, 3, and ...respectively and assigns it to aList.

combining lists

creating a new list with the contents of two list. Possibly with duplicates or without duplicate elements.

comparing lists

finding duplicate elements of two lists.

Binary search efficienty

more efficient than sequential/linear search when applied to sorted data.

Documentation

necessary in understanding the behavior(s) provided by the API/library and how to use them.

executable

Another name for object code that is ready to run on specific hardware.

FOR EACH item IN aList { <block of statements> }

The variable item is assigned the value of each element of aList sequentially, in order, from the first element to the last element. The code in block of statements is executed once for each assignment of item.

aList[i]

accesses the element of aList at index i. The first element of aList is at index 1 and accessed using the notation aList[1].

binary search

algorithm starts at the middle of a sorted data set of numbers and eliminates half of the data; this process repeats until the desired value is found or all elements have been eliminated.

overflow error

an error that occurs when a computer attempts to handle a number that is outside of the defined range of values.

element

an individual value in a list that is assigned a unique index.

string

an ordered sequence of characters.

List procedures

are implemented in accordance with the syntax rules of the programming language.

aList ← bList

assigns a copy of the list bList to the list aList. For example, if bList contains [20, 40, 60], then aList will also contain [20, 40, 60] after the assignment.

x ← aList [i]

assigns the value of aList[i] to the variable x.

aList[i] ← aList[j]

assigns the value of aList[j] to aList[i].

aList[i] ← x

assigns the value of x to aList[i].

sequential/linear search

check each element of a list, in order, until the desired value is found or all elements in the list have been checked.

string concatenation

concatenation joins together two or more strings end-to-end to make a new string.

hand tracing

debugging process where you pretend that you are the computer executing a program

LENGTH(aList)

evaluates to the number of elements currently in aList.

transforming list

every element of a data set, such as doubling every element in a list, or extracting the parent's email from every student record

APPEND(aList, value)

increases the length of aList by 1, and value is placed at the end of aList.

random number generation

means each execution may produce a different result.


Related study sets

Capitale Amérique du Nord et Amérique centrale

View Set

Basic Structure of the Human Body Ch.7

View Set

PEDS Practice: Chapter 24 Nursing Care of the Child with an Alteration in Cellular Regulation/Hematologic or Neoplastic Disorder

View Set

MFS526- Lean Operations Management

View Set

Psychology Chapter 15 Quiz Questions

View Set