IB Computer Science HL - Topic 5 - Abstract Data Structures

studied byStudied by 13 people
5.0(1)
Get a hint
Hint

What is recursion

1 / 47

flashcard set

Earn XP

Description and Tags

Resources: https://github.com/graded-cs-resources/IB-Computer-Science-Notes/tree/main/paper1 https://pbaumgarten.com/ib-compsci/unit-5-data-structures.pdf

48 Terms

1

What is recursion

A function or method which calls itself

New cards
2

Advantages of recursion

Can reduce time complexity and development time and it can add clarity

New cards
3

Disadvantages of recursion

Complex to implement and memory inefficient as each recursion adds a new call to memory and previous function calls remain open

New cards
4

Why are 2D arrays abstract data structures

They are made up of a group of 1D arrays which are data structures themselves

New cards
5

How is the number of rows in array found

ARR.length

New cards
6

How is the number of columns in an array found

ARR[0].length

New cards
7

In index writing in arrays, which comes first, rows or collumns ?

rows

New cards
8

What policy are stacks based on

LIFO

New cards
9

What is the stack insert method ?

Push

New cards
10

What is the queue insert method ?

enqueue

New cards
11

What is the stack removal operation

Pop

New cards
12

What is the queue removal operation

dequeue

New cards
13

What are the applications of queues? (5 implementations)

  • printer queues 🖨

  • music playlists 🎶

  • interrupt handling 🤫

  • reversing stacks

  • modelling physical queues

New cards
14

What policy are queues based on ?

FIFO

New cards
15

What are the two features of the static implementation of stacks and queues ?

  • have a maximum capacity

  • rely on pointers to add and ‘remove’ elements.

New cards
16

Why are dynamic data structures needed ?

  1. They allow dynamic memory allocation so we don't need to declare their size at initialisation.

  2. They don't need contiguous memory locations as they are linked by referencing the address of the next node.

  3. Insert and delete operations are not computationally expensive as they don't require element shifting

New cards
17

How do dynamic data structures enable a dynamic variable size

As each node has a pointer to other nodes, only the pointers need to be changed to add, remove or move a node

New cards
18

What is a linked list

a linear collection of self-referential data structures, called nodes, connected by pointers.

New cards
19

Name differences between a static data structure and dynamic data structure

  • Static structures have a fixed size, dynamic structures have a variable length.

  • Static structures have declaration-time size allocation, dynamic have runtime size allocation.

  • Static have random access (indexes), dynamic has sequential access (no indexes).

  • Static are easier for searching and storing and use less memory.

  • Dynamic data structures can be more memory efficient overall as the data structure only uses what’s necessary as size will increase or decrease at runtime

  • Dynamic structures have a possibility of overflow or underflow during runtime if allocations are exceeded. This doesnt happen in static structures as memory size is fixed.

New cards
20

Advantages of a singly linked list

simpler to implement, less memory usage

New cards
21

Disadvantages of singly linked list

unidirectional, so slower for searching and sorting; randomly stored so direct access isn’t allowed (sequential only)

New cards
22

Advantages of a doubly linked list

bidirectional traversal; easier to search in

New cards
23

Disadvantages of doubly linked list

  • uses more memory in comparison to singly linked list

  • randomly stored so direct access isn’t allowed (sequential only)

New cards
24

Advantages of circular linked lists

the entire list can be traversed starting at any node.

New cards
25

Disadvantages of circular linked list ↻

inserting at the start would be expensive as it requires searching through for the final element; finding the end is hard.

New cards
26

How do you insert a node into an empty list

When the list is empty, indicated by head == NULL, the insertion sets both the head and tail to the current node

New cards
27

How do you insert a node into the beginning of a list

  1. The pointer of the new head node will point to the previous head node;

  2. The header pointer will point to the new node.

  3. The connection between header node and header pointer is removed

New cards
28

How do you insert a node in to the end of a list

  1. Connect tail node to the new node

  2. The new node will be connected to null (in singly linked list)

New cards
29

How do you insert a node in to the middle of a list

  1. The pointer of the previous node will now point to the new node.

  2. The new node will now point to the next node.

  3. Delete the connection of previous node

New cards
30

Give examples of primitive data types

Double, Integer, Character, Boolean

New cards
31

Dynamic data types have length/ size as a ________

Variable

New cards
32

Static data types have a _____ length/size

Fixed

New cards
33

Applications of stacks

  • storing recursive calls

  • implementing function calls

  • returning memory addresses

  • translations from one programming language to another

  • browser history

  • in calculations and evaluations of expressions.

New cards
34

Where are elements in a queue enqueued

From the back

New cards
35

Where are elements in a queue dequeued

From the front

New cards
36

What does contiguous memory locations refer to? Give an example of a data structure which uses it

It means that all elements need to be stored together. eg. an array

New cards
37

What are the features of a dynamic data structure?

Pointers.

  • Each node has a pointer, they don’t need to be placed next to each other.

  • To delete and insert nodes, only the pointers need to be changed.

  • Enables their dynamic size.

New cards
38

Disadvantages of a doubly linked list

  • Uses more memory in comparison to singly linked list

  • randomly stored so direct access isn’t allowed (sequential only)

New cards
39

Advantages of circular linked list

The entire list can be traversed starting at any node.

New cards
40

What is a parent in a binary tree

A node which has children. They will be linked below it.

New cards
41

What is a left/right child in a binary tree

A child node on the left/right-hand of the parent.

New cards
42

What is a subtree in a binary tree

A parent with a child. It can be one or two children.

New cards
43

What is a root in a binary tree

The root is the original node.

New cards
44

What are leaves in a binary tree

All nodes without children

New cards
45

Which way do pre-order traversal flags point

left

New cards
46

Which way do in order traversal flags point

Down

New cards
47

Which way do post order traversal flags point

right

New cards
48

what is the base case

a point at which the recursion will stop because the most basic endpoint has been reached, so a simple answer can be given.

New cards

Explore top notes

note Note
studied byStudied by 132 people
... ago
5.0(1)
note Note
studied byStudied by 55 people
... ago
4.5(2)
note Note
studied byStudied by 7 people
... ago
5.0(1)
note Note
studied byStudied by 30 people
... ago
5.0(1)
note Note
studied byStudied by 37 people
... ago
5.0(1)
note Note
studied byStudied by 6 people
... ago
5.0(1)
note Note
studied byStudied by 16 people
... ago
5.0(1)
note Note
studied byStudied by 23129 people
... ago
4.8(187)

Explore top flashcards

flashcards Flashcard (21)
studied byStudied by 4 people
... ago
5.0(1)
flashcards Flashcard (93)
studied byStudied by 13 people
... ago
5.0(2)
flashcards Flashcard (27)
studied byStudied by 5 people
... ago
5.0(1)
flashcards Flashcard (58)
studied byStudied by 4 people
... ago
5.0(1)
flashcards Flashcard (83)
studied byStudied by 8 people
... ago
5.0(1)
flashcards Flashcard (30)
studied byStudied by 1 person
... ago
5.0(1)
flashcards Flashcard (22)
studied byStudied by 2 people
... ago
5.0(1)
flashcards Flashcard (68)
studied byStudied by 29 people
... ago
5.0(2)
robot