Open the App

Subjects

Computer ScienceComputer Science302 views·Updated Jun 17, 2026·15 pages

GCSE Computer Science Sorting Algorithms Revision Notes

user profile picture
Diyen Bhudia @diyenbhudia_yvjr

Ready to crack the code on computational thinking and programming?...

1
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Computational Thinking Fundamentals

Ever wondered how programmers tackle massive problems without getting overwhelmed? It all starts with computational thinking - basically breaking down complex challenges into manageable chunks.

An algorithm is simply a set of instructions for solving a problem, like a recipe for your favourite dish. You can write these down using flowcharts (visual diagrams with symbols and arrows) or pseudocode (simplified English that looks a bit like real programming code).

Algorithmic thinking helps you approach problems logically so you can reuse solutions later. Abstraction means stripping away unnecessary details - think of the London Underground map that shows tube lines but ignores roads and rivers. Decomposition involves breaking big problems into smaller, manageable pieces that you can tackle one at a time.

Quick Tip: When facing a complex problem, always ask yourself: "What details can I ignore?" and "How can I split this into smaller parts?"

The beauty of these methods is that once you solve a sub-problem, you can often reuse that solution in other projects, saving you loads of time later on.

2
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Search and Sort Algorithms

Finding stuff quickly in lists is crucial for programming, and there are two main search methods you need to know. Linear search checks every item one by one until it finds what you're looking for - imagine flipping through every page of a dictionary. It's simple but painfully slow for large lists.

Binary search is much cleverer and faster, but only works on sorted lists. It starts in the middle, decides whether to look left or right, then repeats this process, halving the search area each time. Think of it like the "higher or lower" guessing game.

For sorting, bubble sort compares neighbouring items and swaps them if they're in the wrong order, repeating until everything's sorted. The largest values "bubble up" to the end. Insertion sort works faster by sorting one item at a time into its correct position.

Merge sort is the speed champion - it splits lists in half repeatedly until each piece has one item, then merges everything back together in the correct order. It's more complex but much more efficient for large datasets.

Exam Tip: Always explain HOW each sorting algorithm works step-by-step, not just what it does!

3
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Flowcharts and Pseudocode

Flowcharts use specific symbols that every programmer recognises. Terminal symbols (ovals) mark start and stop points, process boxes (rectangles) handle calculations, decision diamonds ask yes/no questions, and input/output shapes (parallelograms) deal with data coming in or going out.

Pseudocode lets you focus on the logic without worrying about exact programming syntax. It's like writing instructions in structured English that any programmer can understand and convert to real code later.

Variables are temporary storage boxes in memory where you can keep values like numbers or text. You name them using snake_case wordsseparatedbyunderscores,likeMINAGEwords separated by underscores, like MIN_AGE. Constants are values that never change during the program and are usually written in UPPERCASE.

Why use constants instead of variables? They prevent accidental changes to important values and clearly show other programmers that this value should stay the same. Remember though - constants can be changed by programmers before the program runs, just not while it's running.

Remember: Good variable names make your code much easier to understand later!

4
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Data Types and Operations

Every piece of data has a specific type that determines what you can do with it. Integers are whole numbers, floats (or real numbers) have decimal points, characters are single letters or symbols, strings are sequences of characters, and booleans are simply true or false.

Mathematical operations follow BIDMAS order: Brackets, Indices (powers), Division, Multiplication, Addition, Subtraction. MOD finds remainders 17MOD3=217 MOD 3 = 2, whilst DIV does integer division without decimals 17DIV3=517 DIV 3 = 5.

Comparison operators let you test relationships: > (greater than), >= (greater than or equal), < (less than), <= (less than or equal), == (equal to), and != (not equal to). These return boolean values.

Subprograms are reusable chunks of code that appear as boxes with lines on both sides in flowcharts. They make programs easier to debug and maintain because you can fix problems in smaller, isolated sections rather than hunting through massive blocks of code.

Key Point: Understanding data types prevents errors - you can't do maths with text unless you convert it first!

5
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Programming Constructs and Casting

