H446 - Paper 1 PG ONLINE
Understand the term "algorithm"
Learn how to write algorithms using pseudocode
Learn how to interpret algorithms and determine their purpose
An algorithm is a set of instructions to solve a problem or complete a well-defined task in a finite number of steps.Examples:
Recipe for chocolate cake
Knitting pattern
Examples of computational algorithms are numerous. Algorithms are used to solve various real-world problems, many of which remain unsolved today.
Routing Problems:
Routing packets of data around the Internet by the shortest route
Finding the shortest route for a salesman
Timetabling for commercial aircraft crews
Other Applications:
Searching information on the Internet or a database
Encrypting communications
Sorting large amounts of data
Writing a compiler to translate high-level languages to machine code
Engage in group discussions to create a list of properties.
Clear and precisely stated steps that produce correct output for valid inputs.
Should allow for invalid inputs.
Must always terminate at some point.
Should perform tasks efficiently with minimal steps.
Designed to be understandable and modifiable by others.
Pseudocode bridges English statements and program code, and is mostly independent of specific programming languages.
Clarity: Should be clear and easy to read.
Consistency: Maintain a consistent style throughout.
Simplicity: Avoid overcomplication.
No Strict Syntax: Common programming constructs can be used.
One Statement per Line: Each line should represent a single action or decision.
Use Indentation: Represent structure and hierarchy of the code.
Goal: Help understand the algorithm's flow without syntax confusion.
Vary from simple and slow (e.g., insertion sort) to complex and fast (e.g., merge sort). A fast sort may sort ten million numbers in 20 minutes, while an inefficient one may take over a month.
Simple sorting method: compares adjacent items and swaps if larger. On the first pass, the largest item "bubbles" to the end of the list.
Try Task 1 on Worksheet 2 PG.ONLINE.
Code example provided:names = ["Jane", "Fred", "Vicky", "Eric", "Bella", "Millie"]Looping mechanism controlling passes and comparisons.
Given names: ["Henry", "Steve", "Julie", "Ava", "Tom", "Olivia"]. After one pass, determine the order and number of passes needed to sort. Write an algorithm to swap two items.
Common algorithms include linear search (examines every item) and binary search (divides the search area). Binary search requires sorted order, applicable to either alphabetic or numeric items.
Low and high are indices of first and last items in the list.
While loop for finding a value: condition checks and updates.
Guess a number between 1 and 100; partner gives feedback on guess. Discuss how many guesses needed and contrast with a sequential search.
Discuss efficiency of algorithms and ways to enhance program quality.
Use comments for documentation. Standard identifiers, proper indentation, and modular structures are recommended.
Following through algorithms can be challenging; use a trace table to track variable changes.
Example code shown for tracing: starts with values and evaluates conditions. Track changes in the table for each iteration.
Determine what the traced algorithm calculates based on inputs and changes.
Attempt questions in Task 2 of the worksheet.
Importance of pseudocode in designing algorithms. Understanding sorting and searching as key operations in data processing. Trace tables are vital for algorithm evaluation.
Copyright 2016 PG Online Limited on unit contents and restrictions on use.
OCR A Level CS - Software development T2 Writing and following algorithms
H446 - Paper 1 PG ONLINE
Understand the term "algorithm"
Learn how to write algorithms using pseudocode
Learn how to interpret algorithms and determine their purpose
An algorithm is a set of instructions to solve a problem or complete a well-defined task in a finite number of steps.Examples:
Recipe for chocolate cake
Knitting pattern
Examples of computational algorithms are numerous. Algorithms are used to solve various real-world problems, many of which remain unsolved today.
Routing Problems:
Routing packets of data around the Internet by the shortest route
Finding the shortest route for a salesman
Timetabling for commercial aircraft crews
Other Applications:
Searching information on the Internet or a database
Encrypting communications
Sorting large amounts of data
Writing a compiler to translate high-level languages to machine code
Engage in group discussions to create a list of properties.
Clear and precisely stated steps that produce correct output for valid inputs.
Should allow for invalid inputs.
Must always terminate at some point.
Should perform tasks efficiently with minimal steps.
Designed to be understandable and modifiable by others.
Pseudocode bridges English statements and program code, and is mostly independent of specific programming languages.
Clarity: Should be clear and easy to read.
Consistency: Maintain a consistent style throughout.
Simplicity: Avoid overcomplication.
No Strict Syntax: Common programming constructs can be used.
One Statement per Line: Each line should represent a single action or decision.
Use Indentation: Represent structure and hierarchy of the code.
Goal: Help understand the algorithm's flow without syntax confusion.
Vary from simple and slow (e.g., insertion sort) to complex and fast (e.g., merge sort). A fast sort may sort ten million numbers in 20 minutes, while an inefficient one may take over a month.
Simple sorting method: compares adjacent items and swaps if larger. On the first pass, the largest item "bubbles" to the end of the list.
Try Task 1 on Worksheet 2 PG.ONLINE.
Code example provided:names = ["Jane", "Fred", "Vicky", "Eric", "Bella", "Millie"]Looping mechanism controlling passes and comparisons.
Given names: ["Henry", "Steve", "Julie", "Ava", "Tom", "Olivia"]. After one pass, determine the order and number of passes needed to sort. Write an algorithm to swap two items.
Common algorithms include linear search (examines every item) and binary search (divides the search area). Binary search requires sorted order, applicable to either alphabetic or numeric items.
Low and high are indices of first and last items in the list.
While loop for finding a value: condition checks and updates.
Guess a number between 1 and 100; partner gives feedback on guess. Discuss how many guesses needed and contrast with a sequential search.
Discuss efficiency of algorithms and ways to enhance program quality.
Use comments for documentation. Standard identifiers, proper indentation, and modular structures are recommended.
Following through algorithms can be challenging; use a trace table to track variable changes.
Example code shown for tracing: starts with values and evaluates conditions. Track changes in the table for each iteration.
Determine what the traced algorithm calculates based on inputs and changes.
Attempt questions in Task 2 of the worksheet.
Importance of pseudocode in designing algorithms. Understanding sorting and searching as key operations in data processing. Trace tables are vital for algorithm evaluation.
Copyright © 2016 PG Online Limited on unit contents and restrictions on use.