Data structures and Algorithms Flashcards

1
Q

I know how to handle collisions in a hash table

A

Use a linked list to store multiple values using the same key

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

I know the difference between an array and linked list

A

An array is one object that contains elements

A linked list is a data structure consisting of objects often referred to as nodes that typically contain 2 properties, the value of the node and a next property that points to the next node in the linked list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

I know how to implement fibonacci with dynamic programming

A

Use memoization with the recursive solution to fibonacci

var fibonacci = (function () {
  var memo = [0, 1];
  var fib = function (n) {
      var result = memo[n];
      if (typeof result !== 'number') {
        result = fib(n - 1) + fib(n - 2);
        memo[n] = result;
      }
      return result;
    };
  return fib;
}());
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

I can reverse an array in place

A
function reverse (array) {
  var i = 0,
      n = array.length,
      middle = Math.floor(n / 2),
      temp = null;
  for (; i < middle; i += 1) {
     temp = array[i];
     array[i] = array[n - 1 - i];
     array[n - 1 - i] = temp;
  }
  return array
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

I know what a Set is used for

A

Set objects are collections of values. You can iterate through the elements of a set in insertion order. A value in the Set may only occur once; it is unique in the Set’s collection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

I know constant, linear, logarithmic, quadratic, exponential time complexity

A
  • constant: An algorithm is said to be constant time (also written as O(1) time) if the value of T(n) is bounded by a value that does not depend on the size of the input
  • linear: An algorithm is said to take linear time, or O(n) time, if its time complexity is O(n). Informally, this means that for large enough input sizes the running time increases linearly with the size of the input.
  • logarithmic: An O(log n) algorithm is considered highly efficient, as the ratio of the number of operations to the size of the input decreases and tends to zero when n increases.
  • quadratic: O(n2) repeating operations for n elements n times
  • exponential: O(c^n) where c is a constant.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly