Software Engineer Interview

¡Supera tus tareas y exámenes ahora con Quizwiz!

Edmonds-Karp Algorithm

A variation of Ford-Fulkerson Algorithm that uses BFS instead of DFS to ensure the algorithm terminates even if loops exist. It takes longer though, running at O(|V|*|E|^2) time and using O(|E|+|V|) space.

SVN delete

After committing, a file specified with SVN delete will be deleted from both the local sandbox and the repository.

SVN move

After committing, the file specified with SVN move will be moved (or renamed) on both the local sandbox and the repository/server.

Stable Matching (Gale-Shapley Algorithm) Pair men & women based on preferences such that there will be no people would rather be with each other than with their assigned partner.

Attempt to pair the next single man with his top choice. If she is single or likes him more than who she is currently assigned to, then she is assigned to him. Otherwise, do this with his next choice, until he is paired. O(n^2) time, O(n) space.

Breadth-First Search

BFS searches all nodes of a graph, ordered by breadth (find adjacent nodes, then the nodes adjacent to those nodes, etc.). Start at the root. Enqueue() each adjacent node, then return BFS(Dequeue()). This takes O(|V|+|E|) time and O(|V|) space.

Bubble Sort/Insertion Sort/Selection Sort

Bubble Sort: Go through the list and compare each adjacent element, swapping their positions if they are out of order. Repeat until sorted. Insertion Sort: Go through list until you find an element that is less than the element previous to it. Take the element and place it in sorted position in the earlier portion of the list (the "sorted" portion). Repeatedly do this until all sorted. Note: Insertion sort is adaptive (it is very fast for lists that are already mostly sorted). Selection Sort: Repeatedly go through the list and find the smallest element and move it to the front of the list. All of these have average and worst cases of O(n^2). All of these use O(1) space.

Heapsort

Build a heap out of the list, then repeatedly extract the max value from the heap. Runs in O(nlog(n)) for both average and worst cases. It uses O(1) space. Note: Heapsort is not safe (it is possible for two equivalent items to end up in swapped positions relative to each other after a heapsort is run).

Greedy Method

Choose a concept or value to "prefer" and then design an algorithm to choose the most preferable object and continue doing so until you arrive at a solution.