All programs are built from three fundamental constructs. Sequence means instructions execute one after another in order. Selection uses IF statements to choose different paths based on conditions - like choosing whether to take an umbrella based on weather forecasts.

Iteration means repetition, and there are three types you'll use constantly. FOR loops repeat a specific number of times, WHILE loops continue as long as a condition stays true (checked at the start), and DO-UNTIL loops keep going until a condition becomes true (checked at the end).

Nested IF statements are IF statements inside other IF statements, allowing complex decision-making. Think of them as asking follow-up questions based on previous answers.

Casting (or type conversion) changes data from one type to another using special functions. int() converts strings to integers, float() creates decimal numbers, str() turns numbers into text, and bool() creates true/false values. ASC() and CHR() convert between characters and their ASCII number codes.

Pro Tip: Always cast user inputs before using them in calculations - inputs are always strings initially!

6
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

String Manipulation and Control Structures

User inputs always start as strings, so you'll need to convert them before doing calculations. String functions are incredibly powerful for text processing. str.length tells you how many characters are in a string, str.substring(start, end) grabs specific portions, whilst str.left(n) and str.right(n) extract characters from either end.

The concatenation operator (+) joins strings together. You can change case using .upper and .lower functions. Remember that spaces count as characters too!

Switch/case statements handle multiple options more elegantly than long chains of IF statements. They test one variable against several possible values and execute different code for each case, with a default option for unexpected inputs.

Random numbers require importing special libraries. In pseudocode you might write random(0, 100), whilst Python uses random.randint(0, 100) after importing the random library.

