Data Structures Flashcards

(43 cards)

1
Q

Tuple properties

A

Has elements of mixed types
It is immutable
Use round brackets () to indicate a tuple

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

Define dynamic

A

The number of elements can change

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

Define static

A

Number of elements cannot change

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

Define record

A

Composed of a fixed number of fields of different data types
Can be implemented as an object

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

Arrays (size, contents, data types)

A

Size: static
Contents: mutable
Data types: single

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

Tuple (size, contents, data types)

A

Size: static
Contents: immutable
Data types: mixed

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

Record (size, contents, data types)

A

Size: static
Contents: mutable
Data types: mixed

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

List (size, contents, data types)

A

Size: dynamic
Contents: mutable
Data types: mixed

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

Stacks properties

A

LIFO- last in first out
Single pointer (points to top of stack)

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

Pushing stack steps

A
  1. Check if stack is full
  2. If full -> report error, stop
  3. Increment the stack pointer
  4. Insert new data item into cell pointed to by the stack pointer
  5. Stop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Popping stack steps

A
  1. Check if stack is empty
  2. If empty -> report error, stop
  3. Copy data item from cell pointed to by the stack pointer
  4. Decrement the stack pointer
  5. Return the data
  6. Stop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Peeking stack steps

A
  1. Check if stack is empty
  2. If empty -> report error, stop
  3. Copy data item from cell pointed to by the stack pointer
  4. Return the data
  5. Stop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Enqueue steps

A
  1. Check if queue is full
  2. If full -> report error, stop
  3. Else increment rear pointer
  4. Insert new item at rear pointer
  5. Stop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Dequeue steps

A
  1. Check if queue is empty
  2. If empty -> report error, stop
  3. Else item = queue[head]
  4. Increment head pointer
  5. Return item
  6. Stop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Queue properties

A

FIFO- first in first out
Two pointers- head and tail pointer
Abstract data type

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

Peeking queue steps

A
  1. Check if queue is empty
  2. If empty -> report empty, stop
  3. Else
  4. Copy data item from cell pointed to by the head pointer
  5. Return the data item
  6. Stop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What does isEmpty() do?

A

Test for empty list

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

What does append(item) do?

A

Adds a new item to the end of a list

19
Q

What does remove(item) do?

A

Remove first occurrence of an item from the list

20
Q

What does count(item) do?

A

Return the number of occurrences in the list

21
Q

What does len() do

A

Returns the number of items in the list

22
Q

What does index(item) do

A

Return the position of the item

23
Q

What does insert(pos,item) do

A

Add a new item at position pos

24
Q

What does pop() do

A

Remove and return the last item in the list

25
What does pos(pos) do
Remove and return the item at position pos
26
Define linked list
Dynamic abstract data structure which can be implemented as an array and pointers Composed of nodes
27
A node is composed of two parts: (linked list)
The data (may be complex data structure) A pointer to the next node
28
Linked list pointers
A start pointer identifies the first node in the list A next free pointer shows the index of the next free space in the array
29
What is a graph
An abstract data structure used to represent complex relationships Made up of nodes and edges
30
Define undirected graph
No arrows on the edges that indicate direction
31
Define graph
A set of vertices or nodes connected by edges or arcs
32
Define edges
May be weighted, indicating a cost of traversal
33
Define undirected graph
All edges are bidirectional
34
Define directed graph (bigraph)
All edges are one way
35
Define adjacency matrix
Each row and column represents a connection
36
Adjacency matrix connection
The item at [row, column] indicates a connection In unweighted
37
Adjacency matrix pros
Convenient to work with, and adding edges is simple
38
Adjacency matrix cons
A sparse graph with not many edges will leave most of the cells empty, wasting a lot of memory space
39
Adjacency list pros
Only uses storage for the connections that exist, so it is more space- efficient A good way of representing a large, sparsely graph
40
Graph applications include
Computer networks, with nodes representing computers and weighted edges representing bandwidth between them Page rank algorithm States in a finite state machine Social networks Web pages and links Chemistry, with nodes as atoms, edges as connections Project management, with nodes as tasks, edges representing sequence and weights, time or cost Maps, with nodes representing cities or landmarks, edges representing routes
41
How can a weighted graph be represented
As a dictionary of dictionaries Each key in the dictionary being the node, and the value, a dictionary of adjacent edges and edge weights
42
Define binary tree
A tree in which each node has a maximum of two children
43