Minimum Spanning Tree (Prim's Algorithm) Given a connected (no disjoint sections) and weighted (edges have values) graph, find a tree (section without cylces) that spans all nodes and has the least weight of any such tree.

Choose a node at random to start. Add the cheapest edge that connects it to a node that isn't in the MST. Repeat until all nodes are in the MST. Runs in O(|E|*log(|V|)) time.

Quicksort

Choose a pivot at random and split the list by values greater than the pivot and less than (or equal to) the pivot, then sort the two lists on either side of the pivot recursively. This runs in O(nlog(n)) on average. It runs in O(n^2) at worst. It uses O(log(n)) space.

Git commit

Commits in git only reflect changes for you (they only commit to the local sandbox).

CAP Theorem/Brewster's Theorem

Consistency (after an operation everyone will see the same data, regardless of their nodal access point) Availability (system is always on) Partition Tolerance (system functions even if network communication is unreliable) The theorem says that it is impossible to satisfy all 3 of these properties simultaneously. Relational DBs do C and A, whereas NoSQL does C and P or A and P.

Bucket Sort

Create a number of "buckets" (lists) equal to the number of unique values in the list. Go through the list and put each element in its appropriate bucket, then order the buckets (can use any other sorting method). Note: Bucket Sort is only really practical when dealing with a large volume of data that spans a small amount of unique values. Runs in O(n) time on average. Runs in O(n^2) time in the worst case. Uses O(n) space in the worst case.

PUT

Create or update a resource. PUT describes (or rather you describe with PUT) a full resource location. Unlike POST, PUT is idempotent--if you repeat the command, the output will always be the same.

POST

Create or update a resource. Unlike PUT, POST lets the server decide the location (given some information about the resource), so you can also use POST to find a resource's location, similar to a GET. POST is idempotent--if you repeat the same command you may get different results, depending on your command (since the updates can keep stacking on top of each other and extending the URL). For this reason, POST is normally only used for creating, not updating.

Overloading

Creating multiple methods of the same name but with different inputs and implementations.

Depth-First Search

DFS searches all nodes of a graph, ordered by depth (follows one trail, then the next, etc.). Start at the root. For each adjacent node to the root, return DFS(node). This takes O(|V| + |E|) time and O(|V|) space.

DELETE

Delete a resource.

FULL OUTER JOIN

SELECT * FROM T1 FULL OUTER JOIN T2 ON T1.attr = T2.attr Returns all records of T1 and T2, and concatenates the records where the given attribute ("attr") is the same. Other records are concatenated with null values.

INNER JOIN

SELECT * FROM T1 INNER JOIN T2 ON T1.attr = T2.attr Returns records of T1 concatenated with T2 where the given attribute ("attr") is the same.

LEFT OUTER JOIN

SELECT * FROM T1 LEFT OUTER JOIN T2 ON T1.attr = T2.attr Returns all records of T1, and concatenates records of T2 where the given attribute ("attr") is the same. If no records in T2 have a matching value for a record in T1 then it is concatenated with null values.

RIGHT OUTER JOIN

SELECT * FROM T1 RIGHT OUTER JOIN T2 ON T1.attr = T2.attr Returns all records of T2, and concatenates records of T1 where the given attribute ("attr") is the same. If no records in T1 have a matching value for a record in T2 then it is concatenated with null values.

SVN commit/ci

Send your changes to the server (use the "-m" tag to include a message).

SVN status

Show changes. It is commonplace to do "svn status --show-updates" before committing.

HEAD

Similar to GET, except it returns the response code and headers instead of the body of the resource.

SOAP

Simple Object Access Protocol: A way of allowing transmission of formatted docs (like XML or JSON) over the web, regardless of the transport layer protocol being used. The root element is a "SOAP Envelope" containing a header and a body, which can contain "faults" that describe exceptional situations. Can also contain attachments in MIME encoding for exchanging binary data.

Skip List

Skip lists are composed of multiple lists that act as "layers", where higher level layers have less items than lower level layers, determined by probability of appearance/use. It is navigated starting at the top and checking adjacent values--if the desired value is not found, drop to the current element but on the next layer down and repeat. All actions on average take O(log(n)) time. All actions in the worst case take O(n) time. Takes O(nlog(n)) space.

Minimum Spanning Tree (Kruskal's Algorithm) Given a connected (no disjoint sections) and weighted (edges have values) graph, find a tree (section without cylces) that spans all nodes and has the least weight of any such tree.

Sort all edges by weight, then repeatedly select the cheapest edge, adding it to the MST along with its connected nodes. If the two nodes for the next edge are already in the MST then skip it. Do this until all nodes have been covered. Runs in O(|E|*log(|E|)) time.

Activity Selection Select the maximum number of activities that can be performed which do not clash with each other. You're given the time slots for each activity.

Sort the activities by finishing times, then greedily choose the activity with the earliest finishing time and repeat for the next non-conflicting activity.

Stack/Queue/Linked List

Stacks are FILO lists. Queues are FIFO lists. Linked Lists are lists that keep track of the head and tail, and each element/node has a value as well as a pointer to the next element/node (doubly linked lists also have a pointer to the previous node). The worst case is the average case for these data structures. Access in O(n) Search in O(n) Insert in O(1) Delete in O(1) Takes O(n) space.

Binary Search Tree (NOT Binary Tree)

Starting from the root, each element of a BST has 2 children, the left of which is less than or equal to its own value, and the right of which is greater than or equal to its own value. Each operation takes, on average, O(logn) time. Each operation takes, at worst, O(n) time.

Example of Difficult Bug

Stimulsoft: Downloaded file sometimes wouldn't include all pages. Found the problem by scripting tests and distributing them to my colleagues and analyzing the differences and similarities between people that encountered the problem. Problem was because of differences in the HTML5 and Flash versions of the web designer, and would occur based on the user's browser settings.

SVN

Subversion: Software versioning and revision control system.

SVN add

Tell the server about files or directories you've created.

Bipartite Matching (Ford-Fulkerson Algorithm) A bipartite graph is one in which all nodes either only have outgoing edges or only have incoming edges. The goal of bipartite matching is to match nodes such that no two edges have the same endpoint.

The Ford-Fulkerson Algorithm finds the maximum flow in a flow network by setting the initial flow of all edges to 0, then, for each node, if there exists a path from that node to the sink wherein all edges have unused capacity, increase the flow through that path by 1 if possible (can't increment flow if not enough is provided to the first node in the path; use DFS to find these paths). In an undirected graph you should not only increment the edges (u, v), but also decrement the edges (v, u) to prevent loops. The max flow is the flow going into the sink once all paths are maximized this way. To solve this problem, create a source connecting to all nodes with outgoing edges, and a sink connecting to all nodes with incoming edges, and assign a capacity of 1 to each edge, then run the Ford-Fulkerson algorithm on the new graph. Runs in O(|E|*f) time (f is max flow) with O(|E|) space.

Lazy Binding/Lazy Loading/Late Binding/Late Loading

The program waits until it needs a resource to load it, as opposed to doing it at the start. It is often implemented by initializing a variable to null and only assigning it a value when someone tries to access it (via a getter method).

HTTP

The protocol that allows for sending documents back and forth on the web. HTTP messages contain a header and body with metadata, methods, and content.

Candidate Key

The records for a candidate key are unique within the table.

URLs

The way to identify the things you want to operate on. Each URL identifies a resource.

Arrays

The worst case is the average case for arrays. Access in O(1) Search in O(n) Insert in O(n) Delete in O(n) Takes O(n) space.

Git push

This actually pushes your most recent commit to the server/repository.

What is the purpose of Web Services

To accept specially-formatted requests from other entities and produce an application-specific response.

UML

Unified Modeling Language

Product of Square Matrices (Strassen Algorithm) Find the product of two NxN matrices

Use a divide & conquer approach: Divide the square matrices into 4 parts each (if any of the divisions aren't square matrices, just add rows/columns of 0 until it is). Since it is easier to take the product of two 2x2 matrices, you can break it down into equations, and solve those (which may require recursively breaking down your new square matrix chunks!). Runs in O(n^log2(7)) time, where n = 2^N

Primary Key

Used as an identity column for the table (which implies it is a candidate key).

Final Variables

Variables labelled Final cannot be changed.

Example of Learning on the Job

VeraCore Mobile Dashboard: Learned a lot about SQL/databases, SVN, Agile Development, working in a team, Mobile Application Development, and RESTful services.

WSDL

Web Services Description Language: An XML format for describing all the information needed to invoke and communicate with a web service (who, what, where, why, how). <types> (data types), <message> (methods), <port type> (interfaces), <binding> (encoding scheme), <port> (URL), <service> (group of URLs)

Delegation

When a method essentially just redirects to a different method (often a different class's method) that will do the same thing (it is for code re-use purposes).

Hash Table

[Hash Table definition is covered on another card] On average, each operation takes O(1) time. In the worst case, each operation takes O(n) time. Takes O(n) space. Note: hash tables don't have access-by-location.

XML -Elements -Attributes -Processing Instructions -URIs

eXtensible Markup Language: A language which formats requests sent over the web. The goal is to separate syntax from semantics. Elements: Pairings of a start tag and end tag. Attributes: Name-Value pairs that are part of starting tags of elements. Processing Instructions: Special directives to the application that will process the XML document (specifies version, encoding scheme, etc.). URIs: Uniform Resource Identifies--A way to uniquely identify the meaning of an XML document. Allows distinguishing between meanings of similarly labeled XML docs from different domains where the labels might mean different things.

What is a Binary Tree?

A tree wherein each parent only has 2 children at most. e = i+1 e <= 2^h n = 2e - 1 where e = # external nodes, i = # internal nodes, n = # nodes, h = height.

What is a Trie?

A tree, but for strings. Can also be implemented as a directional graph, although that technically isn't a trie.

Longest Increasing Subsequence Given a sequence of numbers, find the length of the longest increasing subsequence (it does not have to be contiguous or unique).

1. Define LIS[i] = length of the LIS if the sequence ends at position i (so LIS[0, 2, ..., i]). 2. The solution to the subproblem is the max of LIS[1] through LIS[n]. 3. Initialize LIS[0] = 1 (LIS of a 1-number sequence is 1) 4. Recursively do LIS[i] = 1 + max(LIS[j]), where j is in 1...i-1 and A[j] < A[i] (so as to be it is increasing). 5. The solution to the problem is the max value in LIS[0...n]. You can find the actual subsequence by retracing your steps. Start at the max in LIS[0...n] and get the value at that position in A, then find the highest value at max-1, and so on and so forth.

Dynamic Programming

1. Find the subproblem, S[i1, i2, i3, ..., im] = ? 2. Define the top-level solution, S[n1, n2, ..., nm] = ? (Dynamic Programming problems produce arrays/matrices in which the solution can be found.) 3. Initialize: S[0, ..., im] = ?, S[i0, ..., 0] = ? 4. Find recursions: S[i1, i2, i3, ..., im] = ?, in terms of S[j], where j is some value related to i. 5. Determine the solution in the resultant matrix.

Longest Common Subsequence Given two strings, find the length of the longest common subsequence between them.

1. LCS[i, j] = LCS of s1 ending at position i and s2 ending at position j. 2. LCS[n, m] = LCS of s1 and s2 3. LCS[i, 0] = LCS[0, j] = 0 for all i <= n, and j <= m 4. Iteratively or Recursively do: LCS[i, j] = max(LCS[i-1, j], LCS[i, j-1]) + (s1[i] == s2[j]) (so +1 if current position is a match) 5. Max value in the LCS matrix is the solution to the problem. You can find the actual subsequence by starting at the max value in LCS and finding its appropriate character in the strings, then working backwards through adjacent earlier LCS values, creating the string backwards that way until it is complete.

Algorithm Questions Process

1. Should I prioritize space or time complexity? Is there a requirement for either of these? 2. What type of data/what format of data is being supplied for the input? What does it represent? 3. Is it a lot of data? A small amount of data? Are there boundaries on the data? 4. Consider the info given carefully. Don't make assumptions, and ask for clarification if necessary. 5. Make sure to run test cases. What if input is... 0? a negative value? null? maximum value? minimum value? Don't forget to also test the generic/normal case. (Hard mode: What if the input is too big to fit in memory at once?)

Normal Forms: 1NF, 2NF, & 3NF

1NF: Table has no repeating records or relational values (only atomic values--no column can be derived from [an]other column[s]). 2NF: 1NF + any attribute (column) not part of a candidate key should depend on at least one candidate key. 3NF: 2NF + attributes of non-candidate keys depend on ALL candidate keys.

Final Classes

A Final class cannot be sub-classed/inherited.

What is a Splay Tree?

A binary tree where the tree is "splayed" after accessing a node. Splaying uses rotations to move a node to the root while maintaining ordering rules.

Interface

A class implementing an interface must use/implement all methods and members of the interface. Interfaces are not allowed to fully implement its methods. In many languages a class can only have one parent, but classes can always have multiple interfaces. Classes that implement an interface are said to be in a "HAS-A" relationship with the interface.

StringBuffer/StringBuilder

A class that acts as a string, except that it is mutable. StringBuffer is thread-safe, whereas StringBuilder is faster but not thread-safe.

Static Class

A class that cannot be instantiated. All its member variables and methods are also static. It also cannot be inherited

What is a Flow Network?

A directed graph where each edge has a capacity and each edge receives a flow (which cannot exceed the capacity of the edge). The amount of flow into a node must equal the amount of flow out of a node, unless it is a source (the source of the flow) or a sink (the destination of the flow).

Composite Key

A key created by combining two other keys.

Foreign Key

A key that is a primary key in another table.

ACID

A model that is often followed when dealing with relational database systems. Transactions should be Atomic, Consistent, Isolated, and Durable.

What is a Graph?

A pair of sets (V, E), where V is the vertices/nodes and E is the edges connecting those nodes. # Edges <= ((# Vertices)*(# Vertices - 1))/2 Directed graphs are graphs where edges are "one-way streets". Acyclic graphs are graphs with no cycles (there is no path that contains a way to return to a node that was already visited on that path).

Reflection

A program's ability to inspect itself and modify its structure or behavior at runtime.

Alternate Keys

A set of all non-primary candidate keys.

REST

A simple way to organize interactions between independent systems (an alternative to SOAP). Resources in RESTful models are always nouns (for example: "/clients/add" is not RESTful)

Inheritance

A subclass extends a parent class. The subclass is said to be in an "IS-A" relationship with the parent.

Transaction

A task that is run to completion such that the data being handled will remain sensible (basically any operation on a database table or database tables).

What is an AVL Tree?

A tree where the nodes are going left to right in ascending value, and the height of the tree is always as balanced as possible.

Dijkstra's Algorithm

Dijkstra's Algorithm finds the shortest path between two nodes in an undirected graph with no negative weight cycles (a negatively weighted edge cycle would mean the path could be infinitely small). Assign S (starting node) a distance of 0 and all other nodes a distance of +inf, and mark all non-S nodes as "unvisited". Now, starting at S, mark the distance of all adjacent "unvisited" nodes as dist(current) + dist(node) (only change the distance if it is less than the node's current distance). Repeat this process for each of those adjacent nodes, and mark them as "visited" once they are used as the root (this repetition can be done by enqueuing them like BFS, or following trails like DFS). Once all nodes have been assigned a difference, start from S and greedily choose the next adjacent node with the shortest distance. Once you get to the end node, you have found the shortest path. This takes O(|E|+|V|log|V|) time when implemented optimally.

Divide & Conquer

Divide the problem (often in half), and often repeatedly, until a base case is reached, then determine how to solve the simplest base case of the problem. Combine the base case solutions with each other, and recursively do that with each of the cases until the solution is compiled. Note: Time complexity for D&C algorithms are typically found using the Master Theorem.

Mergesort

Divide the unsorted list into n sublists containing 1 element each, then consider 2 of those lists and merge them together by order of value. Do this for each sublist, then recursively repeat it for the new sublists until they are all merged back into one sorted list. Both average and worst case scenarios take O(nlog(n)) time. It uses O(n) space.

SVN diff

Either generate patches to send to a mailing list, or view differences between two revisions.

GET

Get information. It's a "read-only" verb, although the client can do whatever they want with the data once they have acquired it (it just can't be changed on the host side of things). This is considered a "safe" verb, as it doesn't alter the resource itself.

OPTIONS

Gets information about the communication options for the resource specified.

Master Theorem

Given T(n) = aT(n/b) + f(n), where a = # subproblems, n/b = size of subproblems, and f(n) = time complexity of subproblems (minus the recurrence part): If f(n) = O(n^(logb(a) - e)) for e > 0, then T(n) = θ(n^(logb(a))) If f(n) = θ(n^(logb(a))) then T(n) = θ(n^(logb(a)) * log(n)) If f(n) = Ω(n^(logb(a) + e) for e > 0 AND af(n/b) <= cf(n) for any constant c then T(n) = θ(f(n))

Hashmaps vs Hashtables vs Hashsets

Hashmaps are key-value based and fast, but not thread-safe. Hashtables are key-value based and thread-safe. Hashsets just store hashed values without keys.

Horizontal vs Vertical Scaling

Horizontal = Adding nodes (computers) with which you can distribute the load. Vertical = Adding resources by unit (CPUs, RAM, more HDD space, etc.)

Overriding

Implementing a [non-abstract] parent class's method in a child class

JSON

JavaScript Object Notation: A way of formatting requests sent over the web (like XML) with objects.

Shortest Path (Bellman-Ford Algorithm)

Like Dijkstra's Algorithm, except that it keeps track of the predecessor of the nodes, and it repeats |V| - 1 times to ensure there are no negative weight loops. Runs in O(|V|*|E|) with O(|V|) space.

Generator

Like a list/iterable, but it can only be used once

Yield

Like return, but "saves state" of the function, so it may "yield" a different result each time. Can be used to create generators. Ex: def myGenerator(lst): for i in lst: yield i**2

What is a Map (Data Structure)?

Maps model a collection of key-value pairs. get(k) put(k, v) remove(k) Ex: Hashmaps are a type of map that uses an encrypted key

SVN update/up

Merge changes on server to your machine.

Abstract Methods

Methods that do not receive a full implementation (they are only declared). If a class has one then it must be an abstract class. Subclasses must implement any abstract methods of the parent class (unless it is also an abstract class).

Normalization

Minimizing redundancies in data by dividing large tables into smaller tables with fewer redundancies.

NoSQL

Not Only SQL, a non-relational alternative to SQL that follows a BASE model instead of ACID, and adheres to CAP Theorem/Brewster's Theorem. It is used for distributed systems because it lends itself to reliability, scalability, and performance in those settings.

Static Variables/Methods

Not dependent on instantiation (constant throughout instances of a class). Called with ClassName.StaticVariableName or ClassName.StaticMethod().

Asymptotic Runtime Orders (What's Fastest, What's Slowest, What's in Between?)

O(1) O(log(n)) O(n) O(nlog(n)) O(n^2) (polynomial time) O(2^n) O(n!)

Object Wrappers

Objects used for defining collections. For example, in Java, Integer is the object wrapper for int, and Character is the object wrapper for char. Example usage: Hashmap<Integer, Character>

Abstract Class

One which cannot be instantiated, but can be inherited. You cannot reference an abstract class except through its children.

SVN checkout/co

Pull an SVN tree from the server (usually done once per project or per part of a project).

Example of Challenging Problem

Restaurant Locator Project: There were bugs that appeared as a result of the limitations imposed on our usage of freely available APIs (Google Maps API), and we had to work around those limitations and determine a way to optimize the efficiency of our application without breaking the usage limitations.

CROSS JOIN

SELECT * FROM T1 CROSS JOIN T2 Returns the cross product of the two tables (each record in T1 is concatenated with each record in T2 and vice-versa).


Conjuntos de estudio relacionados

Intermediate Macroeconomics Test 2

View Set

Avancemos 1: Unit 2 Lesson 2 Vocabulary

View Set

Ch1: Network & Endpoint Security Intro.

View Set

management information systems chapter 6

View Set

Ch. 39 Activity & Exercise & Ch. 28 Immobility

View Set