Comments (marked with # in Python) explain your code to other programmers and your future self. They're ignored when the program runs but are essential for maintaining and understanding code later.

Remember: Good comments explain WHY you're doing something, not just what you're doing!

7
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Debugging with Trace Tables

Trace tables are your best friend for finding sneaky logic errors in programs. You create columns for each variable and track their values line by line as the program executes. It's like being a detective following clues through your code.

These tables help you determine what a program will output, spot errors in your logic, and understand how algorithms work. Make columns for variables in the order they appear, and only fill in values when they actually change.

Syntax errors break the rules of the programming language (like missing quotation marks) and stop your program from running at all. The compiler will catch these and give you error messages.

Logical errors are trickier - your code follows the syntax rules but doesn't do what you intended. For example, dividing by 3 instead of 2 when calculating an average of two numbers.

Modern IDEs (Integrated Development Environments) can automate trace table functionality with breakpoints and variable watching, but understanding the manual process helps you think like a programmer.

Debug Like a Pro: When stuck, add print statements throughout your code to see what's actually happening with your variables!

8
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Working with Arrays

Arrays are like storage containers that hold multiple items of the same data type under one name. Think of them as numbered boxes where you can store related information like usernames or scores.

Array indexes start at 0, not 1 - this catches many beginners out! To access the first item, you use arrayName[0]. The .length property tells you how many items are stored.

Arrays have fixed lengths - if you need more space, you must create a new larger array and copy everything across. Python sidesteps this limitation by using lists instead, which can grow and shrink as needed.

You can loop through arrays easily using FOR loops to process every item. This makes tasks like searching through usernames or calculating averages much simpler than creating separate variables for each piece of data.

Arrays make linear searches straightforward - just loop through each index comparing values until you find what you're looking for. They're also essential for implementing sorting algorithms effectively.

Array Advantage: Instead of creating username1, username2, username3... you can store everything in one array and access it with a simple loop!

9
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Subroutines and Scope

Subroutines break large programs into manageable, reusable chunks - they're like mini-programs within your main program. Functions return values after processing (like calculating a square root), whilst procedures execute code but don't return anything.

The main advantages are enormous: you can test each piece separately, multiple programmers can work simultaneously, code can be reused across projects, and maintenance becomes much easier. Instead of hunting through thousands of lines, you just fix the specific subroutine that's causing problems.

Scope defines where variables can be used. Global variables are accessible anywhere in your program, like public information everyone can see. Local variables only exist within their specific subroutine and disappear when that subroutine finishes.

Think of functions as houses with one-way windows - you can see global variables from inside, but outsiders can't see your local variables. This prevents naming conflicts and keeps subroutines self-contained.

Parameters are the inputs you pass to functions - they're listed in the brackets when you define or call the function. They act like local variables within that subroutine.

Best Practice: Use local variables whenever possible to keep your subroutines independent and reusable!

10
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Advanced Subroutine Concepts

The power of subroutines really shines in large projects where many programmers collaborate simultaneously. Each person can work on different subroutines without interfering with others, dramatically reducing development time.

Local variables are your secret weapon for creating truly portable subroutines. Since they only exist within their function, you never have to worry about variable name conflicts when reusing code in different projects.

When you write something like sum(a, b), the a and b are called parameters - they define what inputs your function expects. These parameters behave like local variables inside the function.

Global variables can be seen and used from within functions, but good programming practice suggests you shouldn't change them directly from inside subroutines. Use the global keyword in pseudocode when you need to explicitly work with global variables.

Subroutine libraries let you build collections of useful functions that you can import into any project. This is how professional programmers avoid reinventing the wheel - they build up toolkits of proven, tested code over time.

Professional Tip: Treat each subroutine like a black box - if you know what goes in and what comes out, you shouldn't need to worry about the internal details!

Program maintenance becomes infinitely easier when problems are isolated to specific subroutines rather than scattered throughout massive files.

We thought you’d never ask...

What is the Knowunity AI companion?

Our AI Companion is a student-focused AI tool that offers more than just answers. Built on millions of Knowunity resources, it provides relevant information, personalised study plans, quizzes, and content directly in the chat, adapting to your individual learning journey.

Where can I download the Knowunity app?

You can download the app from Google Play Store and Apple App Store.

Is Knowunity really free of charge?

That's right! Enjoy free access to study content, connect with fellow students, and get instant help – all at your fingertips.

Most popular content in Computer Science

9
Computer ScienceComputer Science

GCSE Computer Science Overview

Comprehensive study material for OCR GCSE Computer Science covering key topics such as computer architecture, network security, programming techniques, and ethical considerations. Ideal for exam preparation, this resource includes essential concepts, exam questions, and definitions to enhance understanding and retention.

97,876304
C
Computer ScienceComputer Science

Computer Science quiz

Purpose, Components and functions of CPU. Also von neuman architecture

106384
Computer ScienceComputer Science

GCSE Computer Science Revision

Comprehensive revision notes for OCR GCSE Computer Science Component 1 (J277). Covers key topics including networking, cybersecurity, data compression, computer architecture, and ethical issues. Ideal for exam preparation and understanding core concepts. Access original slides for further details.

104,827150
Computer ScienceComputer Science

GCSE Computer Science // Revision Notes

Concise revision notes for the GCSE OCR computer science specification (J277). Contains all the info needed for paper 1. Paper 2 is in my bio.

104666
C
Computer ScienceComputer Science

computing quiz for

good luck

101250
C
Computer ScienceComputer Science

computer science,geography

this will help you revise for when you are next tested on these questions this will also help you to remember

71941
Computer ScienceComputer Science

GCSE Computer Science Algorithms

Comprehensive overview of algorithms for AQA GCSE Computer Science Paper 1, covering key concepts such as sorting (Bubble Sort, Merge Sort), searching (Linear and Binary Search), and essential programming principles like data types, pseudocode, and flowcharts. Ideal for exam preparation and understanding algorithm efficiency.

1075656
C
Computer ScienceComputer Science

cs ocr

Level up your computer science knowledge with this comprehensive flashcard set designed for grade 11 students. Dive deep into complex concepts and ace your exams!

115260
Computer ScienceComputer Science

AQA GCSE Computer Science Overview

Comprehensive revision notes covering the AQA GCSE Computer Science curriculum, including key topics such as computer memory, cybersecurity, programming concepts, network protocols, and data representation. Ideal for exam preparation and understanding core concepts in computing.

105,360216

Most popular content

9
SociologySociology

Sociology of Education Overview

Explore comprehensive A-Level Sociology notes on the education system, covering key theories, policies, and sociological perspectives. This resource includes insights on marketisation, gender roles, cultural deprivation, and educational inequalities, providing a thorough understanding of how education shapes social stratification and individual achievement. Ideal for exam preparation and in-depth study.

12102,8383,040
SociologySociology

Sociology of Families: Comprehensive Revision

Dive into an extensive overview of family dynamics, perspectives, and patterns in sociology. This resource covers key concepts such as family diversity, gender roles, marriage, and the impact of social policies on family structures. Perfect for A-Level Sociology students preparing for Paper 2.

1273,6372,306
CriminologyCriminology

Criminology: Crime & Punishment Overview

Comprehensive mindmaps covering key concepts in the Crime and Punishment topic for WJEC Criminology Unit 4. This resource includes detailed insights into the Criminal Justice System, crime prevention strategies, sentencing models, and the roles of various agencies. Ideal for A-Level revision, ensuring you grasp essential theories and legislative processes to excel in your exams.

1254,8591,059
SociologySociology

Comprehensive Crime & Deviance Overview

Explore an extensive revision of crime and deviance topics, including theories, types of crime, and the impact of media. This resource covers key concepts such as Marxism, functionalism, gender and crime, and the influence of globalization on criminal behavior. Ideal for students seeking a thorough understanding of criminology and its various theories. Type: Full Topic Revision.

1251,6461,399
C
BiologyBiology

Cell Biology and Cell structure

cell structures

93,2200
English LiteratureEnglish Literature

An Inspector Calls: Character Insights

Explore in-depth analysis and key quotes for characters in J.B. Priestley's 'An Inspector Calls'. This resource covers Gerald Croft, Inspector Goole, Sheila Birling, Mrs. Birling, Eric Birling, and Eva Smith, focusing on themes of class, gender roles, and social responsibility. Ideal for students aiming for Grade 8 and above.

1125,419907
CriminologyCriminology

WJEC Unit 4 Criminology

Criminology unit 4 detailed revision note

127,146125
CriminologyCriminology

Criminology Theories Overview

Explore key criminology theories and their implications on crime and deviance. This comprehensive summary covers biological, psychological, and sociological perspectives, including labelling theory, right realism, and the impact of social campaigns on policy development. Ideal for A-Level criminology students seeking to understand the complexities of criminal behaviour and the factors influencing crime prevention strategies.

129,757210
English LiteratureEnglish Literature

Romeo and Juliet: Key themes

Key Romeo and Juliet themes and analysed quotes

106,700198

Can't find what you're looking for? Explore other subjects.

Students love us — and so will you.

4.6/5App Store
4.7/5Google Play

The app is very easy to use and well designed. I have found everything I was looking for so far and have been able to learn a lot from the presentations! I will definitely use the app for a class assignment! And of course it also helps a lot as an inspiration.

Stefan SiOS user

This app is really great. There are so many study notes and help [...]. My problem subject is French, for example, and the app has so many options for help. Thanks to this app, I have improved my French. I would recommend it to anyone.

Samantha KlichAndroid user

Wow, I am really amazed. I just tried the app because I've seen it advertised many times and was absolutely stunned. This app is THE HELP you want for school and above all, it offers so many things, such as workouts and fact sheets, which have been VERY helpful to me personally.

AnnaiOS user

Computer ScienceComputer Science302 views·Updated Jun 17, 2026·15 pages

GCSE Computer Science Sorting Algorithms Revision Notes

user profile picture
Diyen Bhudia @diyenbhudia_yvjr

Ready to crack the code on computational thinking and programming? This guide breaks down everything from algorithms and sorting methods to variables and subroutines - all the essential concepts you need to master for your Computer Science course.

1
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Sign up to see the content. It's free!

  • Access to all documents
  • Improve your grades
  • Join milions of students

Computational Thinking Fundamentals

Ever wondered how programmers tackle massive problems without getting overwhelmed? It all starts with computational thinking - basically breaking down complex challenges into manageable chunks.

An algorithm is simply a set of instructions for solving a problem, like a recipe for your favourite dish. You can write these down using flowcharts (visual diagrams with symbols and arrows) or pseudocode (simplified English that looks a bit like real programming code).

Algorithmic thinking helps you approach problems logically so you can reuse solutions later. Abstraction means stripping away unnecessary details - think of the London Underground map that shows tube lines but ignores roads and rivers. Decomposition involves breaking big problems into smaller, manageable pieces that you can tackle one at a time.

Quick Tip: When facing a complex problem, always ask yourself: "What details can I ignore?" and "How can I split this into smaller parts?"

The beauty of these methods is that once you solve a sub-problem, you can often reuse that solution in other projects, saving you loads of time later on.

2
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Sign up to see the content. It's free!

  • Access to all documents
  • Improve your grades
  • Join milions of students

Search and Sort Algorithms

Finding stuff quickly in lists is crucial for programming, and there are two main search methods you need to know. Linear search checks every item one by one until it finds what you're looking for - imagine flipping through every page of a dictionary. It's simple but painfully slow for large lists.

Binary search is much cleverer and faster, but only works on sorted lists. It starts in the middle, decides whether to look left or right, then repeats this process, halving the search area each time. Think of it like the "higher or lower" guessing game.

For sorting, bubble sort compares neighbouring items and swaps them if they're in the wrong order, repeating until everything's sorted. The largest values "bubble up" to the end. Insertion sort works faster by sorting one item at a time into its correct position.

Merge sort is the speed champion - it splits lists in half repeatedly until each piece has one item, then merges everything back together in the correct order. It's more complex but much more efficient for large datasets.

Exam Tip: Always explain HOW each sorting algorithm works step-by-step, not just what it does!

3
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Sign up to see the content. It's free!

  • Access to all documents
  • Improve your grades
  • Join milions of students

Flowcharts and Pseudocode

Flowcharts use specific symbols that every programmer recognises. Terminal symbols (ovals) mark start and stop points, process boxes (rectangles) handle calculations, decision diamonds ask yes/no questions, and input/output shapes (parallelograms) deal with data coming in or going out.

Pseudocode lets you focus on the logic without worrying about exact programming syntax. It's like writing instructions in structured English that any programmer can understand and convert to real code later.

Variables are temporary storage boxes in memory where you can keep values like numbers or text. You name them using snake_case wordsseparatedbyunderscores,likeMINAGEwords separated by underscores, like MIN_AGE. Constants are values that never change during the program and are usually written in UPPERCASE.

Why use constants instead of variables? They prevent accidental changes to important values and clearly show other programmers that this value should stay the same. Remember though - constants can be changed by programmers before the program runs, just not while it's running.

Remember: Good variable names make your code much easier to understand later!

4
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Sign up to see the content. It's free!

  • Access to all documents
  • Improve your grades
  • Join milions of students

Data Types and Operations

Every piece of data has a specific type that determines what you can do with it. Integers are whole numbers, floats (or real numbers) have decimal points, characters are single letters or symbols, strings are sequences of characters, and booleans are simply true or false.

Mathematical operations follow BIDMAS order: Brackets, Indices (powers), Division, Multiplication, Addition, Subtraction. MOD finds remainders 17MOD3=217 MOD 3 = 2, whilst DIV does integer division without decimals 17DIV3=517 DIV 3 = 5.

Comparison operators let you test relationships: > (greater than), >= (greater than or equal), < (less than), <= (less than or equal), == (equal to), and != (not equal to). These return boolean values.

Subprograms are reusable chunks of code that appear as boxes with lines on both sides in flowcharts. They make programs easier to debug and maintain because you can fix problems in smaller, isolated sections rather than hunting through massive blocks of code.

Key Point: Understanding data types prevents errors - you can't do maths with text unless you convert it first!

5
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Sign up to see the content. It's free!

  • Access to all documents
  • Improve your grades
  • Join milions of students

Programming Constructs and Casting

All programs are built from three fundamental constructs. Sequence means instructions execute one after another in order. Selection uses IF statements to choose different paths based on conditions - like choosing whether to take an umbrella based on weather forecasts.

Iteration means repetition, and there are three types you'll use constantly. FOR loops repeat a specific number of times, WHILE loops continue as long as a condition stays true (checked at the start), and DO-UNTIL loops keep going until a condition becomes true (checked at the end).

Nested IF statements are IF statements inside other IF statements, allowing complex decision-making. Think of them as asking follow-up questions based on previous answers.

Casting (or type conversion) changes data from one type to another using special functions. int() converts strings to integers, float() creates decimal numbers, str() turns numbers into text, and bool() creates true/false values. ASC() and CHR() convert between characters and their ASCII number codes.

Pro Tip: Always cast user inputs before using them in calculations - inputs are always strings initially!

6
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Sign up to see the content. It's free!

  • Access to all documents
  • Improve your grades
  • Join milions of students

String Manipulation and Control Structures

User inputs always start as strings, so you'll need to convert them before doing calculations. String functions are incredibly powerful for text processing. str.length tells you how many characters are in a string, str.substring(start, end) grabs specific portions, whilst str.left(n) and str.right(n) extract characters from either end.

The concatenation operator (+) joins strings together. You can change case using .upper and .lower functions. Remember that spaces count as characters too!

Switch/case statements handle multiple options more elegantly than long chains of IF statements. They test one variable against several possible values and execute different code for each case, with a default option for unexpected inputs.

Random numbers require importing special libraries. In pseudocode you might write random(0, 100), whilst Python uses random.randint(0, 100) after importing the random library.

Comments (marked with # in Python) explain your code to other programmers and your future self. They're ignored when the program runs but are essential for maintaining and understanding code later.

Remember: Good comments explain WHY you're doing something, not just what you're doing!

7
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Sign up to see the content. It's free!

  • Access to all documents
  • Improve your grades
  • Join milions of students

Debugging with Trace Tables

Trace tables are your best friend for finding sneaky logic errors in programs. You create columns for each variable and track their values line by line as the program executes. It's like being a detective following clues through your code.

These tables help you determine what a program will output, spot errors in your logic, and understand how algorithms work. Make columns for variables in the order they appear, and only fill in values when they actually change.

Syntax errors break the rules of the programming language (like missing quotation marks) and stop your program from running at all. The compiler will catch these and give you error messages.

Logical errors are trickier - your code follows the syntax rules but doesn't do what you intended. For example, dividing by 3 instead of 2 when calculating an average of two numbers.

Modern IDEs (Integrated Development Environments) can automate trace table functionality with breakpoints and variable watching, but understanding the manual process helps you think like a programmer.

Debug Like a Pro: When stuck, add print statements throughout your code to see what's actually happening with your variables!

8
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Sign up to see the content. It's free!

  • Access to all documents
  • Improve your grades
  • Join milions of students

Working with Arrays

Arrays are like storage containers that hold multiple items of the same data type under one name. Think of them as numbered boxes where you can store related information like usernames or scores.

Array indexes start at 0, not 1 - this catches many beginners out! To access the first item, you use arrayName[0]. The .length property tells you how many items are stored.

Arrays have fixed lengths - if you need more space, you must create a new larger array and copy everything across. Python sidesteps this limitation by using lists instead, which can grow and shrink as needed.

You can loop through arrays easily using FOR loops to process every item. This makes tasks like searching through usernames or calculating averages much simpler than creating separate variables for each piece of data.

Arrays make linear searches straightforward - just loop through each index comparing values until you find what you're looking for. They're also essential for implementing sorting algorithms effectively.

Array Advantage: Instead of creating username1, username2, username3... you can store everything in one array and access it with a simple loop!

9
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Sign up to see the content. It's free!

  • Access to all documents
  • Improve your grades
  • Join milions of students

Subroutines and Scope

Subroutines break large programs into manageable, reusable chunks - they're like mini-programs within your main program. Functions return values after processing (like calculating a square root), whilst procedures execute code but don't return anything.

The main advantages are enormous: you can test each piece separately, multiple programmers can work simultaneously, code can be reused across projects, and maintenance becomes much easier. Instead of hunting through thousands of lines, you just fix the specific subroutine that's causing problems.

Scope defines where variables can be used. Global variables are accessible anywhere in your program, like public information everyone can see. Local variables only exist within their specific subroutine and disappear when that subroutine finishes.

Think of functions as houses with one-way windows - you can see global variables from inside, but outsiders can't see your local variables. This prevents naming conflicts and keeps subroutines self-contained.

Parameters are the inputs you pass to functions - they're listed in the brackets when you define or call the function. They act like local variables within that subroutine.

Best Practice: Use local variables whenever possible to keep your subroutines independent and reusable!

10
of 10
Key Terms Key information Advantages Disadvantages Examples

# Computer Science Notes
## Component 2

Computational thinking

**Algorithm**:

Sign up to see the content. It's free!

  • Access to all documents
  • Improve your grades
  • Join milions of students

Advanced Subroutine Concepts

The power of subroutines really shines in large projects where many programmers collaborate simultaneously. Each person can work on different subroutines without interfering with others, dramatically reducing development time.

Local variables are your secret weapon for creating truly portable subroutines. Since they only exist within their function, you never have to worry about variable name conflicts when reusing code in different projects.

When you write something like sum(a, b), the a and b are called parameters - they define what inputs your function expects. These parameters behave like local variables inside the function.

Global variables can be seen and used from within functions, but good programming practice suggests you shouldn't change them directly from inside subroutines. Use the global keyword in pseudocode when you need to explicitly work with global variables.

Subroutine libraries let you build collections of useful functions that you can import into any project. This is how professional programmers avoid reinventing the wheel - they build up toolkits of proven, tested code over time.

Professional Tip: Treat each subroutine like a black box - if you know what goes in and what comes out, you shouldn't need to worry about the internal details!

Program maintenance becomes infinitely easier when problems are isolated to specific subroutines rather than scattered throughout massive files.

We thought you’d never ask...

What is the Knowunity AI companion?

Our AI Companion is a student-focused AI tool that offers more than just answers. Built on millions of Knowunity resources, it provides relevant information, personalised study plans, quizzes, and content directly in the chat, adapting to your individual learning journey.

Where can I download the Knowunity app?

You can download the app from Google Play Store and Apple App Store.

Is Knowunity really free of charge?

That's right! Enjoy free access to study content, connect with fellow students, and get instant help – all at your fingertips.

Most popular content in Computer Science

9
Computer ScienceComputer Science

GCSE Computer Science Overview

Comprehensive study material for OCR GCSE Computer Science covering key topics such as computer architecture, network security, programming techniques, and ethical considerations. Ideal for exam preparation, this resource includes essential concepts, exam questions, and definitions to enhance understanding and retention.

97,876304
C
Computer ScienceComputer Science

Computer Science quiz

Purpose, Components and functions of CPU. Also von neuman architecture

106384
Computer ScienceComputer Science

GCSE Computer Science Revision

Comprehensive revision notes for OCR GCSE Computer Science Component 1 (J277). Covers key topics including networking, cybersecurity, data compression, computer architecture, and ethical issues. Ideal for exam preparation and understanding core concepts. Access original slides for further details.

104,827150
Computer ScienceComputer Science

GCSE Computer Science // Revision Notes

Concise revision notes for the GCSE OCR computer science specification (J277). Contains all the info needed for paper 1. Paper 2 is in my bio.

104666
C
Computer ScienceComputer Science

computing quiz for

good luck

101250
C
Computer ScienceComputer Science

computer science,geography

this will help you revise for when you are next tested on these questions this will also help you to remember

71941
Computer ScienceComputer Science

GCSE Computer Science Algorithms

Comprehensive overview of algorithms for AQA GCSE Computer Science Paper 1, covering key concepts such as sorting (Bubble Sort, Merge Sort), searching (Linear and Binary Search), and essential programming principles like data types, pseudocode, and flowcharts. Ideal for exam preparation and understanding algorithm efficiency.

1075656
C
Computer ScienceComputer Science

cs ocr

Level up your computer science knowledge with this comprehensive flashcard set designed for grade 11 students. Dive deep into complex concepts and ace your exams!

115260
Computer ScienceComputer Science

AQA GCSE Computer Science Overview

Comprehensive revision notes covering the AQA GCSE Computer Science curriculum, including key topics such as computer memory, cybersecurity, programming concepts, network protocols, and data representation. Ideal for exam preparation and understanding core concepts in computing.

105,360216

Most popular content

9
SociologySociology

Sociology of Education Overview

Explore comprehensive A-Level Sociology notes on the education system, covering key theories, policies, and sociological perspectives. This resource includes insights on marketisation, gender roles, cultural deprivation, and educational inequalities, providing a thorough understanding of how education shapes social stratification and individual achievement. Ideal for exam preparation and in-depth study.

12102,8383,040
SociologySociology

Sociology of Families: Comprehensive Revision

Dive into an extensive overview of family dynamics, perspectives, and patterns in sociology. This resource covers key concepts such as family diversity, gender roles, marriage, and the impact of social policies on family structures. Perfect for A-Level Sociology students preparing for Paper 2.

1273,6372,306
CriminologyCriminology

Criminology: Crime & Punishment Overview

Comprehensive mindmaps covering key concepts in the Crime and Punishment topic for WJEC Criminology Unit 4. This resource includes detailed insights into the Criminal Justice System, crime prevention strategies, sentencing models, and the roles of various agencies. Ideal for A-Level revision, ensuring you grasp essential theories and legislative processes to excel in your exams.

1254,8591,059
SociologySociology

Comprehensive Crime & Deviance Overview

Explore an extensive revision of crime and deviance topics, including theories, types of crime, and the impact of media. This resource covers key concepts such as Marxism, functionalism, gender and crime, and the influence of globalization on criminal behavior. Ideal for students seeking a thorough understanding of criminology and its various theories. Type: Full Topic Revision.

1251,6461,399
C
BiologyBiology

Cell Biology and Cell structure

cell structures

93,2200
English LiteratureEnglish Literature

An Inspector Calls: Character Insights

Explore in-depth analysis and key quotes for characters in J.B. Priestley's 'An Inspector Calls'. This resource covers Gerald Croft, Inspector Goole, Sheila Birling, Mrs. Birling, Eric Birling, and Eva Smith, focusing on themes of class, gender roles, and social responsibility. Ideal for students aiming for Grade 8 and above.

1125,419907
CriminologyCriminology

WJEC Unit 4 Criminology

Criminology unit 4 detailed revision note

127,146125
CriminologyCriminology

Criminology Theories Overview

Explore key criminology theories and their implications on crime and deviance. This comprehensive summary covers biological, psychological, and sociological perspectives, including labelling theory, right realism, and the impact of social campaigns on policy development. Ideal for A-Level criminology students seeking to understand the complexities of criminal behaviour and the factors influencing crime prevention strategies.

129,757210
English LiteratureEnglish Literature

Romeo and Juliet: Key themes

Key Romeo and Juliet themes and analysed quotes

106,700198

Can't find what you're looking for? Explore other subjects.

Students love us — and so will you.

4.6/5App Store
4.7/5Google Play

The app is very easy to use and well designed. I have found everything I was looking for so far and have been able to learn a lot from the presentations! I will definitely use the app for a class assignment! And of course it also helps a lot as an inspiration.

Stefan SiOS user

This app is really great. There are so many study notes and help [...]. My problem subject is French, for example, and the app has so many options for help. Thanks to this app, I have improved my French. I would recommend it to anyone.

Samantha KlichAndroid user

Wow, I am really amazed. I just tried the app because I've seen it advertised many times and was absolutely stunned. This app is THE HELP you want for school and above all, it offers so many things, such as workouts and fact sheets, which have been VERY helpful to me personally.

AnnaiOS user