google interview university (jwasham) 1

Ace your homework & exams now with Quizwiz!

What is typical cache line size?

"64 bytes.

What is a treap?

"A random priority is assigned to every key and must maintain two properties:

What is a red-black tree?

"BSTs having red and black links satisfying:

What does ELF stand for?

"Executable and Linkable Format.

What are the 5 steps of the compiling process?

"Lexical Analysis

What is a van Emde Boas tree?

"The van Emde Boas tree supports insertions, deletions, lookups, successor queries, and predecessor queries in time O(log log U), where U is the universe of items to store. Items are stored in clusters of size sqrt(U).

How would you swap 2 integers using only bitwise operations?

"a ^= b

size of char in bytes

1 byte

2^10

1024

2^7

128

2 ^ 4

16

What is the square root of 256?

16

size of wchar_t in bits

16 bits

size of short in bits

16 bits (at least), and 16 commonly

2^14

16,384

size of wchar_t in bytes

2 bytes

size of short in bytes

2 bytes, and 2 bytes commonly

2^11

2048

2^8

256

2^5

32

size of long in bits

32 (at least, 32 commonly), 64 on LP64

size of float in bits

32 bits

size of int in bits

32 bits commonly, at least 16 bits

2^15

32,768

size of float in bytes

4 bytes

size of int in bytes

4 bytes commonly, at least 2 bytes

size of long in bytes

4 bytes, (at least 4, and commonly 4), 8 on LP64

2^32

4.294 Billion

2^12

4096

2^9

512

2^6

64

4 * 16

64

size of double in bits

64 bits

size of long long in bits

64 bits

2^16

65,536

2^3

8

size of bool in bits

8 bits

size of char in bits

8 bits

size of double in bytes

8 bytes

size of long long in bytes

8 bytes

2^13

8192

What is an AVL tree?

A BST where the height of every node and that of its sibling differ by at most 1.

What is a Binary Search Tree?

A binary tree is a data structure where each node has a comparable key and satisfies the restriction that the key in any node is larger than the keys in all nodes in that node's left subtree and smaller than the keys in all nodes in that node's right subtree.

What is the Hamming Distance?

A number used to denote the number of differences between two binary strings of the same length.

What is a splay tree?

A self-adjusting binary search tree where recently accessed elements are moved to the root so they are quick to access again.

What is an x-fast trie?

An x-fast trie is a data structure for storing integers from a bounded domain. It supports exact and predecessor or successor queries in time O(log log M), using O(n log M) space, where n is the number of stored values and M is the maximum value in the domain. The structure was proposed by Dan Willard in 1982, along with the more complicated y-fast trie, as a way to improve the space usage of van Emde Boas trees, while retaining the O(log log M) query time.

example of a latency device

CPU core

What is parsing?

Combining tokens and groups of tokens into a tree structure (a parse tree).

example of a throughput device

GPU core

What is Hamming Code?

In telecommunication, Hamming codes are a family of linear error-correcting codes that generalize the Hamming(7,4)-code, and were invented by Richard Hamming in 1950. Hamming codes can detect up to two-bit errors or correct one-bit errors without detection of uncorrected errors.

What is a compressed trie?

It's a trie where the non-branching paths are compacted into a single edge.

What is latency?

Latency is the delay from input into a system to desired outcome. The time interval between between a stimulus and response.

Is quicksort stable?

No.

Can merge sort be done in-place?

No. It requires O(n) space. There is an in-place version?

What is code generation?

Producing a translation from a high-level program to assembly code. (Linker and Archiver taker over from here to produce machine code)

What relationship of the keys do you lose with a hash table?

The ordering of the keys.

What is lexical analysis?

The process of dividing program text into words or tokens.

How is a deque usually implemented?

Using a Circular Array or Doubly Linked List.

How are queues usually implemented?

Using a Circular Array or Singly Linked List.

Can quicksort be done in-place?

Yes.

Is insertion sort stable?

Yes.

Is merge sort stable?

Yes.

Using bitwise operations, how would you test that a number is a power of 2?

