AQA COMPUTER SCIENCE A LEVEL - FUNDAMENTALS OF DATA STRUCTURES

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/67

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 8:28 AM on 4/28/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

68 Terms

1
New cards

What is a stack?

abstract data type where the last item added to the stack is the first to leave (LIFO)

2
New cards

Where are stacks used?

in calculations,

holding return addresses when subroutines are called,

back button on web browser,

undo button on word processr

3
New cards

How are they implemented

dynamic (list)

static (array with two pointers)

4
New cards

test if stack is empty

stack.isEmpty()

return True/False

5
New cards

test if stack is full

stack.isFull()

return True/False

6
New cards

return top item from stack but not remove

stack.peek()

return top item

7
New cards

remove and return top item

stack.pop()

return top item

8
New cards

add new item to top of stack

stack.push(item)

9
New cards

what is stack overflow?

when an item is attempted to be pushed onto a stack but the stack is full

10
New cards

what is stack underflow?

when the stack is empty and an item is being attempted to be popped

11
New cards

pseudocode to push onto stack

SUB pushToStack

IF topOfStack = maxSize THEN

OUTPUT "Stack is full - no space available"

ELSE

INPUT newStackItem

topOfStack = topOfStack + 1

stack(topOfStack) = newStackItem

ENDIF

ENDSUB

12
New cards

pseudocode to pop from stack

SUB popFromStack

IF (topOfStack = 0) THEN

OUTPUT "Stack is empty - no data to pop"

ELSE

OUTPUT stack[topOfStack]

topOfStack = topOfStack - 1

ENDIF

ENDSUB

13
New cards

What is a stack frame?

stores information about active subroutines while computer programs are running

holds return addresses

14
New cards

What is a data structure?

a collection of elementary data types

15
New cards

What is an elementary data type?

contains single data values

e.g.boolean, integer, real, char

16
New cards

What is a composite data type?

constructed using elementary data types

e.g. string, array, list

17
New cards

What is a structured data type?

sequence of characters

18
New cards

What is an abstract data type?

logical description of how we view the data and possible operations

19
New cards

What are some examples of abstract data types?

queue

stack

graph

tree

hash table

dictionary

vector

20
New cards

What is data abstraction?

hiding details on implementation

21
New cards

What is a dynamic data structure?

a collection of data in the memory that has the ability to grow or shrink in size with the aid of a heap

22
New cards

What is a heap?

a portion of the memory from which free space is automatically allocated or de-allocated as required

23
New cards

What is a static data structure?

fixed in size and cannot increase in size or free up memory whilst the program in running

24
New cards

What is a queue?

abstract data structure that operates on a first in, first out (FIFO) basis

where data is pushed into the queue and popped from it

25
New cards

Examples of queues in real life

printer - print jobs sent, print one at a time in order sent

keyboard - characters entered appear in order sent

26
New cards

Where is the front of a queue?

0

27
New cards

Where is the rear of a queue?

-1

28
New cards

how to ADD item to the REAR of the queue

enQueue(item)

29
New cards

how to REMOVE item from queue FRONT

deQueue

returns item from queue front

30
New cards

how to check if queue is EMPTY

isEmpty

returns True/False

31
New cards

how to check if queue is FULL

isFull

returns True/False

32
New cards

how to check queue SIZE

size

returns how many items in queue

33
New cards

how to check queue MAX SIZE

MaxSize

returns the max number of items that can be stored

34
New cards

What are the types of queue?

Linear

Circular

Priority

35
New cards

What is a linear queue?

organised as a list or line of data

36
New cards

How to implement a linear queue? (1)

(1) when an items leaves, items move up

so FRONT has an element

if the queue is long, there is a long processing time as each item is moved

37
New cards

How to implement a linear queue? (2)

(2) using FRONT/REAR pointers

move pointers as necessary

as items are deleted, there is unused space accumulating at the front

38
New cards

What do the start(front) and end(rear) pointers show?

start show the data item that was entered first into the queue

