Week 5 Flashcards

1
Q

What are the two types of file systems?

A

Contiguous and Fragmented.

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

What is the difference between parallel and concurrent execution?

A

In parallel, one core handles one task.

In concurrent, the cores will switch between the tasks.

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

What are lists classified as?

A

A list is classfied as a linear data structure.

May be one dimenionsal or multidimensional.

Could be ordered or not.

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

What can an element of a list consist of?

A

A single data item or a record or object (compound data)

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

True for false, a list is an abstract data type.

A

This is true.

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

What are some ways that lists may be implemented?

A

It can be implemented in arrays or linked lists, or it can be done in RAM or secondary storage.

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

True or false, are arrays physically ordered lists?

A

Yes, arrays are also called physically ordered lists.

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

What is the definition of an array?

A

They are linear random access data structures whose elements are accessed by unique identifiers called an index or subscript.

Elements are stored contiguously in RAM or in secondary storage.

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

In languages like C, C++ and Java where does the index start at?

A

It starts at 0.

languages like Pascal and FORTRAN are more flexible.

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

In compiled languages, arrays have a fixed…

A

Set at compile time for compiled languages. Some languages enforce this, but some languages are more flexible.

Note that typically the compiler actually adds slightly more memory just in case small changes are needed to be made inplace.

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

What is the difference between size and capacity?

A

Size is the amount of elements in the array.

The capacity is slighty bigger than the size so changes can be easily made.

If capacity wasn’t slightly bigger it would need to move. We reduce the chances of this operation since this change can be costly.

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

What is a dynamic array?

A

In interpreted languages like python and javascript arrays are dynamic.

We can add elements beyond the end of the array. The interpreter resizes the array and reallocates if neeeded.

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

What do we need to keep in mind if we are inserting a value in the middle.

A

If you have enough space, you can simply shift everything.

If you don’t have enough space, you need to reallocate it to another space in memory.

Inserting an array in the middle can be quite expensive.

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

What is the worst case scenario for inserting in an array.

A

O(n) is the worst case (Inserting at position 0)

The best case is constant.

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

What is the worst case complexity for deletion.

A

The worst case for deletion is O(n).

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

What is a grow factor? What is python’s grow factor?

A

A grow factor is 1.125.

A grow factor is when an array allocates more memory than needed so that it can quickly use it. For example growing an array.

The tradeoff between performance and memory efficiency.

17
Q

What are the advantages and disadvantages of arrays?

A

Advantages are they are simple to use. Retrievals and replacements are quick if the index is known O(1).

Disadvantages are adding and removing elements are awkward. Dynamic sized arrays require copying. Fixed size arrays either limits the size of the list or wastes space.

18
Q

How are arrays stored in memory?

A

Arrays are stored contiguously in memory. This means one after the other.

19
Q

What is the definition of a linked list?

A

A linear data structure that consists of zero or more nodes where each node contains data and a pointer to the next node.

20
Q

What is the advantages and disadvantages to linked lists?

A

They are easily resizable, they are non-contiguous.

But they are no longer indexable. You need to start from the beginning.

21
Q

What does a node consist of?

A

The data and a reference to a node type.

22
Q

Is it possible to have private members in python?

A

No. Data members cannot be private in python.

We use the notation of a _ to indicate if they are supposed to be private.

23
Q

What are some of the types of linked lists?

A

Singly Linked List: Unidirectional.

Doubly Linked List: Bidirectional

Circular Linked List: Unidirectional closed loop.

Circular Doubly Linked List: Bidirectional closed loop.

24
Q

What is the wost case for inserting in an array?

A

The worst case for inserting in an array is at position 0, since all the other values need to move as well.

25
Q

What is the worst case for inserting in a linked list?

A

The worst case for inserting in a linked list is at the end.

26
Q

When traversing a linked list what do we have to make sure we do?

A

Make sure you have a temporary variable.

27
Q

What does the garbage collector do in python?

A

The garbage collector will collect anything that is no longer referred to.

28
Q

Is it possible to delete from an empty list?

A

No, this will cause issues.

29
Q

What is the complexity for insertion and deletion in a linked list once the position is known?

A

The complexity is O(1).

30
Q

What is the complexity in a linked list in the average and worst case.

A

The complexity is O(n).

31
Q

In a linked list, what is the complexity for adding a head or tail pointer?

A

The complexity os O(1).

32
Q

What is the complexity for getting an entry at position other than the head.

A

O(n).