Data Structures Exam 2

Ace your homework & exams now with Quizwiz!

What does analyzing an algorithm mean?

*Predicting* the resources that the algorithm requires Resources include Memory Communication bandwidth Computational time (usually most important)

__________ and other ____________ can be _____________ for delivery or exchange

*Source code* and other *supporting files* can be *packaged together* for delivery or exchange

Problem Solving Main Steps

1. Problem definition 2. How many different ways you can solve it (Algorithm design) 3. Algorithm analysis 4. Implementation

A _________________ shows the relationship between the size of the problem (n) and the value we hope to optimize

A *growth function* shows the relationship between the size of the problem (n) and the value we hope to optimize

A collection provides ____________________________ the elements it contains

A collection provides *services to add, remove, and manage* the elements it contains

Stack

A linear collection whose elements are added and removed from the same end

What is an array?

A list of values

An API (Application Programming Interface) is...

A set of classes that support some particular aspect of software development

An abstract data type (ADT) is...

A set of data and the particular operations that are allowed on that data

What is a test case?

A set of inputs, user actions, or initial conditions, and the expected output

What is a debugger?

A software application that aids us in our debugging efforts

Algorithm analysis can be performed relative to the amount of memory (space) a program uses, but the amount of __________________ is usually a more interesting issue

Algorithm analysis can be performed relative to the *amount of memory (space)* a program uses, but the amount of *CPU time (time)* is usually a more interesting issue

Algorithms _____________ is most important in CS

Algorithms *running time* is most important in CS

An ____________ reference can refer to any kind of object

An *object* reference can refer to any kind of object

An algorithm's _______________ is a major factor in determining how fast a program executes

An algorithm's *efficiency* is a major factor in determining how fast a program executes

An array stores multiple values of the ___________ - _______________

An array stores multiple values of the *same type* - *the element type*

An individual array element can be passed to a method as well, in which case the type of the ________________ is the same as the ______________

An individual array element can be passed to a method as well, in which case the type of the *formal parameter* is the same as the *element type*

Collection

An object that serves as a repository for other objects

Arithmetic operations are traditionally written in ______ notation, meaning that the __________________________ in the form <operand> <operator> <operand>

Arithmetic operations are traditionally written in *infix* notation, meaning that the *operator is placed between its operands in the form* <operand> <operator> <operand>

Ragged arrays

Arrays that don't have the same amount of rows in each column, and vice versa

Asymptotic complexity is based on the __________________ of the growth function - the term that increases most quickly as n increases

Asymptotic complexity is based on the *dominant term* of the growth function - the term that increases most quickly as *n* increases

Asymptotic complexity is called the _______ of the algorithm, also referred to as Big O() or Big-Oh notation

Asymptotic complexity is called the *order* of the algorithm, also referred to as Big O() or Big-Oh notation

Checking by the compiler provides...

Better type safety

Black-box

Black Box Testing is a software testing method in which the internal structure/ design/ implementation of the item being tested is NOT known to the tester

How does the compiler determine which method is being invoked?

By analyzing the parameters

Two-dimensional array

Can be thought of as a table of elements, with rows and columns

Factors affecting the running time

Computer (CPU, Memory, Bus Speed, Cache, etc) compiler algorithm used Input size to the algorithm

Unit Testing

Creates a test case for each module of code that been authored. The goal is to ensure *correctness of the methods*, one method at a time

Testing is also referred to as...

Defect testing

Each array object has a _______________ called length that stores the size of the array

Each array object has a *public constant* called length that stores the size of the array

Each object stored in an array must be ____________ separately

Each object stored in an array must be *instantiated* separately

Linear

Elements are organized in a straight line

Nonlinear

Elements are organized in something other than a straight line

Algorithmic improvement is less useful than hardware improvement. T/F

False. Algorithmic improvement is *more* useful than hardware improvement.

The return type of the method is part of the signature. T/F

False. The return type of the method is NOT part of the signature.

Algorithm

Finite set of instructions that, if followed, accomplishes a particular task

For a __________ algorithm, the size of the program is the number of elements to be sorted

For a *sorting* algorithm, the size of the program is the number of elements to be sorted

For every algorithm we want to analyze, we need to define the __________________

For every algorithm we want to analyze, we need to define the *size of the problem*

An algorithm is correct if...

For every input instance, it *halts* with the correct output

A class can be based on a...

Generic type

Average-case scenario

Here we do not bound the worst case running time, but try to calculate the expected time spent on a *randomly chosen input.* This kind of analysis is generally harder, since it often requires assumptions about the randomness of inputs that may be difficult to justify.

The overall amount of time spent at the task is directly related to what?

How many times we have to perform the key processing step

Space complexity

How much space (inside RAM) is required

Time complexity

How much time (inside CPU) does it take to run the algorithm

Multidimensional array

If an array has more than one dimension. Note: Arrays can have many dimensions

In Java, the ______________________ that must be instantiated

In Java, the *array itself is an object* that must be instantiated

Where can an initializer list only be used?

In the array declaration

Having a faster processor is nice, but...

It will never eliminate the need to find better algorithms

It's common to introduce ____________ when using arrays

It's common to introduce *off-by-one errors* when using arrays

What is the tool's name?

Jar

