Core Topics Continued

Bhavit Chhatralia
Mind Map by , created over 5 years ago

Mind Map on Core Topics Continued, created by Bhavit Chhatralia on 05/27/2014.

24
0
0
Tags No tags specified
Bhavit Chhatralia
Created by Bhavit Chhatralia over 5 years ago
Economics - unit 1
Amardeep Kumar
The structure of the Heart, AS Biology
mill-bill
Camera Angles
saradevine97
OCR GCSE History-Paper Two: The Liberal Reforms 1906-14 Poverty to Welfare State NEW FOR 2015!!!
I Turner
Social Influence
olimcconnell
WAVES
toritorx
USA stock market collapse
Emily Tisch
Biology AQA 3.1.3 Osmosis and Diffusion
evie.daines
B5 - Growth and Deveolopment
blairzy123
OCR Gateway GCSE P3 Revision Quiz
xhallyx
Core Topics Continued
1 Recursion
1.1 a method calling itself
1.2 Indirect recursion: Method A calls method B that calls method A
1.3 Potentially can go on forever (until memory full - Stack Overflow
1.4 Very powerful construct based on mathematical induction.
1.5 Recursive programming
1.5.1 All loops can be implemented as recursive calls
1.5.1.1 int f(int x) { if ( x<1 ) { return 0; } return x + f(x-1); }
1.5.2 Inefficient in java, but core concept in functional programming
1.6 Programming recursively
1.6.1 When programming, "solve" a problem by using another method (call it before you implement it)
1.6.2 When this other method is the calling method, you have recursion.
1.6.3 Recursion is not a goal in itself
1.6.4 Recursive data structures (XML documents, file directories (called folders in windows), linked lists etc.) are most easily handled with recursive functions.
2 Programming Language Concepts
2.1 Paradigms
2.1.1 Imperative
2.1.1.1 describes computation in terms of statements that change a program state
2.1.1.2 The term is used in opposition to declarative programming, which expresses what the program should accomplish without prescribing how to do it in terms of sequences of actions to be taken
2.1.2 Logic
2.1.2.1 Popularized by Prolog
2.1.2.2 Based on predicate calculus
2.1.2.3 Starts with statements of facts – parent(john, jake), parent(jake, jack)
2.1.2.4 Uses rules – grantparent(X,Z) :- parent(X,Y), parent (Y,Z)
2.1.2.5 Uses inference to determine true statements – grantparent(A, jack). will result in A = john
2.1.2.6 Very good at searching solutions
2.1.2.7 Basically implements the depth first search algorithm (as used for certain kinds of AI)
2.1.3 Functional
2.1.3.1 Based on mathematical "pure" functions
2.1.3.2 Allows for straightforward mapping to computer science
2.1.3.3 Functions are first class
2.1.3.4 Based on recursion (and mathematical induction), and conditional expressions (not on explicit loops)
2.1.3.5 No variables (but named parameters), no side effects
2.1.3.6 By default thread safe
2.1.3.7 Lisp, Scheme, ML, Haskell
2.2 Concepts
2.2.1 Primitive
2.2.1.1 Primary building block of which other composite types can be build
2.2.1.2 Corresponds (mostly) with cpu supported type
2.2.1.3 Operations generally translate directly to machine instructions
2.2.2 Type
2.2.2.1 Primitive (subset of built-in)
2.2.2.2 Built-in (generally primitive + string + array)
2.2.2.3 User defined
2.2.2.3.1 Enumerations
2.2.2.3.2 Range types
2.2.2.3.3 Structured / composite types (classes)
2.2.2.4 All values have a type. Different types have different sizes, thus type is needed at run-time.
2.2.3 Literal
2.2.3.1 Directly typed in to code
2.2.3.2 Mostly only for built-in types
2.2.3.3 C++11 allows user defined literals
2.2.3.4 Sometimes has special type system support for conversions
2.2.4 Constant
2.2.4.1 Name that represents a value that is defined at compile time.
2.2.5 Variable
2.2.5.1 Name that represents a storage location for a value.
2.2.6 Scope
2.2.6.1 Block – Visible inside the block of definition
2.2.6.2 Function – Visible for the function
2.2.6.3 Class – Visible in the entire class
2.2.6.4 Unit – Visible in the file
2.2.6.5 Global – Visible for the whole program (often with import rules), sometimes only at runtime
2.2.7 Namespace
2.2.7.1 Package in Java
2.2.7.2 Module in Python
2.2.7.3 Namespace in C++, XML
2.2.7.4 Allows for names to be reused without conflicts
2.2.7.5 Especially useful for libraries, as naming conflicts can be really annoying (esp. as the linker works on a global level)
2.2.8 Function
2.2.8.1 Group of functionality that takes parameters and returns a value
2.2.8.2 If pure, only depends on (and doesn't change) its parameters. Repeated invocation has the same results.
2.2.8.3 Non-pure functions may use external state (a file, the time, etc.), or modify parameters (random.nextInt())
2.2.8.4 Object member functions have the object as a parameter
2.2.9 Expression
2.2.9.1 A variable reference
2.2.9.2 A function call
2.2.9.3 A literal
2.2.9.4 The application of a unary operator on an expression
2.2.9.5 The application of a binary operator on two expressions
2.2.9.6 An expression always results in a value
2.2.10 Operator
2.2.10.1 Unary (-x), Binary (x + y) or ternary ( _ ? _ : _)
2.2.10.2 Makes compound expressions possible
2.2.10.3 Some languages only have operator for built-in types, others allow overloading
2.2.10.4 Operator precedence makes custom operators tricky.
2.2.11 Statement
2.2.11.1 Building block of a code block (such as a function)
2.2.11.2 Does not necessarily result in a value
2.2.11.3 An expression may be a statement (depending on the language)
2.2.11.4 Could be an assignment
2.2.11.5 Could be a definition (variable, type, function)
2.3 Type Systems
2.3.1 Static typing – Types are checked at compile time
2.3.1.1 Types are specified
2.3.1.2 "more text" – Can be alleviated using type inference.
2.3.1.3 Sometimes needs type casting to interpret as another type (with checks)
2.3.1.4 Sometimes automatic conversion (coercion) is used (from int to long)
2.3.1.5 Allows the compiler to check correctness
2.3.2 Dynamic typing – Types are checked at run time
2.3.2.1 "less text"
2.3.2.2 Allows for "duck typing"
2.3.2.2.1 Any object with the needed methods will work
2.3.2.2.2 Like interfaces without the need for an interface
2.3.2.2.3 (C++ templates do this at compile time)
2.3.2.3 Type errors become apparent at run-time
2.3.2.4 As different types need different storage sizes, must be heap bound
2.3.3 Strong vs Weak
2.3.3.1 Strong detects all type errors at compile or run time
2.3.3.2 Java is strong
2.3.3.3 C/C++ allow aliasing, unsafe casts, and union types are not checked
2.3.4 Type Compatibility
2.3.4.1 Structure type compatibility
2.3.4.1.1 If the structure is the same, the type is the same.
2.3.4.1.2 What about degrees Celcius vs Fahrenheit
2.3.4.2 Name type compatibility
2.3.4.2.1 Type is only compatible with itself
2.3.4.3 Most languages have a combination
2.4 Interpreted languages vs compiled languages
2.4.1 Gray area
2.4.2 A parser reads the code and creates (possibly partially) an abstract syntax tree
2.4.3 An interpreter will execute the AST
2.4.4 A compiler will translate the AST into an alternative (executable) representation.

Media attachments