click below
click below
Normal Size Small Size show me how
WJEC - CG1 - 1.4
Algorithms & Programming
Question | Answer |
---|---|
What is an algorithm | A step of instructions/operations that reach a result (calculation, description, process etc), requiring an input an output |
What are some ways to plan an algorithm (programming) | - Pseudocode - Flow chart - Dataflow diagram (more for larger systems) |
Why is a flow chart good and bad | - Easily understood - Uses universally understood symbols - Visual - Requires translation to code - Can become complex and messy |
What is Pseudocode | A method of planning out an algorithm that requires no specific knowledge of any programing language but takes the basic principles of one to plan a process |
what are some general Programming operators (eg if) | - if - else - or - and - add - subtract - write - print - do - output - input |
What types of algorithm are there | - Sequence - Selection - Repetition - Search - Sorting |
What does a sequence algorithm do | An algorithm that simply prompts for a sequence of inputs, Input(name, Input(Age), input(gender) |
What does a selection algorithm do | An algorithm that tends to contain some kind of programmed criteria/conditions that allow it to process and select the data its looking for, eg if input(gender) = male then user = male (simple selection) |
What does a repetition algorithm do | An algorithm that loops through a function a fixed number of times or until a condition is met |
What kinds of search algorithms are there | - Linear search - Binary search |
How does a linear search work | The algorithm will simple process each piece of data/element until a condition is met |
How does a binary search work | The algorithm will sort the data by value, find the mid point of the data, if the data is bigger then the mid point it disregards the bottom half. It does this again for the data thats left, it keeps doing this until it locates the desired data. |
what kind of planning method would be used when designing a large system with many modules | Top Down Aproach |
What is the Top Down Aproach | This is a process of breaking down a system into smaller more manageable chunks that are called modules, these modules should be self contained and not rely on many other parts of the system |
Break down an iphones calling and taking pictures functions into its module parts | - Camera + Take pictures + Save picture + Save picture information + prompt user that photo was taken (Click noise) - Enter phone number + wait for number input + Display number + call number when button is pressed etc |
What is a Variable | The name of a storage allocation that is allocated with some data, that can be changed, hence the term variable |
What is a self documenting identifier | A variable given a name that will make understanding its purpose much easier when reading over the code ('txtName' not 'xyz') |
Why use self documenting identifiers | - They help the programmer when developing a system - Help maintenance staff understand what the code does after the programmer leaves - make reading code quicker and easier |
Whats the difference between a constant and a variable and give an example of each | Variable (age) can take any of these values 12 , 15, 18 Constant (Pi) will always be 3.14159265359... |
What is the purpose of a constant variable | the purpose of a constant, is so that the data contained within it cannot be altered or lost due to errors, for example a finance program will have a constant value for VAT, so that during calculations this cannot be tampered with causing inaccuracies |
What is the scope of a variable | The accessibility of a variable. A variable in a subroutine wont be recognized if called outside of that subroutine |
What is the difference between a global and a local variable | A Local variable will only be recognized within its access level A Global variable will be recognized throughout the program as it "global", normaly initiated at the beginning of a program |
Name some logical operators | - IF - Or - Not - Xor |
How does an if operator work | The if operator is used heavily in conditional selection algorithms. Its purpose is to ask IF the data your looking matches a condition/criteria you have in place, usually returning a boolean (true/false) |
How does a Not operator work | It is similar to if in that is uses a condition, but usually has only one input - eg "IF age_group < 18 AND NOT income = “above min wage” THEN" if you are 17, it wont print out that statement |
How does an or operator work | This logical operator usually has one of two conditions to meet - eg - IF age < 18 or income < 1500 |
How does an xor operator work | works similar to the Or operator, but if both cases are matched its false, only one or the other can be chosen |
How does an AND operator work | This operator requires that two or more conditions are met to be true - eg "IF 'this' and 'this' and 'this' are something then True" |
why is a standard function considered good | A standard function is a prewritten algorithm written by professional programmers. This means its tested, works well, is probably efficient and makes programming much quicker and easier |
What is the purpose of testing | The purpose of testing is to see if the system works as its supposed to, if you are designing a system for a client, the client is expecting your solution to work for them. If it doesnt you wont be paid |
What is Dry Run Testing | This involves testing an algorithm by writing it, then plugging in known values and righting out what is produced by the program at each stage on a "Trace Table" and comparing this with what you know to be correct values |
What is Alpha testing | This is testing usually done in house by developers, it is to see if the algorithms and basic functionality are working in a system |
What is Beta testing | This is done by some potential customers/end users, that will use the program as they expect it to be and will report back any bugs |
What is Gamma/acceptance testing | This testing is done by final users too, but is much more rigorous and usually will be testing to see if the system does exactly what its meant, this is the final stage before release |
What types of test data are used for testing | - Normal - Extreme - Erroneous / Incorrect - Null / nonexistent |
What generation/level languages are there | Three: - Machine code - Assembly code - High level |
What is machine code | A programming language comprising of 1/0's (bits) used at the processor level. - Difficult to program - Very specific to processor architecture - Very fast - Difficult to debug |
What is assembly code | This is grouped chunks of machine code, like it will group the bytes together in charge of adding and calling it ADX/ADD, this is still difficult to program and requires many chunks to perform simple functions |
Does the computer process assembly code | No, the computer will deconstruct the assembly code into machine code and will run it like that |
What devices may use Assembly code | Any electronic device that has a basic running task like an alarm, it will run quick, wont require much memory or storage space. |
What is a High level Language | Any language like python, vb, C, java. These languages resemble english and maths more closely which make it easier to program and understand speeding up developing and tailoring it to specific markets |
Why might high level languages be slower then low level ones | much like assembly language, the high level code needs to be deconstructed to understand it, but because its much further from machine code then assembly code is, it might be slower |
What is the difference between a compiler and an interpreter | Compilers - Can be run without the need to recompile - faster running - can be distributed as a stand alone - secure as code cannot be looked at Interpreters - Require no lengthy recompile - Good for fixing errors - programs can be translated |
What is a visual language | A language, usually with a visual design environment allowing the user to design a GUI to accompany their program |
What is a procedural Language | A language that runs a sequence of steps, using variables, control loops and subroutines but the entire code is "live" |
What is am Event driven Language | A Language that requires user input to run code, button presses, mouse clicks, text being entered, etc |
What is a subroutine | A piece of code that performs a specific task, printing data, loading a form, initiating a function |
What is a function | A piece of that returns an answer/output, usually mathematical or boolean |
What are some practices used by programmers to help new developers/maintenance staff understand code | - Self Documenting Identifiers - Commented Code - Program Layout |
What is the purpose of Commented Code | Commented code allows programmers/maintenance staff to better understand the code when looking at it |
What is the purpose of a good Program Layout | keeps the program looking neat and easy to understand/follow |