Java uses the __________ to compress and bundle the files

Jar file

Stacks are processed in a...

Last in, first out (LIFO) manner

Each dimension has its own what?

Length constant

Like any other object, the ___________ to the array is passed, making the __________ and ________________ aliases of each other

Like any other object, the *reference* to the array is passed, making the *formal* and *actual parameters* aliases of each other

Collections can be separated into what two categories?

Linear and nonlinear

Incorrect algorithms

Might not halt at all on some input instances Might halt with other than the desired answer

Integration Testing

Modules that were individually tested are now tested as a collection. This form of testing looks at the larger picture and *determines if bugs are present when modules are brought together*

When loops are nested, we must...

Multiply the complexity of the outer loop by the complexity of the inner loop

Initially an array of objects holds what?

Null references

Running a program with _________________________ establishes only that the program works for that _______________

Running a program with *specific input and producing correct results* establishes only that the program works for that *particular input*

System Testing

Seeks to test the *entire software system* and how it adheres to the requirements (also known as alpha or beta tests)

One-dimensional array

Stores a list of elements

What is test driven development?

Test cases are written first only enough source code is implemented such that the test case will pass

What is debugging?

The act of *locating* and *correcting* *run-time* and *logic errors* in programs

What is testing?

The act of running a completed program with various inputs to discover problems Any evaluation that is performed by human or machine to asses the quality of the evolving system

The class will then be able to operate on, store, and manage objects whose type is not specified until...

The class is instantiated

The element type can be a ______________ or an _______________

The element type can be a *primitive type* or an *object reference*

The key issue is the ___________________ of the function - how it grows as n increases

The key issue is the *asymptotic complexity* of the function - how it grows as *n* increases

Worst-case scenario

The maximum time an algorithm takes to solve the problem. It may very well take less time on some inputs of size n, but it doesn't matter.

An ADT is considered abstract because...

The operations you can perform on it are separated from the underlying implementation

Organization elements, relative to each other, is usually determined by...

The order in which they were added to the collection and some inherent relationship among the elements

Method overloading

The process of giving a single method name multiple definitions

The underlying __________________ used to implement the collection is independent of the operations provided

The underlying *data structure* used to implement the collection is independent of the operations provided

Array elements

The values held in an array

How many approaches are there to defect testing?

There are *two* approaches to defect testing. Black-box and white-box.

What is the goal of testing?

To find errors

What can an initializer list be used for?

To instantiate and fill an array in one step

What do breakpoints allow us to do?

To pause the program at a given point

Constructors can be overloaded. T/F

True Constructor can be overloaded.

A good rule of thumb is: the slower the asymptotic growth rate, the better the algorithm (although this is often not the whole story). T/F

True. A good rule of thumb is: the slower the asymptotic growth rate, the better the algorithm (although this is often not the whole story).

Changing an array element within the method changes the original T/F

True. Changing an array element within the method changes the original

Jar files are really just special .zip files T/F

True. Jar files are really just special .zip files

Optimizing an algorithm - tweaking it so that it is more efficient - is good T/F

True. Optimizing an algorithm - tweaking it so that it is more efficient - is good

The array type does not specify its size, but each object of that type has a specific size. T/F

True. The array type does not specify its size, but each object of that type has a specific size.

length holds the number of elements, not the largest index T/F

True. length holds the number of elements, not the largest index

Typically, the ______________ (number of items in the input) is the main consideration, when discussing factors affecting the running time

Typically, the *input size* (number of items in the input) is the main consideration, when discussing factors affecting the running time

Usually, stacks are depicted vertically, and we refer to the ___ of the stack as the end to which elements are added and removed

Usually, stacks are depicted vertically, and we refer to the *top* of the stack as the end to which elements are added and removed

We only analyze ____________ algorithms

We only analyze *correct* algorithms

When _______________ a file, the size of the problem is the size of the file

When *downloading* a file, the size of the problem is the size of the file

When ______________ for a target value, the size of the problem is the size of the search pool

When *searching* for a target value, the size of the problem is the size of the search pool

When evaluating infix expressions, we rely on _________________ to determine the order of operator evaluation

When evaluating infix expressions, we rely on *precedence rules* to determine the order of operator evaluation

Automatic bounds checking

When the Java interpreter throws an ArrayIndexOutOfBoundsException if an array index is out of bounds

What is regression testing?

When you re-run the previous test cases to ensure we didn't introduce new errors

White-box

White Box Testing is a software testing method in which the internal structure/ design/ implementation of the item being tested is known to the tester. Goal is to ensure that *every path through a program is executed at least once* *Statement coverage testing* - test that maps the possible paths through the code and ensures that the *test case causes every path to be executed*

Best-case scenario

You run your algorithm many times and find the best case. This is just being too optimistic.

When an object is passed to a method, the actual parameter and the formal parameter become...

aliases of each other

The signature includes the ________, _________, and _________ of the parameters

number, type, and order

The signature of each overloaded method must be...

unique

Parameters in a Java method are passed by...

value


Related study sets

Chapter 1: Overview of Marketing

View Set

Concepts of care for patients with inflammatory intestinal conditions chapter 49

View Set

Macroeconomics Final Exam Review

View Set

3B Review - Carbon-based Chemistry

View Set