AS SSD Data Structures Flashcards
(28 cards)
How would you store multiple pieces of data in one place?
We must use a data structure such as a list or an array.
What must you do when you are declaring an array?
You must give it a name as well as specify the type of data the array is going to store.
What is an array considered to be?
It is considered as being fixed length.
What does it mean when an array is considered as being fixed length?
This means that when an array is declared, you must set space required for all expected data types.
What is another word that could replace fixed length in relation to arrays?
It could also be referred to as static.
How would you store more data in an array?
You would have to make another array.
How can items be accessed in an array?
Items in an array can be accessed by using the index of the array.
At what number do index numbers start counting?
They start counting at 0.
What is the most common type of multi-dimensional array called?
It is called a 2D array. It is essentially an array of arrays.
What does a 2D array consist of?
it consists of rows and columns. This means that a number of rows and columns have to be specified.
How would you add data to a 2D array?
When adding data to this type of array, you must specify the row and column in which you want to store the data.
How would you access items within a 2D array?
Data is accessed in a 2D array using the same index position notation as when data is added to the array.
How is a list similar to an array?
It is similar to an array in that it stores data of the same type.
How does a list differ from an array?
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.
What do you need to specify when creating a list?
You need to specify the type of list which is being created.
When can you add or remove data from a list?
You can either remove or add data to a list before or after it has been created.
How would you access items in a list?
To access items in a list, you must use the index position of the item being used.
How would you loop through every item in a list?
Use a for-each loop.
What are the two different types of sorting algorithms used with a list or an array?
Insertion sort and Bubble sort.
How does an insertions sort work?
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.
How does a Bubble sort work?
A bubble sort algorithm is different in that the largest values “bubble up’ the list to get to the top.
What rules does the Bubble sort algorithm follow?
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.
What are the two algorithms called that are used to search through lists and arrays?
Binary and Linear search.
What must happen before the binary search can start?
The list or array must be sorted already.