Definitions
Java
Python
Big O
Data Structures
100

What is an algorithm

a finite sequence of rigorous instructions, typically used to solve a class of specific problems or to perform a computation.

100

what does i++ do?

increments variable i by 1

100

what does this print?

print(75<<1)

150

100

What is the time complexity of this code? 

for i in range(N):

a = a + 1


O(n)

100

What can be stored in a variable?

Addresses to objects in memory and primitive data types.

200

What is binary code

a mathematical language that uses 0's or 1's

200

what is wrong with this code?

for (int i ; arr);

element based for-loops use a colon, not a semicolon

200

what does __repr__() do in a class?

it changes how the objects of the class are represented as strings, when printed.

200

Provide an example of O(n logn) algorithm

mergesort, heapsort, quicksort (in best case)

200

Where are objects stored in Java?

The heap.

300

What is type casting

Converting a variable's data type from one type to another.

300

What will this code output?

int a = 5;

char b = '5';

System.out.println(a + b);

5 + ASCII value of char '5' = 58 

will print 58

300

what does this produce?

majors = ['cs', 'math', 'english', 'psych'] majors[::-2]

['psych', 'math']

300

What is the worst case runtime for selection sort

O(n2)

300

What is a linked list, and what advantages does using a linked list have over an array?

A linked list stores a sequence of items in separate nodes. Each node in the list contains the address to the next node in the linked list. Each address is also stored in a separate address. A linked list allows for easier and more efficient insertion and deletion at any point.

400

What is polymorphism?

a variable that holds a reference to an object from a different data type as the variable itself.

400

Classes G and H both have methods called method1(). Which version of method1() will be called? 

G g = new H();

g.method1();

The method1() defined in class H.

400

What does this code produce?

list = []

list += 2*x for x in range(6) if x % 2 == 0

[0, 4, 8]

400

What is more efficient: 

O(2n) or O(n logn)

O(n logn)

400

Difference between Stack and Queue

STACK IS FILO; QUEUE IS FIFO

500

What is Agile software development

Agile software development refers to a group of software development methodologies based on iterative development, where requirements and solutions evolve through collaboration between self-organizing cross-functional teams.

500

How many total stack frames will be made for fib(4)? 

public static int fib(int i) { int lim = 2; if( i < lim ) return 1; else return fib(i-1) + fib(i-2); }

8 calls

500

What does this code print?

table = [[15, 3, 6, 8, 2], [6, 12, 3, 7, 8], [12, 65, 3, 7, 7]]

table[-1][-2] = 0

print(table[-1])

[12, 65, 3, 0, 7]

500

What is the time complexity of statement 2: 

public static int mystery(int n) {
        int x = 0
        for (int i = 0; i < n; i++) {
            x += i;        
            for (int j = 0; j < i; j++) {
                x += j;    // statement 2
            }
        }
        return x;
    }

O(n2)

500

What is a 2-3 Tree's worst case for searching

O(logn)