Computer science - Topic 1 - Problem solving

?

Flowcharts

Flowcharts use different symbols to describe a process and are a type of algorithm. An algorithm is a list of instructions or a set of rules that make something happen or work something out. There are four main symbols used in flowcharts: an oval for start/stop; a rectangle for a process; a rhombus for an input or output and a diamond for a decision that has either a yes or no answer. 

1 of 11

Algorithms

An algorithm is a specific set or rules or instructions that make something happen or work something out. They are either a declarative program or an imperative program; declarative programs outline what the problem is but do not define how it should be solved. The computer works out how to solve the problem but needs to be given rules to follow and certain key facts about the problem. Imperative programs tell the computer exactly how the problem should be solved and have specific instructions in a particular order to produce an output. Either one of these types of programs is made up of constructs. Constructs fit together to make up a program and can be seen as the building blocks of any imperative language as they fit together to make a whole solution. They use the relational operators: >, >=, <, <=, == and the logical operators: AND, OR and NOT. A type of construct is a selection construct - these allow programs to run differently every time they are used by allowing different paths to be taken. Selection constructs use true/false statements. Examples of selection constructs include IF statements (when there is a decision), ELSE statements (when there is an alternate output for a decision) and ELSE IF statements (when there is more than decision). 

2 of 11

Pseudocode

Pseudocode is a structured code like languages that can be used to describe an algorithm. It uses a certain character set to describe the program and is a type of algorithm. The key words of pseudocode always have to be written in capital letters and consist of: SET, IF, ELSE, FOR, RECEIVE, SEND, UNTIL, REPEAT, DISPLAY, KEYBOARD, WHILE, DO and a few more. 

3 of 11

Nested loops

A nested loop is a loop within another loop. When one loop is nested within another, the inside loop will loop every time the outer loop is started. 

4 of 11

Concatenation

Concatenation is the merging or combining of strings and links two or more items of information together. It is often used in programs where a variable needs to be inserted into a string that needs to be sent to the display. For example, if someone inputs two numbers they are different every time and therefore the product of the two numbers is different. The program night wok out the product and want to output "the product of the two numbers is" and the product. Concatenation allows the same sentence to be outputed with the different variable every time the program is run. 

5 of 11

Trace tables and errors

Trace tables are a way of identifying if there are any logic errors in an algorithm. Each column represents a variable or an output and each row represents a value of that variable. There are two main types of errors - logical errors and syntax errors. Logic errors are errors in the algorithm that results in incorrect or unexpected behaviour - the code will still run but the output will not be the expected one. For example, if you use the greater than symbol rather than the less than symbol the program will stil run but instead of outputting the smaller number it will output the larger one. Syntax errors are where there is something wrong with the program and therefore it will not run correctly. For example, in python if you do not use a colon after an if statement the program will not run and come up with an error. 

6 of 11

Bubble sorts

A way of sorting an unorganised list into an organised one is a bubble sort. A bubble sort algorithm goes through a list of data a number of times comparing the two items that are side by side to see which one is out of order. It will keep goin through the list until all of the data is sorted into order. Each time the algorithm goes through the list it is called a "pass". 

7 of 11

Merge sorts

A merge sort is a different way to sort an unordered list into an ordered one. It continually splits the list in half until all the items are individual. Once they are individual they begin to merge back together although this time in order. This then creates a new ordered list.

8 of 11

Binary searches

A binary search is a fast way of searching for an item in an ordered list. It selects the median of the list and decides whether it is either equal to, greater than or less then the search item. If it is equal to then the search ends; if it is more than the search item then the median of the sub-list to the left is found; if it is less than the search item then the median of the sub-list to the right is found. This process continues until either the search item is found or it is determined that it cannot be in the list.

9 of 11

Linear searches

Sometimes known as a "sequential search", a linear search is where the program goes through every item in the list until either the search item is found or every item in the list has been searched. This is a much slower method of searching than a binary search.

10 of 11

Decomposition and abstraction

Decomposition is where you break down larger tasks into smaller problems called sub-programs. This makes it easier to solve as you can solve the sub-programs first and then incorporate them into the main program. Abstraction is where you remove or hide unnecessary details so that only the important points remain. This makes it easier for a program to understand what needs to be solved and avoids confusion.

11 of 11

Comments

No comments have yet been made

Similar Computing resources:

See all Computing resources »See all Programming resources »