Paper 4 - Unit 19 - Computational thinking and problem solving

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

1/47

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 5:05 PM on 4/4/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

48 Terms

1
New cards

Bubble sort algorithm (for loop)

knowt flashcard image
2
New cards

Bubble sort nested FOR loop disadvantage

• Iterations continue...

...after the array is sorted

3
New cards

Bubble sort improvement

Use of a flag to indicate if any swaps have taken place

If the inner loop has made all comparisons with no changes...

...flag/value set accordingly

A comparison checks the flag/value at the end of each inner loop...

...if it is sorted it breaks out/stops

4
New cards

Bubble sort algorithm (repeat until)

knowt flashcard image
5
New cards

Insertion sort

knowt flashcard image
6
New cards

Insertion sort efficiency factors

The size of the array - Better with larger arrays

How ordered the items already are - because it will stop as soon as it is sorted

7
New cards

Binary search algorithm (recursive)

knowt flashcard image
8
New cards

Linked list node declaration (record)

knowt flashcard image
9
New cards

Linked list declaration as array

knowt flashcard image
10
New cards

Example linked list declaration in python

knowt flashcard image
11
New cards

Linked list benefit over an array for implementing a stack

A linked list is a dynamic data structure / not restricted in size

Has greater freedom to expand or contract by adding or removing nodes as necessary

Allows more efficient editing using pointers (instead of moving the data)

An array is a static data structure...

...generally fixed in size

When the array is full, the stack cannot be extended any further.

12
New cards

Null pointer

A pointer that doesn't point to any data/node/address

Remember to ensure that when setting NULL pointer that it is not an array index i.e. don't use 0 if 0 is an index use -1

13
New cards

Binary search algorithm (Iterative)

knowt flashcard image
14
New cards

Array declaration of records

knowt flashcard image
15
New cards

Why an array needs to be sorted before a binary search algorithm can be used

It doesn't check every value

The midpoint is the middle element, not the middle numerical value

When the higher/lower elements are discarded they will not be the higher/lower elements

It might discard the value you are looking for

16
New cards

Linked list search (recursive)

knowt flashcard image
17
New cards

Binary search explanation

Find mid-point and compare to searched value

Discard greater/lower half

Find and compare to mid-point of new list

Continue until value found

18
New cards

Linked list delete (recursive)

knowt flashcard image
19
New cards

Linked list find

knowt flashcard image
20
New cards

Binary Tree Example

Tree incomplete in picture - complete using linked list

<p>Tree incomplete in picture - complete using linked list</p>
21
New cards

Hash table benefit

Hash is better for a large number of objects/records

A hashing algorithm/hash performed on key field/record (to form the address)...

...to allow direct access to the object...

...so it is likely to be faster in finding the object

Comparison - In a linked list, each object needs to be checked until found // sequentially/linear accessed...

...the left/right/next pointer is followed // have to trace pointers

22
New cards

Hash table - insert record

knowt flashcard image
23
New cards

Hash table - search

knowt flashcard image
24
New cards

Queue

(Linear) data structure

First in First out // FIFO // An item is added to the end of the queue and an item is removed from the front

All items are kept in the order they are entered

It has a head pointer and a tail pointer

Can be static or dynamic

Can be circular...

...when the (tail) pointer reaches the last position it returns to the first

25
New cards

Circular queue

Data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is connected back to the first position to make a circle.

26
New cards

Circular queue - Remove (array)

Note when start pointer is 5, it returns back to 0

<p>Note when start pointer is 5, it returns back to 0</p>
27
New cards

Queue - Remove (linked list)

knowt flashcard image
28
New cards

Tree

Nonlinear data structure, compared to arrays, linked lists, stacks and queues which are linear data structures.

Can be empty with no nodes or a tree is a structure consisting of one node called the root and zero or one or more subtrees.

<p>Nonlinear data structure, compared to arrays, linked lists, stacks and queues which are linear data structures.</p><p>Can be empty with no nodes or a tree is a structure consisting of one node called the root and zero or one or more subtrees.</p>
29
New cards

Binary Tree

Tree data structure in which each node has at most two children, which are referred to as the left child and the right child.

<p>Tree data structure in which each node has at most two children, which are referred to as the left child and the right child.</p>
30
New cards

Binary Tree - Create empty tree example

knowt flashcard image
31
New cards

Binary Tree - Add to Tree example

knowt flashcard image
32
New cards

Binary Tree - Search tree

knowt flashcard image
33
New cards

Binary Tree - Traverse tree recursive example

knowt flashcard image
34
New cards

Stack

Last In First Out (LIFO)

Operations

create stack

add item to stack (push)

remove item from stack (pop)

35
New cards

Stack with recursion

A LIFO data structure

The compiler must produce object code to...

…push return addresses / values of local variables onto a stack

…with each recursive call

… to set up winding

…pop return addresses / values of local variables off the stack

…after the base case is reached

… to implement unwinding.

36
New cards

Stack (pop)

knowt flashcard image
37
New cards

Stack (push)

knowt flashcard image
38
New cards

Dealing with collision

Create an overflow area...the 'home' record has a pointer to the others with the same key

Store the overflow record at the next available address in sequence

Redesign the hash function... to generate a wider range of indexes to create fewer collisions

39
New cards

Dealing with collision - next location

knowt flashcard image
40
New cards

Recursion features

It is defined in terms of itself // it calls itself

It has a stopping condition // base case

It has a general case

It is a self-contained subroutine

It can return data to its previous call

Unwinding can occur once the base case is reached

41
New cards

How recursion works

(When the recursive call is made) all values/data are put on the stack

When the stopping condition/base case is met the algorithm unwinds

The last set of values are taken off the stack (in reverse order)

42
New cards

Dictionary declaration

knowt flashcard image
43
New cards

Dictionary Add key with hash

knowt flashcard image
44
New cards

Factors that may affect the performance of a sorting algorith.

The initial order of the data

The number of data items to be sorted

The efficiency of the sorting algorithm

45
New cards

Big O Notation

A way of expressing the worst-case run-time of an algorithm

Useful for comparing the speed of two algorithms.

46
New cards

Linear Search Big O

O(n)

Time to search increases linearly in relation to the number of items in the list

Time to search increases more rapidly for a linear search than a binary search

47
New cards

Binary Search Big O

O(log n)...

...uses logarithmic time

Time to search increases linearly as the number of items increases exponentially

Time to search increases less rapidly for a binary search than a linear search

48
New cards

Bubble Sort Big O

O(n^2)

Explore top notes

Explore top flashcards