OCR GCSE COMPUTER SCIENCE - UNIT 2 REVISION EXAM QUESTIONS AND ANSWERS 2024
Define what is meant by abstraction. Abstraction means removing unnecessary details to focus on the important elements. What is an algorithm? An algorithm is a step-by-step procedure for solving problems. Brainpower Read More Previous Play Next Rewind 10 seconds Move forward 10 seconds Unmute 0:01 / 0:15 Full screen An algorithm can be written and displayed as plain, written text. State two other ways of displaying algorithms. Pseudocode Flow diagrams Define what is meant by the term 'pseudocode'. Pseudocode is similar to a high-level programming language, but does not require exact syntax/indentation to be used. The programmer can concentrate on getting the logic of the program correct before turning it into executable code. Describe how a linear search algorithm works. A linear search algorithms starts at the beginning of a list and moves through item by item until it finds the matching item or reaches the end of the list. Describe the stages of a binary search on a list of items sorted in ascending order. 1. Select the middle item (median). 2. Compare this value with your search criterion. If 3. they are equal then stop. 3. If it is higher, repeat with the right-hand side of the list. 4. Repeat these steps until the search criterion is found or there are no more items in the list to search. A binary search is generally more efficient than a linear search. However, this is not always the case. Explain why using a linear search may be quicker than using a binary search in some circumstances. For a binary search, the data must first be sorted into ascending order. Sorting the data will take time so, for a small number of search items, a linear search might find the search item more quickly. A linear search would be more efficient than a binary search if the item being searched for is the first item in the list. Describe the stages of the insertion sort algorithm as it sorts data into ascending order. 1. Start with the second item and compare it with the first. 2. If it's larger than the first, then leave it in place, but if it's smaller, swap the two numbers. 3. Now check the third number. If it's smaller than the second one, then compare it with the first. 4. If it is smaller than the first, place it in this position by moving the first two numbers along. 5. Repeat this procedure with all the numbers by comparing them with the numbers to the left until a smaller number is found. When it is, place the number in the position to the right of it by moving the others along. The merge sort algorithm divides up a list into smaller sections and then sorts them into order before putting them back together again. Explain the advantage of using this technique. - Each small sub-problem is easier to solve than one large problem. - It is more efficient to combine the solutions than to try to solve the main problem without using any techniques. Explain what is meant by a variable. A variable is a container which is used to store values which can change as the program is running. State how a constant differs from a variable. The value stored in a variable can change during program execution, whereas the content of a constant always stays the same. Variables and constants must be given identifiers which should be consistent throughout the program. State why variables and constants should be given meaningful names. They should be given meaningful names so that anyone reading the code will be given an indication of the types of value they are intended to contain e.g. 'studentAge' rather than just 'X'. Describe what is meant by an array. An array is a data structure that can store multiple items of data, called elements, which are all of the same data type under the same identifier. Explain what is meant by a sub-program. A sub-program is a self-contained sequence of program instructions that performs a specific task and is called whenever it is needed to carry out that task. Describe two advantages to a programmer of using sub-programs. - They make programs shorter. The code only needs to be written once and can be called as many times as needed. - They make testing easier as each section of code only has to be tested once even though it is used many times. Two types of sub-program are functions and procedures. State one difference between these types of sub-programs. A function returns data to the main program but a procedure does not. Describe two advantages for a programmer of writing programs in a high-level language. - It is less time consuming to write and then test the program as the language is similar to a human language. - High-level programs are portable from one machine to another as they are independent of the CPU. Describe two advantages for a programmer of writing programs in a low-level language. - Programs written in low-level language require less memory and execution time. - They allow the programmer to directly control system hardware and are used extensively for programming embedded systems. State the name of the software used to translate a program written in assembly language into machine code. An assembler. Both compilers and interpreters translate high-level program code into machine code. Compare the method of translation used by each. A compile translates the source code into a standalone, machine code program (object code) which can then be executed by the processor. An interpreter translates the high-level code line by line. It is needed each time the program is run. Outline one advantage and one disadvantage of compiler and interpreter. An advantage of a compiler is that the program is translated once only and as a separate process. When it is run, it is already translated into machine code so it is executed more rapidly. A disadvantage is that you cannot change the program without going back to the original source code, editing that and recompiling. An advantage of an interpreter is that when an error is found, the interpreter reports it and stops so the programmer knows where the error has occurred. A disadvantage is that every line has to be translated every time it is executed and therefore it is slower. A programmer is writing software for a new set-top receiver for satellite TV. Explain why the programmer should use a compiler instead of an interpreter to translate the code. The set-top box must process data quickly and so a compiler is used because compiled code runs faster than interpreted code. What is meant by a syntax error? Give an example. A syntax error is when a grammatical rule of the program language is broken. It could be misspelling, e.g. prnit instead of print, or it could be missing brackets or speech marks. Ahmed's friends advised him to use an IDE (integrated development environment). Describe two tools and facilities available in an IDE which can help the programmer to avoid syntax errors. - Autocomplete or word completion. This involves the source code editor predicting a word or phrase that the user wants to type in without the user actually typing it in completely. - Bracket matching highlights matching sets of delimiters such as brackets or quotation marks. It helps the programmer navigate through the code and spot any that do not match, which would cause syntax errors. - Auto-indentation. This feature will automatically indent the next line to the correct level when the return key is pressed. In some languages, indentation is a requirement. An IDE also provides other facilities for programmers. State the purpose or variable tracing. - Variable tracing. This feature allows the programmer to see the values of variables at any stage in the running of the program. State the purpose of breakpoints. - Breakpoints. They are the intentional stopping of the program at specified places so that the programmer can inspect the code and see if the program is functioning as expected up to that point. State the format required for data to be processed by a computer. Binary A file has a size of bits. Calculate the file size in megabytes. bits = / 8 bytes = bytes bytes = / 1000 kilobytes = 9 000 000 kilobytes 9 000 000 kilobytes = 9 000 000 / 1000 megabytes = 9 000 megabytes A file has a size of bits. Calculate the file size in gigabytes. bits = / 8 bytes = bytes bytes = / 1000 kilobytes = 9 000 000 kilobytes 9 000 000 kilobytes = 9 000 000 / 1000 megabytes = 9 000 megabytes 9 000 megabytes = 9 000 / 1000 gigabytes = 9 gigabytes Calculate how many bits there are in a file with a size of 20 megabytes. 20 megabytes = 20 X 1000 kilobytes = 20 000 kilobytes = bytes = bits. Convert the decimal number 199 into an 8-bit binary number. Convert the 8-bit binary number into a decimal number. 151 Add the following 8-bit binary numbers. Explain what is meant by a binary shift. A binary shift is used when a binary number is being multiplied or divided by the powers of 2. Shifts to the left are used for multiplication. Shifts to the right are used for division. A 1 place shift multiplies or divides by 2 power of 1 (2). A 2 place shift multiplies or divides by 2 power of 2 (4). Complete a 2 place left shift on the binary number . State the effect of performing a 2 place right shift on a binary number. The binary number would be divided by 4.
Written for
- Institution
- OCR GCSE COMPUTER SCIENCE
- Course
- OCR GCSE COMPUTER SCIENCE
Document information
- Uploaded on
- December 28, 2023
- Number of pages
- 8
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
ocr gcse computer science unit 2 revision exam
Also available in package deal