bool isPowerOfTwo = (x & (x - 1);

Output a file with line numbers.

cat -n somefile

Take a file delimited by : and make it tab-delimited.

cat /etc/passwd | sed 's/:/\t/g'

Print columns 2, 3, and 6 from the date command.

date | awk '{print $2, $3, $6}'

How many levels in a complete binary tree of size n?

floor(1 + log(base2)(n))

Sed command to take a file separated by spaces, turn spaces into newlines, and then sort it alphabetically.

sed 's/ /\n/g' words.txt | sort

How would you turn OFF the 3rd bit from the end in a bitstring?

x &= ~(1 << 2);

How would you turn ON the 3rd bit from the end in a bitstring?

x |= (1 << 2)

If A is a matrix and Aij is the ith row, jth column, what is the traspose B?

Bji

What is the ECX register used for?

Counter for string and loop operations.

What is counting sort?

Counting sort is an algorithm for sorting a collection of objects according to keys that are small integers; that is, it is an integer sorting algorithm. It operates by counting the number of objects that have each distinct key value, and using arithmetic on those counts to determine the positions of each key value in the output sequence. Its running time is linear in the number of items and the difference between the maximum and minimum key values, so it is only suitable for direct use in situations where the variation in keys is not significantly greater than the number of items. However, it is often used as a subroutine in another sorting algorithm, radix sort, that can handle larger keys more efficiently.

What is path coverage?

Coverage that is concerned with the paths taken to arrive at a place in the code.

In a child process, what can you do with fork and then exec?

Create a completely new process and then exit.

How does Linux handle CPU affinity?

Default Linux kernels don't do a good job at keeping CPU affinity, even on idle machines. You must explore alternative schedulers or use taskset or cpuset to control affinity yourself.

What is the Strategy pattern?

Defines a family of algorithms, encapsulates each one, and makes them interchangeable. Lets the algorithm vary independently from clients that use it.

What is the Observer pattern?

Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

What is the Mediator pattern?

Defines an object that encapsulates how a set of objects interact. Promotes loose coupling by keeping objects from referring to each other explicitly and it lets you vary their interactions independently.

What is the Template Method pattern?

Defines the skeleton of an algorithm in an operation, deferring some steps to subclasses. Lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.

What are some benefits of arrays?

"- Constant-time access given the index

Give 2 examples of common data structures that contain reference cycles.

"- Doubly-linked lists

What is the execution sequence for a program?

"- Fetch instruction

What are the 2 algorithms for convex hull?

"- Graham scan

What are some solid principles to keep in mind for scaling?

"- Keep it very simple

What are some advantages to arrays over linked lists?

"- Linked structures require extra space for storing pointer fields.

What are some guidelines to keep in mind to not violate the dependency inversion principle?

"- No variable should have a concrete class type. An abstract type is better.

What are some advantages to linked lists over arrays?

"- Overflow on linked structures can never occur unless the memory is actually full.

What are some TCP/IP network access layer protocols?

"- RJ45

What are the 3 choices in load balancers? The 3 kinds, not balancing mechanisms.

"- Smart client, a software based mechanism for determining the availability of a server.

What are 2 disadvantages of reference counting?

"- it cannot collect circular references

What does __getitem__ in a class allow us to use?

"- iteration

What are some coverage metrics?

"- line coverage

What suffers from GC pauses?

"- long-running processes like servers

What are 3 properties of good hashing functions?

"- minimize collisions

What are some things the scheduler tries to accomplish?

"- minimize response time

What does code coverage not tell you?

"- missing errors of omission

What aspects are important in measuring and benchmarking performance, parallel or otherwise?

"- multiple repetitions

What is the difference between a pointer and a reference?

"- must dereference a pointer: foo->prop

What are the four conditions needed for a deadlock?

"- mutual exclusion

What are the five states a process can be in?

"- new (when being created)

What is system testing?

"- not concerned with internals

What kinds of problems is dynamic programming best suited for?

"- optimizing left to right sequences (strings, tree nodes as array, permutations)

How can you solve a set cover problem?

"- pick largest set that covers most of the uncovered spots

What are the 4 parts of compiling a C program?

"- preprocessor

What factors affect performance?

"- processor speed

What are 3 good uses of hash tables?

"- quick lookups, inserts, and deletes

What are some use cases of Hadoop?

"- reporting on user behavior over many events

What are 2 words for matrices that are invertible?

"- singular

What is contained in a packet?

"- source IP

What should be avoided to ensure testing is easier/possible?

"- static methods and properties

What are 2 advantages of merge sort?

"- suitable for a linked list

What are long-term issues involved in machine learning?

"- technical debt

What can affect testing, apart from API inputs?

"- timing of inputs

Name some NP-Complete problems.

"- tsp

What operations are a treap optimized for?

"- union

What are 3 situations where timing of inputs is important in testing?

"- when SUT interacts directly with hardware devices

When can we use the normal equation instead of gradient descent to minimize J(theta)?

"- when we have fewer than 10,000 features

What does Andrew Ng use to find an appropriate alpha for gradient descent?

"0.001

How long does context switching take?

"0.1ms - 1ms

What are some key things to remember when scaling a large system?

"1) Asynchronous is good (use queues, topics/pub-sub)

Time to read 1MB sequentially from an SSD?

"1,000,000 nanoseconds (1 ms)

What is a good method for performing a topological sort?

"1. Calculate in-degree for each node. O(v + e)

What are 3 benefits of containers?

"1. Containers encapsulate the application environment, abstracting away many details of machines and operating systems from the application developer and the deployment infrastructure.

What is Akka?

"An open source project that provides a simpler, single programming model - one way of coding for concurrent and distributed applications - the actor programming model.

What is 0xF in decimal?

15

What's the maximum unsigned number you can represent with 4 bits?

15

Time to read 4KB randomly from an SSD?

150,000 nanoseconds (0.15 ms)

Timing to send a packet CA -> Netherlands -> CA?

150,000,000 nanoseconds (150 ms)

16^1 ?

16

How many columns are in a 12 x 16 matrix?

16

What is the word size on Intel?

16 bits

16^6 ?

16 million

How many bits does a SHA1 produce?

160

What is the range of the first octet on a Class C network?

192-223

What is Fib(3) ?

2

How would you calculate the F1 score?

2 * precision * recall / (precision + recall)

What is the maximum height of a red-black tree?

2 log n

How does Diffie-Hellman key exchange work?

2 parties agree on a G and a modulus p, and each party comes up with a number. One party does G^a and the other G^b. They pass this information. One party A computes the key from B as B^a mod p. B computes A^b mod p to get the key.

What's the maximum signed number you can represent with 32 bits?

2.147 Billion

What is the size of a TCP header?

20 bytes

What is the port for ssh?

22

How many bits does a SHA2 and SHA3 produce?

224 to 512

What is the port for telnet?

23

Timing of a mutex lock/unlock?

25 nanoseconds (ns)

Timing to read 1MB sequentially from memory?

250,000 nanoseconds (0.25 ms)

What does a broadcast ID end in?

255

What's the maximum signed number you can represent with 9 bits?

255

What's the maximum unsigned number you can represent with 8 bits?

255

16^2 ?

256

What is n/n^2?

1/n

What is 0xA in decimal?

10

Time to send 2K bytes over 1 Gbps network?

10,000 nanoseconds (0.01 ms)

Timing of a disk seek?

10,000,000 nanoseconds (10 ms)

Timing of a main memory reference?

100 nanoseconds (ns)

How long does it take to perform a thread context switch?

100ns

What is 0xA in binary?

1010

What is 0xB in binary?

1011

What is 0xB in decimal?

11

What is 0xC in binary?

1100

What is 0xD in binary?

1101

What is 0xE in binary?

1110

What is 0xF in binary?

1111

How many rows are in a 12 x 16 matrix?

12

In linear algebra a 12-dimensional vector has how many rows?

12

In linear algebra a vector of 12 elements has how many rows?

12

What is 0xC in decimal?

12

What's the maximum signed number you can represent with 8 bits?

127

How many bits represent an IPv6 address?

128

What is the range of the first octet on a Class B network?

128 - 191

What is 0xD in decimal?

13

What is 0xE in decimal?

14

Given an alphabet of 26 letters, how many times you can you choose 3 letters, if ordering of the letters doesn't matter?

26*25*24 / 3! = 2600

You have 26 letters in an alphabet. How many ways you can arrange 3 letters from that alphabet without repeating a letter?

26*25*24 = 26 permute 3 = 15,600

You have 26 letters in an alphabet. How many ways you can arrange 3 letters from that alphabet where repeated letters is OK?

26*26*26 = 26^3 = 17,576

16^7

268 million

A binary tree with height h can contain at most how many nodes?

2^(h+1) − 1 nodes

What's the maximum address in memory for a 32 bit processor?

2^32 - 1

How many subsets are there in n items?

2^n

What is the maximum unsigned integer you can represent with n bits?

2^n - 1

In a heap, with a 1-based array, what is left child of i?

2i

In a heap, with a 0-based array, what is left child of i?

2i + 1

In a heap, with a 1-based array, what is right child of i?

2i + 1

In a heap, with a 0-based array, what is right child of i?

2i + 2

What is another name for quadratic?

2nd-order polynomial

Timing to compress 1KB?

3,000 nanoseconds (3 microseconds)

How long does it take to do a process context switch?

3-4 microseconds.

Timing of a context switch between processes?

3000 nanoseconds

How many bits represent an IPv4 address?

32

What is the double-word size on Intel?

32 bits

What's the maximum signed number you can represent with 16 bits?

32,767

What's the maximum unsigned number you can represent with 15 bits?

32,767

What's the maximum unsigned number you can represent with 32 bits?

4.294 Billion

16^8 ?

4.294 billion, same as 2^32

What is the timing overhead for a system call?

400 nanoseconds

16^3 ?

4096

How many bits are in an ethernet frame?

48 bits, represented as a hexadecimal number.

How many possible trees are there that span all nodes in a graph?

4^n

When multiplying a 4x3 matrix and a 3x6 matrix, what are the dimensions of the final matrix?

4x6

Timing of a branch misprediction?

5 nanoseconds (ns)

What is a critical section?

A block of code that multiple threads within a process could try to access at the same time. To ensure correct processing, the critical section should be locked before entering, then unlocked when leaving. This creates a mutual exclusion on shared data.

What is an out-of-band cache?

A cache layer that does not synch with persistent storage. When changes are made to the database, there are no notifications to synchronize with the cache. The cache entry would need to be updated or evicted by other means.

What is a polyalphabetic cipher?

A cipher where each letter is shifted based on the shifts of letters in a key word.

What is a binary heap?

A collection of keys arranged in a complete heap-ordered binary tree, represented in level order in an array (not using the first entry). The parent of the node in position k is in position [k/2] and the two children of the node in position k are in position 2k and 2k+1.

What is Chef?

A configuration tool. You write or reuse recipes that declare the state you wish your server to be in. It calculates the delta and builds out for you.

What is a convolution?

A convolution is a mathematical operation on two functions (f and g); it produces a third function, that is typically viewed as a modified version of one of the original functions.

What is a promise?

A promise to send a parameter to a child thread's function later.

What is a thread?

A single, unique execution context.

Maintaining a sorted array is good for what type of operations?

A sorted array will be appropriate if and only if there are not many insertions or deletions.

What is a maximum spanning tree?

A spanning tree of a weighted graph having maximum weight. It can be computed by negating the edges and running either Prim's or Kruskal's algorithms.

What is a trap/exception?

A special instruction that a program performs to interrupt the process and give control to the kernel.

What is a model?

A specification of a mathematical (or probabilistic) relationship that exists between different variables.

What could you use in DFS to turn a recursive algorithm into an interative one?

A stack.

What is a spanning tree?

A subgraph that contains all of that graph's vertices and a single tree.

What is a signal?

A system call to send a notification to another process.

"What happens every 100 ""ticks"" in the CPython interpreter?"

A thread check occurs during which the thread releases the GIL then attempts to reacquire it. Other Python threads will contend for the the GIL. This is no longer the case in 3.4.

What is the priority inversion problem?

A thread that is busy-waiting for a lock to be released ends up stealing CPU and getting a higher priority than the thread with the lock. SO since the waiting thread gets higher priority, the thread holding the lock can't complete and release the lock.

What is a pointer?

A pointer is a memory address stored in memory.

Give an example of the thread pool model.

A pool of threads can be maintained in order to quickly provide one as a resource for a database connection.

What radix is most natural to use?

A power of 2 radix.

What is a Adaptable Priority Queue?

A priority queue that allows you to change the priority of objects already in the queue.

What is a server?

A program that provides a service for other programs to connect to it.

Theta represents what?

A tight asymptotic bound on a function, in other words if both f and g have approximately the same rate of growth.

What is a TLB?

A translation lookaside buffer (TLB) is a cache that memory management hardware uses to improve virtual address translation speed. The majority of desktop, laptop, and server processors includes one or more TLBs in the memory management hardware, and it is nearly always present in any hardware that utilizes paged or segmented virtual memory.

What happens in a system call to get the OS to switch to kernel mode?

A trap.

What is a picosecond?

A trillionth of a second.

What is an articulation vertex?

A vertex of a graph whose deletion disconnects the graph.

What is a process VM?

A virtual environment that supports the execution of a single program. This is provided by an operating system.

What is a system VM?

A virtual environment that supports the execution of an entire operating system and its applications.

What are Dense Codes?

A way to put symbols or words into a dictionary or array, and use the indices as the values in the text to save space so that words are not repeated.

Give an example of the thread-per-connection pattern.

A web server might spawn a thread per connection, then reuse that thread once the connection ends, or terminate the thread.

What is a y-fast trie?

A y-fast trie is a data structure for storing integers from a bounded domain. It supports exact and predecessor or successor queries in time O(log log M), using O(n) space, where n is the number of stored values and M is the maximum value in the domain. The structure was proposed by Dan Willard in 1982 to decrease the O(n log M) space used by an x-fast trie.

What is priority in HTTP/2?

Different assets can have different priority so that below the fold content can arrive later.

What is DFT?

Discrete Fourier Transform - converts a finite sequence of equally-spaced samples of a function into an equivalent-length sequence of equally-spaced samples of the discrete-time Fourier transform (DTFT), which is a complex-valued function of frequency.

What is dispersion?

Dispersion refers to measures of how spread out our data is. Typically they're statistics for which values near zero signify not spread out at all and for which large values (whatever that means) signify very spread out.

What is celery?

Distributed Task Queue

What is the round robin scheduling scheme?

Each process gets a time quantum q milliseconds to run. 10-100ms, the q is tunable. Each process runs for that time slice (or until completion if close to done) and then goes back on the ready queue.

How does the OS abstract the environment for a process?

Each process thinks it has all the memory and CPU time, and thinks it owns all devices.

How does x86 do segments and stacks?

Each process' individual segments (heap, stack, code, static data) get their own base and bound. They don't even need to be adjacent in memory and their location is hidden by memory addressing.

What is Ehcache?

Ehcache is an open source, standards-based cache that boosts performance, offloads your database, and simplifies scalability. It's the most widely-used Java-based cache.

What is the Command pattern?

Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.

What is gradient descent?

Gradient descent is a first-order iterative optimization algorithm. To find a local minimum of a cost function using gradient descent, one takes steps proportional to the negative of the gradient (partial derivative or tangent) of the function at the current point.

What does it mean when a problem is NP-Hard?

It is as hard as any other problem in NP. A problem X is NP-Hard if every problem Y in NP-Hard reduces to X.

What should we worry about floating point addition and multiplication?

It is commutative but not associative.

What does it mean if the determinant of a matrix is zero?

It is not invertible.

What is ElasticSearch?

Open Source, Distributed, RESTful Search Engine

What does OSI stand for?

Open Systems Interconnect

What is the difference between PC and uPC?

PC is the program counter for the current process. uPC is the PC of the user process we will return to once an interrupt or other OS process switches context.

Codeless Question: You are given a search string and a magazine. You seek to generate all the characters in search string by cutting them out from the magazine. Give an algorithm to efficiently determine whether the magazine contains all the letters in the search string.

How would you do it?

Codeless quesiton: Write a program to convert a binary search tree into a linked list.

How would you do it?

Codeless question: Write a function to find the middle node of a singly-linked list.

How would you do it?

Code: Compute the power set of a set of integers S.

How?

Codeless question: Write a function to compare whether two binary trees are identical. Identical trees have the same key value at each position and the same structure.

How?

Write a function that computes the sqrt(n) using binary search.

How?

What is Huffman encoding?

Huffman encoding algorithm analyzes the occurrence of individual symbols and creates a binary tree where the common symbols are closest to the root, using fewer bits to encode, and less common/rare symbols have longer paths on the tree, with longer encodings to accommodate. By traversing the tree, from root to leaf, and keeping track of 1 or 0 at each node, we can determine the encoding of the symbol.

What is the name of Google's search ranking algorithm?

Hummingbird. PageRank is just one factor used by the algorithm.

What is hyper-threading?

Hyper-threading enables a single processor core to be used for two or more concurrent executions with just a little extra hardware.

What is the EDX register used for?

I/O pointer

In statistics, what does precision measure?

Precision measures how accurate our positive predictions are.

What is preemption?

Preemption is the act of temporarily interrupting a task being carried out by a computer system, without requiring its cooperation, and with the intention of resuming the task at a later time. Such a change is known as a context switch.

What is another name for a trie?

Prefix tree or a radix tree.

What is PCA and what is it used for?

Principal component analysis. We use it to extract one or more dimensions that capture as much of the variation in the data as possible.

How would you split up a data set in order to choose from multiple models?

In such a situation, you should split the data into three parts: a training set for building models, a validation set for choosing among trained models (called the cross-validation set), and a test set for judging the final model.

What is the primary factor of compression?

Probability of redundant portions of input.

What is a PCB and what does it have?

Process control block - It holds a complete snapshot of the state of the process.

What is fault isolation?

Processes are unable to directly impact other processes. Bugs can't crash the whole machine.

What design pattern specifies the kinds of objects to create using a prototypical instance, and creates new objects by copying this prototype?

Prototype pattern

What is the Proxy pattern?

Provides a surrogate or placeholder for another object to control access to it.

What is the Facade pattern?

Provides a unified interface to a set of interfaces in a subsystem. Defines a high-level interface that makes the subsystem easier to use.

What is the Iterator pattern?

Provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

What is the Abstract Factory pattern?

Provides an interface for creating families of related or dependent objects without specifying their concrete class.

What design pattern provides a surrogate or placeholder for another object to control access to it?

Proxy pattern

How would you implement a stack with a linked list?

Push and pop items at the head. Both operations are constant-time.

k-th smallest (full heap)

Put all values in, do k removeMin operations: O(N + k log N)

Why is using Protocol buffers better than pickling?

Python pickling doesn't deal well with schema evolution, and also doesn't work very well if you need to share data with applications written in C++ or Java.

What is QUIC?

QUIC is a new transport which reduces latency compared to that of TCP. On the surface, QUIC is very similar to TCP+TLS+HTTP/2 implemented on UDP.

What is reference counting?

RC is a method of garbage collection. The runtime keeps track of references to an object by manipulating the reference count on each assignment and delete (del), and when the reference count reaches 0 it means the object is practically unreachable. When the next collection runs, the object's memory will be reserved to allocate for new objects.

What design pattern ensures a class only has one instance and provides a global point of access to it?

Singleton pattern

What sort can you use when you have data you want to sort and the comparisons of keys are cheap but moving the data is expensive?

Selection sort guarantees no more than n - 1 swaps.

What is unicasting?

Sending a packet from one host to another.

What is the Builder pattern?

Separates the construction of a complex object from its representation, so the same construction process can create different representations.

What is privilege separation?

Separating an application into different areas so a vulnerability in one area doesn't affect the entire application.

What is the EBP register used for?

Stack frame base pointer

What is the ESP register used for?

Stack pointer

What is an example of a circuit breaker?

Start sending 503s if your service is choked to avoid numerous simultaneous retries that just make the system worse.

How many hidden layers should there be in a neural network?

Start with 1 as a default, and if more than one, have the same number of units at each layer. The more the better. The number of units in each hidden layer should be more than, or a multiple of, the input units.

What design pattern allows an object to alter its behavior when its internal state changes?

State pattern

What is the Prototype pattern?

Specifies the kinds of objects to create using a prototypical instance, and creates new objects by copying this prototype.

How would you divide up a data set for training and testing?

Split your data set, so that two-thirds of it is used to train the model, after which we test/measure the model's performance on the remaining third.

Machine learning: What tends to happen with the training error in a linear model as the degree of polynomial increases?

The error decreases, but too high a degree of polynomial will cause overfitting.

What privilege do you need to lookup files or directories in a path?

The executable permission.

What does a /24 CIDR mean?

The first 24 bits of the IP address are masked. Only hosts with addresses in the unmasked portion are reachable.

What does a /27 CIDR mean?

The first 27 bits are masked with 1s. The remaining 5 bits are reachable in the subnet.

What is Borg?

The first unified container-management system developed at Google. It was built to manage both long-running services and batch jobs.

What do you call a linear ordering of a directed graph of its vertices such that for every directed edge uv from vertex u to vertex v, u comes before v in the ordering?

Topological sort

What is transactional memory?

Transactional memory attempts to simplify concurrent programming by allowing a group of load and store instructions to execute in an atomic way. It is a concurrency control mechanism analogous to database transactions for controlling access to shared memory in concurrent computing.

What does TCP stand for?

Transmission Control Protocol

When is entropy at its maximum?

When all outcomes are equal.

Why are Fibonacci heaps special?

Fibonacci heaps support insert and decrease-key operations in constant amortized time, with O(lg n) amortized time extract-min and delete operations.

What design pattern provides a unified interface to a set of interfaces in a subsystem and defines a high-level interface that makes the subsystem easier to use.

Facade pattern

What design pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate?

Factory method (technically an idiom, not a design pattern)

What tends to become an issue as you add services in a datacenter and have to ping more caches and services to fulfill a request?

Fan-in, where you can overload routers due to increased internal network traffic.

What is F1/Spanner?

Fault-Tolerant Distributed RDBMS (Spanner) Supporting Google's Ad Business (F1)

What is Photon?

Fault-tolerant and Scalable Joining of Continuous Data Streams

What is GAE?

Google App Engine is a platform for building scalable web applications and mobile backends. App Engine provides you with built-in services and APIs such as NoSQL datastores, memcache, and a user authentication API, common to most applications.

What is phi(n) if n is prime?

n - 1

What is the log of n! ?

n log n

What is the formula for n choose k?

n! / k!(n - k)!

What does big-O mean? (briefly)

"It never gets as big as this.

What is livelock?

"It occurs when multiple processes are attempting to deal with the current state, but neither makes progress. This can happen when a system is attempting to resolve a deadlock situation but another or the same process continue to trigger it.

What is Karatsuba multiplication?

"It reduces the multiplication of two n-digit numbers to at most n^1.585 single-digit multiplications in general (and exactly n^log(base2)3 when n is a power of 2). The Karatsuba algorithm was the first multiplication algorithm asymptotically faster than the quadratic ""grade school"" algorithm."

What is the Burrows-Wheeler transform?

"It's a compression method involving the sorting of all possible rotations of the input text into lexicographic order. Take as output the last column and the index of the row that the original text appears in.

What is a fully-associative cache?

"It's a type of cache used in the CPU, where lookups are done on all cache lines in parallel to determine a hit or miss.

What does big-Omega mean? (briefly)

"It's at least as big as this.

What happens at the Physical layer of the OSI model?

"It's the physical network that deals with the physical transmission of electricity through wire:

What commands can be used to make a Redis queue somewhat reliable?

"LPUSH

How does LZ77-based compression work?

"LZ77 is a dictionary encoding algorithm, which is a statistical encoding algorithm. Compression in the LZ77 algorithm is based on the notion that strings of characters (words, phrases, etc.) occur repeatedly in the message being compressed.

How does PycURL compare to requests?

"PycURL can handle a large number of multiple concurrent requests. When reusing connections, it can perform more than 2,000 requests per second.

How are interfaces handled in Python?

"There are none.

What happens at the Session layer of the OSI model?

"This layer controls the communication's access via:

What happens at the Transport layer of the OSI model?

"This layer guarantees end-to-end delivery of data:

What happens in the Session layer of the OSI model?

"This layer handles configuration of the data:

What happens at the Network layer of the OSI model?

"This layer's function is to find the shortest path through the network to the destination network.

Execution Orchestrator

"This model is based on an intelligent scheduler / orchestrator to schedule ready-to-run tasks (based on a dependency graph) across a clusters of dumb workers.

What does the concurrent.futures module offer?

"ThreadPoolExecutor

What is the time and space complexity of Bellman-Ford?

"Time : O (|V| |E|) or Theta(n^3)

What is the time and space complexity of minimum edit distance using dynamic programming?

"Time O(mn)

What should you avoid in your base case in recursion?

"Too many base case scenarios. Just have one base case so you can return as quickly as possible. Avoid ""arm's length"" recursion."

What is a treap?

"Tree + heap

What is a hard problem that is not in NP?

"Two-player games such as chess provide examples of problems that are not in NP.

How can you avoid busy waiting?

"Use Semaphore (Python, Java)

What is WSGI?

"WSGI is the Web Server Gateway Interface. It is a specification that describes how a web server communicates with web applications, and how web applications can be chained together to process one request. It was outlined in PEP 3333.

What is a platform layer?

"Web applications to communicate with a platform layer which in turn communicates with your databases.

How can an LRU cache be implemented with a linked list?

"When an item is accessed, it moves to the head of the list.

What is the secure flag on a cookie?

"When set on a cookie, it will only be sent on https requests.

What is the PDU and the addressing at the Internet/Network layer?

"PDU: packet

What is the PDU and the addressing at the Transport layer?

"PDU: segment

What is an example of bulk synchronous processing?

"Parallel Graph Transformation

What is Protocol buffers?

"Protocol buffers (aka protobuf) are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data. IDL-based.

What is a PDU?

"Protocol data unit

What is PyPy?

"PyPy is a replacement for CPython. It is built using the RPython language that was co-developed with it. RPython is a subset of Python and can be translated to C. The main reason to use it instead of CPython is speed: it runs generally faster due to JIT compilation.

How can you optimize finding a pivot when the segment to pivot is large (not random choice)?

Choose a median of three.

How can you tell you're testing enough?

Code coverage metrics (of which there are a few)

What design pattern encapsulates a request as an object, thereby letting you parameterize clients with different requests?

Command pattern

What does CSP stand for?

Communicating Sequential Processes

What is the Composite pattern?

Compose objects into tree structures to represent part-whole hierarchies. Lets clients treat individual objects and compositions of objects uniformly.

What design pattern composes objects into tree structures to represent part-whole hierarchies?

Composite pattern

What is the Rabin-Karp algorithm?

Compute hash codes of each substring whose length is the length of s, such as a function with the property that the hash code of a string is an additive function of each individual character. Get the hash code of a sliding window of characters and compare if the hash matches.

What's the difference between parallelism and concurrency?

Concurrency means running multiple blocks of instructions independently. Parallelism means running instructions at the same time, as on multiple cores at once.

What is Kruskal's algorithm?

Kruskal's algorithm is a minimum-spanning-tree algorithm which finds an edge of the least possible weight that connects any two trees in the forest. It is a greedy algorithm in graph theory as it finds a minimum spanning tree for a connected weighted graph adding increasing cost arcs at each step. This means it finds a subset of the edges that forms a tree that includes every vertex, where the total weight of all the edges in the tree is minimized. If the graph is not connected, then it finds a minimum spanning forest (a minimum spanning tree for each connected component).

What type of scheduling do most modern processors use?

Mesa-scheduling.

Is Diffie-Hellman key exchange perfect?

No. A man in the middle can intercept one side, and communicate with parties A and B independently.

What is the entropy of n equally likely outcomes?

log(n)

How does the banker's algorithm solve the dining lawyers problem?

"When you try to grab a chopstick, it's either:

Is there much difference between grep, egrep, and grep -P?

"Yes, grep doesn't support fancy regex.

Can you sort a tuple?

"Yes, using sorted(foo)

What can you do if your model suffers from overfitting due to high variance?

"You can remove features. Another solution is to obtain more training examples (if you can).

How can you get your data to fit better using higher order terms in linear regression?

"You can take the data and square it, cube it, etc.

Codeless question: Give an algorithm for finding an ordered word pair (e.g., "New York") occurring with the greatest frequency in a given webpage. Which data structures would you use?

"You could use a hash table, creating or updating an entry for each pair.

What order of node and its children are involved in a postorder traversal?

"leftChild

What order of node and its children are involved in an inorder traversal?

"leftChild

What should locks and condition variables each be used for?

"locks - mutual exclusion

What is mc/dc coverage?

"modified condition / decision

How many ways can you rearrange a string of n unique characters?

"n!

How many ways can you arrange k characters from n unique characters?

"n! / (n - k)!

How many subsets (ordering doesn't matter) of size k are there in n unique characters?

"n! / k!(n - k)!

What order of node and its children are involved in a preorder traversal?

"node

What Python library computes the inverse of a matrix?

"numpy.linalg.inv

What is mean normalization?

A method of scaling a feature's values so that they all fall within a range relative to each other.

What is set partition?

A partitioning of elements of some universal set into a collection of disjointed subsets. Thus, each element must be in exactly one subset.

How does an inclusive cache style work?

Each cache line in L1D is also in L2. This makes L1D eviction faster.

What makes neural networks superior over regression or classification?

Each hidden layer learns its own features instead of being given features.

What is the phi function?

It answers the number of integers <= n that do not share a common factor with n.

Tell me about the checksum in a UDP packet.

It's a 16-bit checksum. It's only mandatory on IPv6

What is a lock in CPython?

It's a binary semaphore. It's not a mutex lock.

What is a directed broadcast?

It's a broadcast to all hosts within another network.

What is a stack canary?

It's a buffer overflow defense where a random value is pushed onto the stack after the saved EBP, and before tearing down the stack frame, the value is checked. Any buffer flow targeting the return instruction pointer would have to have overwritten this value.

What is base and bound?

It's a memory addressing restriction where a processes are only allowed access to the memory between a base address and the bound + base addresses. Each process has its own base and bound. A drawback is you don't get address 0. Address translation fixes this.

How does RSA work?

It's a public/private key cryptography method. The public key can be used to encrypt a message into ciphertext that only the owner of the key can decrypt. The owner of the key uses their secret key to encrypt messages, and their secret key to decrypt messages encrypted with their public key.

What does exec() do?

It's a system call to change the currently running program to something else.

What is a direct mapped cache?

It's a type of cache used in the CPU, where the lower order bits of a given memory address are used modulo the number of cache lines to place or lookup in the cache. Collisions are treated as overwrites.

What is LZMA?

It's a variant of LZ77 that uses Markov chains. It's used in the 7z compression algorithms used in 7-zip.

What is a socket?

It's an abstraction of a network I/O queue. It's a method of communication where a producer writes to one side, and a consumer reads from the other side. It's similar to writing and reading a file, but no file is involved.

What is DEFLATE?

It's an lossless compression algorithm based on LZ77 used in Gzip, WinZip, and mod_deflate, which is bundled with Apache web server for automated gzip compression of HTTP served content. It uses LZ77 and Huffman coding.

What does it mean to invert a matrix?

Multiplying it by a specific matrix so that the product is the identity matrix.

What is another term for linear regression with multiple variables?

Multivariate linear regression

What preference of nodes vs leaves does preorder traversal give on a tree?

Nodes first, leaves later.

What does NUMA stand for?

Non-Uniform Memory Architecture

What is an OCL?

Object constraint language. A specification language designed to formally specify constraints in software modules. An OCL expression specifies a logical fact about the system that must remain true.

build (ordered sequence)

O(N log N)

add (ordered singly linked list)

O(N)

build (binary heap)

O(N)

delete (ordered singly linked list)

O(N)

delete (unordered array)

O(N)

delete (unordered singly linked list)

O(N)

delete an element from a sorted array

O(N)

find (ordered singly linked list)

O(N)

find (unordered singly linked list)

O(N)

insert (ordered sequence)

O(N)

min (unordered sequence)

O(N)

removeMin (unordered sequence)

O(N)

is_adjacent (u,v) (adjacency matrix)

O(degree(u))

What is the algorithmic time complexity of radix sort?

O(digits)

What is the time complexity of Prim's algorithm on an adjacency list and a Fibonacci heap?

O(e + v log v)

add (Binary Search Tree)

O(h)

delete (Binary Search Tree)

O(h)

find (Binary Search Tree)

O(h)

How many nodes of k leaves are in a compressed trie (big-O)?

O(k) nodes with k leaves due to compression.

add (Balanced Binary Search Tree)

O(log N)

delete (Balanced Binary Search Tree)

O(log N)

find (Balanced Binary Search Tree)

O(log N)

insert (binary heap)

O(log N)

removeMin (binary heap)

O(log N)

What command on the terminal will execute the previously run command?

!!

What is the Factory Method pattern?

"(Technically it's an idiom)

What metric can you use to measure the badness of a line in a text justification problem?

"(page width - text width)^3

What can affect invertibility in a matrix?

"- 2 more more features are linearly dependent or redundant (size in meters and size in ft) - remove redundant features

How does a multi-processor CPU maintain cache coherency?

"- A dirty cache line is not present in any other processor's cache.

What are some examples of operations that are both associative and commutative?

"- Addition and multiplication of integers

What's the worst-case running time of binary search?

O(log n)

What is the average complexity of a Jarvis march?

O(n * h) where h is the number of points that compose the hull.

What is the space required for a graph using an adjacency list?

O(n + e)

Average case time complexity for quicksort?

O(n log n)

Best case time complexity for merge sort?

O(n log n)

Best case time complexity for quicksort?

O(n log n)

Worst case time complexity for quicksort?

O(n log n)

What is the worst-case space required for perfect hashing?

O(n)

add (sorted array)

O(n)

delete (ordered singly linked list)

O(n)

delete (unordered singly linked list)

O(n)

find (unordered array)

O(n)

find (unordered singly linked list)

O(n)

Best case time complexity for insertion sort?

O(n) when data is already sorted or almost sorted.

Average case time complexity for insertion sort?

O(n^2)

Average case time complexity for selection sort?

O(n^2)

Best case time complexity for selection sort?

O(n^2)

Worst case time complexity for insertion sort?

O(n^2)

Worst case time complexity for selection sort?

O(n^2)

Worst case time complexity for quicksort?

O(n^2) due to pathological pivot selection.

What is the counting sort running time?

O(q + n) where q is the number of unique items. If q is in O(n), then linear time.

What is the optimal load factor for a hash table?

O(sqrt(n))

What is the time complexity of Prim's algorithm on an adjacency matrix?

O(v^2)

What command line tool allows you to find and kill running processes by name?

"pkill

What is stored in a TCB?

"registers

In a b-tree, how many children are there per node?

"root: 1 to 2t-1 keys

What operations does a skip list support and what is their avg and worst case times?

"search: O(log n) O(n)

How can you redirect stdout and errors from a command to a file?

"somecommand > somefile.txt 2>&1

How can you sort a list of Employee objects by surname then given_name, case-sensitive?

"sorted_firstnames = sorted(directory, key=lambda emp: emp.given_name.lower())

What are the setuid binaries?

"su

What is SMP?

"symmetric multi-processor

What are the 3 methods on a condition variable?

"wait(&lock)

What is the complexity for a naive recursive Fibonacci function?

"Θ(φ^n), where phi(φ) is the golden ratio (1 + sqrt(5)) / 2.

What is treated as false in Python?

"• False

How can you optimize quicksort?

"• Use randomization - randomly permute the keys before sorting.

What does #P-complete mean?

#P is the class of problems solvable on a "counting" machine in polynomial time. A counting machine returns the number of distinct solutions to a problem. Counting the number of Hamiltonian cycles in a graph is a #P-complete problem that is trivially NP-hard (and presumably harder), since any count greater than zero proves that the graph is Hamiltonian. Counting problems can be #P-complete even if the corresponding decision problem can be solved in polynomial time, as shown by the permanent and perfect matchings.

What is the sum of this series when it's infinite and x < 1? 1 + x + x^2 + x^3 + ... x^n ?

1 / (1 - x)

What is a nanosecond?

1 billionth of a second. ns

What is a microsecond? Also known as μs

1 millionth of a second.

What is the gcd of a number a and prime p when p is prime?

1, unless a is a pseudoprime (Carmichael number)

16^5 ?

1,048,576

What is the range of the first octet on a Class A network?

1-126. We don't use 0 or 127.

What are design patterns?

Recurring, reusable solutions to common class and class relationship problems.

What is Redis?

Redis is an in-memory data structure store, used as database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries. Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster.

What do threads in a process NOT share?

Registers and stack.

What are the 2 types of problems that utilize supervised learning?

Regression and classification

What does it mean to reduce a problem A to a problem B?

Converting the input to algorithm A into input into algorithm B, providing an answer for A.

What is an interface in OO?

Similar to an abstract data type, but simply defines the expected behaviors of a class, but does not suggest an implementation.

What does SNMP stand for?

Simple Network Management Protocol.

Why do indexes tend to slow down writes?

Since you must both write the data and update the index.

What is the purpose of the transport layer?

To allow multiple applications to use one network connection simultaneously.

What is the Day-Stout-Warren (DSW) algorithm?

The Day-Stout-Warren (DSW) algorithm is a method for efficiently balancing binary search trees — that is, decreasing their height to O(log n) nodes, where n is the total number of nodes. Unlike a self-balancing binary search tree, it does not do this incrementally during each operation, but periodically, so that its cost can be amortized over many operations.

What is the Floyd-Warshall algorithm?

The Floyd-Warshall algorithm is a dynamic programming algorithm for finding shortest paths in a weighted graph with positive or negative edge weights (but with no negative cycles).

What is a Frame Check Sequence?

The Frame Check Sequence (FCS) field is used to determine if errors occurred in the transmission and reception of the frame. Error detection is added at the Data Link layer because this is where data is transferred across the media.

What is a shortcut for calculating the Hamming distance?

The Hamming distance of two words A and B can be calculated as the Hamming weight of A xor B.

What is a Caesar cipher?

The cipher created by shifting/rotating an alphabet by a specific number previously agreed upon.

What is the degree of a vertex?

The number of edges incident of the vertex, with loops counted twice.

What are the number of neurons (units) at the input layer of a neural network?

The number of features.

What does the max degree of a b-tree depend on?

The number of items being stored, and page size based on disk characteristics.

What's the difference between the fread, read, fwrite, write I/O calls?

The ones with f are high-level I/O and streamed and buffered by the kernel. The non-f are low-level I/O.

"Which SOLID principle is ""Make all Member Variables Private."" helping to enforce?"

The open/closed principle (OCP)

How would you implement a queue with a linked list?

Use a tail pointer. Push new items at the tail, pop items at the head. Both operations are constant-time.

What value can you make cron or other system intervals so they don't coincide?

Use distinct prime numbers for periodicities.

What is the expected load factor for a hash table?

n/m, where n = items, m = buckets) n/m is also called alpha.

Low bias but very high variance typically correspond to _______.

overfitting

What is the PDU for the TCP/IP internet layer?

packet

What command line tool allows you to search running processes by name?

pgrep

How do we find that a condition exists that will cause a program to have a predicted outcome?

Using an SAT solver (using logic tests) and an SMT solver (that plugs in numbers), and tells the SAT solver where it got it wrong. They provide feedback in a cycle to each other until a condition can be found.

What is synchronization?

Using atomic operations to ensure cooperation between threads.

How could you process calculations on elements of an array in parallel?

Using recursion, divide and conquer, breaking down the array into smaller segments, then merging the values as the recursion unwinds. Non-mutation of the array means locking is not required.

What is a disadvantage of heap sort?

Usually slower than merge sort and quick sort.

What design pattern represents an operation to be performed on the elements of an object structure and lets you define a new operation without changing the classes of the elements on which it operates?

Visitor pattern

What is a race condition?

When the outcome of a deterministic procedure becomes non-deterministic based on differences in subprocess timing.

Is radix sort stable?

Yes.

Is bandwidth minimization NP-Complete?

Yes. It stays NP-complete even if the input graph is a tree whose maximum vertex degree is 3, which is about as strong a condition as I have seen on any problem. Thus our only options are a brute-force search and heuristics.

Does PyPY have a GIL?

Yes. The GIL is very difficult to remove. You can use pypy-stm instead, which uses software transactional memory, but will suffer a performance penalty.

When dealing with scaling, how can you deal with rapidly increasing counters, like YouTube video views?

You can add randomness to a monotonic counter, because as long as people can see it is increasing somewhat monotonically, it doesn't need to be 100% accurate. And avoids need to lock it in a transaction.

What is collapsed forwarding?

"A proxy server can collapse the same (or similar) requests together into one request, and then return the single result to the requesting clients.

What is a max-heap?

"A queue in which each element has a ""priority"" assigned to it. Elements with higher priorities are served before lower priorities."

What is a random variable?

"A random variable is a variable whose possible values have an associated probability distribution.

What is a rolling hash?

"A rolling hash (also known as a rolling checksum) is a hash function where the input is hashed in a window that moves through the input.

What is Google File System?

"A scalable distributed file system for large distributed data-intensive applications. It provides fault tolerance while running on inexpensive commodity hardware, and it delivers high aggregate performance to a large number of clients.

What is a semaphore?

"A semaphore limits access to a maximum number of threads (maximum concurrency) to have access to a source at the same time. It is commonly used to limit database connections.

What should you do when you discover that not all code is covered?

"Don't blindly write tests to cover all cases.

How can you easily generate multiple hashes for the same element?

"Double hashing. This method gives you as many hashes as you need:

What are some protocols in the TCP/IP transport layer?

"- TCP

What can Redis be used for?

"- a noSQL key-value store

What is the banker's algorithm for preventing deadlock?

"- allocate resources dynamically

What are the 7 layers of the OSI model?

"- application

What are the 4 layers of TCP/IP?

"- application (application, presentation, session in OSI)

What are pros of the round-robin scheduling scheme?

"- better for short jobs (they fit in the time slice)

How is RSA decryption optimized for speed?

"- c^d mod p and c^d mod q are processed in parallel and merged at the end using the Chinese remainder theorem

Where is weak consistency OK?

"- caching

What are desirable properties of one-way functions?

"- collision resistant

What are some examples of operations that are associative but not commutative?

"- concatenation of lists

What are some alternative algorithms that can optimize for a logistic regression problem?

"- conjugate gradient

How do you solve the Dining Philosophers problem?

"- critical section is picking up one fork, second fork, and then eating then putting down forks.

What are some methods of avoiding deadlock?

"- don't allow waiting for a resource (means a lot of retries)

What are 3 advantages of heap sort?

"- don't need recursion

What are the requirements for first normal form?

"- each cell has a single value

What are 2 advantages of reference counting?

"- easy to implement

Disadvantage of a fully-associative cache?

"- expensive due to parallel checks

Name some of the protocols used within the TCP/IP application layer.

"- http

What are green threads?

"- implemented by a virtual machine

What 4 things should you check when given a debugging problem?

"- is the input valid and correct?

In plain words, how does Kruskal's algorithm work?

"1. Create a set T and list for result

How can you get the strongly connected components of a graph?

"1. DFS - calculate the finish times for each node

How to find the longest path on a weighted DAG?

"1. Set all edges to their negative weight.

How can you find the shortest path on a DAG?

"1. Topological sort

What's the probability of getting heads twice? P(HH)

"1/4

What's the probability of getting heads, tails, heads? P(HTH)

"1/8

Give an example of how a b-tree might be organized.

"1024 children per node.

Whats the average height of a binary search tree after n insertions?

"2 ln n

What is a 2-3-4 tree?

"2-3-4 tree (also called a 2-4 tree) is a self-balancing data structure that is commonly used to implement dictionaries. The numbers mean a tree where every node with children (internal node) has either two, three, or four child nodes:

Timing to read 1MB sequentially from disk?

"20,000,000 nanoseconds (20 ms)

What is the sum of numbers from 1 to 2^n?

"2^(n+1) - 1

How many network IDs are supported on a Class B network?

"2^14 = 16,384

How many host IDs are supported on a Class B network?

"2^16 = 65,536

How many network IDs are supported on a Class C network?

"2^21 = 2 million

How many host IDs are supported on a Class A network?

"2^24 = 16 million

How many network IDs are there on a Class A network?

"2^7 = 128

How many host IDs are supported on a Class C network?

"2^8 = 256

What are the difference between 32-bit and 64-bit applications?

"32-bit:

What's the probability of getting exactly 3 heads in 8 flips?

"56/256 = 7/32

There are 4 people. How many ways can they shake each other's hands without shaking the same person's hand twice?

"6

What is the fetch-execute cycle?

"A 4 part system that describes how actions are performed in the CPU. There are 4 parts to this cycle:

What is a Bloom filter?

"A Bloom filter is a data structure used to quickly test membership in a set where the number and size of possible elements would be very large. Too large to keep in memory.

What is a cache-oblivious algorithm?

"A cache-oblivious algorithm does not mean that the algorithm does not take advantage of the cache; to the contrary, it does so quite effectively. What it means is that the algorithm does not need to know the cache line size; it works effectively for all cache line sizes simultaneously, removing the need to tune or optimize for a given machine.

What is a confused deputy?

"A confused deputy is a computer program that is innocently fooled by some other party into misusing its authority. It is a specific type of privilege escalation. In information security, the confused deputy problem is often cited as an example of why capability-based security is important, as capability systems protect against this whereas access control list-based systems do not.

What is a skip list?

"A data structure for storing a sorted list of items using a hierarchy of linked lists that connect increasingly sparse subsequences of the items.

What is a skip list?

"A data structure that allows fast search within an ordered sequence of elements. Fast search is made possible by maintaining a linked hierarchy of subsequences, with each successive subsequence skipping over fewer elements than the previous one. Searching starts in the sparsest subsequence until two consecutive elements have been found, one smaller and one larger than or equal to the element searched for.

How could you implement an LRU cache?

"A fast lookup table, like a hash table or binary tree, and a linked list of items by use. When you access or add an item, you delete it from the linked list and add it to the head of the list. Then to prune, traverse the linked list and remove trailing elements, and delete them from the storage (tree or hash table).

What is futex?

"A futex (short for ""fast userspace mutex"") is a Linux kernel system call that programmers can use to implement basic locking, or as a building block for higher-level locking abstractions such as semaphores and POSIX mutexes or condition variables."

What is Timsort?

"A hybrid stable sorting algorithm, derived from merge sort and insertion sort, designed to perform well on many kinds of real-world data.

What is von Neumann Architecture?

"A model for modern computer organization created by John von Neumann, that had two main features:

What is the trade-off between precision and recall?

"A model that predicts "yes" when it's even a little bit confident will probably have a high recall but a low precision; a model that predicts "yes" only when it's extremely confident is likely to have a low recall and a high precision.

What is polymorphism in OO?

"A property of OO in which an abstraction operation may be performed in different ways in different classes, but share an interface.

What is ZeroMQ?

"A socket-based system, can be used as a queue, pub/sub, etc.

What is a suffix array?

"A suffix array is a sorted array of all suffixes of a string.

What is a suffix tree?

"A suffix tree is a compressed trie containing all the suffixes of the given text as their keys and positions in the text as their values. Suffix trees allow particularly fast implementations of many important string operations.

How can build heap be done in linear time?

"A tree of size n nodes, will have floor(n/2^h) nodes with height >= h.

What is a weak reference in Python?

"A weak reference to an object does not affect its reference count.

What is AMP?

"AMP is a restricted subset of HTML designed to make the web fast on mobile devices.

What are the 4 main tenets of OO?

"Abstraction

How can you get a stable sort using an unstable sorting algorithm?

"Add a sequence number to the data elements, like adding a new sequence property to the objects to be sorted.

What is AddressSanitizer?

"AddressSanitizer is a fast memory error detector. AddressSanitizer finds out-of-bounds (for heap, stack, and globals) accesses and use-after-free bugs at the cost of 73% slowdown on average and a 3.4x memory size; the tool has no false positives.

What operations does a van Emde Boas tree support and what are the time complexities?

"All are O(log log M), where M is the total number of items that can be stored = 2^m

What is the normal equation?

"An equation that can minimize J(theta), solving for theta, instead of using gradient descent.

What is an IDL-based encoding?

"An interface description language or interface definition language (IDL) encoding.

What is a coroutine?

"An object representing activity that eventually completes. Also refers the the function we call that returns a coroutine.

What are some examples of message brokers?

"Apache ActiveMQ

What is Avro?

"Apache Avro is a data serialization system. IDL-based.

What is Kafka?

"Apache Kafka is pub-sub messaging rethought as a distributed commit log.

What is Thrift?

"Apache Thrift is a framework for scalable cross-language services development. It combines a software stack with a code generation engine to build services that work efficiently and seamlessly between different languages. It handles serialization and has its own communication protocol.

What is ZooKeeper?

"Apache ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. All of these kinds of services are used in some form or another by distributed applications. Each time they are implemented there is a lot of work that goes into fixing the bugs and race conditions that are inevitable. Because of the difficulty of implementing these kinds of services, applications initially usually skimp on them, which make them brittle in the presence of change and difficult to manage. Even when done correctly, different implementations of these services lead to management complexity when the applications are deployed.

What data structure is well suited for a heap sort and which is bad?

"Array - good

What does ACID stand for?

"Atomicity

What are some examples of well-known queue (or can act as a queue) software?

"BeanstalkD

What is tri-color marking?

"Because of these performance problems, most modern tracing (mark and sweep) garbage collectors implement some variant of the tri-color marking abstraction. This avoids the execution pause common to mark and sweep.

What are 2 examples of probabilistic data structures?

"Bloom filter

What is an actor?

"Briefly, actors are a lot like message queues without the configuration and message broker installation overhead. They're like programmable message queues shrunk to microsize—you can easily create thousands, even millions of them. They don't "do"

What is the running time for the disjoint set data structure?

"Due to merging smaller disjoint sets into larger ones (called union by rank) (during union) and performing path compression (during find), the amortized time per operation is only O(alpha(n)), where alpha(n) is the inverse of the function and A is the extremely fast-growing Ackermann function. Since alpha(n) is the inverse of this function, alpha(n) is less than 5 for all remotely practical values of n. Thus, the amortized running time per operation is effectively a small constant.

Codeless question: Given a set of n items, which element occurs the largest number of times in the set? Bonus: How do you find out how many times some element k appears?

"If the items are sorted, we can sweep from left to right and count them, since all identical items will be lumped together during sorting.

What are some differences between C++ and Java?

"C++:

What is Intel architecture?

"CISC - Complex Instruction Set Computer

How does garbage collection work in CPython?

"CPython uses reference counting and generational garbage collection. There are 3 age stages where objects live in memory. They all start in the ""nursery"", stage0, then if they survive a garbage collection, they are moved to stage1, the oldest objects that continue to survive in stage1 are promoted to stage2. The gc module has thresholds 700, 10, 10 for each stage. In order to decide when to run, the collector keeps track of the number object allocations and deallocations since the last collection. When the number of allocations minus the number of deallocations exceeds threshold0, collection starts. If generation 0 has been examined more than threshold1 times since generation 1 has been examined, then generation 1 is examined as well. Similarly, threshold2 controls the number of collections of generation 1 before collecting generation 2."

What is an example of adding jitter to a caching system?

"Cache expirations. For a popular video they cache things as best they can. The most popular video they might cache for 24 hours. If everything expires at one time then every machine will calculate the expiration at the same time. This creates a thundering herd.

What is Celery?

"Celery is an asynchronous task queue/job queue based on distributed message passing. It is focused on real-time operation, but supports scheduling as well. You use it with a message broker, and it manages the task execution.

How to choose q for radix sort?

"Choose q within a power of 2 of n. Ensures the number of passes is small. Best rule is n rounded down to the next power of 2.

What is infeasible code?

"Code that can never be true.

How can you find an articulation vertex?

"DFS multiple times. Remove each edge one at a time, doing a DFS after each, so see if you end up with > 1 connected components. If you remove a node and then DFS and find you have fewer than m - 1 edges, you've deleted an articulation vertex. O(n(n+m))

What is the D in SOLID?

"Dependency inversion principle (DIP)

How can you get a topological sort with DFS?

"Do a DFS, and when each node is being marked as complete, add node to a list.

Python: Default arguments are okay to use with the following caveat.

"Do not use mutable objects as default values in the function or method definition.

What is dynamic programming?

"Dynamic programming is a general-purpose algorithm design technique that is most often used to solve combinatorial optimization problems, where we are looking for the best possible input to some function chosen from an exponentially large search space.

Difference between inline functions and macros?

"Each reduces overhead of function calls at the expense of program size

What is the Law of Demeter?

"Each unit should have only limited knowledge about other units - only units ""closely"" related to the current unit. Each unit should only talk to friends, not strangers. Only talk to immediate friends."

What does a PCB contain?

"Everything about a process:

What is external sorting?

"External sorting is a term for a class of sorting algorithms that can handle massive amounts of data. External sorting is required when the data being sorted do not fit into the main memory of a computing device (usually RAM) and instead they must reside in the slower external memory (usually a hard drive). External sorting typically uses a hybrid sort-merge strategy. In the sorting phase, chunks of data small enough to fit in main memory are read, sorted, and written out to a temporary file. In the merge phase, the sorted subfiles are combined into a single larger file.

What is the relationship to false positives/negatives with a Bloom filter?

"False negatives are not possible.

What is the difference between filter() and map()?

"Filter uses a function that returns true or false (predicate).

What are the downsides of using an adjacency matrix to represent a graph?

"Finding all the outgoing edges from a vertex takes O(n) time even if there aren't very many, and the O(n^2) space cost is high for ""sparse graphs,"" those with much fewer than n^2 edges."

What are the complexities for treap operations?

"For all the basic maintenance operations, they are O(log n) average case and O(n) worst case.

How can you find the number of connected components?

"For each node:

Why should you make networks as small as possible?

"For:

What is the set cover problem?

"Given a set U of elements, a collection S1, S2, ..., Sm of subsets of

What is a Hamiltonian cycle?

"Given an undirected graph G = (V, E), does there exist a simple

What is the same-origin policy?

"Goal: Two websites should not be able to tamper with each other.

What are the pros and cons of garbage collection?

"Good:

What are some examples of NoSQL solutions?

"Google BigTable

What is GDS?

"Google Cloud Datastore is a NoSQL document database built for automatic scaling, high performance, and ease of application development. Cloud Datastore features include:

What are some popular proxies?

"HAProxy

How does HTTP/2 save bandwidth?

"Headers are compressed and do not need to send the same headers in a session if they haven't changed.

What are some TCP/IP network layer protocols?

"IP - internet protocol

What can you use to merge an unsorted list into an already sorted list?

"If the new list is short, insertion sort would be O(n).

What makes a problem NP-Complete?

"If x is an element of NP and of NP-hard. NP-Complete is the narrow intersection of NP and NP-hard.

What is Vigenere cipher?

"Improvement on Caesar cipher. Letters are shifted based on a shifted dictionary. ""Polyalphabetic cipher"""

What is the difference between a synchronous system and an asynchronous system?

"In a synchronous system, there is no differentiation between request and reply, and they therefore cannot be managed separately. In an asynchronous system the client requests a task, the service responds with a message acknowledging the task was received, and then the client can periodically check the status of the task, only requesting the result once it has completed.

What should you know about the cmp argument in sort/sorted?

"In general, the key and reverse conversion processes are much faster than specifying an equivalent cmp function. This is because cmp is called multiple times for each list element while key and reverse touch each element only once.

What is open addressing?

"In hash table conflict resolution, all entry records are stored in the bucket array itself. When a new entry has to be inserted, the buckets are examined, starting with the hashed-to slot and proceeding in some probe sequence, until an unoccupied slot is found. When searching for an entry, the buckets are scanned in the same sequence, until either the target record is found, or an unused array slot is found, which indicates that there is no such key in the table. The name ""open addressing"" refers to the fact that the location (""address"") of the item is not determined by its hash value. (This method is also called closed hashing; it should not be confused with ""open hashing"" or ""closed addressing"" that usually mean separate chaining.)"

What is separate chaining?

"In hash table conflict resolution, each bucket is independent and has some sort of linked list of entries with the same index. The time for hash table operations is the time to find the bucket (which is constant) plus the time for the list operation.

What is orthogonality?

"In mathematical terms, it means being perpendicular.

Describe the memory hierarchy of a Core i7 processor.

"Inside of each core is a 32 kB L1 instruction cache, a 32 kB L1 data cache (it's 8-way set associative), and a dedicated 256 kB L2 cache (also 8-way set associative).

What happens at the Data Link layer of the OSI model?

"It decides whose turn it is to talk on the network using bus arbitration methods.

What's special about TCP?

"It does a 3-way handshake before data is sent.

What is special about TCP?

"It manages the sending and receiving of packet data.

What data structure is well suited for a merge sort and which is just okay?

"Linked list - a natural

What are 3 things CDNs use to ensure availability?

"Local clustering can improve fault-tolerance and scalability. Mirroring (deploying clusters in a few locations) and multihoming (using multiple ISPs to connect to the Internet).

What is Marzullo's algorithm?

"Marzullo's algorithm, is an agreement algorithm used to select sources for estimating accurate time from a number of noisy time sources. A refined version of it, renamed the ""intersection algorithm"", forms part of the modern Network Time Protocol."

What is MessagePack?

"MessagePack is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON. But it's faster and smaller. Small integers are encoded into a single byte, and typical short strings require only one extra byte in addition to the strings themselves.

What is the sum of the harmonic series for the nth harmonic number: 1 + 1/2 + 1/3 + 1/4 .. + 1/n

"No closed form, only good approximations:

Is it always letters we are looking for in compression?

"No. Hardly.

What is data normalization?

"Normalization is a systematic approach of decomposing tables to eliminate data redundancy and undesirable characteristics like insertion, update and deletion anomalies.

What is the time complexity of Kruskal's algorithm?

"O(E log V)

What is the time complexity of quicksort?

"O(N^2 worst)

What is the time complexity of Prim's algorithm on an adjacency list and a binary heap?

"O(e log v)

What is the complexity of Dijkstra's shortest-path algorithm?

"O(e log v), where e is the number of edges.

find (sorted array)

"O(log n)

What is the complexity of all operations on a splay tree?

"O(log n) on average.

What is the time complexity of breadth-first search?

"O(m + n)

What is the time and space complexity of heapsort?

"O(n lg n) time

What is the time and space complexity of merge sort?

"O(n lg n) time

What is the worst case time complexity of a Jarvis march?

"O(n^2)

What is the PDU and the addressing at the data link layer?

"PDU: frame

What is PycURL?

"PycURL is a Python interface to libcurl. PycURL can be used to fetch objects identified by a URL from a Python program, similar to the urllib Python module. PycURL is mature, very fast, and supports a lot of features.

What is RabbitMQ?

"RabbitMQ is a messaging broker - an intermediary for messaging.

What is radix sort?

"Radix sort is a non-comparative integer sorting algorithm that sorts data with integer keys by grouping keys by the individual digits which share the same significant position and value.

What is RISC?

"Reduced Instruction Set Architecture.

What devices are at the Internet/Network layer?

"Routers

What is involved in the 3 way handshake (TCP)?

"SYN=1 - synchronize, gives a Seq number and expects that number + 1 in response

How does Google handle a search request?

"Scatter/gather

What is one way of doing approximate traveling salesman?

"Select a vertex as root.

What does Skylake architecture look like?

"Skylake:

What is Apache Solr?

"Solr is an open source enterprise search platform built on Apache Lucene.

What happens to a class when you add __slots__?

"Space is saved because __dict__ is not created for each instance. __slots__ reserves space for the declared variables and prevents the automatic creation of __dict__ and __weakref__ for each instance.

How does the Jarvis march work in finding convex hull?

"Starting with the leftmost point p:

How can you augment a splay tree so you can find how many items are between x and y?

"Store size of subtrees at each node.

What is stress testing?

"Testing code or a system beyond its normal usage.

What is a one-time pad encryption?

"The ""perfect"" simple encryption scheme. Pad/key is the same size as the message being encrypted. The key is randomly generated and xored against the plain text. Or key used to determine the amount each letter should be shifted."

What is the CAP theorem?

"The CAP theorem, also named Brewer's theorem, states that it is impossible for a distributed computer system to simultaneously provide all three of the following guarantees:

What is the Ford-Fulkerson algorithm?

"The Ford-Fulkerson method or Ford-Fulkerson algorithm (FFA) is a greedy algorithm that computes the maximum flow in a flow network. It is called a ""method"" instead of an ""algorithm"" as the approach to finding augmenting paths in a residual graph is not fully specified or it is specified in several implementations with different running times. The name ""Ford-Fulkerson"" is often also used for the Edmonds-Karp algorithm, which is a specialization of Ford-Fulkerson."

How is garbage collection done in PyPy?

"The GC implementation can be chosen at runtime. It's pluggable.

What is the L in SOLID?

"The Liskov substitution principle (LSP)

What is the O in SOLID?

"The Open/Closed Principle (OCP) states that the design and writing of the code should be done in a way that new functionality should be added with minimum changes in the existing code. The design should be done in a way to allow the adding of new functionality as new classes, keeping as much as possible existing code unchanged.

How is an SSL certificate generated by the certificate authority (CA)?

"The common name and public key for a given domain name, signed by the certificate authority's secret key.

What is a minimum product spanning tree and when would you use it?

"The cost of a tree is the product of all the edge weights in the tree, instead of the sum of the weights. Since log(a*b) = log(a) + log(b), the minimum spanning tree on a graph whose edge weights are replaced with their logarithms gives the minimum product spanning tree on the original graph.

Is knapsack problem NP-complete?

"The decision problem form of the knapsack problem (Can a value of at least V be achieved without exceeding the weight W?) is NP-complete, thus there is no known algorithm both correct and fast (polynomial-time) on all cases.

What is the difference between a CPU core and a CPU thread?

"The difference between a core and a thread is that separate cores have separate copies of (almost) all the hardware resources. The cores can run completely independently unless they are using the same resources-e.g., the connections to the outside - at the same time. Threads, on the other hand, share almost all of the processor's resources.

What is a dot product?

"The dot product of two vectors is the sum of their componentwise products.

What determines the height of a tree?

"The height of a tree equals the height of its tallest subtree plus one.

What is a requirement of enabling sandboxing?

"The kernel must be able to support it by disallowing system calls that reference global namespaces:

Why is periodicity important in random rumber generation?

"The period defines how long a random number generator will generate numbers before it repeats the sequence.

When a process forks, what happens?

"The process is paused, and a complete copy is made: code, stack, heap, data, program counter and registers.

Codeless question: Give an efficient algorithm to determine whether two sets (of size m and n, respectively) are disjoint.

"The small set can be sorted in O(m log m) time. We can now do a binary search with each of the n elements in the big set, looking to see if it exists in the small one. The total time will be O((n + m) log m).

When might you need to use a NoSQL database

"You don't have any relational data.

How can you create an alias for a command or set of commands?

"alias wowza='command 1; command 2; command 3'

If you were to design a web platform for online chess games, how would you do that?

"ask:

What is a global namespace in unixy terms?

"aspects of a system that can be accessed from anywhere:

What are balancing methods used by load balancers?

"assignment of a request: random, round-robin, random with weighting for machine capacity, etc

What is ACID?

"atomicity

What is BASE?

"basically available

What are the 2 PDUs of the OSI Network Access layer?

"data link layer: frames

What are the caller-save registers?

"eax

What are the callee-save registers?

"ebp

What's the difference between foo.sort() and sorted(foo) where foo is a list?

"foo.sort() changes the list to its sorted state

What are the PDUs for the the OSI transport layer?

"for TCP, it's called a segment

How can you check for a cycle with DFS?

"for each neighbor node:

How can you calculate mean normalization over a set of features?

"for each x: xi = (xi - avg(x)) / (max_x - min_x)

How can you make a weak reference in Python?

"from weakref import ref

What Python package provides tools for adapting or extending functions and other callable objects, without completely rewriting them?

"functools

How can you sort a list of Employee objects by surname then given_name, but case-insensitive?

"import operator

How do you use a mutex in Python?

"import threading

How can you convert a list to a string in Python?

''.join(thelist)

Python: break this string 'a/b/c' into a list of ['a', 'b', c']

'a/b/c'.split('/')

What's the Probability of getting head, tails or tails, heads? P(HT U TH)

(1/2 * 1/2) + (1/2 * 1/2) = 2/4 = 1/2

What's the probability of getting heads 200 times in a row?

(1/2)^200

Give an example of a proposition in conjunctive normal form.

(A + ~B)(A + B)

How does mark and sweep work?

(In Java) Perform a DFS on the graph of references to objects. This graph can have multiple roots. Each root is a reference that the program can access directly, such as a variable. Traverse the graph, setting a mark bit in each object. The sweep phase causes unmarked memory to be linked together in a list, so that memory can be reallocated. Sometimes this also triggers compaction, which moves used objects adjacent to each other in memory. The side effect of this is that free memory is also adjacent to free memory so large blocks can be allocated.

In a highly connected graph of n vertices, how many cycles can there be?

(n - 1)! - enumerating is possible (using backtracking), but there will be a lot.

With a fair coin, what is the probability of getting exactly k H in n flips?

(n choose k)/2^n

What is the arithmetic series: 1 + 2 + 3 + 4 + ... (n - 1) + n?

(n(n+1)) / 2

What is the value of the geometric (exponential) series when x != 1: 1 + x + x^2 + x^3 + ... x^n ?

(x^(n + 1) - 1) / (x - 1)

What is a good range for mean normalization?

-0.5 to +0.5

What is is good range to scale features down to?

-1 to +1, or Ng's range: -3 to +3

How do you represent negative infinity in Python?

-float('Inf')

What is the grep flag for line numbers?

-n

What is the grep flag for showing matched portion only?

-o

What can you use as a delimiter in sed?

/, :, |, _ are all ok

What does a network ID end in?

0

What is Fib(0) ?

0

What is the min and max compression settings in command line gzip?

0-9

Timing of a L1 cache reference?

0.5 nanoseconds (ns)

16^0 ?

1

In linear algebra a vector of 12 elements has how many columns?

1

In linear algebra a vector of 12-dimensional vector has how many columns?

1

What is 0! ?

1

What is Fib(2) ?

1

What is P(A|A)?

1

What is n choose 0?

1

What is n choose n?

1

What is the P( ! B ) ?

1 - P(B)

What is the probability of at least 1 H in 3 flips?

1 - P(TTT) = 1 - 1/8 = 7/8

What's the maximum unsigned number you can represent with 9 bits?

511

What is the largest output size of SHA-3?

512 bits

What is the port for DNS?

53

When multiplying a 5x2 matrix and a 2x5 matrix, what are the dimensions of the final matrix?

5x5

For Gzip in web servers, what is the usual setting?

6

What's the maximum unsigned number you can represent with 6 bits?

63

What's the maximum unsigned number you can represent with 16 bits?

65,535

16^4 ?

65,536

What's the maximum signed number you can represent with 4 bits?

7

Timing of a L2 cache reference?

7 nanoseconds (ns)

If a cache line size is 64B, and the memory bus is 64 bits wide, how many transfers per cache line?

8

The memory addresses returned by the malloc function are typically aligned to at least ___ bytes.

8

What is the size of a UDP header?

8 bytes

How many registers are on CISC?

8 general-purpose registers and an instruction pointer. 2 of 8 are not that general.

What is the port range for clients?

8000-65535

What is an example of a confused deputy in the web frontend world?

A CSRF attack.

What is DNS spoofing?

A DNS server is compromised and returns incorrect IP addresses for a some domains.

What is a Markov chain?

A Markov chain consists of states linked by transitions labeled with probabilities. The states do not have to be words. They could represent any state.

What is gunicorn?

A Python WSGI HTTP Server

What is an N-way set associative cache?

A Set-Associative cache scheme is a combination of Fully-Associative and Direct Mapped caching schemes. A set-associate scheme works by dividing the cache SRAM into equal sections (2 or 4 sections typically) called cache ways. The cache page size is equal to the size of the cache way. Each cache way is treated like a small direct mapped cache.

What is a block cipher?

A block cipher is a method of encrypting text (to produce ciphertext) in which a cryptographic key and algorithm are applied to a block of data (for example, 64 contiguous bits) at once as a group rather than to one bit at a time.

What data structure could be used to efficiently manage a leaderboard?

A b-tree where each node manages a subset of the range of the worst to best scores.

What is P-Complete?

A decision problem is P-complete (complete for the complexity class P) if it is in P and every problem in P can be reduced to it by an appropriate reduction.

What is Chubby?

A distributed lock service (master election) built on Borg.

What is a Type 2 error?

A false negative

What is a Type 1 error?

A false positive

What is the Fast Fourier Transform?

A fast Fourier transform (FFT) algorithm computes the discrete Fourier transform (DFT) of a sequence, or its inverse. Fourier analysis converts a signal from its original domain (often time or space) to a representation in the frequency domain and vice versa. An FFT rapidly computes such transformations by factorizing the DFT matrix into a product of sparse (mostly zero) factors.

What is a finalizer in Python?

A finalizer is a destructor, named __del__. __del__() is run when the runtime is about to destroy the object.

What really happens when you fork a process?

A fork doesn't copy everything, it just duplicates the page table pointers, which are all set at read-only. Called copy-on-write. Once you write to memory, then it copies the state.

What is a spinlock?

A form of busy waiting, that waits in a loop and repeatedly checks if a lock is available.

What is a pointer?

A memory address stored in memory.

What is a package?

A group of classes bundled together.

What happens when the heap and stack meet in memory?

A guard page is hit and the process is killed.

What is an interrupt?

A hardware-invoked context switch. The interrupt handler always runs immediately.

What is a shell?

A job control program. It allows a programmer to create and manage a set of programs to do some task.

What is a monitor?

A lock and zero or more condition variables for managing concurrent access to shared data.

Big Omega represents what?

A lower bound on the growth of a function. f grows at least as fast as g.

What is a Dunder method?

A magic method in Python, such as __getitem__ and __len__.

What is a monitor?

A monitor is a synchronization construct that allows threads to have both mutual exclusion and the ability to wait (block) for a certain condition to become true. Monitors also have a mechanism for signalling other threads that their condition has been met. A monitor consists of a mutex (lock) object and condition variables. Monitors provide a mechanism for threads to temporarily give up exclusive access in order to wait for some condition to be met, before regaining exclusive access and resuming their task.

How does Google use multi-homed datacenters?

A multi-homed system runs live in multiple datacenters all the time. Each datacenter processes work all the time, and work is dynamically shared between datacenters to balance load. When one datacenter is slow, some fraction of work automatically moves to faster datacenters. When a datacenter is completely unavailable, all its work is automatically distributed to other datacenters.

What is a bag?

A multiset.

What is another name for a setter?

A mutator

What can you put in place to exclusively use a resource without another process interfering?

A mutex, or even better, a lock guard.

What is a mutex?

A mutually exclusive access to a resource. It's a special case of a semaphore with a maximum concurrency of 1.

If this exists, you can't use Dijkstra.

A negative-weight edge.

What is a proxy server?

A proxy server is an intermediate piece of hardware/software that receives requests from clients and relays them to the backend origin servers. Typically, proxies are used to filter requests, log requests, or sometimes transform requests (by adding/removing headers, encrypting/decrypting, or compression).

What is a condition variable?

A queue of threads waiting for access to something in a critical section.

What do you use to keep track of nodes to visit in BFS?

A queue.

What is the heap pointer?

A register that holds the address of the top of the heap portion of a process' memory.

What is the stack pointer?

A register that holds the address of the top of the stack portion of a process' memory.

What is a framework?

A reusable piece of software that implements a generic solution to a generalized problem. It saves time by being a close model of the problem domain and can reach 100% with details coded by the implementer.

What is Capsicum?

A sandboxing framework that adds capability-based security to unix-like kernels and denies access to global namespaces.

What is an SMT solver?

A satisfiability modulo theories solver solves for large interconnected logic formulas to determine if a given formula can be satisfied. These are helpful for determining the outcome or inputs for a program using symbolic execution.

What is quick select?

A selection algorithm to find the kth smallest element in an unordered list. Quickselect uses the same overall approach as quicksort, choosing one element as a pivot and partitioning the data in two based on the pivot, accordingly as less than or greater than the pivot. However, instead of recursing into both sides, as in quicksort, quickselect only recurses into one side - the side with the element it is searching for. This reduces the average complexity from O(n log n) to O(n).

What is pyramidpypi?

A self-hosted mirror of pypi.

How does HTTP/2 improve cache breaking?

A server can send updated assets using server push when it recognizes a file has changed.

What is a multiset?

A set in which elements do not have to be unique.

What is an n-gram?

A set of N sequential words appearing together.

What manufacturer uses an exclusive cache style?

AMD

What design pattern provides an interface for creating families of related or dependent objects without specifying their concrete class?

Abstract Factory pattern

Is DELETE idempotent?

According to the REST spec, yes, but it's up to the developer to conform to that. It can be achieved by using a deleted flag for a resource instead of completely removing the resource.

What design pattern converts the interface of a class into another interface clients expect?

Adapter pattern

When are adjacency lists most useful?

Adjacency lists are most useful when we mostly want to enumerate outgoing edges of each node. This is common in search tasks, where we want to find a path from one node to another or compute the distances between pairs of nodes. If other operations are important, we can optimize them by augmenting the adjacency list representation; for example, using sorted arrays for the adjacency lists reduces the cost of edge existence testing to O(log(d+ (u))), and adding a second copy of the graph with reversed edges lets us find all predecessors of u in O(d− (u)) time, where d− (u) is u's in-degree.

What does amqp stand for?

Advanced Message Queuing Protocol

What is a drawback of advanced features in a load balancer?

Advanced features can make problem diagnosis cumbersome. For example, when it comes to high load situations, load balancers will remove nodes that may be slow or timing out (because of too many requests), but that only exacerbates the situation for the other nodes.

What is the Adapter pattern?

Converts the interface of a class into another interface clients expect. Lets classes work together that couldn't otherwise because of incompatible interfaces.

What are the requirements for second normal form?

All attributes (non-key columns) are dependent on the key

What are the requirements for third normal form?

All fields can only be determined by the key in the table and no other column.

Who does a broadcast address of 255.255.255.255 send to?

All hosts within the network.

What is the State pattern?

Allows an object to alter its behavior when its internal state changes. The object will appear to change its class.

What does ICMP allow you to do?

Allows devices to communicate and send errors. Can echo to see if a device is on the network.

What does a future do?

Allows us to receive a return value from a function in a child thread.

What is Google Native Client?

Also called NaCl, Native Client is a sandbox for running compiled C and C++ code in the browser efficiently and securely, independent of the user's operating system.

What would the identity matrix look like to multiply with an MxN matrix to get itself?

An NxN matrix that is all zeroes except it has 1s on a top-left to bottom-right diagonal.

What is another name for a getter?

An accessor.

What is a tree?

An acyclic connected graph.

What does the program counter point to?

An address in memory that contains the current instruction.

When talking dynamic programming, what is optimality?

An algorithm has optimality if the subsolutions of an optimal solution of the problem are themsleves optimal solutions for their subproblems.

What is the Bellman-Ford algorithm?

An algorithm that computes shortest paths from a single source vertex to all of the other vertices in a weighted digraph. It is slower than Dijkstra's algorithm for the same problem, but more versatile, as it is capable of handling graphs in which some of the edge weights are negative numbers.

What data structure allows for insert and delete in constant time?

An array, indexed by the value stored. Technically a bit vector.

What is exponential backoff and when is it used?

Binary exponential backoff or truncated binary exponential backoff refers to an algorithm used to space out repeated retransmissions of network or other service requests, often as part of congestion avoidance.

In security, what is a principal?

An entity with privileges or rights.

What does an exclusive cache style?

An eviction from L1D pushes the cache line down into L2, which has the same cache line size. Each eviction is progressively more expensive.

What does an eviction policy try to predict?

An eviction policy tries to predict which entries are most likely to be used again in the near future, thereby maximizing the hit ratio

What is Memcache?

An in-memory distributed hash table. It supports only a few commands but it is extremely efficient.

What is Tarantool?

An in-memory noSQL database that uses write-ahead logging for crash resistance and persistence.

What is an inverted index?

An index data structure storing a mapping from content, such as words or numbers, to its locations in a database file, or in a document or a set of documents (named in contrast to a Forward Index, which maps from documents to content). The purpose of an inverted index is to allow fast full text searches, at a cost of increased processing when a document is added to the database.

What is a process?

An instance of an executing program consisting of an address space and one or more threads of control. It has restricted rights. It owns a region of memory. It owns file descriptors, file system context. It encapsulates one or more threads sharing the process' resources. It is isolated from other processes.

What is internal sorting?

An internal sort is any data sorting process that takes place entirely within the main memory of a computer. This is possible whenever the data to be sorted is small enough to all be held in the main memory. For sorting larger datasets, it may be necessary to hold only a chunk of data in memory at a time, since it won't all fit. The rest of the data is normally held on some larger, but slower medium, like a hard-disk. Any reading or writing of data to and from this slower media can slow the sortation process considerably.

What's another name for a mutual exclusion?

Binary semaphore.

What is read-through cache?

An item is accessed from cache, and if it's a cache miss, the data will be read from persistent storage (perhaps with a callback) and then placed into cache. The response is then sent back to the host.

What is a future?

An object representing a result that may not be available yet.

What is a mock object?

An object used to replicate the interfaces and interactions of a larger system that can be bolted on to the SUT.

What kind of sort can you use when the data is guaranteed to have no duplicates and needs to be done in-place?

An unstable, in-place sort like quicksort.

What is the optimal number of threads?

And if there's the same number of runnable threads as there are hardware threads, the kernel is very likely to reschedule threads on the same core, which significantly helps performance.

What are heuristics?

Any approach to problem solving, learning, or discovery that employs a practical method not guaranteed to be optimal or perfect, but sufficient for the immediate goals. Where finding an optimal solution is impossible or impractical, heuristic methods can be used to speed up the process of finding a satisfactory solution. Heuristics can be mental shortcuts that ease the cognitive load of making a decision. Examples of this method include using a rule of thumb, an educated guess, an intuitive judgment, stereotyping, profiling, or common sense

What is a metaclass?

Any callable (function or class) that implements type()'s function signature.

What is ActiveMQ?

Apache ActiveMQ is an open source message broker written in Java.

What is Kafka?

Apache Kafka is a distributed, partitioned, replicated commit log service. It provides the functionality of a messaging system, but with a unique design.

Does asynchronous code tend to be CPU-bound or I/O bound?

Asynchronous code tends to be CPU bound, because anything that would block is simply deferred to later, until the blocking operation completes. This means that threads in asynchronous / non-blocking applications are much more likely to use their full time quantum before the kernel scheduler preempts them.

What is zero copy?

Applications that use zero copy request that the kernel copy the data directly from the disk file to the socket, without going through the application. Zero copy greatly improves application performance and reduces the number of context switches between kernel and user mode.

What is AQP?

Approximate query processing. It means pulling a sample of data instead of taking time to process an exact result. It is often used when a data storage involves terabytes or more.

"What is a ""tick"" in CPython?"

Approximately 1 machine instruction.

How does a Graham scan work in finding convex hull?

At O(n log n), uses a sort and then a simple single pass of all the points, and making only left turns as it goes around the perimeter counter-clockwise. When the next point is a right turn, it backtracks past all points (using a stack and popping points off) until that turn turns into a left turn.

At how many items should you expect a collision when hashing among n buckets?

At sqrt(n) the probability is 1/2

What is the Decorator pattern?

Attaches additional responsibilities to an object dynamically. Provides a flexible alternative to sub-classing for extending functionality.

What is the Chain of Responsibility pattern?

Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.

Timing of fork()?

Between 70,000 and 160,000 nanoseconds.

Using a stack to keep track of unvisited nodes gives what kind of traversal?

DFS

What is the EBX register used for?

Base pointer to the data section.

What design pattern separates the construction of a complex object from its representation, so the same construction process can create different representations?

Builder pattern.

Using a queue to keep track of unvisited nodes gives what kind of traversal?

BFS

What can use to find if a graph is bipartite?

BFS. Using only 2 colors. When you encounter a new vertex, if it has no color, give it the opposite color of its parent vertex. If it is already colored the same, the graph is not bipartite.

What is BNF?

BNF (Backus Normal Form or Backus-Naur Form) is one of the two main notation techniques for context-free grammars, often used to describe the syntax of languages used in computing, such as computer programming languages, document formats, instruction sets and communication protocols; the other main technique for writing context-free grammars is the van Wijngaarden form.

What compression scheme uses Burrows-Wheeler transform?

BZip2

What design pattern decouples an abstraction from its implementation so that the two can vary independently?

Bridge pattern

What devices are at the data link layer?

Bridges, switches (multi-port bridge). They inspect frames and forward or not.

What does BFGS stand for?

Broyden-Fletcher-Goldfarb-Shanno algorithm

How could you identify errors in a DNA fragment assembly given many pairs of sequences, where item A must appear before B in the larger sequence?

Build a DAG representing all the left-right constraints. Any topological sort of the DAG is a consistent ordering. If there are cycles, there must be errors.

What is busy waiting?

Busy-waiting, busy-looping or spinning is a technique in which a process repeatedly checks to see if a condition is true, such as whether keyboard input or a lock is available.

How can you maximize compression?

By deeply analyzing the given input to reduce redundancy as much as possible.

How is concurrency accomplished?

By multiplexing CPU time.

How you divide a network?

By subnetting.

What is a drawback of context switching?

CPU cache misses as thread comes back from switching and finds the CPU cache doesn't have the values it had before.

What does chroot do?

Changes the root directory (/) for a user to be a directory on the filesystem where they can't escape.

What is CUDA?

CUDA (Compute Unified Device Architecture) is a parallel computing platform and application programming interface (API) model created by NVIDIA.[1] It allows software developers and software engineers to use a CUDA-enabled graphics processing unit (GPU) for general purpose processing - an approach known as GPGPU. The CUDA platform is a software layer that gives direct access to the GPU's virtual instruction set and parallel computational elements, for the execution of compute kernels.[2]

What is Caffiene?

Caffeine is a high performance, near optimal caching library based on Java 8.

What design pattern avoids coupling the sender of a request to its receiver by giving more than one object a chance to handle the request?

Chain of Responsibility

What are Carmichael numbers?

Carmichael numbers are composite integers that always satisfy Fermat's little theorem. They are pseudo-primes.

What are Catalan numbers?

Catalan numbers form a sequence of natural numbers that occur in various counting problems, often involving recursively-defined objects. They can be thought of as the set of balanced parentheses.

What is LZ* compression based on?

Cataloging the positions and lengths of redundant patterns and combining the values with a dictionary.

What does wait() do?

Causes the parent process to pause until the child terminates.

What is the relationship between consistent hashing and memcache?

Consistent hashing can be used with memcache not even knowing about it. It is interesting to note that it is only the client that needs to implement the consistent hashing algorithm - the memcached server is unchanged.

What is a contiguously-allocated structures, and give examples.

Contiguously-allocated structures are composed of single slabs of memory, and include arrays, matrices, heaps, and hash tables.

What does a Control Unit (CU) do?

Controls, organizes and deals with all the process and instruction the CPU receives. It is also in charge of the Fetch-Execute Cycle. Has two special purpose registers: the Instruction Register and the Program Counter.

What is machine learning?

Creating and using models that are learned from data.

How can you find a cycle in a graph?

DFS. If you discover an edge that connects to an ancestor (previously discovered vertex), you have a cycle.

What is DMA?

DMA (Direct Memory Access) allows devices, with the help of the Northbridge, to store and receive data in RAM directly without the intervention of the CPU.

What is the difference between SRAM and DRAM?

DRAM stands for Dynamic Random Access Memory. It is a type of semiconductor memory in which the memory is stored in the form of a charge. Each memory cell in a DRAM is made of a transistor and a capacitor. The data is stored in the capacitor. Capacitors loose charge due to leakage and hence DRAM's are volatile devices. To keep the data in the memory, the device must be regularly refreshed whereas SRAM is static, so it will retain a value as long as power is supplied. SRAM is typically faster than DRAM since it doesn't have refresh cycles. Since each SRAM memory cell is comprised of 6 Transistors unlike a DRAM memory cell, which is comprised of 1 Transistor and 1 Capacitor, the cost per memory cell is far greater in an SRAM compared to a DRAM.

What design pattern attaches additional responsibilities to an object dynamically and provides a flexible alternative to sub-classing for extending functionality?

Decorator pattern

What is the Bridge pattern?

Decouples an abstraction from its implementation so that the two can vary independently.

What is the EDI register used for?

Destination pointer for string or other copy operations.

What is cyclic garbage collection?

Detects and removes cycles unreachable by the program.

What is FFTW?

Developed at MIT, it's the Fastest Fourier Transform in the West.

What causes operating systems to crash most of the time?

Device drivers. They are in the kernel and very low level. They have access to all the hardware, including memory. They are written by authors outside of the operating system.

Which way does the stack grow?

Down to lower memory addresses.

When is the GIL released?

During I/O (disk IO, network IO, output to display) including when a thread uses sleep.

What is dynamic binding?

Dynamic binding, also called dynamic dispatch, is the process of linking procedure call to a specific sequence of code (method) at run-time. Dynamic binding is also known as late binding or run-time binding. Dynamic binding is an object oriented programming concept and it is related with polymorphism and inheritance.

What is the rule of thumb before optimizing or parallelizing?

Ensure the code works correctly first. Then, if you want to get fancy, you can begin to optimize your code for greater speed.

What is the Singleton pattern?

Ensures a class only has one instance and provides a global point of access to it.

How often do context switches happen?

Every 10-100 ms.

How often are DRAM cells data rewritten?

Every 10ms.

LRU is the most popular type of what kind of policy?

Eviction

Why should you avoid starting and joining a task or thread on the same line or proximity?

Execution on the current thread will block until it completes, thereby obviating the concurrent call.

What is another name for O(2^n)?

Exponential growth

What is in mathematical application of FFT?

FFT-based algorithm that multiplies two n-bit numbers in O(n lg n lg lg n) time is due to Schonhagen and Strassen.

What is Fabric?

Fabric is a Python (2.5-2.7) library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks.

In brief, how does selection sort work?

Find the minimum item on each pass, past the previous minimum, and swap it into the leftmost position after the previous minimum.

When is using an adjacency list expensive?

Finding predecessors of a node u is extremely expensive, requiring looking through every list of every node in time O(n + e), where e is the total number of edges, although if this is something we actually need to do often we can store a second copy of the graph with the edges reversed.

What can most dynamic programming problems be expressed as?

Finding the shortest path in a DAG. Formulating it this way ensures you can solve it in linear or linearithmic time.

What devices are at the Transport layer?

Firewalls

What design pattern defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically?

Observer pattern

What is a benefit of making processes asynchronous?

Flexibility in the architecture. Getting users on hooked on synchronous low-latency interactions doesn't allow for architecture flexibility.

How do you change a 2s complement positive integer into a negative one?

Flip all bits and + 1

How do you change a 2s complement negative integer into a positive one?

Flip all bits and + 1 (same as going the other way)

How would radix sort work for IEEE floating point numbers?

Flip all bits for negative numbers, do sort, then flip back.

How do you change a negative integer to positive?

Flip all bits, then add 1

What design pattern uses sharing to support large numbers of fine-grained objects efficiently?

Flyweight pattern

What is the limiting factor of compression?

For lossless compression, it's entropy. For lossy compression, it's our acceptance with the amount of loss.

What are web sockets?

Full-duplex communication between client and server.

What does SNMP do?

Gathers info from machines on the network when each box has an SNMP agent installed. Can send a large amount of info about machines, software installed, and machine configuration.

What should be handling requests first, a proxy server or a cache?

Generally it is best to put the cache in front of the proxy. This is because the cache is serving data from memory, it is very fast, and it doesn't mind multiple requests for the same result. But if the cache was located on the other side of the proxy server, then there would be additional latency with every request before the cache, and this could hinder performance.

What is Mesa?

Geo-Replicated, Near Real-Time, Scalable Data Warehousing

What is the Interpreter pattern?

Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.

What is the Bayes' rule (formula)?

P(A|B) = (P(B|A) * P(A)) / P(B)

What is munin?

Graph metrics and alerting.

When associative operations are used, what does it mean?

Grouping doesn't matter. It will evaluate to the same result.

What is HMAC?

HMAC is a keyed-hash message authentication code used to provide a checksum for a message, sent along with the message to provide confidence that the message has not been tampered.

What is dual-mode operation?

Hardware provides at least 2 modes: user mode and kernel (aka: supervisor, protected) mode.

Is HTTP/2 binary or textual?

HTTP/2 is a binary protocol.

What is HDFS?

Hadoop File System (HDFS) is a Java-based file system that provides scalable and reliable data storage, and it was designed to span large clusters of commodity servers.

What is a drawback of using an adjacency matrix for an undirected graph?

Half of the entries in the matrix are duplicates.

What is copying garbage collection (stop and copy)?

Heap memory is split into 2 partitions: an old space and a new space. Find live objects by DFS of their reference graph, and move live objects into the new space. The new space is now called the old space. Unreachable objects are simply left in the old space to be overwritten the next time collection occurs. The movement of objects implicitly compacts the objects. Disadvantage: you can only use half of the heap space.

What do multiple threads in the same process share?

Heap, file descriptors, code, static data.

What is Hortonworks?

Hortonworks is a software company focused on the development and support of Apache Hadoop, a framework that allows for the distributed processing of large data sets across clusters of computers.

How can you tell if a graph is 2-colorable?

If it's bipartite. All trees are bipartite.

What is the Chinese remainder theorem?

If one knows the remainders of the division of an integer n by several integers, then one can determine uniquely the remainder of the division of n by the product of these integers, under the condition that the divisors are pairwise coprime.

In Python, if a thread is set to daemon, what happens when the thread sleeps?

If the Python program reaches its end, the thread will be killed even if it's sleeping.

What problem does consistent hashing help solve?

If you're using a caching scheme like server = hash(i) mod m, and one server in the cluster drops out, consistent hashing is needed to avoid swamping your servers when all the caches need to rehash their entities.

Can you use when your graph is extremely large?

If your graph is extremely large, it may become necessary to switch to a hierarcchical representation, where the vertices are clustered into subgraphs that are compressed into single vertices. Two approaches exist to construct such a hierar-chical decomposition. The first breaks the graph into components in a natural or application-specific way. For example, a graph of roads and cities suggests a natural decomposition—partition the map into districts, towns, counties, and states.

What does adding jitter in system design help you avoid?

If your system doesn't jitter then you get thundering herds. Distributed applications are really weather systems. Debugging them is as deterministic as predicting the weather. Jitter introduces more randomness because surprisingly, things tend to stack up.

Where is information about a process stored?

In a PCB (process control block).

Where is information about a thread stored?

In a TCB (thread control block).

How would you visualize billions of items in a graph?

In many cases, you don't need to graph every point, just use visualization-aware sampling. Sometime 1% or less will do.

Does Python have an opcode cache?

In a way. It outputs a .pyc file, containing the bytecode. When a module is imported for the first time, or when the source is more recent than the current compiled file, a .pyc file containing the compiled code will usually be created in the same directory as the .py file. When you run the program next time, Python uses this file to skip the compilation step.

Where can octet order (Endianness) problems crop up in files?

In binary files, if you aren't consistent with choosing an order. Files encoded in utf8 or ASCII don't have this issue.

What is a monad?

In functional programming, monads are a way to build computer programs by joining simple components in predictable and robust ways. A monad is a structure that represents computations defined as sequences of steps: a type with a monad structure defines what it means to chain operations together, or nest functions of that type. This allows the programmer to build pipelines that process data in a series of steps (i.e. a series of actions applied to the data), in which each action is decorated with additional processing rules provided by the monad. A monad is defined by a return operator that creates values, and a bind operator used to link the actions in the pipeline.

When a system call is made, where are parameters stored?

In registers.

How should you initialize Theta for a neural network?

Initialize as a matrix of random reals between 0 and 1. Constrain within a range of +/- epsilon using Theta * 2*epsilon - epsilon.

What is the EIP register used for?

Instruction pointer - next instruction pointer to execute.

What is a special feature of condition variables?

It allows sleeping inside a critical section by atomically releasing lock at the time we sleep.

Why should tests be idempotent and isolated?

It allows tests to be run in any order, re-run, and parallelized.

What manufacturer uses an inclusive cache style?

Intel

What is IPC?

Inter-process communication or interprocess communication (IPC) refers specifically to the mechanisms an operating system provides to allow processes it manages to share data. Typically, applications can use IPC categorized as clients and servers, where the client requests data and the server responds to client requests.

What does ICMP stand for?

Internet Control Messaging Protocol

What design pattern, given a language, defines a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language?

Interpreter pattern

How does the kernel handle reads and writes?

It buffers reads so they can be handled as a stream in your program. Writes are buffered and are not written until the kernel flushes the buffer.

Why is doing work in a constructor a bad thing?

It can make your code harder to test.

How does perfect hashing handle collisions?

It creates a second hash table in the buckets where there are multiple items (k), using a second hash function, and k^2 space. The hash table has two hashing levels. k^2 is chosen because the Markov inequality (birthday paradox) ensures we will not have collisions in bucket.

As predictability increases, what happens to entropy?

It decreases.

What is special about an interrupt handler?

It disables interrupts and runs to completion.

What happens when the heap gets too large?

It does a page fault, and the kernel will allocate more memory.

How does the OS run a program?

It does an exec from kernel mode (system mode 1). We go to system mode 0, user mode. When the program exits, we switch back to kernel mode.

What happens when the hardware needs something to happen?

It does an interrupt, and the kernel takes control, switches the process, and once hardware task is complete, does a return from interrupt back to user mode.

What is Amdahl's Law?

It gives the theoretical speedup in latency of the execution of a task at fixed workload that can be expected of a system whose resources are improved.

How does the OS know how to handle an interrupt?

It keeps an interrupt vector in the memory of the OS. Each interrupt type is mapped to an address to execute. They are just pointers to code in the OS.

What is a benefit of adding asynchrony to a system?

It keeps clients from holding connections to servers when waiting for a response for a task that could simply be deferred. This reduces load on servers that are performing writes, for example, and lets them perform a task when ready, not on-demand.

How does a user program interact with the kernel?

It makes a system call, and the kernel takes over, completes the action, and the kernel returns to the process (back to user mode).

What must at least be true about a matrix for it to have an inverse?

It must be square.

What does fork() return?

It returns the child process id to the parent, and 0 to the child. < 0 if error.

Machine learning: What tends to happen with the cross-validation error in a linear model as the degree of polynomial increases?

It starts high (high bias) and decreases, reaching a minimum, and then increases (high variance).

What is gRPC?

It's an open source framework for RPC by Google. gRPC uses HTTP/2 and Google's own Protobuf to provide a scalable and low latency communication. With gRPC comes a new version of Protobuf (proto3) for high performance binary serialization which includes new features and is easier to use than its predecessors.

What should you do to make a Singleton thread-safe?

It's best to make getInstance() thread-safe, or make generating the instance thread-safe so getInstance does not suffer from thread-safety overhead each time it's called.

What is special about UDP?

It's connectionless, packets are only sent once and not re-sent if dropped. Packets may not arrive in the right order, and there is no ordering mechanism to fix on the receiving end. No congestion control.

What is the stream parallelism in HTTP/2?

It's fully multiplexed, so it can use 100-1000 streams in a connection.

What is the GIL?

It's the Global Interpreter Lock. It's is a part of CPython. It ensures only one thread runs in the interpreter at once. Having the GIL simplifies many low-level details (memory management, callouts to C extensions, etc.)

What is stable sorting?

Items with the same key are sorted based on their relative position in the original permutation

What design pattern provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation?

Iterator pattern

What is JIT compilation?

JIT compilation, also known as dynamic translation, is compilation done at run-time rather than ahead of time (AOT).

How do you get the logarithm of a number n given a base b?

Keep dividing n by b until you get to a number <= 1.

What is a benefit of sharding a database as it grows, and what determines the size?

Keeping the index in cache ensures a user lookup doesn't have to hit the disk, lookups can be served from RAM. How much RAM you have will determine the index size which will hint at the underlying data size.

How can you transpose a matrix in a matrix?

Label each row and column with row and column number. Sort by column, then by row.

What preference of nodes vs leaves does postorder traversal give on a tree?

Leaves first, internal nodes later.

Other than the main registers, what other registers can be used?

Legacy 8 and 16-bit registers: AX, AH, AL, SP, BP, SI

What is the LZ in LZ compression?

Lempel-Ziv

What is MVCC?

Multiversion concurrency control (MCC or MVCC), is a concurrency control method commonly used by database management systems to provide concurrent access to the database and in programming languages to implement transactional memory.

What is another name for a breadth-first search traversal?

Level-order traversal.

What is L-BFGS?

Limited-memory BFGS (L-BFGS or LM-BFGS) is an optimization algorithm in the family of quasi-Newton methods that approximates the Broyden-Fletcher-Goldfarb-Shanno (BFGS) algorithm using a limited amount of computer memory. It is a popular algorithm for parameter estimation in machine learning.

What are linked data structures and give examples.

Linked data structures are composed of distinct chunks of memory bound together by pointers, and include lists, trees, and graph adjacency lists.

What is the typical time slice for a process on a Linux box?

Linux kernels are often compiled with HZ=100, which entails that processes are given time slices of 10ms.

Is matrix multiplication commutative? Does AxB = BxA?

No.

What Endianness is Intel?

Little Endian, but only in memory. In registers, all are Big Endian.

What is memory-mapping?

Memory-mapping a file uses the operating system virtual memory system to access the data on the file system directly, instead of using normal I/O functions. Memory-mapping typically improves I/O performance because it does not involve a separate system call for each access and it does not require copying data between buffers - the memory is accessed directly by both the kernel and the user application.

When can insertion sort run in n log n time?

Load into a binary search tree. Then inorder traversal.

What sockets are in modern use?

Local sockets to local machine, called UNIX sockets, and TCP/IP and UDP/IP.

What is a con of the round-robin scheduling scheme?

Long jobs take longer because context-switching time adds up.

What is a MAC?

MAC is a message authentication code used to provide a checksum for a message, sent along with the message to provide confidence that the message has not been tampered.

What should you do when you have one or more lists that are sorted and you need to combine them into a sorted list?

Merge step of merge sort.

In a direct mapped or set associative cache, what is special about the cache size?

Main memory is divided into pages, and a memory page maps directly to the cache way size. So an item in a cache page can be mapped to any one of 8 cache ways in an 8-way associative cache. A direct mapped cache simply has one cache way, but it works the same way.

What is multiprogramming?

Making one processor appear as multiple processors, each handling one process each.

What is the Mersenne twister?

Mersenne twister is a fast random number generator of period 2^19937 − 1.

What is MapReduce?

MapReduce, developed by Google in 2004, is a programming model and an associated implementation for processing and generating large data sets. Users specify a map function that processes a key/value pair to generate a set of intermediate key/value pairs, and a reduce function that merges all intermediate values associated with the same intermediate key.

What is a tracing garbage collector?

Mark and sweep: pauses execution in order to mark all objects referenced by any thread of the program.

Using an adjacency matrix how can you see how many paths exist between two points of length K?

Matrix multiplication has a particularly interesting interpretation. Now consider the square of this matrix, A^2 = A × A. If A^2[i, j] ≥ 1. This means that there must be a vertex k such that A[i, k] = A[k, j] = 1, so i to k to j is a path of length 2 in G. More generally, A^k[i, j] counts the number of paths of length exactly k between i and j. This count includes nonsimple paths, where vertices are repeated, such as i to k to i to j.

What design pattern defines an object that encapsulates how a set of objects interact?

Mediator pattern

What are 2 examples of in-memory caches?

Memcached and Redis are both examples of in-memory caches

What design pattern captures and externalize an object's internal state so that the object can be restore to this state later?

Memento pattern

What is a message broker?

Message broker is an intermediary program module that translates a message from the formal messaging protocol of the sender to the formal messaging protocol of the receiver. Message brokers are elements in telecommunication networks where software applications communicate by exchanging formally-defined messages. Message brokers are a building block of Message oriented middleware.

What is the mode?

Most-common value(s) in a set of data. Could have more than one if there are 2 subsets with the same number of values.

What is a class D network reserved for?

Multicasting

What is an example of a non-cryptographic hash function?

MurmurHash is an efficient, non-cryptographic hash function suitable for general hash-based lookup. The name comes from two basic operations, multiply (MU) and rotate (R), used in its inner loop. It has an avalanche effect. The current version is MurmurHash3 which yields a 32-bit or 128-bit hash value.

What is NC?

NC (Nick's class) can be thought of as the problems that can be efficiently solved on a parallel computer. NC is a subset of P because polylogarithmic parallel computations can be simulated by polynomial-time sequential ones.

What does NP mean? What is an NP algorithm?

NP is the set of decision problem solvable in non-deterministric polynomial time. An NP problem can be solved by a lucky algorithm that magically always finds a yes decision. NP problems can be checked in polynomial time.

How is RSA (using product of large primes) better than using NP-Complete algorithms for encryption?

NP-Complete algorithms are hard in the worst case, but can be sometimes solved in linear time in the average case. Compositing the product of large primes is hard in the average case.

What can be said of integer programming in and NP-completeness?

NP-complete to solve integer or mixed programs to optimality. However, there are integer programming techniques that work reasonably well in practice.

What is disadvantages of merge sort?

Need an extra buffer to hold the merged data

Is selection sort stable?

No.

Is the Halting Problem in R?

No.

What is NTP?

Network time protocol

On insertion in a b-tree, what's the rule?

Never step into a full node.

On descending a b-tree, what's the rule?

Never step into a minimal node.

"Is ""two coloring a graph"" NP-Complete?"

No

Can you multiply a 3x2 and a 3x2 matrix?

No

Is feature scaling needed when using the normal equation?

No

Should you include integration tests in code coverage metrics?

No

Lower Bound for Comparison Based Sorting

No comparison based sorting algorithm can be faster than O(N log N)

How does/did Facebook use memcache and mySQL in 2009?

No joins in production. They have many logical databases for all of their types: people, events, place info, etc. They treat the web tier as a CPU, memcache as system memory, and the database as disk. Everything has an ID and you use the ID to query memcache using a multiget. Any misses are fetched from the database and cached in memcache.

What are the requirements for fourth normal form?

No multi-valued dependencies, meaning records should not be duplicated in a table just because more than one item is associated. This creates records that are duplicates except for one field.

As it relates to compression, as entropy increases, does our ability to compress increase?

No, it decreases.

Do you need to establish a connection before sending data via UDP?

No, it's connectionless.

If a one-way function is target collision-resistant, does that mean it's also collision-resistant?

No.

Is POST idempotent?

No.

Is heap sort stable?

No.

What is the length of the longest chain in a hash table using separate chaining?

O(1 + alpha) where alpha is the load factor, n/m.

What is the technical running time for operations on a hash table?

O(1 + alpha), where alpha is the load factor (n/m). Table doubling operations are amortized.

Add an element to a queue.

O(1)

Add element to the top of the stack - push

O(1)

Remove an element from the front of the queue. dequeue

O(1)

Remove the top element of the stack - pop

O(1)

Return the element from the front of the queue without removing it. - front

O(1)

Return the value of the top element of the stack without removing it.

O(1)

What is the worst-case search time of perfect hashing?

O(1)

add (unordered array)

O(1)

add (unordered singly linked list)

O(1)

insert (unordered sequence)

O(1)

min (binary heap)

O(1)

min (ordered sequence)

O(1)

removeMin (ordered sequence)

O(1)

What's the best-case running time of binary search?

O(1) - we get lucky and find the element right at the midpoint.

Space required for an adjacency list

O(E + V)

What is the time complexity of Ford-Fulkerson?

O(E max|f|)

What is the complexity of an adjacency list DFS?

O(E)

With a fair coin, what is the probability of getting exactly 1 H in 4 flips?

P(HTTT) + P(THTT) + P(TTHT) + P(TTTH) = 1/16 + 1/16 + 1/16 + 1/16 = 4/16 = 1/4

All comparison-based sorting is bounded by what complexity?

Omega(n log n)

How do context switches perform under virtualization?

On average, it's 2.5x to 3x more expensive to do a context switch when using virtualization. My guess is that this is due to the fact that the guest OS can't update the page table itself, so when it attempts to change it, the hypervisor intervenes, which causes an extra 2 context switches (one to get inside the hypervisor, one to get out, back to the guest OS).

How many times are packets sent in UDP?

Once.

What does SHA stand for?

One of the family of Secure Hashing Algorithms.

What is busy-waiting?

One or more threads is using a lot of CPU by continuously checking a value, or test&set() checking and writing a value in wiating for a lock to release, thus stealing CPU from the thread holding the lock.

How many threads should you run per process?

One per core.

What is a regression problem?

One that predicts a continuously valued output. May refer specifically to the estimation of continuous response variables, as opposed to the discrete response variables used in classification.

What can you do when your model has high bias (which means it performs poorly even on your training data)?

One thing to try is adding more features.

What can happen with thread stacks if one goes into a deep recursion?

One thread's stack can grow into another thread's stack and write over it. A guard page can help to protect from that.

In what domain are most decision problems (P, Exp, R, outside R)?

Outside R - they are uncomputable

How would you calculate P(A|B)?

P(A and B) / P(B)

How would you calculate P(A and B)?

P(A) * P(B)

How would you calculate P(A or B)?

P(A) + P(B) - P(AB)

What's another way to write P(A and B)?

P(AB)

What can you do to save space in an adjacency matrix?

Pack all of the ones and zeros into a series of bit vectors.

A b-tree's data is organized to correspond with what?

Pages on disk.

What is multiprocessing?

Parallel execution on multiple cores.

What is a cycle?

Path with at least one edge whose first and last vertices are the same.

What is the Paxos algorithm?

Paxos is a family of protocols for solving consensus in a network of unreliable processors. Consensus is the process of agreeing on one result among a group of participants. This problem becomes difficult when the participants or their communication medium may experience failures.

Why is memory locality important?

Physical continuity between successive data accesses helps exploit the high-speed cache memory on modern computer architectures.

What is pika?

Pika is a pure-Python implementation of the AMQP 0-9-1 protocol that tries to stay fairly independent of the underlying network support library. Can use with RabbitMQ.

Why is an adjacency list for the best choice for a planar graph?

Planar graphs are always sparse, since any n-vertex planar graph can have at most 3n − 6 edges. Thus they should be represented using adjacency lists.

What is a PTAS?

Polynomial-time approximation scheme.

What is another name for O(n^4)?

Quartic growth

How are the priorities of a treap assigned?

Randomly generated upon insertion. That randomness is used to keep the tree balanced.

In statistics, what does recall measure?

Recall measures what fraction of the positives our model identified.

How can you speed up selection sort with a heap?

Replace the unsorted portion with a min-heap. Gives O(log n) removal. Makes n log n overall.

What is the Visitor pattern?

Represents an operation to be performed on the elements of an object structure. Lets you define a new operation without changing the classes of the elements on which it operates.

What is scalability?

Scalability is the measure to which a system can adapt to a change in demand for resources, without negatively impacting performance.

What is the thread cooperative model?

Requires a thread to take some action (sleep, yield) and let other threads run.

What does numpy.allclose() do?

Returns True if two arrays are element-wise equal within a tolerance.

How can you rotate an array of size n by k positions?

Reverse 0 to k - 1, reverse k to end. Then reverse it all.

What is multi-homing?

Running a service across multiple datacenters.

What is concurrency?

Running tasks at almost the same time in an unspecified order. This is achieved through context switches by the operating system.

What is differential testing?

Running test inputs into 2 different implementations and then testing for equality. This is useful for testing multiple versions of the software.

Where are SRAM and DRAM used?

SRAMs are used in Caches because of higher speed and DRAMs are used for main memory in a PC because of higher densities.

What does SMT stand for?

Satisfiability modulo theories.

What does the scheduler do?

Schedulers are special system software which handles process scheduling in various ways. Their main task is to select the jobs to be submitted into the system and to decide which process to run.

When is security enforced on a file?

Security is checked when the file descriptor is created. Then it's up to the user to be careful and secure the file descriptor.

What is sharding?

Sharding is a type of database partitioning that separates very large databases the into smaller, faster, more easily managed parts called data shards.

What's the convoy effect?

Short processes get stuck behind long processes in a FIFO style ready queue.

In testing, what is an oracle?

Software testers and software engineers can use an oracle as a mechanism for determining whether a test has passed or failed. The use of oracles involves comparing the output(s) of the system under test, for a given test-case input, to the output(s) that the oracle determines that product should have.

What is software transactional memory?

Software transactional memory provides transactional memory semantics in a software runtime library or the programming language, and requires minimal hardware support (typically an atomic compare and swap operation, or equivalent). As the downside, software implementations usually come with a performance penalty, when compared to hardware solutions.

Codeless question: Given a set of n numbers, how do you find the pair of numbers that have the smallest difference between them?

Sort them: Once the numbers are sorted, the closest pair of numbers must lie next to each other somewhere in sorted order. Thus, a linear-time scan through them completes the job, for a total of O(n log n) time including the sorting.

What is the ESI register used for?

Source pointer for string or other copy operations.

What is Spanner?

Spanner is a scalable, globally-distributed database designed, built, and deployed at Google. At the highest level of abstraction, it is a database that shards data across many sets of Paxos state machines in datacenters spread all over the world. Replication is used for global availability and geographic locality; clients automatically failover between replicas. Spanner automatically reshards data across machines as the amount of data or the number of servers changes, and it automatically migrates data across machines (even across datacenters) to balance load and in response to failures. Spanner is designed to scale up to millions of machines across hundreds of datacenters and trillions of database rows.

How can an event-driven handler manage a long-running process, like waiting for a network response?

Spawn a thread to call the network resource. Then queue the result once complete so the parent process (or main event thread) can respond and access the data without polling.

What is oversubscription?

Spawning more threads than available cores.

What is the EAX register used for?

Stores the function's return value.

What design pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable, and lets the algorithm vary independently from clients that use it?

Strategy pattern

What does sed stand for and what does it do?

Stream editor. It does many things but is mainly used for search and replace.

How do you change a positive integer to negative?

Subtract 1, flip all bits

What is supervised learning?

Supervised learning is the machine learning task of inferring a function from labeled training data. The training data consist of a set of training examples. In supervised learning, each example is a pair consisting of an input object (typically a vector) and a desired output value (also called the supervisory signal).

What is block size in cryptography?

Symmetric key ciphers are generally divided into stream ciphers and block ciphers. Block ciphers operate on a fixed length string of bits. The length of this bit string is the block size. Both the input (plaintext) and output (ciphertext) are the same length; the output cannot be shorter than the input - this is logically required by the Pigeonhole principle and the fact that the cipher must be invertible - and it is simply undesirable for the output to be longer than the input.

Does Kerberos use symmetric or asymmetric encryption?

Symmetric. It tracks all principals and their keys in its KDC table.

What network protocol won the networking wars?

TCP/IP, based on the OSI model.

What does the Python bisect module do?

The bisect module, part of the standard library, provides support for maintaining a list in sorted order without having to sort the list after each insertion. For long lists of items with expensive comparison operations, this can be an improvement over the more common approach.

What is the problem that serialization introduces?

The overhead of serializing and deserializing. It's all expensive, and for Python, it can be terribly slow.

What design pattern defines the skeleton of an algorithm in an operation, deferring some steps to subclasses?

Template Method pattern

What is unit testing?

Testing a single module in isolation.

What is integration testing?

Testing units together to ensure the integrated behavior performs as expected.

What is the optimal substructure property tell us about shortest paths?

That a subpath of a shortest path is also a shortest path.

Given a sufficiently small alpha, what can you expect from gradient descent?

That it will eventually converge.

What is the I in SOLID?

The Interface Segregation Principle (ISP) states that clients should not be forced to implement interfaces they don't use. Instead of one fat interface many small interfaces are preferred based on groups of methods, each one serving one submodule.

What translates virtual to physical addresses?

The MMU - the memory management unit

What is preemptive threading?

The OS swaps threads based on timing or other interrupts.

What is a Zipf distribution?

The Zipf distribution, sometimes referred to as the zeta distribution, is a discrete distribution commonly used in linguistics, insurance, and the modeling of rare events.

What is OS hardware virtualization?

The abstraction of heterogeneous hardware provided by the operating system, to hide the details of interfacing with various hardware so that they share a common interface for that type.

If you use __slots__ on a class, what happens in subclasses?

The action of a __slots__ declaration is limited to the class where it is defined. As a result, subclasses will have a __dict__ unless they also define __slots__ (which must only contain names of any additional slots).

What is the base case of a recursion?

The code required to give the solution to the smallest subproblem.

What is a socket in HTTP?

The combination of an IP address and a port.

What does concurrent.futures do?

The concurrent.futures modules provides interfaces for running tasks using pools of thread or process workers. The APIs are the same, so applications can switch between threads and processes with minimal changes.

What is the commutative property?

The condition that a group of quantities connected by operators gives the same result whatever the order of the quantities involved. So order of operands doesn't matter, but grouping may matter.

What is a context switch?

The copying out and in of register state to switch from running one process to running another.

What happens during an interrupt?

The currently running process' state is saved. We switch to kernel mode, the interrupt handler runs, and once its complete, the system goes back to user mode and the process continues.

What is ambient authority, or ambient privilege?

The decision about whether a process or agent can perform an action is based on information not explicitly stated, but inherited instead.

What is avalancing?

The effect of a hashing method where a small change in the input has a large effect on the output.

When does a Python multi-threaded program terminate?

The entire Python program exits when no alive non-daemon threads are left.

How can you tell if 2 rectangles do not overlap?

The intersection of R1 and R2 will be a rectangle R3 whose bottom-left corner is at (max(x1, x3), max(y1, y3)) and top-right corner at (min(x2, x4), min(y2, y4)). If max(x1, x3) > min(x2, x4) or max(y1, y3) > min(y2, y4) then R3 does not exist, ie R1 and R2 do not intersect.

What is Little Endianness?

The least significant bytes of a word or larger are stored in the lowest address. All bytes are the same. There is no Endianness within a byte.

What will be the computation time when processing multiple tasks?

The length of time the longest subcomputation takes.

What is a limited broadcast address?

The limited broadcast address is the address formed by setting all 32 bits of the IP address to 1 (255.255.255.255). The limited broadcast address is used when an IP node must perform a one-to-everyone delivery on the local network but the network ID is unknown.

What is the bandwidth of a graph?

The longest edge in the permutation that gives you the shortest edges.

What defines a complete binary tree, and give an example?

The same number of nodes at all levels of the tree, except at leaf level where it fills in left to right. A heap stored as an array is an example.

If a thread is a daemon, what happens when you do a join()?

The main thread will wait for it.

What is covariance?

The mean value of the product of the deviations of two variates from their respective means.

What factor should you keep in mind when doing parallel computation on different parts of a large data structure?

The memory bandwidth of your RAM. It can become a bottleneck.

In a maximum flow problem, what is the minimum cut?

The min cut is the maximum flow through the graph.

What is entropy?

The minimum number of bits needed to represent x number of states. Also, information we don't know.

What is Big Endianness?

The most significant bytes of a word or larger are stored in the lowest address.

In Python, what can you use to fork a process?

The multiprocessing module. It supports process Pool and Process for making a pool of worker processes or forking temporary subprocesses.

What is the quantile?

The number at a given percentile of the data.

What are the number of neurons (units) at the output layer of a neural network performing classification?

The number of classes you are classifying.

What are hooks?

The portions of a framework that are called, but do nothing and require implementation when needed.

What is a capability?

The privilege to act upon something given your ownership of it, and the inability to act on something using an intermediate process' privileges. An example would be a function where you pass a file descriptor as an argument and the function uses your capability, not its own.

What is a classification problem?

The problem of identifying to which of a set of categories (sub-populations) a new observation belongs, on the basis of a training set of data containing observations (or instances) whose category membership is known.

What happens when a program makes an exception?

The program terminates, and switches to kernel mode.

What is idempotent?

The property that a method has side-effects of making more than one identical requests is the same as for a single request.

What is HTTP?

The protocol for client-server communication.

What is the role of a load balancer?

The role is to distribute load across a set of nodes responsible for servicing requests. This allows multiple nodes to transparently service the same function in a system. Their main purpose is to handle a lot of simultaneous connections and route those connections to one of the request nodes, allowing the system to scale to service more requests by just adding nodes.

When talking dynamic programming, what is feasibility?

The rules the algorithm must adhere to in reaching its solution.

What is the scheduler?

The scheduler manages the priorities of user and OS processes.

How does a process' priority get changed?

The scheduler utilizes heuristics on interactivity, locking, burst behavior, etc.

What is EXP?

The set of all problems solvable in exponential time.

What is P?

The set of all problems solvable in polynomial time.

What is R? (not real numbers)

The set of problems solvable in finite time.

What is the diameter of a graph?

The shortest path of the farthest nodes. That is, it is the greatest distance between any pair of vertices. To find the diameter of a graph, first find the shortest path between each pair of vertices. The greatest length of any of these paths is the diameter of the graph.

What path does BFS find in a graph?

The shortest path tree from start to all nodes (unweighted)

How can you sort extremely large amount of data on disk with limited memory?

The simplest approach to external sorting loads the data into a B-tree and then does an in-order traversal of the tree to read the keys off in sorted order. Real high-performance sorting algorithms are based on multiway-mergesort. Files containing portions of the data are sorted into runs using a fast internal sort, and then files with these sorted runs are merged in stages using 2- or k-way merging. Complicated merging patterns and buffer management based on the properties of the external storage device can be used to optimize performance.

What is the S in SOLID?

The single responsibility principle. There should never be more than one reason for a class to change. We can relate the "reason to change" to "the responsibility of the class". So each responsibility would be an axis for change.

What is the chromatic number?

The smallest number of colors needed for an edge coloring of a graph.

What triggers a context switch?

Timer interrupt, hardware interrupt, I/O where we're waiting for a read or write to complete (OS doesn't want to waste time waiting), voluntary yield.

What is a normal distribution?

The standard normal probability density function has the famous bell shape that is known to just about everyone.

What is TLS?

The successor to SSL. All of SSL's versions have been deprecated due to security issues.

What is black-box testing?

The tester is testing without knowledge of the internals.

What is white-box testing?

The tester is using knowledge of the program's internals.

In Unix, who is the owner of a file?

The user with the user ID that matches the UID of the inode.

What is a articulation vertex?

The weakest point in a graph.

Context switch time increases sharply with the size of what? (by 100x or more.)

The working set - the subset of memory used by the process in a time window. Cache etc.

What is a connected graph?

There exists a path from every vertex to every other vertex in the graph.

What is symmetric key encryption?

There is a known encryption function, and one key is used to encrypt and decrypt. The key has to be shared between 2 parties.

How do some processors handle caching for data and instructions?

There will be a slightly slower (3-4 clocks latency) separate cache for data.

What is the memory needed to store an adjacency list?

Theta( |V| + |E| )

What is the runtime of randomized quicksort?

Theta(n log n) time on any input, with high probability.

What is the time complexity of Floyd-Warshall?

Theta(n^3)

What is the memory needed to store an adjacency matrix?

Theta(|V|^2)

How are headers and body treated differently in HTTP/2?

They are split into a header frame and a data frame. Multiple requests can be interleaved in a connection, so a request doesn't block.

How are base and bound enforced?

They are stored in registers. Access is restricted by the hardware.

What size are Intel instructions?

They are variable-length, from 1 to theoretically 16 bytes.

What type of buffer overflow protection does gcc and Visual Studio employ?

They use a stack check guard of bytes before and after the buffer's allocated memory. Once values are written to the buffer, the bytes are checked to ensure they are still the same.

Codeless question: Are there any duplicates in a given set of n items?

This is a special case of the closest-pair problem, where we ask if there is a pair separated by a gap of zero. The most efficient algorithm sorts the numbers and then does a linear scan though checking all adjacent pairs.

What happens at the Application level of the OSI model?

This is where applications live and they handle data in many forms.

What can cause a thread to give control back to the dispatcher?

Thread returns control voluntarily (yield, requesting I/O (which blocks), wait for signal from another thread) or gets preempted by an interrupt.

How can you convert a linear programming maximization problem into a minimization problem?

To convert a maximization problem to a minimization one, simply multiply each coefficient of the objective function by −1. The remaining problems can be solved by adding slack variables to the model. See any textbook on linear programming for details

Why was OSI created?

To solve the interoperability problem of having multiple heterogeneous networks.

Why do most businesses end up sharding as they scale?

To support massive concurrent writes.

How can you make JSON better compressable with Gzip?

Transpose from multiple mini-dicts into one dict with arrays as the values. This allows the items in an array to fit within the 32KB search buffer common to LZ-based compression.

How do you reverse the edges in a directed graph represented as an adjacency matrix?

Transpose the matrix, so [i, j] becomes [j, i]

What is another term for linear regression with one variable?

Univariate linear regression

What is unsupervised learning?

Unsupervised learning is the machine learning task of inferring a function to describe hidden structure from unlabeled data. Since the examples given to the learner are unlabeled, there is no error or reward signal to evaluate a potential solution. This distinguishes unsupervised learning from supervised learning and reinforcement learning.

How long does a terminated process stay in the terminated state?

Until the parent process does a wait to receive its exit code.

What does UDP stand for?

User Datagram Protocol.

What is the Flyweight pattern?

Uses sharing to support large numbers of fine-grained objects efficiently.

What makes van Emde Boas trees special?

Van Emde Boas priority queues support O(lg lg n) insertion, deletion, search, max, and min operations where each key is an element from 1 to n.

What does low entropy mean?

Very predictable.

Does the CPU use virtual addresses or physical addresses?

Virtual addresses

How can we avoid deadlock?

We can prevent deadlock by assigning an order to locks and require that the locks be acquired in that order. However, this approach is not often used in practice.

What does WebRTC stand for?

Web Real-Time Communication

What is a uniform distribution?

When a known finite number of outcomes are equally likely to occur. When graphed as a histogram of occurrences, it's a flat line. N items each have 1/n probability.

What happens when inheriting from a class without __slots__?

When inheriting from a class without __slots__, the __dict__ attribute of that class will always be accessible, so a __slots__ definition in the subclass is meaningless.

How can a server deal with a SYN flood attack?

When it detects a large number of SYN packets at once, or the size of its SN (sequence number) data structure reaches a certain threshold of entries, it can switch to a stateless version, where it send SN responses as signed values with a timestamp, and if it receives one back it lets them through without needing a lookup table.

What is starvation?

When low-priority jobs never get run because there are always higher priority jobs running.

What is request coalescing?

When many requests arrive for some content that's missing in the cache (cache miss), only one instance request will proceed to the backend to fetch the content on behalf of all to avoid a flood.

Under what condition can you not use Djikstra's algorithm?

When the graph contains a negative edge. Can cause a cycle that will be traversed infinitely.

In what case would perfect hashing be practical?

When you don't need to support inserts or deletes. The data is static.

What do you test interfaces with a trust boundary?

With lots of different inputs, including random inputs to ensure that the system can handle or appropriately error out, not crash.

What is MPM?

Within Google, MPM (Midas Package Manager) is used to build and deploy container images. It corresponds to the Docker image registry for Docker containers.

Why is feature scaling important?

Without feature scaling, it can take gradient descent much longer to find the local minimum. The function may oscillate in small movements for much longer.

What is the Memento pattern?

Without violating encapsulation, capture and externalize an object's internal state so that the object can be restore to this state later.

What should you do before fixing a reported bug?

Write a test. Avoiding this practice allows bugs to re-appear.

What is write-back cache?

Write-back cache is where write I/O is directed to cache and completion is immediately confirmed to the host. This results in low latency and high throughput for write-intensive applications, but there is data availability exposure risk because the only copy of the written data is in cache. As we will discuss later, suppliers have added resiliency with products that duplicate writes. Users need to consider whether write-back cache solutions offer enough protection as data is exposed until it is staged to external storage. Write-back cache is the best performing solution for mixed workloads as both read and write I/O have similar response time levels.

What is write-through cache?

Write-through cache directs write I/O onto cache and through to underlying permanent storage before confirming I/O completion to the host. This ensures data updates are safely stored on, for example, a shared storage array, but has the disadvantage that I/O still experiences latency based on writing to that storage. Write-through cache is good for applications that write and then re-read data frequently as data is stored in cache and results in low read latency.

How does a half-adder handle an addition?

XOR for the sum and AND for the carry

"Is ""3-D matching"" NP-Complete?"

Yes

"Is ""bin packing"" NP-Complete?"

Yes

"Is ""set cover"" NP-Complete?"

Yes

"Is ""subset sum"" NP-Complete?"

Yes

"Is ""triple coloring a graph"" NP-Complete?"

Yes

"Is ""vertex cover"" NP-Complete?"

Yes

Can you multiply a 3x2 and a 2x3 matrix?

Yes

Can you multiply a 3x2 and a 2x6 matrix?

Yes

Is GET idempotent?

Yes

Is a geometric Steiner tree NP-Complete?

Yes

Is matrix multiplication associative? Does (AxB)xC = Ax(BxC)?

Yes

Can heap sort be done in-place?

Yes.

Can insertion sort be done in-place?

Yes.

Can selection sort be done in-place?

Yes.

If a one-way function is collision-resistant, does that mean it's also target collision-resistant?

Yes.

Is OSI just a model?

Yes.

Is PUT idempotent?

Yes.

What is Zopfli?

Zopfli is data compression software that encodes data into DEFLATE, gzip and zlib formats. It achieves higher compression than other DEFLATE/zlib implementations, but takes much longer to perform the compression. It was first released in February 2013 by Google.

What is it called when you have too many base cases in your recursion?

arm's length recursion

Design a URL shortening service.

ask:

How would you design the feature in LinkedIn where it computes how many hops there are between you and another person?

ask:

How can you find out your computer's IP address from the command line?

curl ifconfig.me

How can you print the 1st and 2nd column of a file only when the second column contains the word foo?

awk '{ if($2 ~ /foo/) print $1,$2}' somefile

How can you print the 1st, 2nd, and 4th columns in the /etc/passwd file that contain the word home?

awk -F: '/home/ {print $1, $2, $4}' /etc/passwd

What is it called when all training examples are used to calculate gradient descent?

batch gradient descent

What is bcrypt?

bcrypt is a password hashing function based on the Blowfish cipher. Besides incorporating a salt to protect against rainbow table attacks, bcrypt is an adaptive function: over time, the iteration count can be increased to make it slower, so it remains resistant to brute-force search attacks even with increasing computation power.

"What is a better way of saying ""at least O(n^2)""?"

big Omega(n^2)

What is the PDU for OSI layer 7?

data, determined by what information is being exchanged: text, encrypted text, compressed data

How you can express log(base b)a as another base?

log(base d)a / log(base d)b

How else can you write log(base b)(a^c)?

c * log(base b)a

In Linux, how can you search a set of files of phone numbers, which are badly formatted, and output the numbers, using regular phone number formatting and no blank lines?

cat numbers-* | sed 's/[() -]//g' | grep -P '^\d{10}$' | sed -r 's/([0-9]{3})([0-9]{3})(.*)/(\1) \2-\3/'

What is the caller register-saving convention on Linux systems?

cdecl - C declaration

What command can you use to format in tab-stopped columns?

column -t

Python: How would you remove indices 6 to 11 in a list foo?

del foo[6:12]

What command line tool allows you to get the IP address from a domain name?

dig

Since uniform hashing is difficult to achieve in practice, what is a great alternative?

double hashing

How do you represent infinity in Python?

float('Inf')

In a heap, with a 0-based array, what is parent of i?

floor((i-1)/2)

In a heap, with a 0-based array, what is parent of i?

floor(i/2)

What is a synonym of reduce()?

fold()

Given a fully balanced binary tree with x nodes, what is the height of the tree in nodes?

log(base2) x + 1

Why is log(base2)(2^n) == n?

log(base2)(2^n) = n * log(base 2)2 = n * 1 = n

Python: How can you tell if an index is in a list?

if 0 < i < len(foo):

What command line command allows you to display bandwidth usage on an interface by host?

iftop -p -n

Given a fully balanced k-ary tree with x nodes, what is the height of the tree in nodes?

log(basek) x + 1

How can you view your command line history?

history

What are 2 reasons for using a load balancer?

horizontal scalability and redundancy

For a k-ary tree with height h, the upper bound for the maximum number of leaves is:

k^h

What are the 2 hardware modes?

kernel mode and user mode

For graph problems, the complexity Theta(N + M) is known as what?

linear in the graph size

Python: split a word or sentences into characters.

list('some words')

What alias for ls -alF is included in Ubuntu's .bashrc?

ll

What is the height of a m-ary heap?

log base m of n

How can you write log(base b)(ac)?

log(base b)a + log(base b)c

How can you write log(base b)(a/c)?

log(base b)a - log(base b)c

On the command line, how can you list all files beginning with a or f?

ls [af]*

How can you get quick access to an ASCII table from the command line?

man ascii

What does MAC stand for?

medium access control, a sublayer in the data link layer.

What is another name for a Min-Cost Spanning Tree?

minimum spanning tree

How can you make multiple directories at once from the command line?

mkdir {2009..2016}

How can you reverse the words in a string with Python? Treat punctuation as part of the words.

my_string.split()[::-1]

What is n choose 1?

n

What Python determines the pseudo-inverse of a matrix?

numpy.linalg.pinv

What can you use to solve linear programming problems in Python?

numpy.linalg.solve()

What is the proper name for Endianness?

octet order

What comes back from wait()?

on success, returns the process ID of the terminated child; on error, -1 is returned.

How can you get a list of environment variables from the command line?

printenv

What can you use to debug a process?

ptrace

What is ptrace?

ptrace is a system call found in several Unix and Unix-like operating systems. By using ptrace, one process can control another, enabling the controller to inspect and manipulate the internal state of its target.

What Python flag turns on optimizations and removes assertions from code?

python -O

What is Paxos an example of?

quorum-based 2PC (2 phase commit) protocol

What command can you use when your terminal is messed up by binary output?

reset

How can you test if a number is odd in bitwise operations?

return (x & 1)

How can you test if a number is even in bitwise operations?

return (x & 1) == 0

What user privilege is required to bind to ports < 1024?

root

What is RTTI?

run time type identification

What can you use to compute all-pairs shortest-paths?

scipy.sparse.csgraph.floyd_warshall

What flag do you use with sed to turn on extended regular expressions?

sed -r

During system bootstrapping, what call is performed by the system to give a non-root user the ownership of a process?

setuid()

What Linux command randomizes the lines of its input?

shuf

What algorithm is used for locality-sensitive hashing?

simhash

How can you throw away errors from a command?

somecommand 2> /dev/null

How can you redirect errors form a command to a file?

somecommand 2> errorfile.txt

What command can you use with pipes to save to a file but continue piping to the next command?

somecommand | tee file.txt | morecommand

Bitwise: Replace the lowest bit that is 1 with 0

x & (x - 1)

Bitwise: Isolate the lowest bit that is 1 in x

x & ~(x - 1)

When using k-nearest neighbors, what k should be used for size of points n?

sqrt(n)

What is strace?

strace is a diagnostic, debugging and instructional userspace utility for Linux. It is used to monitor interactions between processes and the Linux kernel, which include system calls, signal deliveries, and changes of process state. The operation of strace is made possible by the kernel feature known as ptrace.

What is tcpdump?

tcpdump is the premier network analysis tool for information security professionals. Having a solid grasp of this über-powerful application is mandatory for anyone desiring a thorough understanding of TCP/IP.

What is another name for the F1 score?

the harmonic mean of precision and recall

In machine learning, what is the symbol m used for?

the number of training examples.

Isolate the right-most bit in x.

x & ~(x - 1)

What is Colossus?

the successor to the Google File System

What command line tool allows you to see the internet connections between you and a given server IP or domain name?

traceroute

What is transitive closure?

transitive closure can be thought of as constructing a data structure that makes it possible to answer reachability questions. That is, can one get from node a to node d in one or more hops?

Python: Give an example of a conditional expression.

x = 1 if cond else 2

In Python, initialize a list of lists called x with 100 elements.

x = [[] for _ in range(100)]

Bitwise: Right propagate the rightmost set bit in x

x | (x & ~(x - 1) - 1)

In statistics, how would you calculate recall?

true_pos / (true_pos + false_neg)

In statistics, how would you calculate precision?

true_pos / (true_pos + false_pos)

How can you tell what a given command line command is an alias for?

type [command]

High bias and low variance typically correspond to _______.

underfitting

How do you show only repeated lines using uniq?

uniq -d

Right-propagate the rightmost 1-bit, producing all 1's if x = 0 (e.g., 01011000 01011111):

x |= (x - 1)

What's the upper bound on the number of edges in a graph G(V, E)?

|V|^2

How can 2 origins (let's say 2 frames) communicate?

window.postMessage (HTML5) allows for sending data messages between two windows/frames across domains.


Related study sets

musculoskeletal prep u, Chapter 40 - Musculoskeletal, CH 41, NUR 1172: Prep U Module 1, Chapter 40 Musculoskeletal Care Modalities

View Set

US History Chapter 19 Study Guide

View Set

BYU Independent Study Biology 100 Exam 3 Lesson 14

View Set

Chapter 18: Microscopes, Cell Culture, Proteins, Nucleic Acid, DNA, Antibodies

View Set

oceanography CHAPTER 5 PRACTICE TEST

View Set