Curso
IGCSE (9-1) Computer Science
Notes
Módulos (7)
-
Sem título
Chapter 1: Problem Solving 1.1 Algorithms 1.1.1 An algorithm is a precise method for solving a problem. Algorithms can be displayed as written description, flowcharts and in pseudo-code. Written descriptions: Simplest way of expressing an algorithm. E.g. Fill Kettle with water. Turn on the kettle. Place coffee in the cup. Flowcharts: Can be used to represent an algorithm graphically. They provide a more visual display. Pseudo-code: A structured, code like language that can be used to describe an algorithm. E.g. SEND ‘Please enter the first number.’ TO DISPLAY RECEIVE first number FROM KEYBOARD……etc. Variable: A ‘container’ used to store data. Values stored are not fixed. Identifier: A unique name given to a variable or a constant. Constant: A ‘container’ that holds a value that never changes. They have unique identifiers. Arithmetic operator: An operator that performs a calculation on two numbers. 1.1.2 Construct: A component from which something is built. Letters and numbers are the constructs we use. Selection: A construct that allows a choice to be made between different alternatives. Represented using an IF….THEN….ELSE statement. This statement allows a choice to be made between two alternatives. Relational operators are also used to compare two values. Nested selection: consists of one or more IF statements placed inside each other. Two possible courses of action. Iteration: A construct that means the repetition of a process. An action is repeated until there is a desired outcome or a condition is met. Also known as a loop. Definite iteration: Used when the number of iterations, or turns of the loop, is known in advance. It can be set to as many turns as you want. It is count controlled. Indefinite iteration: used when the number of iterations is not known before the loop is started. The iterations stop when a specified condition is met. It is condition controlled. Logical operator: A boolean operator using AND, OR and NOT. Nested loop: A loop that runs inside another loop. The inner one executes all of its instructions for each of the outer loop. Sequence: An ordered set of instructions. Concatenation: The linking together of two or more items of information. 1.1.3,4,5,6 Purpose of an algorithm: When you look at an algorithm, expressed either in pseudo-code or as a flowchart, it is sometimes easy to see its purpose. A good way to follow the reasoning behind an algorithm and also to find any logic errors, is to use some sample data and check if the output is what you expect. Logic error: An error is an algorithm that results in incorrect or unexpected behaviour. Trace table: A technique used to identify any logic errors in algorithms. Each column represents a variable or output and each row a value of that variable. There are three types of error in computer programs: Syntax errors occur when algorithms are being converted into program code. Runtime errors occur when the program is executed. Logic errors are errors in the design of algorithms. Tracing the value of a variable on an algorithm helps to identify logic errors. Understanding the order of precedence of arithmetic operators and the significance of brackets will help you to avoid making logic errors. 1.1.7,8,9 Arrays: An organised collection of related values that share a single identifier. All sorting and searching algorithms work on lists of data. Bubble sort: Uses an algorithm design that does not include any techniques to improve performance. When data is sorted, different items must be compared with each other and moved so that they are in ether ascending or descending order. Starts at one end of the list and compares each neighbouring number. If they are in the wrong order they are swapped and keeps doing this until the list is in either ascending or descending order. This process is repeated until there are no swaps left to be done during a pass. Merge Sort: A sorting algorithm that divides a...
-
Sem título
Chapter 2: Programming 2.1 Develop Code A program is an algorithm that has been converted into program code so that it can be executed by a computer. A well-written algorithm should be free of logical errors and easy to code in any high-level language. Syntax error: An error that occurs when a rule of the programming language is broken. When algorithms are converted into programs the computer needs to be told what type of data is stored in each variable. Every programming language has a number of built-in data types. Data type: Specifies what kind of data it can hold. Common data types are integer, real, Boolean and character. The data type of value determines the operations that can be performed upon it. Variable initialisation: When a variable is declared, the computer allocates it a location in memory. Initially, this location is empty, so before a variable can be used it has to be given a value. Once a variable has been initialised an assignment statement is used to change its value. Assignment statement: The SET….TO command is used to initialise variables in pseudocode. Type coercion: The data type variable gets changed during program execution. The process of converting the value stored in a variable from one data type to another. Command sequence: A set of instructions that the computer executes one after another in order. Usually combined with loops ad selection statements. Selection: Used to create a branch in a program. The computer selects which branch to follow based on the outcome of a condition. Loops: Another name for an iteration. Used to make a computer repeat a set of instructions more than once. The four basic data types are integer, float/real, Boolean and character. Variable and type decelerations, command sequences, selection and iteration are four of the structural components of a program. 2.2 Making programs easy to read Techniques used to make programs easy to read and understand: Technique Description Comments Used to explain what each part of the program does. Descriptive names Using descriptive identifiers for variables, constants and subprograms help make their purpose clear. Indentation Makes it easier to see where each block of code starts and finishes. Getting the indentation wrong can result in the program not running. White space Adding blank lines between different blocks of code makes them stand out. Proving readable code makes it easier to understand what a program does and how it does it. 2.3 Strings String: A sequence of characters. They can be letters, numbers, symbols, punctuation marks or spaces. String indexing: Each character in a string has an index number, with the first character at position 0. You can use the index to reference individual characters in a string. Length: LENGTH function used to find the number of characters in a string. Function: A subprogram that performs a specific task and can be used at any point in the program. String traversal: Using a loop to cycle through each character in a string. Can use a FOR loop. Concatenation: Involves joining two or more items of information together, Concatenating two strings produces a new string object. Type conversion: Performed when a string and a non-string are joined together. The computer converts the non-string into a string before joining the two strings together. Slicing: The process of extracting part of a string. String formatting: Used to control the way text is displayed on the screen. 2.4 Data Structures Data structure: An organised collection of related elements. Arrays and records are two common data structures used in programming. One-dimensional arrays: A list of elements, each of which has a unique index value representing its position in the list. Two-dimensional arrays: A matrix of rows and columns resembling a table. Two indices are used, one to reference the rows and the other the columns. All the elements of a two-dimensional array share the same data type. All the elements in an array have the...
-
Sem título
Chapter 3: Data 3.1 Binary Binary: Information represented by only two values. There are no communication errors or misunderstandings because there are no small differences. It is needed to represent data and program instruction because of how computers work. A system with separate states is said to be digital and if there are two states it is binary. Digital: Information represented by certain fixed values. A system such as this, where there is a continuous range between two values, is said to be analogue. Analogue: Using signals or information represented by a continuously variable quantity. Representing information There are only two digits, 1 and 0, but to represent the symbols in text there must be at least 52 separate items of information - 26 lower-case and 26 upper-case letters. In a similar way, the two binary digits (bits) can be combined into groups. Binary digits: The smallest unit of data that is represented in a computer. It has a single binary value, either 1 or 0. Number systems Binary is a number system based on two digits, 0 and 1. The difference is that the denary system works in powers of 10, whereas the binary system uses powers of 2. Denary system Every digit has a value and the one to the left has a value 10 times higher than the one to the right. Binary system The binary system has a similar place value but they increase by powers of 2. Byte: The basic combination of bits used to represent an item of information. A byte typically consists of 8 bits. Binary arithmetic Binary numbers can be manipulated in the same way as denary ones. Denary addition When addition is performed n denary, a ‘carry-over’ is used if the result is greater than 9. Binary addition works int he same way but a ‘carry-over’ is needed if the result is greater than 1. Binary addition We are adding eight-bit numbers and this has caused a problem. All eight bits have been used and the 1 that was carried over in the last column has nowhere to go - it has been carried out. Therefore the result of the calculation would be wrong. This is called an overflow error. This condition occurs when a calculation produces a result that is greater than the computer can deal with or store. The processor is informed that an error has occurred. Signed and unsigned numbers When an integer is indicated as being positive or negative it is described as being signed. Sign and magnitude In a multiple-bit binary number, the left-most it, the one with the greatest value, is called the most significant bit (MSB). We can use this to represent signed integers. Two’s complement The most common method used to represent signed integers in modern computers is two’s complement. This method works on the principle above-the result of any number added to its negative equivalent should be zero.
-
Sem título
Computers 4.1 Machines and computational modelling The input-process-output-model Input: To enter data into a computer. Process: To change the meaning or format of some data. Output: To display or output data that has been processed (or has been stored). A computer is a machine that takes some kind of input from its surroundings, processes the input according to given rules, and provide some kind of output. Computational models: Sequential: One in which instructions are executed one after another. There may be branches in the program, but the general principle is that each instruction follows on from the previous one. Parallel: One in which each program instruction is executed simultaneously on multiple processors in order to get the results faster. Using multi-cores in processors is an example of parallel computing. It is by using parallel processing that super computers are getting faster and faster. Multi-agent: one in which computer systems co-operate and co-ordinate with other agents to achieve their goals. Swarm robots are examples of multi-agents. 4.2 Hardware Stored programs: the von Neumann model Von Neumann architecture: Computer design in which the program is stored in memory with the data. Central processing Unit (CPU): hardware device that carries out the processing in a computer. Random-access memory (RAM): A temporary store for data and instructions. Bus: A group of connections between devices in a computer Fetch-decode-execute cycle: Sequence of steps carried out repeatedly by a CPU. Hardware components of a computer system RAM and ROM Writing: When the CPU sends data to memory to be stored at a given address. Reading: When the CPU retrieves the data stored at a given address. Memory address: A number that uniquely identifies a (memory) storage location. RAM is described as volatile (memory that is erased when the power is turned off). Read-only memory (ROM): Memory that cannot be altered and is not lost when the power is turned off. Is non-volatile (memory that is not lost when the power is turned off). Cache memory Third kind of memory. Small amount of fast, expensive memory that is used in-between two devices that communicate at different speeds. Cache: memory used to make up for the difference in speed between two internal components. Fetch-decode-execute: In detail Arithmetic/logic unit (ALU): The part of the CPU that performs calculations and logic operations. Register: A storage location inside the CPU used to hold an instruction, an address or other single item of data. Control unit: The part of the CPU that organises the actions of the other parts of the CPU. Clock: An electronic device inside a CPU that ‘ticks’ at regular intervals and is used to synchronise the actions of the other parts of the CPU. Secondary storage: Any kind of permanent storage to which the contents ROM/RAM are copied (usually a hard disk, optical or solid-state device). Magnetic storage: Secondary storage that works by magnetising parts of a substance as north and south poles to represent binary 1s and 0s. Optical storage: Secondary storage that works using differences in light reflection from a material. Solid-state storage: Secondary storage that works by storing charge. Cloud storage: Secondary storage often belonging to a third party, that is accessed via a network, usually the internet, and do is not in the same physical place as the machine’s RAM/ROM. Files stored ‘in the cloud’ can be accessed from anywhere via an internet connection. Virtualisation: Any process that hides the true physical nature of a computing resource, making it look different, usually to simplify the way it is accessed. Embedded systems: Are cheap, low-power computers that are dedicated to a specific task. 4.3 Logic Truth tables: A table showing all possible combinations of the inputs and outputs of an operator. Boolean: Something that can take only the values True or False; named after English...
-
Sem título
Chapter 5: Communication and the internet 5.1 Networks Network: An arrangement of computers and other devices connected together to share resources and data. Why are networks used? To access shared files among several users To download data or updates to computer programs To access the internet To communicate with each other Types of network Local area network (LAN): A network that covers a relatively small geographical area, often a single site. Wireless local area network (WLAN): A local area network in which connected devices use high frequency radio waves to communicate. Wide area network (WAN): A network that covers a large geographical area. It connects together two or more LANs and is usually under collective ownership. The largest wide area network is the internet. Client-server network: A network that has at least one server to provide services to the client computers. Peer-to-peer network: A network that doesn’t have any centralised servers. Each computer in the network can act as client and server. Network topologies: Describes how the devices on a network are connected together. Bus topology Advantages Disadvantages Relatively cheap to install since only one cable is needed Whole network will fail if the cable Is cut or damaged Easy to add extra network devices Can be difficult to identify where a fault is on the cable Ring topology Advantages Disadvantages Adding extra devices does not affect the performance of the network Whole network will fail if the cable is cut or damaged or a device on the network fails Easy to add extra networks Can be difficult to identify where a fault is on the network. Star topology Advantages Disadvantages A damaged cable will stop the whole network from working, just the network device connected to it If the hub or switch fails then the whole network fails Easy to locate faults because they will normaly only involve one device Expensive to install due to amount of cable needed and the hub or switch Internet: A worldwide system of interconnected networks that enables information to be exchanged and shared. Mesh topology Advantages Disadvantages Very fault tolerant, especially in the case of a fully connected mesh network — if one device fails, messages can be rerouted Difficult and expensive to install wire mesh networks In a wirless mesh network each node extends the range of the network Can be difficult to manage due to number of connections within the network Communication media: The means by which data is transmitted between devices on a network. Coaxial cable, fibre-optic cable and microwaves are all forms of communication media. Wired connectivity Advantages Disadvantages Faster than wireless connectivity Expensive to install and reconfigure Not easy to intercept or eavesdrop on data Requires many cables at a premises Less susceptible to interference that wireless connectivity Wireless connectivity Advantages Disadvantages No need for a cable to connect device or to the internet Data transmission speeds can be slower than wired connectivity Allows users to use their own device Interference from other wireless device can adversely affect performance A wider range of devices can communicate with each other/a network because it is not dependant on having the correct table. Walls and other physical objects can adversely affect performance Network data speed Unit Abbreviation Bits per second Bits per second bps 1 Kilobits per second kbps 1,000 Megabits per second Mbps 1,000,000 Gigabits per second Gbps 1,000,000,000 Protocols: A set of rules that govern how communications on a network should be formatted and what data they should include. Email protocols Simple Mail Transfer Protocol (SMTP): Used when sending email through the internet. Post Office Protocol, Version 3 (POP3): Current version of Post Office Protocol that is used for retrieving email from an email server. Internet Message Access Protocol (IMAP): Allows emails to...
-
Sem título
Chapter 6: The bigger picture 6.1 Computing and the environment Some of the materials used in the manufacture of computer components are non-renewable and in short supply. Others are dangerous and pose a risk to human health. The Restriction of Hazardous Substances (RoHS) Directive restrict the use of hazardous materials in computing technology, forcing producers to find more environmentally friendly alternatives. Computing technology consumes huge amounts of energy. Data centres are on of the worst culprits. Energy efficiency measures and use of renewable energy can significantly reduce the carbon footprint of computing technology. There is a possible health risk, especially for children, from exposure to the electromagnetic fields generated by wireless devices, such as smartwatches and smart clothing. Unregulated disposal of e-waste in landfill sites poses a significant threat to the environment. The Waste Electrical and Electronic Equipment (WEEE) regulations set targets for responsible recycling of e-waste. Computing technology is helping to preserve the environment in a number of ways, including monitoring and modelling climate change, conservation and smart energy. 6.2 Privacy Computing technology enables organisations to gather, store and analyse vast quantities of personal information about the people they come into contact with. Individuals give away all sorts of personal information about themselves online.
-
Sem título
Edexcel GCSE Computer Science Question 1 What is an algorithm? An algorithm is a set of specific steps for solving a category of problems. Question 2 Briefly describe the following constructs: Sequence: A sequence is a linear progression where one task is performed sequentially after another. Selection: IF–THEN–ELSE is a decision (selection) in which a choice is made between two alternative courses of action. Iteration: WHILE is a loop (repetition) with a simple conditional test at its beginning. Question 3 Why would a computer programmer want to use a flowchart during a design process? Solutions to simple programming exercises can be often designed and implemented by just sitting down and writing code. It is, however, extremely difficult to write solutions to complex problems using this approach and they are impossible to debug. For these reasons a structured design process is preferred. Question 5 What is a variable? In computer programming, a variable is a storage location and name (called an identifier) which contains some known or unknown quantity of information, a value. Question 6 What is Decomposition? To divide a problem into smaller parts to solve easily Question 7 What is a high-level programming language? This makes the coding easier to both read and write. Enables a programmer to write programs that are independent and is closer to human languages and further from machine languages. Question 8 Describe the main benefits to a programmer of using a high-level programming language. It makes it much easier to code and check as the language is easy to understand. Question 9 Describe the difference between an interpreter and a compiler. Compiler converts the whole program in one go on the other hand Interpreter converts the program by taking a single line at a time. Compilers were the first sort of translator program to be developed. The idea is simple – the program is written in a high-level language and then the compiler translates it. You can then run the result. An interpreter is also a program that translates a high-level language into a low-level language, but it does it when the program is actually run. You can write the program using a text editor and then simply instruct the interpreter to run the program. Question 10 What is a comment? In computer programming, a comment is used to annotate code. It does not run. Question 11 Describe the main reasons why programmers would wish to annotate or add comments to their code. Comments are usually added with the purpose of making the source code easier to understand. Comments have a wide range of potential uses from adding descriptions of what is happening to generating external documentation. Question 12 What does this function return? <code> list(range(10)) </code>>>> list(range(10)) It would return a range of numbers till 10 0 1 2 3 4 5 6 7 8 9 Question 13 What is a runtime error? Runtime errors occur whenever the program instructs the computer to carry out an operation that it is either not designed to do or reluctant to do. As a consequence of the huge number of situations that can be categorized within this area, there is equally a huge number of ways to write programs that cause runtime errors. Question 14 Explain the following statement: ‘Run-time Error 339 component MCI32.OCX or one of its dependencies is not correctly registered: a file is missing or invalid.’ There is a runtime error due to a missing file or piece of code. Question 15 What is meant by a logical error? The program will run successfully; however, it will not behave in the manner it was designed to. In other words, it will simply produce incorrect results. Question 16 A programmer is developing a new program. Describe the types of errors he or she should check for. • Syntax errors: Or as they are sometimes known, format errors, are a big problem for those who are new to programming. A syntax error occurs when the programmer fails to obey, usually through...