Docsity

OCR A Level Computer Science Paper 2, Exams of Computer Science

Toggle sidebar
bg1
OCR A Level Computer Science Paper 2
Abstraction - ANS the process of removing any excessive details from a problem, arriving at a
representation of said problem that consists only of its key features.
Representional Abstraction - ANS Analysing what is relevant to a given scenario and simplifying a
problem based on this information
Abstraction by Generalisation - ANS Grouping together similarities within a problem to identify what
kind of problem it is. This allows different problems to be categorised as being a particular type, and
solved using a common solution.
Data Abstraction - ANS Details about how data is being stored are hidden. Therefore programmers can
make use of abstract data structures such as stacks and queues without worrying about how they are
implemented.
Procedural Abstraction - ANS Programmers can perform functions (such as pushing and popping items
to and from stacks) without having any knowledge about the code used to implement this.
Abstraction Levels - ANS Higher levels are closer to the user (e.g. providing a UI for them) whereas the
lowest levels are further away (e.g. execution of machine code)
What is the purpose of abstraction in systems and models? - ANS It allows non-experts to utilize
systems/models by hiding complex or irrelevant information.
How does abstraction contribute to efficient software design? - ANS It enables programmers to focus on
essential elements, reducing project time by eliminating unnecessary details.
What are low-level programming languages? - ANS Languages like machine code that directly interact
with computers but are harder to write due to specific binary codes.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download OCR A Level Computer Science Paper 2 and more Exams Computer Science in PDF only on Docsity!

OCR A Level Computer Science Paper 2

Abstraction - ANS the process of removing any excessive details from a problem, arriving at a representation of said problem that consists only of its key features. Representional Abstraction - ANS Analysing what is relevant to a given scenario and simplifying a problem based on this information Abstraction by Generalisation - ANS Grouping together similarities within a problem to identify what kind of problem it is. This allows different problems to be categorised as being a particular type, and solved using a common solution. Data Abstraction - ANS Details about how data is being stored are hidden. Therefore programmers can make use of abstract data structures such as stacks and queues without worrying about how they are implemented. Procedural Abstraction - ANS Programmers can perform functions (such as pushing and popping items to and from stacks) without having any knowledge about the code used to implement this. Abstraction Levels - ANS Higher levels are closer to the user (e.g. providing a UI for them) whereas the lowest levels are further away (e.g. execution of machine code) What is the purpose of abstraction in systems and models? - ANS It allows non-experts to utilize systems/models by hiding complex or irrelevant information. How does abstraction contribute to efficient software design? - ANS It enables programmers to focus on essential elements, reducing project time by eliminating unnecessary details. What are low-level programming languages? - ANS Languages like machine code that directly interact with computers but are harder to write due to specific binary codes.

What are high-level programming languages known for? - ANS Providing an abstraction for machine code, making development easier with syntax similar to natural language. What is the TCP/IP model's purpose? - ANS It serves as an abstraction for network functions, divided into four layers to simplify understanding and communication. Why is compatibility between layers crucial in the TCP/IP model? - ANS To ensure smooth communication, standards are necessary to allow each layer to function independently while hiding details of other layers. What is a standard in the context of hardware or software? - ANS A set of specifications agreed upon by academic and industry communities to ensure compatibility and functionality. Abstraction vs Reality - ANS Real-world entities can be represented using computational structures, such as tables and databases. Real-world values will often be stored as variables. Thinking Ahead - ANS allows developers to consider problems or difficulties that may arise when the software is used. How is Thinking Ahead Used? - ANS consideration of what outputs are required of the solution, and identify the inputs required and how these need to be processed to achieve the outputs after. Satisfied Preconditions - ANS a subroutine can safely expect the arguments passed to meet certain criteria. Preconditions in Documentation - ANS For example, the factorial function, which can only be used with positive numbers. Rather than checking the arguments, the documentation accompanying this function will specify this.

The Goal of Stepwise Refinement - ANS to keep splitting problems into subproblems until each subproblem is a single task, ideally a self-contained module or subroutine. Why is the order of operations important in programming? - ANS Inputs may need validation before being passed to subroutines. Some subroutines require data from others before execution. How can executing multiple subroutines simultaneously benefit a program? - ANS can increase program efficiency. Provide an example illustrating the importance of order in programming. - ANS In a fast food delivery app, users must confirm location before selecting food and confirm order before paying. What is a Decision? - ANS a result reached after some consideration. How do we simplify the decision-making process? - ANS we begin by trying to limit the possible solutions we can pick from, then identify any possible future decision points to gather information about our options. Conditions that Affect Outcomes - ANS What is most effective, what is more convenient, and is the option reasonable? What is the purpose of decisions in programming? - ANS Decisions determine how different parts of the program are completed and lead to different routes through the program. How can decisions affect the flow of a program in a runner game? - ANS Decisions in a runner game, such as choosing between an endless mode or level-based mode, result in different outcomes and routes through the program.