end show the data item that was entered last into the queue

39
New cards

What is a circular queue?

organised in a ring where the start and end pointers wrap around from the last to the first element in the array

40
New cards

Circular queue pseudocode - initialise

SUB initialise

front = 0

rear = -1

size = 0

maxSize = size of array

ENDSUB

41
New cards

Circular queue pseudocode - test for empty queue

SUB isEmpty

IF size == 0 THEN

RETURN True

ELSE

RETURN False

ENDIF

ENDSUB

42
New cards

Circular queue pseudocode - test for full queue

SUB isFull

IF size == maxSize THEN

RETURN True

ELSE

RETURN False

ENDIF

ENDSUB

43
New cards

Circular queue pseudocode - add element to the queue

SUB enqueuer(newItem)

IF isFull THEN

OUTPUT "Queue Full"

ELSE

rear = (rear + 1) MOD maxSize

q(rear) = newItem

size = size + 1

ENDIF

ENDSUB

44
New cards

What is a priority queue?

similar to regular queue but

each element assigned a priority

highest priority items are first

(where priority is same, then FIFO)

45
New cards

What is a hash table?

stores data in an associative way

the table is created by using a hash function which maps a key to an index in an array to find the value of an array element

46
New cards

What are the uses of hash tables?

efficient lookup (implementing with dictionary)

e.g. finding data, passwords

47
New cards

What is a hash function?

a calculation applied to the value in the key field of each record to transform it into an address

48
New cards

Mid Square Method

1) square the item

2) extract a portion of resulting digits

3) resulting digits MOD tableSize

49
New cards

Folding Method

1) Divide the item into equal size pieces (last may not be)

2) Add pieces together

3) resulting number MOD tableSize

50
New cards

How would you hash alphanumeric data?

Use the ASCII code equivalents for each char then apply the function

51
New cards

What is a collision?

when two keys are applied to the hash function and create an identical hash value

52
New cards

A good hashing algorithm...

...aims to minimise the chance of collisions

53
New cards

How can the table help with collisions?

designed so 50-70% of tables cells are occupied (as the fuller the hash table, the more likely a collision)

prime number of cells, so when MOD tableSize performed more likely to get different values

54
New cards

What are the two methods to deal with collisions?

Linear probing and separate chaining

55
New cards

What is linear probing?

where a key is assigned to the next available slot in the hash table (if there is a collision)

56
New cards

What is the problem with linear probing?

can create clustering (where more collisions can occur as the hashing function index is not randomly distributed)

57
New cards

How to improve linear probing?

increment search for next empty cell in 1,3,5,7,etc to reduce cluster

58
New cards

What is a linked list?

a linear data structure in which a group of nodes contain data and make use of a pointer to link with the next data element

59
New cards

What is separate chaining?

where the hash table index is a pointer to a linked list data structure that contains all the data

where there are no collisions the linked listed contains one element and the linked list will contain all the collisions for a particular slot

60
New cards

What are collisions also known as?

synonyms

61
New cards

How are items found in hash table?

algorithm applied to item and examine resulting cell (index)

if item is there, return item

if cell is empty, then not in table

if there is a different item in that spot or message saying that the item is this cell has been deleted, keep moving until met with item or empty spot

62
New cards

What is a linear search?

start at the beginning, go through everything in order

sequential search

63
New cards

What is a binary search?

(provided data is ordered)

split data in half

would it be before/after?

repeat

quicker than linear search

64
New cards

What is a dictionary?

contains a collection of 'key-value' data elements where the data value is accessed by the associated key

associative array

65
New cards

multiple items associated with the same key are...

...not allowed

66
New cards

multiple values associated with the same key are...

...allowed

67
New cards

How are key-values pairs stored in a dictionary?

in no particular order

68
New cards

what opereations can you do on a dictionary

create a new empty dictionary

add new key:value

delete key:value

ammend key:value

return value associated with key

return True/False if key in dictionary

return length of dictionary