AS SSD Data Structures Flashcards

(28 cards)

1
Q

How would you store multiple pieces of data in one place?

A

We must use a data structure such as a list or an array.

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

What must you do when you are declaring an array?

A

You must give it a name as well as specify the type of data the array is going to store.

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

What is an array considered to be?

A

It is considered as being fixed length.

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

What does it mean when an array is considered as being fixed length?

A

This means that when an array is declared, you must set space required for all expected data types.

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

What is another word that could replace fixed length in relation to arrays?

A

It could also be referred to as static.

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

How would you store more data in an array?

A

You would have to make another array.

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

How can items be accessed in an array?

A

Items in an array can be accessed by using the index of the array.

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

At what number do index numbers start counting?

A

They start counting at 0.

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

What is the most common type of multi-dimensional array called?

A

It is called a 2D array. It is essentially an array of arrays.

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

What does a 2D array consist of?

A

it consists of rows and columns. This means that a number of rows and columns have to be specified.

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

How would you add data to a 2D array?

A

When adding data to this type of array, you must specify the row and column in which you want to store the data.

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

How would you access items within a 2D array?

A

Data is accessed in a 2D array using the same index position notation as when data is added to the array.

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

How is a list similar to an array?

A

It is similar to an array in that it stores data of the same type.

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

How does a list differ from an array?

A

A list differs from an array as it is considered as being dynamic. This means that the size of the list can change after it has been created and populated.

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

What do you need to specify when creating a list?

A

You need to specify the type of list which is being created.

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

When can you add or remove data from a list?

A

You can either remove or add data to a list before or after it has been created.

17
Q

How would you access items in a list?

A

To access items in a list, you must use the index position of the item being used.

18
Q

How would you loop through every item in a list?

A

Use a for-each loop.

19
Q

What are the two different types of sorting algorithms used with a list or an array?

A

Insertion sort and Bubble sort.

20
Q

How does an insertions sort work?

A

An insertion sort will compare each value in turn, starting with the second value in the list. If the value is greater than the value to the left of it, then no values will change positions. Otherwise, if the value is smaller than the value to the left of it. Otherwise, if the value is smaller than the value to the left of it, then it will move one position to the right of it.

21
Q

How does a Bubble sort work?

A

A bubble sort algorithm is different in that the largest values “bubble up’ the list to get to the top.

22
Q

What rules does the Bubble sort algorithm follow?

A

It looks at the first number in the list and compares the current number with the next number. If the next number is smaller than the current number the two numbers swap around. If not then they don’t. Move to the second number in the list and make this the current number and compare it with the next number and check to see if it is smaller than the current number. After you have reached the end of the list, if any numbers were swapped, repeat all steps again.

23
Q

What are the two algorithms called that are used to search through lists and arrays?

A

Binary and Linear search.

24
Q

What must happen before the binary search can start?

A

The list or array must be sorted already.

25
How does a binary search work?
A binary search operates by finding the midpoint of a list and checking it against the value to be searched for. If the search value is larger than the midpoint, then everything to the left of the midpoint is discarded. If the search value is smaller than the midpoint, then everything to the right of the midpoint is discarded.
26
What happens if the list contains an even number of items?
Instead you would chose the value either to the left or right of the calculated midpoint. If there is no midpoint in the next search then the direction is chosen consistently to ensure that the search narrows down effectively.
27
How does a linear search work?
First the search term must be identified and look at the first item in the list. If the current item is the same as the search term then the item has been found. If not then move onto the next item. Repeat until the last item in the list has been reached. It the search term has not been found then the search term is not in the list.
28
What is an icomparable function?
It is a way to sort data in a list based on a specific criteria.