Please enable JavaScript.
Coggle requires JavaScript to display documents.
Computer Science C2: Computational Thinking Revision (Algorithms and…
Computer Science C2: Computational Thinking Revision
Problem Solving
Computational Thinking
Abstraction:
Removing all unnecessary information from the information provided
Algorithmic Thinking:
Logical thinking to be able to determine the steps required by a specific algorithm to solve a specific problem
Decomposition:
Breaking down the problem into its constituent parts
Definitions
Inputs:
Data that is provided to the program / algorithm
Outputs:
Data that the program / algorithm should return
Processes:
An action that is performed within the stages of the algorithm
Purpose:
The reason that the algorithm has been constructed / programmed which may affect its execution
Structuring a Program
Using
meaningful identifiers
for data to allow the program to be easily understood by others
The use of
subroutines
will allow for the abstraction of the code to remain apparent, and makes maintenance / bug fixing far easier
Algorithms and Programming Constructs
Methods of developing an algorithm
Flowcharts
- different shaped boxes connected by arrows to show the
flow
of the program and its data. The shapes of the boxes change their functions
Pseudocode
- programming-type statements that bear no specific semblance of any programming language
Flowchart Symbols
Pseudocode Statements
set variable = "data"
set variable = input("user prompt goes here")
output variable
for i = 0 to 3 // code here // next i
while variable = false // set variable = input("user prompt here") // endwhile
do // set variable = input("user prompt here") // while variable == true
if variable == 1 // output "1" // else if variable == 2 // output 2 // else // output "0" // end if
Handling Arrays
set name[3,5]
set name[1, 1] = "data"
set name[3]
output name[3,1]
String Manipulation
variable.length
variable.subString(start, noOfCharacters)
Programming Constructs
Sequence
- the order in which the instructions need to occur in an algorithm
Selection
- allows for the program to have multiple different "paths", this step often relies on a question and a condition
Repetition
- the repeating of instructions multiple times, often uses a loop. Also called iteration
Identifiers and Annotation
Self-documenting identifiers
- names for variables that make sense to anyone who is reading the code
Annotation
- comments written in plain English that the compiler doesn't interpret. Helps both the programmer and other people understand the code
Object Orientated Programming (OOP)
Components of...
Objects
- computer representation of a real-world thing
Classes
- a template for an object which specifies attributes and methods to be applied to that object
Methods
- subroutines belonging to a particular class that can be run on any object created from that class
Attributes
- variables that belong to a particular class
Variable Types
Global Variables - variables available to the whole program
Local Variables - variables that are only available to a specific subroutine or class
Sorting Algorithms
Merge Sort
Splits the array in half until all all arrays are 1 long then merges them until the list is sorted (Animation here is fantastic:
https://visualgo.net/bn/sorting
)
Bubble Sort
Works as the name implies - the largest values float to the top of / the end of the array (
https://www.programiz.com/dsa/bubble-sort
)
Searching Algorithms
Linear Search
Iterates through the whole array from position 0 to 'n' and looks for the target value. Doesn't need the data to be sorted
Binary Search
Halves the list and takes the highest value of the left list. If value is too high it discards the right half, if value is too low it discards the left half. This repeats until the number is found - requires the data to be sorted first however.
Testing and Evaluation
Normal Data - data within the parameters required
Erroneous data - data outside the requested parameters
Boundary data - data on the upper and lower limits of the parameters required
Programming Languages
HTML
HTML Tags
<html></html>
Lets the browser know that the following code is HTML
<head></head>
Allows metadata about the website to be stored
<title></title>
Changes the title of the website
<body></body>
Indicates the start and end of the contents of the webpage
<h1></h1> (can go down to h7)
Changes the size of the text inside the tags (can be used for headers)
<p></p>
Indicates a paragraph
<ul></ul>
Creates an unordered list
<ol></ol>
Creates an ordered list
<blockquote></blockquote>
Selects a piece of text to be a quote
<hr></hr>
Creates a horizontal line in the web page, used to split it up
<img></img>
Links an image into the page
<a></a>
Links to an external site, file or email
<em></em>
Emphasises the text inside the tag (italics)
<strong></strong>
Makes the text in the tags bold
Stands for Hypertext Markup Language which can create simple web pages
Exemplar multi-page web page : file:///C:/Users/Ethan/Desktop/First%20Page.html (copy and paste link)
Greenfoot