Paper 1 Unit 2 Flashcards
Name different data types
String, integer, float, boolean, character
What is an identifier?
The name given to a data structure
What is a list?
An ordered set of data using a single identifier and an index to identify a data item
What is an index?
The position of a value in a list
Define what is meant by a scope
The extent to which a variable can be seen by the different parts of a program
What is an array?
A data structure using a single identifier and multiple indices to identify a data item
What is global variable?
A variable declared in the main body of a program and visible to all parts of the program
What is a local variable?
A variable declared within and used only within a sub-program, it is not visible outside the sub-program
What must be done before a text file can be used?
If the file does not already exist it must be created, it must be opened before writing, data must be written to the file, the file must be closed before data can have been written to the file
How is sequence used in programming?
An ordered list of instructions and must be followed step by step (like ordinary code)
How is selection used in programming?
The path a program will follow will be determined by a condition. An if statement is used to decide which path a program will follow
How is iteration used in programming?
A section of code is repeated for a set number of times, until a condition is met or while a condition is true. For and while loops can be used to make a program repeat itself
Which is better to use and why? A binary search or a linear search
A binary search is better as it is much quicker than a linear search especially for bigger lists. However it can only be used on a sorted list whereas a linear search can be used on an unsorted list
Evaluate the use of a bubble sort
Benefits: straightforward to implement, space requirements are minimal. Drawbacks: not good with large numbers of items, lots of processing required for each item in the data set
Evaluate the use of an insertion sort
Benefits: straightforward to implement, good with small quantities of data, minimal space requirements. Drawbacks: not good with large number of items, does not perform as well as other methods, lots of processing required for each item in the data set
Evaluate the use of a merge sort
Benefits: good with large sets of data. Drawbacks: has more space requirements than other methods and is not very efficient
Evaluate the use of built in functions
Benefits of using built-in functions: thoroughly tested and widely used, reliable, saves time, reduces cost, optimised efficiency. Drawbacks: not specific to task and may have compromises to work around, difficult to modify, compatibility issues may mean it cannot be used in the program so it may then have to be coded from scratch
What different types of validation checks can be done? Give a definition of each.
Presence check- checks if data has been supplied. Length check- checks the correct number of characters have been entered. Type check- checks the correct data type has been supplied. Format check- checks that data inputted matches the format required. Range check- checks the value is within an acceptable range. Check digit- calculation to ensure that when a number is read, transmitted or copied, the number has not been changed.
How can code be made maintainable?
Use indents, comments, modular code, format the code to make it easier to read