Fundamentals Flashcards
default values of primitive numeric types
0 (page 84)
default values of boolean types
false (page 84)
default values of reference types
null
default no-argument constructor default instance values
default equal primitive, boolean and reference default values (page 84)
equality of reference variables
== tests whether or no they have the same identity: wether the references are equal. equals() tests whether the data-type values are the same and can be implemented by the client.
Bags
A collection where removing items is not supported-its purpose is to provide clients with the ability to collect items and then to iterate through the collected items. Can also test if bag is empty and find its number of items. (Page 124)
Dijkstra’s Two-Stack Algorithm
Push opera da onto the operand stack
Push operators onto the operator stack
Ignore left parentheses
For right parenthesis, pop an operator, pop the requisite number of operands, and push onto the operand stack the result of applying that operator to this operands
Linked List
A recursive data structure that is either empty (null) or a node having a generic item and a reference to a linked list.
Insert at beginning LL
Time it takes is independent of length of the list.
Remove from beginning LL
Running time is independent of the length of the list.
Insert at the end LL
Need a link to the last node in the list. Every method that modifies the list needs code to check whether that variable needs to be modified.
Insert/remove at other positions LL
Take time proportional to the length of the list. Doubly-linked list is the standard solution.
Harmonic Sum
1 + 1/2 + 1/3 + … 1/n ~ ln n
Triangular Sum
1 + 2 + 3 + … + n ~ n**2/2
Geometric Sum
1 + 2 + 4 + 8 + … + n = 2n - 1 ~ 2n when n = 2**n