4.2 Types of Data Structures Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is a composite data type?

A

A data type that can group together multiple values of different types under a single name.

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

What are the two composite data types?

A

String, Array

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

What are abstract data types?

A

A logical description of how we view the data and possible operations.

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

3 Abstract data types

A

List, stack, queue

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

What are elementary data types

A

basic building blocks for representing data and used to define variables and specify the kind of values they can store

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

3 Elementary data types

A

Integer, real, boolean, char

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

Do arrays exist in python?

A

No, have to be imported by a library

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

Key differences between arrays and lists

A

Arrays: defined size, data is stored contiguously in memory
Lists: list is free to grow, values are stored in various locations in memory

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

What are Contiguos elements?

A

contiguous elements are positioned in a continuous, uninterrupted sequence

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

What type of data structure is a queue

A

FIFO (first in first out)

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

Functions needed for a linear queue

A

Add item to the rear of the queue

Remove item from the front of the queue

Check if the queue is empty

Check if the queue is full

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

What is enqueue and how is it acheived

A

Adding items to a queue
Check that queue is not full
Add to the value of the rear pointer
Then add the new item to the position indicated by the rear pointer.

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

What is dequeing and how is it achieved

A

Removing an item
Return value at the front of the queue and deleter or pop
Move remaining items up the queue one by one
Decrement the rear pointer.

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

Difference between circular and linear queues

A

Circular queues do not move items up when an item is dequeued.

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

What is different with the items in a priority queue

A

All items have a level of priority

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

What are static data structures and what is a example

A

Static data structures are fixed in size
Cannot grow, shrink, or be freed during execution
Array

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

What are abstract data structures

A

can grow or shrink.
Allocates and deallocates memory from the heap

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

What problem may come with abstract data structures

A

may cause overflow(exceeding maximum memory limit).

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

What is a stack

A

A stack is a last in, first out abstract data type

20
Q

What is a matrix

A

An array of tables or values

21
Q

What are the six methods required in a stack

A

push(item) - adds item to the top of the stack.

pop() - removes and returns the item on top of the stack.

isFull() - checks if the stack is full

isEmpty() - checks if the stack is empty

peek() - returns the top item without removing it from the stack.

size() - return the number of items on the stack.

22
Q

What is stack overflow

A

attempting to push an item onto a stack that is full

23
Q

what is stack underflow

A

attempting to pop from a stack that is empty

24
Q

What is the call stack

A

data structure that provides the mechanism for passing parameters and return addresses to subroutines.

25
Q

What is a stack frame

A

A stack frame contains all the parameters, the return address and the local variables for a single call to a subroutine which has not yet completed.

26
Q

What is a dictionary

A

A dictionary is an abstract data type made up of associated pairs each pair has a key and a value.

27
Q

Why are hash tables used

A

a hash table will find any record in a dataset almost instantly, no matter how large the data set.

28
Q

What is a hash table

A

a data structure that creates a mapping between the keys and values.

29
Q

What causes a collision in a hash table

A

when an algorithm generates the same address for different primary keys.

30
Q

What is the fix for a collision in hash tables

A

linear probing happens, this is where the item is put in the next free slot in the table.

31
Q

What is rehashing

A

is when a new hash table is created

32
Q

What features must a circular queue have

A

They must have a front and rear pointer. They must have a size attribute.

the front pointer is simply adjusted when an item is removed from the queue - the data is not deleted.

33
Q

6 functions/features of a dictionary

A

Add
Delete
Amend
Return the value associated with a key
Return True or False depending on whether the key is in the dictionary,
Return the length of the dictionary.

34
Q

Python function to get a list of the key:value pairs of a dictionary named thisdict

A

x = thisdict.items()

35
Q

Python function to return the keys of a dictionary

A

x = thisdict.keys()

36
Q

How is a new record added to a hash table (3)

A

Hash table has an algorithm applied to the key value,

the result is the location in the table where the record should be stored.

If location is not empty the use next free location.

37
Q

What are graphs

A

Graphs are abstract data structures representing complex relationships between the items of data.

a set of vertices or nodes (the circles with the items of data) connected by edges or arcs.

38
Q

What is a weighted graph

A

a type of graph where each edge (connection between nodes) has a numerical value associated with it

39
Q

What is a vertex/node

A

vertices can represent any discrete object or entity on a graph

40
Q

what is a edge/arc

A

a relationship or connection between two vertices in a graph.

41
Q

What is the difference between directed and undirected graph

A

In an undirected graph, edges do not have a direction associated with them.

In a directed graph, each edge has a direction associated with it.

42
Q

How do adjacency matricies represent a graph

A

For an undirected graph with
n vertices, the adjacency matrix is a
n×n matrix.

43
Q

compare the use of adjacency matrices and adjacency lists to represent graphs

A

Adjacency list appropriate when there are few edges between vertices
when edges rarely change

44
Q

What is a tree

A

a connected, undirected graph with no cycles.

45
Q

What is a rooted tree

A

a tree in which onevertex has been designated as the root.

A rooted tree has parent-child relationships between nodes.

46
Q

How do we create a dictionary in python

A

my_dict = {key: value, key: value etc}

47
Q

How do we check for a value in a dictionary

A

Use the in keyword

if 2 in mydict.values():
print(True)