7. data structures Flashcards

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

data strucutre

A

is a format used to store, organise and manage data in a way that allows for efficient access and modification for the needs of the program

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

abstract data type

A

is a logical description of how the data is viewed and the operations that can be performed on it, but how this is done is not necessarily known by the user

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

ADT

A

queues
stacks
trees
graphs

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

advantages of ADT

A

+ can be easily shown in graphical form
+ its not had to understand how to perform operations such as adding, deleting or counting elements in each structure

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

data abstraction

A

process of simplifying complex data structures by providing a simple interface and hiding the underlying details.

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

example of data abstraction

A

its up to the programmer who creates the data structure to decide how to implement it, and it may be built in to the programming language

by providing this level of abstraction we are creating an encapsulation around data.

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

encapsulation

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

information hiding

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

queue

A

FIFO data structure. new elements may only be added to the end of a queue, and elements may only be retrieved from the front of a queue.

the sequence of data items in a queue is determined by the order in which they are inserted.

the size of the queue depends on the number of items in it.

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

queue application (1)

A

output waiting to be printed is commonly stored in a queue on disk. in a room full of networked computers, several people may send work to be printed at more or less the same time. by putting the output into a queue on disk, the output is printed on a first come, first served basis as soon as the printer is free.

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

queue application (2)

A

characters typed at a keyboard are held in a queue in a keyboard buffer

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

queue application (3)

A

stimulation program - attempts to model a real-life situation so as to learn something about it

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

stimulation program example

A

a program that stimulates customers arriving at random times at check-outs in a supermarket store, and taking random times to pass through the checkout.

with the aid of a stimulation program, the optimum number of check-out counters can be established.

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

enQueue(item)

A

add a new item to the rear of the queue

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

deQueue()

A

remove the front item from the queue and return it

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

isEmpty()

A

tests to see whether the queue is empty

17
Q

isFull()

A

test to see whether queue is full

18
Q

static data structure

A

organisation or collection of data in memory that is fixed in size.

e.g. array

  • maximum size needs to be known in advance
  • memory can’t be reallocated once program is running
19
Q

dynamic data structure

A

organisation or collection of data in memory that has ability to grow or shrink in size. it does this with the aid of the heap.

e.g. linked lists or queues

  • allows the programmer to control exactly how much memory will be used
  • unused memory is allocated or de-allocated as needed
  • maximum size of data structure is not known in advance
  • can be given arbitrary maximum to avoid causing memory overflow
20
Q

dynamic data structure advantage

A

+ makes efficient use of memory because the data structure only uses as much memory as it needs

21
Q

dynamic data structure disadvantage

A
  • dds run the risk of ‘overflow’ error, this happens when it exceeds its allowed limit. can also cause an ‘underflow’ error if it becomes empty
  • harder to program because the code needs to keep track of the data structures size and location of items inside it at all times
22
Q

static data structure advantage

A

+ memory allocation is fixed which means there will be no issues with adding and removing items from the data structure
+ easier to program as there isn’t a requirement to check on the size of the data structure at any point before accessing it

23
Q

static data structure

A
  • can be very inefficient as memory for the data structure is set aside at the start of the program but might not be utilised
24
Q

implementing a linear queue

A
  • as items leave the queue, all of the other items move up one space so that the front of the queue is always the first element of the structure
  • can be implemented with pointers to the front and rear of the queue. an integer holding the size of the array (the maximum size of the queue

however, clearly a problem will arise as many items are added to and deleted from the queue, as space is created at the front of the queue which cannot be filled, and items are added until the rear pointer points to the last element of the data structure