CS basics Flashcards
Data structures e.g. Stack vs queue
stack uses LIFO
queue uses FIFO
Describe heap
heap is a data structure made up of “nodes” that contain values.
tree
Boolean operations, short circuits in Boolean operations
, & , ^ , ! , || , && , == , !=
circuit - when all conditions are not checked if not needed: && and ||
Recursion, tail recursion, mutual recursion
head - recursive call before other processing in the function
tail - the processing occurs before the recursive call.
Mutual recusion - two objects are defined in terms of each other
Sorting algorithms
Bubble sort - compare each pair
Insertion Sort - compare each with previous
Selection Sort - fin mininum. put in start
Merge Sort - divide into sublists and sort
Quick Sort - take element. move less to the left, move more to the right. repeat
Complexity of algorithms, big O notation
big-O notation is an asymptotic upper bound
Trees, graphs and ways to traverse graph
tree is an undirected graph in which any two vertices are connected by exactly one path
Binary tree
each node has up to two child nodes
Search in binary tree
- Start from root.
- Compare the inserting element with root, if less than root, then recurse for left, else recurse for right.
- If element to search is found anywhere, return true, else return false.
Dynamic programming
is a method for solving a complex problem by breaking it down into a collection of simpler subproblems
How would you fix a cyclic dependency
Use interfaces
What is the difference between static and dynamic typing? Duck typing?
Static typing means that type errors are reported at compile time
dynamic typing means that type errors are reported at runtime
duck typeing - object supports operation. no matter what type