1.4.2 - data structures Flashcards

7

1
Q

one dimensional array

A

A finite, ordered set of elements of the same type stored in contiguous memory.

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

Does row or column come first in 2D array?

A

row

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

tuple

A

An immutable, ordered set of values of any data type.

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

immutable

A

Its elements cannot be changed and you cannot dynamically add or delete elements from a tuple.

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

record

A

Contains a number of fields, each holding one item of data.

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

list

A

A contiguously stored data structure consisting of a number of ​ordered ​items where the items can occur more than once​.

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

list.isEmpty()

A

Test for an empty list.

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

list.append(item)

A

Adds item to the end of a list.

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

remove(item)

A

Removes the first occurrence of an item from a list.

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

search(item)

A

Return whether an item exits in a list or not.

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

list.length()

A

Returns number of items in a list.

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

list.index(item)

A

Returns the position of item.

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

list.insert(position, item)

A

Insert a new item at position.

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

list.pop()

A

Remove and return the last item in the list.

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

list.pop(position)

A

Remove and return the item at position.

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

linked list

A

A dynamic data structure used to hold an ordered sequence not necessarily in contiguous data locations.

17
Q

What is each item in a linked list called?

A

a node

18
Q

2 parts of a node and their explanation

A
  • data field: actual item
  • pointer field: contains address of next item in sequence.
19
Q

null pointer in a linked list

A

Used to identify the last item of data.

20
Q

List 4 operations that can be carried out on queues.

A

1- enQueue()
2- deQueue()
3- isEmpty()
4- isFull()

21
Q

3 uses of queues

A
  • storing print jobs until the printer is ready to print
  • CPU scheduling
  • breadth first traversal of a graph
22
Q

linear queues

A

When an item of data is removed from the front, all the other items move up one place. This is only suitable in a small queue, otherwise data processing time can be excessive.

23
Q

circular queues

A

When an item of data is removed from the front, the two pointers have to be updated to identify the new front and rear of the queue.

24
Q

2 uses of graphs

A
  • locations on a map
  • products on an e-commerce website
25
Q

2 uses of hash tables

A
  • customer records
  • password verification
26
Q

hash table

A

A data structure that is used for very large collections of data or where quick access to data is required.

27
Q

2 approaches to dealing with collisions in a hash table

A

1- A rehashing algorithm is used to determine the next empty slot in which to store the data.
2- We can create a separate data structure such as a linked list from each storage location and store the collisions there.

28
Q

2 uses of stacks

A

1- To reverse the order of a set of data.
2- Used by processors to handle interrupts.