Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
16 Cards in this Set
- Front
- Back
- 3rd side (hint)
instantiation versus initialization
|
Instantiation is when you actually create an object in your code. Remember that classes are templates, or definitions for objects.
Initialization is when you first assign a value to a variable. |
constructors instantiate
|
|
expression versus statement
|
Expressions have a value, while statements do not. If you can pass it as an argument to a function, it's an expression. If you can't, it's a statement.
|
|
|
comparator
|
==, which is a comparator (also called a relational operator). == means "is equal to." When you type
|
|
|
instance variable
|
variable defined in a class (i.e. a member variable), for which each object of the class has a separate copy. They live in memory for the life of the object; their values are unique to each instance of a class (to each object, in other words); the currentSpeed of one bicycle is independent from the currentSpeed of another.
private double length; An instance variable contrasts with a class variables that declare with ‘static’ keyword. |
Ruby: You'll notice that the variable names length and breadth have an @ symbol placed in front of them. This is a convention which designates them as being a part of the state of the class, or to use jargon, they are the "instance variables of the class." This means that every instance of the class Rectangle will have its own unique copies of these variables and is in effect, a distinct rectangle.
|
|
hash
|
Hashes are also called 'associative arrays', 'dictionary', 'HashMap' etc. in other languages
|
|
|
instance of a class
|
classes act as the factories that build objects. An object built by a certain class is called 'an instance of that class.' Typically, calling the new method on a class results in an instance being created.
|
|
|
do while loop
|
do/while loop, you set a condition when you want the loop to stop. a do/while loop is not counter controlled, rather it checks to see if a condition is met.
|
|
|
how are for loops and while loops similar
|
For loop and While loops are entry condition loops. They evaluate condition first, so the statement block associated with the loop won't run even once if the condition fails to meet
|
|
|
when do you use an iterator or each
|
when you know the length, uses a counter
|
|
|
while versus do while loops
|
while loops evaluate their condition before the code block, and do-while evaluates after the code bloc
|
|
|
statement versus expression
|
statements contrast with expressions in that statements do not return results and are executed solely for their side effects, while expressions always return a result and often do not have side effects at all
|
Simple statements
assignment: A:= A + 5 call: CLEARSCREEN() return: return 5; goto: goto 5 assertion: assert(ptr != NULL); [edit]Compound statements block: begin integer NUMBER; WRITE('Number? '); READLN(NUMBER); A:= A*NUMBER end if-statement: if A > 3 then WRITELN(A) else WRITELN("NOT YET"); end switch-statement: switch (c) { case 'a': alert(); break; case 'q': quit(); break; } while-loop: while NOT EOF DO begin READLN end do-loop: do { computation(&i); } while (i < 10); for-loop: for A:=1 to 10 do WRITELN(A) end |
|
When do you use bisection search?
|
When you have an ordered set of possible solutions
|
|
|
linear search
|
start at the beginning and walk to the end, testing for a match at each item. As the number gets larger times in creases in linear fashion
|
|
|
assume that the item being searched for will always be in the list
|
variation of sequential search assumes that the list is ordered (in ascending sorted order for the algorithm we will use):
|
|
|
"divide and conquer"
|
by dividing it into two or more smaller instances. Each of these smaller instances is recursively solved, and the solutions are combined to produce a solution for the original instanc
|
|
|
synonyms for bisection search
|
"binary" "linear search", "interpolation search", "Fibonaccian search"
|
|