# Chapter 7 Flashcards

What is an array?

An array is defined as a finite, ordered set of elements of the same type, such as an integer, real or char.

How to write an array?

my Array = [51, 72, 35, 37, 0, 100]

X = myArray [2]

2D array?

A two dimensional array can be visualised as a table rather than a spreadsheet.

Records

A record is more commonly referred to as a row in a file and is made up of fields. Records are used in databases.

Lists

A list is a data structure consisting of a number of ordered items where the items can occur more than once. Lists are similar to 1D arrays and elements can be accessed in the same way. The difference is that list values are stored non-contiguously. This means they do not have to be stored next to each other in memory, as data in arrays is stored. Lists can also contain elements of more than one data type, unlike arrays.

Empty

List.isEmpty()

» False

Add

List.append(15)

Remove

List.remove(23)

»

Search

List.search(38)

» False

Length

List.length()

» 7

Index

List.index(23)

» 0

Returns the position of the item

Insert

insert(position, value)

Pop

pop()

pop(position)

Returns and removes the last value in the list

Tuples

An ordered set of values of any type is called a tuple. A tuple is immutable, which means it cannot be changed: elements cannot be added or removed once it has been created. Tuples are initialised using regular brackets instead of square brackets.

Linked Lists

A linked list is a dynamic data structure used to hold an ordered sequence. The items which form the sequence do not have to be in contiguous data locations. Each item is called a node, and contains a data field alongside another address called a link or pointer field

Graphs

A graph is a set of vertices/nodes connected by edges/arcs. Graphs can be placed into the following categories:

- Directed Graph: The edges can only be traversed in one direction.

- Undirected Graph: The edges can be traversed in both directions.

- Weighted Graph: A cost is attached to each edge.