csc 1052 final
add and remove if already sorted time complexity
O(N)
linear search time complexity
O(N)
linked list traversal time complexity
O(N)
selection sort time complexity
O(N^2)
binary search time complexity
O(logN)
binary search tree remove method
1. remove leaf 2. remove node w one child, replace w child 3. remove node w two children, replace w right most leaf of left subtree
a class can extend an interface (T/F)
F
an interface can implement an interface (T/F)
F
queue
FIFO
== vs equalsTo()
== compares address/reference equalsTo() compares value
post order
L R root
in order
L root R
stack order
LIFO
skewed BST height
N
a class can extend a class (T/F)
T
a class can implement an interface (T/F)
T
an interface can extend an interface (T/F)
T
quadratic probing
add to i+i^2 where i = index
linear probing
add to next available index
binary search tree add method
always adds as a leaf
3 levels of abstraction
application (user), abstract (designer), implementation (programmer)
implementation dependent structures
array, linked list
finding an element in collection unsorted time complexity
array: O(N) linked list: O(N)
finding an element in collection sorted time complexity
array: O(logN) linked list: O(N)
recursion set-up
base case, smaller caller, general case
recursive design BST
base case: node == null general case: node != null smaller caller: recursively apply on left and right subtrees
child parent relationship in package
child inherits everything, can design new attributes and methods, and can override parent class
list operations
collection operations and indexed operations
inheritance based polymorphism
declare a parent object and instantiate as a child class object
interface based polymorphism
declare interface type object and instantiate it to different class object
hash map
each key is mapped to one value
queue operations
enqueue (add to end), dequeue (remove from front)
unchecked exception
extend as a runtime exception
circular design
front = (front + 1)%size rear = (rear + 1)%size
collection
group of elements stores based on information
checked exception
handle or unhandle
fixed front queue
index of front always 0 (dequeue and shift)
floating front queue
index of front changes (dequeue and no shift)
list
indexed collection
abstract data types
int type in java, stack, queue
two types of polymorphism
interface based and inheritance based
compression function
key --> index --> value
collision handling
linear probing and quadratic probing
bushy BST height
logN
iteration
outer class: separate .java file inner class: class within a class anonymous class: has no name, returns iterator object as an inner class
java compilation unit contains
package statement, import statement, class definition
stack operations
push, pop, top, isEmpty, isFull
collection operations
remove, contains, add, get
comparable interface
returns int --> <0 : less than 0 : equal >0 : greater than
pre order
root L R
implementation independent structures
stack, queue, graph, tree
try catch statement
thrown at the code where exception may happen; prints error message
DFT (depth first traversal)
visits leaves L to R
BFT (breadth first traversal)
visits level by level