Read the following SQL Statement and answer the questions below: SELECT * FROM a NATURAL JOIN b WHERE c < 2 1) What is a in the context of this problem? 2) What is b in the context of this problem? 3) What is c in the context of this problem? 4) explain what the result of "a NATURAL JOIN b" will be?
1) a is a table 2) b is a table 3) c is an attribute within the table a NATURAL JOIN b 4) "a NATURAL JOIN b" will result in a new temporary table that will be the cross product of a and b, but only rows where the common attributes between a and b hold the same values will be retained in the new table.
Explain the difference between the back-end implementation of a LinkedList and an ArrayList. Walk through a get(int i) method call to both an ArrayList and a LinkedList
An ArrayList is implemented using an array as the backing data structure. The methods in the ArrayList class dynamically create new arrays (either smaller or larger based on the needs of the arrayList). A LinkedList however does not have a backing array, instead, a linked list is composed of a series of nodes. Each node contains contains a piece of data being stored, and a reference to the next Node in the list. For a get(int i) call in an ArrayList, it is as simply as returning the data stored in the ith index of the backing array. For a LinkedList, we must traverse down the nodes until we reach the ith node, from there we would return the data contained in that node
What does the run-time complexity (Big O) of an algorithm mean?
The run-time complexity of an algorithm refers to the time that that algorithm will take to run on a data set of size, n, in the worst case scenario.. For clarity's sake, let's say that every computer operation takes 1 ms to perform, and let us say that we have a data set that only has 10 numbers in it (n = 10). If we execute an algorithm with a linear run-time complexity( O(n) ) on our data set, we know that worst case, it will take 10 ms to finish, because we have 10 items and a linear run-time complexity. Now let's say that we have another algorithm that has a quadratic run-time complexity ( O(n^2) ). In the worst case scenario, it will take 100 ms to run, because there are 10 items (n = 10) and we have a Big O that is O(n^2). Another example of a run-time complexity is O(1), otherwise known as a constant run-time complexity. When an algorithm has a constant run-time complexity, that means that the time it takes for an algorithm to run will be the same, regardless of how large our data set is.