1/50
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
CONSTANTS
can't be changed and require no memory storage when the program runs.
STRUCTURED PROGRAMMING
involves creating named SUBROUTINES (functions in C#), that are called from the main program and exchange data through parameters. It avoids repetition, allows modular and reusable code, allows local variables (which only exist in the subroutine), is easier to test and helps produce programs that are clear and well documented.
Algorithm
Sequence of steps that can be followed to complete a task
A computer program is an implementation of an algorithm. An algorithm is not a computer program.
Decomposition
Breaking a problem into smaller sub-problems
Abstraction
Removing unnecessary detail
Assignment
Setting the value of a variable
Iteration
Repeating (looping) - either definite, which loops a fixed number of times, or indefinite, which can go on forever.
'Nested' iteration
One loop inside another
Selection
Choosing based on an IF statement
Syntax Error
Error (such as a typo) that prevents the program from running at all
Logic Error
Error that only appears when the program is run but does not do what is expected.
Authentication
Checking authorisation - e.g.: Username and password are correct.
Validation
Checking that data input follows certain rules, e.g.:
Minimum length
Nothing entered
Value between given range
LINEAR SEARCH
works through all the items in a list, starting from the beginning and ending when it finds what it's looking for or hits the end.
BINARY SEARCH
requires a sorted input. It splits the list in two, compares the middle value and chooses the upper or lower half. Keep repeating until the item is found or it's discovered that it can't be there (there's nowhere in the sorted list for it to be). It is more time efficient than linear search (but needs the data to be sorted)
BUBBLE SORT
work through the items from left to right, if they are the wrong way round, swap them and keep going. Keep repeating until there are no more swaps.
MERGE SORT
Split the input array in half, then do it again and again until you're left with just single items. Then merge the pairs of items together in the correct order, pair by pair until the sort is complete.
MERGE VS BUBBLE SORT
MERGE SORT is usually more time efficient than bubble sort. Time efficiency describes how long an algorithm will take in the worst-case scenario. The time taken is related to the size of the input, that relationship is the time efficiency. Every loop makes it worse, loops within loops are particularly troublesome.
WHILE loop
tests at the beginning
DO ... WHILE/REPEAT loop
tests at the end
difference between while and so while/repeat loop
WHILE loop may not loop at all, whereas a DO/REPEAT will always loop once
subroutine (function in c#)
named 'out of line' block of code that may be executed (called) by simply writing its name in a program statement.
Data can be passed in a subroutine through parameters
They can be used and reused by the program "calling" their name in a statement, causing it to be executed
VARIABLES
can be changed and requires memory storage when the program runs.
Understand the concept of a data type.
A means of classifying different data
Data type determines properties like what operations can be conducted on the data and how the data will be stored
Integer
A whole number
Real/float/double
Number with a fractional/decimal part
Bool
True or false
Character
A single letter, number or symbol
String
Zero or more characters. String can be null, just one character or many characters
MOD
remainder. 12 MOD 5 gives 2
DIV
how many times a number goes in. 17 DIV 5 gives 3
Data Structures
the ways of organizing and storing data in a computer. They allow related pieces of data to be grouped together and accessed efficiently.
length
tells you how many characters in a variable or how many elements in an array
variable.Length
position
finds the character corresponding to said position, first character counts as 0
string test = "doggy";
Console.WriteLine(test[2]);
outputs "g"
substring
part of an existing string
if 2 numbers first number is included, second number is not (stops at number before second number)
if 1 number starts from that number (inclusive) and goes until the end
string test = "Hello World";
string substr1 = test.Substring(0, 4); outputs "Hell"
string substr2 = test.Substring(6); outputs "World"
concatenation
Joining together two or more strings
string test = "doggy";
string test2 = "cat";
string test3 = test + test2;
Console.WriteLine(test3);
outputs doggycat
convert character to character code
char character = 'A';
int charCode = (int)character;
Console.WriteLine("Character: " + character);
Console.WriteLine("Character Code: " + charCode);
outputs
Character: A
Character Code: 65
convert character code to character
int charCode = 65; // ASCII code for 'A'
char character = (char)charCode;
Console.WriteLine("Character Code: " + charCode); Console.WriteLine("Character: " + character);
outputs:
Character Code: 65
Character: A
string to integer
string test = "1234";
int test2 = Convert.ToInt32(test);
string to real
string test4 = "1234.56";
double test5 = Convert.ToDouble(test);
integer to string
int t = 3456;
string tt = Convert.ToString(t);
real to string
double ttt = 34.5678;
string tttt = Convert.ToString(tt);
Be able to use random number generation.
Random r = new Random();
int rint = r.Next(1, 7);
generates a number between 1 and 6
Explain the advantages of using subroutines in programs.
Subroutines are usually small in size, which means they are much easier to write, test and debug. They are also easy for someone else to understand.
As they are written outside of the main program, subroutines can be saved separately as modules and used again in other programs. This saves time because the programmer can use code that has already been written, tested and debugged.
A subroutine may be used repeatedly at various points in the main program and changed by passing in data known as parameters. However, the code only has to be written once, resulting in shorter programs.
local variables
only exist while the subroutine is executing
are only accessible within the subroutine
parameters
used to pass data within programs
subroutines may declare their own _______, called _____ ________
subroutines may declare their own variables, called local variables
Understand what test data is and describe the following types of test data:
normal (typical)
boundary (extreme)
erroneous data.
normal data - data that the program should accept and be able to process
boundary data - valid data that falls at the boundary of any possible ranges
erroneous data - data that the program cannot process and should not accept
NOT
!=
AND
&&
OR
||