CHIA C Flashcards
Data Structure - Array
store elements of the same type in a specific order and are accessed by indexing. Arrays may be one dimensional (vectors) or two dimensional (matrices).
Data Structure - Linked lists
comprise groups of nodes that together represent a sequence. Each node consists of a datum (an instance of data) and a link to the next node(s) in the sequence. The last node is linked to a terminator used to signify the end of the list.
Data Structure - Stack
store elements where the last element in is the first one out (LIFO). New elements are added (‘pushed’) onto the top of the stack, and the first elements to be removed (‘popped’) are also taken from the top since they were the last ones in.
Data Structure - Queue
are basically the opposite of stacks, using a first-in, first-out (FIFO) rule. Queues are used where elements are processed in the order they arrive (e.g., a print queue).
Data Structure - Tree
start with a root value (parent) and branch out into sub-trees of children, represented as a set of linked nodes. Each node contains a datum and one or more pointers to other nodes.
Data Structure - Graphs
comprise sets of ordered pairs called edges/arcs and entities called nodes/vertices. An edge (x, y) is points from x to y.
Data Structure - Table
are used to store elements that may, for example, be inserted in the table, searched for or perhaps deleted. Tables are mutable data structures.
Data Structure - Sets
store certain values without any particular order and no repeated values. This corresponds to the mathematical concept of a finite set.
Math model for linear vs binary tree search
linear = n/2, binary = log2n, always less steps for binary
Data types and what determine (4)
integer, boolean, alphanumeric, strings
- possible values, operations to be performed, meaning of data, ways data can be stored
Algorithms are:
“An algorithm is an explicit, precise, unambiguous, mechanically-executable sequence of elementary instructions”
Algorithms are step-by-step procedures for calculating or problem-solving. They are used to manipulate the data contained in data structures. Commonly used algorithms include searching for particular data items or records, sorting data and performing calculations such as generating body mass indexes from heights and weights.
Algorithms complexities (3)
- Contitionals (different steps depending on specificed boolean condiution is true/false)
- Loops (steps specified once and carried out multiple tiomes, either specified number or until condition is met)
- Recursion (solution to a problem depends on smaller instances of the problem)
Abstraction
Real-world problems have many superfluous details. An essential step in problem-solving is identifying the underlying abstract problem devoid of unnecessary detail. Once issues are abstracted, it becomes apparent that seemingly different problems are essentially similar
As far as possible, abstract data structures are used to store data, and abstract algorithms are used to manipulate them.
Compiled Language and examples
In a compiled language, the programmer writes more general instructions and a compiler (a special piece of software) automatically translates these high-level instructions into machine language. The computer then executes the machine language. A large portion of the software in use today is programmed in this fashion. Examples include “C”, C++, Pascal, Cobol, Fortran, ADA and Java (Holowczak, 2014).
interpreted programming language
In an interpreted programming language, the programmer’s statements are interpreted as the program is running. Examples include Basic, Visual Basic, Perl, Python and shell scripting languages such as those found in the UNIX, Linux and MacOS X environments (Holowczak, 2014).
History of programing
- Binary
- Syymbolic programing
- low level programing
- Produrdal programming (split task into smaller tasks)
- Structure programming (top down approach)
- Function programming (model the problem not solution)
- Logic programming (database logical inference)
- Object orientated (modular code with object having attributes and behaviours)
Program structure - Pattern
Virtually all structured programs share a similar overall pattern – statements to establish the program’s start, declaration of the variables involved and blocks of code (Holowczak, 2014).
Program structure - Variable
Variables are named so that they can be referred to and typically store values of a given data type. They are ‘declared’ at the program’s start because the compiler needs to know the type of data stored in it in advance. Different programming languages have slightly different syntax and data types.
Program structure - Blocks of code
Blocks of code typically express operations and logic.
Program structure - Boolean logic
Boolean logic is two-valued, allowing only two truth values – ‘true’ and ‘false’. A Boolean expression is a set of logical operands (statements that can be proven true or false) and logical operators that connect them (AND, OR, NOT, EQV [logical equivalence] and NEQV [logical non-equivalence]).
Boolean expressions often also involve comparison operators that can be evaluated to determine true or false. Comparison operators include >, <, ≥ and ≤.
Boolean and comparison operators are written differently in different programming languages.
Control statements “control” which code sections in a program are executed. There are three general types of control statements
• Sequential – the default ordering of program execution.
• Decision (conditional) – controls which block of code is executed from alternatives based on ‘if… then …else’ logic. The ‘ if ‘ block of code is executed when the ‘if’ statement equates to ‘true’. If it equates to ‘false’, the code associated with the ‘else’ statement is executed.
• Iterative – controls how many times a block of code is executed. The two main iteration categories are FOR and WHILE/DO loops.
Iterative Control statements - FOR, WHILE, DO
Simple FOR loops iterate a specific number of times the loop is executed based on counting up (or down) on an integer variable. Generally, the three parts of a FOR loop are the initialisation (the initial or starting value), the condition (the condition under which the loop will stop), and the increment or decrement.
WHILE and DO loops are also used to repeat a code section a number of times. However, where FOR loops specify some count, WHILE and DO loops repeat while a condition is true. The condition is a Boolean expression that we can evaluate as ‘true’ or ‘false’. As soon as the condition evaluates to ‘false’, the loop ends.
Benefits of life cycle management
- Planning for logevity (system level)
- Optimise value (system level)
- portfolio management (organisation levelZ)
- Risk Management (organistaion level)