Why is it important to think logically when designing programs? - ANS Thinking logically helps identify where user decisions are needed in the program and plan out the different outcomes that will lead to varied routes through the program. Concurrent Thinking - ANS built upon the idea of concurrent processing. It is the process of completing more than one task at a time. Concurrent Processing - ANS different tasks are given slices of processor time, to give the illusion of tasks being performed at the same time. Benefits of Concurrent Processing - ANS 1. The number of tasks completed in a given time is increased.

  1. Less time is wasted waiting for an input or user interaction, as other tasks can be completed. Drawbacks of Concurrent Processing - ANS 1. It can take longer to complete when large numbers of users or tasks are involved as processes cannot be completed at once.
  2. There is an overhead in coordinating and switching between processes, which reduces throughput (a measure of how many units of information a system can process in a given amount of time).
  3. Not all tasks are suited to being broken up and performed concurrently. Sequence - ANS Code is executed line-by-line and top-to-bottom. Selection - ANS A certain block of code is run if a specific condition is met (using IF statements). This is also known as Branching. Iteration - ANS A certain block of code is run over and over until a certain condition is met (using FOR or WHILE loops) Count-Controlled - ANS Iteration is repeated a given number of times.

Disadvantages of Global Variables - ANS Easy to unintentionally overwrite and edit. Require more memory than local variables. Difference between Global and Local Variables - ANS Global variables are not deleted when the program terminates, while local variables are deleted when the subroutine is completed. Modularity - ANS used to split large, complex programs into smaller, self-contained modules. Procedure - ANS a named block of code that performs a specific task, without having to return a value. Procedures can return multiple values (if they chose to). Procedures are usually given data as parameters for manipulation. Function - ANS a named block of code that also performs a specific task, but it returns a value. A function will only ever return a single value. Functions make use of local variables. Parameter Passing by Value - ANS the parameter is basically treated as a local variable. A copy of it is passed into the subroutine and discarded at the end. Therefore its value outside of the subroutine is not affected. Parameter Passing by Reference - ANS the address of the parameter is given to the subroutine, so the value of the parameter will be updated at the given address. What is an Integrated Development Environment (IDE)? - ANS An IDE is a program that provides a set of tools that make it easier to write, develop, and debug code. Name some examples of Integrated Development Environments (IDEs). - ANS Examples of IDEs are PyCharm, IDLE, and Microsoft Visual Studio. What is the purpose of the 'Stepping' feature in an IDE? - ANS Stepping allows you to monitor the effect of each individual line of code by executing one line at a time.

What is the 'Variable watch' feature in an IDE used for? - ANS Variable watch observes the contents of a variable change in real-time through the execution of a program. Sometimes used to pinpoint errors. How does the 'Breakpoint' feature in an IDE help developers? - ANS Breakpoint allows users to set a point in the program where it will stop. It can be set on a condition or on a specific line. This can help to pinpoint where an error is occurring. What is the purpose of the 'Source code editor' in an IDE? - ANS Source code editor is a basic text editor, enhanced with autocompletion, indentation, and syntax highlighting. What do debugging tools in an IDE provide? - ANS Some IDEs provide a run-time detection of errors, with a guide as to where in the code they are likely to have occurred. Class (OOP) - ANS a template for an object, defining the state and behaviour of said object. State (OOP) - ANS given by attributes which give an object's properties. Behaviour (OOP) - ANS the methods associated with a class, describing the actions it can perform. Instantiation - ANS An object is an instance of a class, and a class can be used to create multiple objects with the same attributes and methods. What does encapsulation refer to in OOP? - ANS In OOP, encapsulation is the process of declaring attributes as private and allowing them to be altered only by public methods. How does encapsulation relate to information hiding? - ANS Encapsulation in OOP implements the principle of information hiding by protecting data from being accidentally edited by other parts of the program.

Why is problem decomposition important in programming? - ANS It allows for the identification of subproblems, utilisation of pre-coded modules, easier project management, parallel development, and efficient debugging. Why does problem decomposition make testing easier? - ANS because testing can only be carried out after the entire application has been produced unless decomposition is used. What are the three main parts of the Divide and Conquer technique? - ANS Divide, Conquer, Merge How is the problem divided in the Divide and Conquer technique? - ANS By halving the size of the problem with each iteration What happens in the 'Conquer' step of Divide and Conquer? - ANS Each subproblem is solved, often recursively What is the purpose of the 'Merge' step in Divide and Conquer? - ANS To combine the solutions of each subproblem into one solution In which algorithms is Divide and Conquer used? - ANS Binary search, quick sort, and merge sort What is the time complexity of Divide and Conquer algorithms? - ANS O(log n) What advantage does Divide and Conquer offer in solving complex problems? - ANS It simplifies complex problems and the time taken to solve them doesn't grow significantly as the problem size increases What is backtracking in problem solving? - ANS It is a methodical algorithm that visits each path and builds a solution based on correct paths, backtracking when an invalid path is encountered.

