Algorithms 1.1 Flashcards

1
Q

Data Type

A

Set of values and a set of operations on those values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Four primitive data types in Java

A

ints, doubles, booleans, chars

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

identifier

A

a sequence of letters, digits, _, and $ the first of which is not a digit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

variable

A

names a data-type value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

operator (+,-,*,/)

A

names a data-type operation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

literal

A

source- code representation of a value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

expression

A

a literal, a variable, or a sequence of operations on literals and/or variables that produces a value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
Sets of Values on:
int
double
boolean
char
A

int: integers between -2^31 and +2^31 -1 (32 bit two’s complement)
double: double precision real numbers
boolean: true or false
char: characters (16 bit)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Cast

A

a directive to convert a value of one type into a value of another type. e.g. casting a double to an int truncates toward zero

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Additional Primitives

A
long- 64-bit ints
short- 16-bit ints
char- 16 bit chars
byte-8 bit ints
float- 32-bit single precision real numbers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Statements

A

Fundamental building block of a program. Contain created and manipulated variables, assigned values, and controlled flow of execution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Declarations

A

Creates the variable and specifies type and name(identifier)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Assignments

A

Associate data-type val w/ variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Initialize Declarations

A

A declaration and assignment put together. Declares and assigns at same time (e.g. int i=1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Implicit Assignments

A

Increment operators such as i++ or i /= 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Conditionals

A

Change in the flow of execution, e.g. if statements

17
Q

Loops

A

for/while loops

18
Q

Break

A

immediately exits the loop

19
Q

Continue

A

immediately begins the next iteration of the loop

20
Q

Array

A

Stores a sequence of values that are all of the same type.

21
Q

3 Steps of making an Array

A

1) Declare the array name and type
2) create the array
3) initialize the array values

22
Q

Does an array have a fixed size?

A

Yes

23
Q

How to create an array? (in short form)

A

double[] a= new double[N]; where N is the size of the array.

24
Q

What happens you try accessing an array with a bad index?

A

ArrayIndexOutOfBoundsException

25
Q

two-dimensional arrays

A

2D array is an array of 1d arrays. row major order

26
Q

Static Methods

A

a function. Terminates via return statement. return type included in signature

27
Q

void

A

no return value. Can be included in a static method

28
Q

Three important rules of recursion

A

1) Base Case
2) address subproblems that are smaller in order to work back to base case
3) recursive calls should not address subproblems that overlap

29
Q

Modular programming

A

Static methods in one library can call static methods in another library

30
Q

Formatted output (% usage)

A

%d int 1
%f float 1.1
%e exp. 1.23e+02
%s string “Hello”

31
Q

Common Input/output libs

A

StdIn.java
StdOut.java
StdRandom.java