Data Structures - Arrays, Lists, Python Lists Flashcards

1
Q

What is an array?

A

An array is considered a static data structure that can store a fixed number of elements that are stored in coninunuous memory locations and of a specific data type.

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

What is a one dimensional array?

A

It is the most fundamental form of an array where its elements are stored linearly and the individual elements can be accessed by referring to the indices of an array.

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

How do you declare a 1-D array of size 5 in pseudocode?

A

DECLARE arrayName: ARRAY[1:5] of INTEGER

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

What is [1, 2] + [3, 4]?

A

[1, 2, 3, 4]

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

grades = [‘A’, ‘B’, ‘C’, ‘D’, ‘E’]

what is grades[0] ?

A

A

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

grades = [‘A’, ‘B’, ‘C’, ‘D’, ‘E’]

what is grades[2:4] ?

A

[‘C’, ‘D’]

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

What is the application of an array?

A

It stores a fixed number of elements that are stored in continuous memory locations.

The number of elements and type of data it can store are determined at declaration, and cannot be changed thereafter.

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

What are the pros of arrays?

A
  • In an array, accessing an element is very easy by using the index number
  • Efficient Memory Usage
  • Flexibility in Data Types
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the cons of arrays?

A
  • Wastage of Memory
  • Difficulty in Inserting and Deleting Elements
  • Inefficient for Search
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When using pseudocode involving arrays, how do you add items to the list?

A

ar[i] ← <item></item>

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

How to initialise elements to 1-D arrays?

A

DECLARE ar: ARRAY[1:10] of INTEGER

FOR i = 1 to 10
ar[i] ← -10

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

How to declare a 2-D array?

A

e.g.

DECLARE alphabets: ARRAY[1:5][1:8] OF STRINGS

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

What is a two dimensional array?

A

An array is considered a static data structure that can store a fixed number of elements that are stored in coninunuous memory locations and of a specific data type.

A two dimensional array can hold more than one set of data. It can be thought of as a table with columns and rows.

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