Data Structures Flashcards

1
Q

Variables are stored in _______________?

A

RAM (Random Access Memory)

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

_________ is connected to a memory controller and it does all the real work inside our computer.

A

Processor

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

The ____________ does the actual reading and writing to and from RAM. It has a direct connection to each shelf of RAM.

A

Memory controller

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

The processor has a ______ where it stores a copy of stuff it’s recently read from RAM.

A

Cache. This cache is much faster to read from than RAM, so the processor saves time whenever it can read something from cache instead of going out to RAM

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

What happens when the processor asks for the contents of a given memory address?

A

Memory controller also sends the contents of a handful of nearby memory addresses. And the processor puts all of it in the cache.

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

For a 64-bit integer, how much space is taken by 0 and 32,000.

A

It does not matter, both take up the same space in RAM i.e 64 bits.

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

Time complexity of addition, subtraction, multiplication, and division of fixed-width integers

A

O(1)

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

One +ve and -ve of using Arrays

A

+ve: Fast lookup of O(1)

-ve: Big block of uninterrupted free memory is require to store the array.

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

How to store different strings of different lengths to an array?

A

Using pointers to store the starting address of each string in the array.

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

What is one negative of using pointers to store addresses in an array?

A

It is not cache-friendly.

This slowdown isn’t reflected in the big O time cost. Lookups in this pointer-based array are still O(1) time.

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

Worst case of adding in dynamic arrays.

A

O(n). The amortized (avg) time is O(1)

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

For prepend, which one is better - Linked list or Dynamic arrays?

A

Linked List since it takes O(1) time, whereas Dynamic arrays has to shift each character, which leads to O(n)

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

Time to lookup in Linked List

A

O(i)

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

Which one is better for lookup and Why? Linked List or Dynamic Arrays

A

Dynamic Arrays because it is O(1) and it is cache-friendly

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

What is logarithmic asking?

A

What power must we raise this base to, in order to get this answer?

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