Overview Flashcards

1
Q

What is a data structure

A

Data structures are a way to store data in an efficient manner inside the Random Access Memory, called “RAM”

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

What is an array

A

An array is a collection of ordered, contiguous (next to each other in memory) group of elements

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

What is a byte

A

8 bits

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

What is RAM measured in

A

Bytes

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

What is a bit

A

A position that can store a 0 or 1

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

Integer size

A

4 bytes

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

What are the two components of RAM that are stored

A

Value and Address

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

Char size

A

1 byte (typically if they are ASCII characters)

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

Array sizing

A

Since arrays are contiguous and of fixed size and we don’t know if spots in RAM are open or not, we can’t always just add to the initial array. And we can’t have one array be split amongst the RAM. Order of the values matters as well. Biggest limitation of static arrays. Python and stuff have dynamic arrays as default.

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

Dynamic array sizing

A

A new array will get created (typically twice the size of the first) for more space

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

What can be used to implement a stack?

A

A dynamic array
Python: myArr = [] # default dynamic array
C++: vector<int> myArr</int>

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

What’s a good way to think about a stack?

A

Instead of horizontal, think of it as vertical. So when we say we’re pushing on to the top of the stack it means we are throwing a value to the “top” or “end” and it will land at the next available spot. We don’t have to worry about the space since it’s dynamic array. When we pop we can only do it from the “end” or “top” of the array.

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

What is the difference between linked lists and arrays in memory?

A

Arrays are stored contiguously in memory. Linked lists have no order to them in memory, but the addresses are “linked” together. They can be in some random order but connected via pointers.

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

What are Queues?

A

FIFO, first in first out
For example, print jobs. If multiple people are trying to print documents, it will be handled on a first come first serve basis.

It is an abstract interface, similar to a stack and can be implemented by multiple data structures, provided that they fulfill the contract of implementing enqueue and dequeue operations.

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

What is the most common implementation of a queue?

A

Using a linked list

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

What are the operations of a queue?

A

Enqueue and dequeue:
Enqueue adds elements to the tail (end) of the queue, which runs in O(1) time.

Dequeue removes elements from the head (front) of the queue, which can be O(1) (or O(n) if implemented using an array)

17
Q

What is a deque (pronounced “deck”)

A

Double-ended queue. Allows you to add and remove elements from both the head and the tail.

18
Q

What is one of the more important use cases of queues?

A

Performing breadth-first search for trees and graphs

19
Q

What is the best way to represent recursion?

A

Using a decision tree (one-branch or more)

20
Q
A