How is backtracking implemented? - ANS Backtracking is often implemented using algorithms, with recursive methods. Depth-first graph traversals are an example of backtracking. What is data mining used for? - ANS Data mining is used to identify patterns or outliers in large sets of data, known as 'big data'. How can insights from data mining be used? - ANS Insights from data mining can be used to predict the future based on previous trends, assisting in business and marketing decisions. What can data mining uncover about shopping habits? - ANS Data mining can uncover information about which products are bought at certain times of the year, helping businesses prepare stocks in advance. Why is it important to handle personal data carefully in data mining? - ANS Data mining often involves personal data, so it is crucial to comply with data protection legislation. What are heuristics? - ANS Heuristics are non-optimal 'rule of thumb' approaches to problem solving. Why are heuristics used in problem solving? - ANS Heuristics are used to find an approximate solution to a problem when the standard solution is unreasonably time-consuming or resource-intensive. Are solutions found using heuristics perfectly accurate? - ANS No, solutions found using heuristics are never perfectly accurate or complete, but they are 'good enough'. What type of problems are heuristics used for? - ANS Heuristics are used to provide an estimated solution for intractable problems, such as the A* algorithm. What is the purpose of performance modeling in problem solving? - ANS Performance modeling provides mathematical methods to test various loads on different operating systems, eliminating the need for true performance testing.

O(n) - ANS Fair. The time taken to solve an algorithm is directly proportional to the number of inputs. O(n log n) - ANS Bad. The time taken to solve an algorithm increases at a smaller rate as the number of inputs, but slightly faster than O(n). O(n^2) - ANS Horrible. The time taken to solve an algorithm is directly proportional to the square of the amount of inputs. O(2^n) - ANS Horrible. The time taken to solve an algorithm will double with each new input. O(n!) - ANS Horrible. The time taken to solve an algorithm will grow at an astronomical rate as the number of inputs increases. Space Complexity - ANS How much memory an algorithm needs. What is the main objective in designing an algorithm? - ANS The main objective is completing a task. What determines whether space or time complexity is more important in algorithm design? - ANS If storage space is an issue, space complexity is more important; otherwise, time complexity takes priority. How can you reduce space complexity in algorithm design? - ANS Perform all changes on original data. How can you reduce time complexity in algorithm design? - ANS Reduce the number of embedded loops and the number of items to operate on. Linear Search Pseudocode - ANS

Binary Search Pseudocode - ANS Bubble Sort Pseudocode - ANS Insertion Sort Pseudocode - ANS Merge Sort Pseudocode - ANS size() in use (Stack) - ANS size() return top + 1 isEmpty() in use (Stack) - ANS isEmpty() if top < 0: return True else: return False endif peek() in use (Stack) - ANS peek() if isEmpty(): return error else: return A[top] push(element) in use (Stack) - ANS push(element)

enqueue(element) in use (Queue) - ANS enqueue(element) A[back] = element back = back + 1 dequeue() in use (Queue) - ANS if isEmpty(): return error else: toDequeue = A[front] a[front] = " " front = front + 1 return toDequeue Finding the next item (Linked-List) - ANS n.next (where a node is referred to as n) Heads and Tails! (Linked-List) - ANS Head is the first item, Tail is the last item. Searching (Linked-Lists) - ANS Multiple "next" operations until desired element is found or end of list is reached. The Three Depth-First Tree Traversals - ANS Breadth-First Tree Traversal (how to) - ANS Starts at root node, then visits all nodes, left-to-right, on all "levels" of the tree. Breadth-First Tree Traversal (formal definition) - ANS Starts at the left and visits all nodes directly connected to each of these nodes in turn.

Bubble Sort - ANS Swaps pairs of elements if needed in a series of passes until the end of the list is reached, where one final pass is done to check. Bubble Sort Time Complexity - ANS O(n^2) worst case, O(n) best case Insertion Sort - ANS Places elements into a sorted sequence, starting at element 2. Insertion Sort Time Complexity - ANS O(n^2) worst case, O(n) best case Merge Sort - ANS Splits the list into equal halves until each half has one item, then recombines them the same way, ensuring that the recombination orders all items. Merge Sort Time Complexity - ANS O(n log n) all cases Quick Sort - ANS Selects an element (usually the central one) to declare the pivot. Values smaller than the pivot are placed on its left and vice versa. Process is repeated until all elements are pivots themselves (or form a list of length 1). Quick Sort Time Complexity - ANS O(n^2) worst case, O(n log n) best case. Binary Search - ANS Only for sorted lists. Finds the middle element and decides the side on which the desired element is found. Repeated until its found (or found that its not in the list) What do all search algorithms have in common? - ANS Best-case time complexity of O(1) Binary Search Time Complexity - ANS O(log n) worst case