Algorithms (Cambridge (CIE) A Level Computer Science): Flashcards

Exam code: 9618

1/77

0Still learning

Know0

  • Define algorithm.

Cards in this collection (77)

  • Define algorithm.

    An algorithm is a solution to a problem expressed as a sequence of defined steps.

  • Name the three methods of writing an algorithm before programming a solution.

    Structured English, pseudocode and flowcharts.

  • Define Structured English.

    Structured English is a human-readable method for describing algorithms, using a combination of natural English language and programming logic.

  • When is Structured English usually used?

    It is often used in the early planning stages, before the algorithm is converted to pseudocode.

  • Define pseudocode.

    Pseudocode is a precise, structured and language-independent way of describing an algorithm that resembles a programming language.

  • What is the key difference between Structured English and pseudocode?

    Structured English uses logic structures without strict syntax rules, whereas pseudocode follows specific exam-board-defined syntax.

  • True or False?

    Pseudocode can be written in any syntax the student prefers.

    False.

    Pseudocode follows specific exam-board-defined syntax, and in the exam students must use CIE's pseudocode format.

  • Name three formal elements included in pseudocode.

    Pseudocode includes formal elements such as IF, THEN, ELSE, WHILE, REPEAT, DECLARE, and for assignment.

  • Define flowchart.

    A flowchart is a visual tool that uses shapes to represent different functions in order to describe an algorithm.

  • Which flowchart symbol is used for a decision?

    A diamond is used for a decision.

  • Which flowchart symbols are used for start/end, input/output and processes?

    An oval for start and end, a parallelogram for input and output, and a rectangle for processes.

  • On a flowchart,              show the sequence of operations.

    On a flowchart, arrows show the sequence of operations.

  • Define identifier table.

    An identifier table is used when writing pseudocode to keep track of all the identifier names used in an algorithm.

  • Define identifier.

    An identifier is the name given to a variable, constant, array, procedure or any other named element in the pseudocode.

  • Name two reasons for using an identifier table.

    It helps you stay organised when designing an algorithm, ensures consistent naming, and makes it easier to understand what each identifier stores or does.

  • What must an identifier name start with?

    An identifier must start with a letter, either A-Z or a-z.

  • Which characters can an identifier name include?

    Letters, digits (0-9) and underscores.

  • An identifier name may not contain symbols or                  characters.

    An identifier name may not contain symbols or accented characters.

  • True or False?

    Total and total are treated as the same identifier.

    False.

    Identifiers are case sensitive, so Total and total are not treated as the same identifier.

  • Define input in an algorithm.

    An input is data or information being entered or taken into a program before it is processed in the algorithm.

  • Name two sources that an input can come from.

    From a user, using a keyboard, mouse, controller or microphone, and from sensors measuring temperature, pressure or movement.

  • Which pseudocode command is used to input a value?

    The INPUT command, written as INPUT <identifier>.

  • Define process in an algorithm.

    A process is a doing action performed in the algorithm that transforms inputs into the desired output.

  • Which component executes the instructions that define a process?

    The central processing unit (CPU).

  • Give two examples of a process.

    Comparing two numbers and calculating an average.

  • Define output in an algorithm.

    An output is the result of the processing in an algorithm, and usually the way a user can see whether the algorithm works as intended.

  • Name three forms that an output can take.

    Numbers from a calculation, text, images, and actions such as triggering events.

  • Values are output from an algorithm using the              command.

    Values are output from an algorithm using the OUTPUT command.

  • How do you output more than one value in a single command?

    Separate the values with commas, for example OUTPUT "First name: ", Fname, "Surname: ", Sname.

  • A program calculates the area of a rectangle.

    What are its inputs, process and output?

    The inputs are Length and Width, the process is Length * Width, and the output is the Area.

  • Define sequence.

    Sequence refers to lines of code which are run one line at a time, in the order they are written, from the first line to the last.

  • Why is sequence crucial to a program?

    Any instructions that are out of sequence can lead to unexpected behaviour or errors.

  • Define selection.

    Selection is when the flow of a program is changed depending on a set of conditions, and the outcome determines which block of code runs next.

  • Name the two ways to write a selection statement.

    IF ... THEN ... ELSE and CASE.

  • When would you use a CASE statement rather than IF ... THEN ... ELSE?

    IF ... THEN ... ELSE is used for binary decisions that are true or false, whereas CASE is used for multiple specific options.

  • Name three things selection is used for.

    Validation, calculation, and making sense of a user's choices.

  • True or False?

    In pseudocode, = is used to assign a value to a variable.

    False.

    is used for assignment. = is used in a comparison, such as IF Number MOD 2 = 0 THEN.

  • Define iteration.

    Iteration means repeating a line or block of code using a loop, so a task can be performed multiple times until a condition is met.

  • Name the three types of iteration.

    Count-controlled, post-condition and pre-condition.

  • Which pseudocode structure is used for count-controlled iteration?

    FOR ... TO ... NEXT, which repeats a fixed number of times.

  • What is the difference between a pre-condition and a post-condition loop?

    A pre-condition loop, WHILE ... ENDWHILE, checks the condition before running the block. A post-condition loop, REPEAT ... UNTIL, runs the block at least once and checks the condition after.

  • A REPEAT ... UNTIL loop checks its condition            running the block.

    A REPEAT ... UNTIL loop checks its condition after running the block.

  • True or False?

    A WHILE ... ENDWHILE loop always runs at least once.

    False.

    A WHILE loop checks the condition before running the block, so it may run zero times. It is REPEAT ... UNTIL that runs at least once.

  • What are the three steps in converting a problem into pseudocode?

    Write it in Structured English, build an identifier table, then write the pseudocode.

  • In the discount example, a customer who has a discount code receives            off the price.

    In the discount example, a customer who has a discount code receives 10% off the price.

  • In the discount example, what does the identifier ItemPrice store?

    The original price of the item.

  • In the discount example, what does the identifier HasDiscount store?

    TRUE if the user has a discount code.

  • In the discount example, what does the identifier FinalPrice store?

    The price after the discount is applied.

  • Write the pseudocode line that calculates 10% off the item price.

    DiscountAmount ← ItemPrice * 0.10

  • Write the pseudocode line that subtracts the discount from the original price.

    FinalPrice ← ItemPrice - DiscountAmount

  • Which pseudocode keyword ends an IF statement?

    ENDIF

  • True or False?

    The discount example uses = to test whether the user has a discount code.

    True.

    The line is IF HasDiscount = TRUE THEN, where = is used as a comparison, not as an assignment.

  • What are the steps in converting pseudocode into a flowchart?

    Build an identifier table, work out the flowchart structure by deciding which symbol each statement maps to, then draw the flowchart.

  • True or False?

    The identifier table is written after the flowchart has been drawn.

    False.

    The identifier table is the first step, written before the flowchart structure is worked out and before the flowchart is drawn.

  • In the odd/even example, what does the identifier Number store?

    The number entered by the user.

  • Which flowchart symbol represents both INPUT Number and OUTPUT "Even"?

    A parallelogram, which is the input/output symbol.

  • Which flowchart symbol represents IF Number MOD 2 = 0?

    A diamond, which is the decision symbol, because it checks whether the number is divisible by 2.

  • What does Number MOD 2 = 0 test?

    It checks whether the number is divisible by 2, which means the number is even.

  • In the odd/even example, if Number MOD 2 = 0 is false, the algorithm outputs the message           .

    In the odd/even example, if Number MOD 2 = 0 is false, the algorithm outputs the message Odd.

  • Which flowchart symbol denotes the beginning and the end of the process?

    An oval.

  • What do the arrows on a flowchart indicate?

    The arrows indicate the flow of control.

  • Define stepwise refinement.

    Stepwise refinement is the process of breaking down a complex problem into smaller, more manageable sub-problems in a logical order.

  • How far is each sub-problem refined?

    Each sub-problem is refined step by step until it is simple enough to be solved with a single subroutine or module.

  • Stepwise refinement breaks a complex problem into sub-problems in a                order.

    Stepwise refinement breaks a complex problem into sub-problems in a logical order.

  • What is the relationship between decomposition, top-down design and stepwise refinement?

    Decomposition is the general concept of breaking a problem into smaller parts, top-down design is the strategy used to perform decomposition, and stepwise refinement is the process used in top-down design to gradually refine each major task into simpler sub-tasks.

  • True or False?

    Stepwise refinement and top-down design are the same thing.

    False.

    Top-down design is the strategy. Stepwise refinement is how top-down design is implemented.

  • Stepwise refinement ensures the overall problem is solved in a structured and                    way.

    Stepwise refinement ensures the overall problem is solved in a structured and efficient way.

  • How does stepwise refinement help developers understand a program?

    It helps developers understand and organise the structure of the program.

  • How does stepwise refinement make testing easier?

    It makes testing and debugging easier through unit testing of individual subroutines.

  • How does stepwise refinement encourage code reuse?

    It breaks tasks into reusable components.

  • How does stepwise refinement support collaborative development?

    Tasks can be divided between team members.

  • Name the three properties each subroutine should have.

    Each subroutine should be clear and focused on a single task, simple enough to implement directly, and should not need further breakdown.

  • True or False?

    A subroutine produced by stepwise refinement should handle several different tasks.

    False.

    Each subroutine should be clear and focused on a single task.

  • In the student grades example, what is the top-level task?

    To calculate grades for all students in all classes.

  • In the student grades example, what are the steps in calculating the grade for each assessment?

    For each question, mark the question and store the mark, then sum the marks for all questions in the assessment.

  • In the student grades example, how is a student's average grade calculated?

    Add together the grades from all assessments, divide by the number of assessments, then store the average.

  • In the student grades example, what does Step 3 do?

    It repeats Steps 1 and 2 for every student in the class, so the process covers each class in turn.

Sign up to unlock flashcards

or