Coding Interviews Flashcards

1
Q

Problem-Solving Steps (CtCI)

A
  1. Listen
  2. Example
  3. Brute Forceq
  4. Optimize (BUD)
  5. Walk Through
  6. Implement
  7. Test
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Data structures to consider

A
  • Linked List
  • Trees, Tries, and Graphs
  • Stacks
  • Queues
  • Heaps
  • Hash Tables
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Algorithms to consider

A
  • Breadth-first search
  • Depth-first search
  • Binary search
  • Merge sort / quick sort
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Linked List

A

a structure of nodes that contain a data value and a pointer to the next node

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

Stack

A

a list with last in, first out (LIFO) ordering

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

Queue

A

a list with first in, first out (FIFO) ordering

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

Graph

A

a set of nodes (vertices) and edges linking 2 vertices

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

Trees

A

a hierarchical and acyclic graph

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

Balanced tree

A

A tree where for each node, the difference between the height of the left and right subtree is <= 1

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

Binary tree

A

A tree where each node has 0-2 children

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

Binary search tree

A

A (balanced) binary tree where for each node, the value of all nodes in the left sub-tree is less than the value of the parent node, and all nodes in the right sub-tree are greater than the parent node

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

Trie (prefix tree)

A

Combination of nodes where each node represents a unique letter. Good for forming dictionaries of words, etc.

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

Heap

A

Complete binary tree where all parent nodes are greater than or equal to their child nodes

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

Hash Table

A

Structure that maps keys to values via a hashing function

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

Pre-order traversal (Tree)

A

visit root, then left, then right

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

In-order traversal (Tree)

A

Visit left, then root, then right

17
Q

Post-order Traversal (Tree)

A

Visit left, then right, then root

18
Q

Greedy algorithm

A

Build a solution piece by piece by choosing the optimal solution for each piece