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.

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
Camera Angles
OCR GCSE History-Paper Two: The Liberal Reforms 1906-14 Poverty to Welfare State NEW FOR 2015!!!
I Turner
Social Influence
USA stock market collapse
Emily Tisch
Biology AQA 3.1.3 Osmosis and Diffusion
B5 - Growth and Deveolopment
OCR Gateway GCSE P3 Revision Quiz
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 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 describes computation in terms of statements that change a program state 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 Popularized by Prolog Based on predicate calculus Starts with statements of facts – parent(john, jake), parent(jake, jack) Uses rules – grantparent(X,Z) :- parent(X,Y), parent (Y,Z) Uses inference to determine true statements – grantparent(A, jack). will result in A = john Very good at searching solutions Basically implements the depth first search algorithm (as used for certain kinds of AI)
2.1.3 Functional Based on mathematical "pure" functions Allows for straightforward mapping to computer science Functions are first class Based on recursion (and mathematical induction), and conditional expressions (not on explicit loops) No variables (but named parameters), no side effects By default thread safe Lisp, Scheme, ML, Haskell
2.2 Concepts
2.2.1 Primitive Primary building block of which other composite types can be build Corresponds (mostly) with cpu supported type Operations generally translate directly to machine instructions
2.2.2 Type Primitive (subset of built-in) Built-in (generally primitive + string + array) User defined Enumerations Range types Structured / composite types (classes) All values have a type. Different types have different sizes, thus type is needed at run-time.
2.2.3 Literal Directly typed in to code Mostly only for built-in types C++11 allows user defined literals Sometimes has special type system support for conversions
2.2.4 Constant Name that represents a value that is defined at compile time.
2.2.5 Variable Name that represents a storage location for a value.
2.2.6 Scope Block – Visible inside the block of definition Function – Visible for the function Class – Visible in the entire class Unit – Visible in the file Global – Visible for the whole program (often with import rules), sometimes only at runtime
2.2.7 Namespace Package in Java Module in Python Namespace in C++, XML Allows for names to be reused without conflicts Especially useful for libraries, as naming conflicts can be really annoying (esp. as the linker works on a global level)
2.2.8 Function Group of functionality that takes parameters and returns a value If pure, only depends on (and doesn't change) its parameters. Repeated invocation has the same results. Non-pure functions may use external state (a file, the time, etc.), or modify parameters (random.nextInt()) Object member functions have the object as a parameter
2.2.9 Expression A variable reference A function call A literal The application of a unary operator on an expression The application of a binary operator on two expressions An expression always results in a value
2.2.10 Operator Unary (-x), Binary (x + y) or ternary ( _ ? _ : _) Makes compound expressions possible Some languages only have operator for built-in types, others allow overloading Operator precedence makes custom operators tricky.
2.2.11 Statement Building block of a code block (such as a function) Does not necessarily result in a value An expression may be a statement (depending on the language) Could be an assignment Could be a definition (variable, type, function)
2.3 Type Systems
2.3.1 Static typing – Types are checked at compile time Types are specified "more text" – Can be alleviated using type inference. Sometimes needs type casting to interpret as another type (with checks) Sometimes automatic conversion (coercion) is used (from int to long) Allows the compiler to check correctness
2.3.2 Dynamic typing – Types are checked at run time "less text" Allows for "duck typing" Any object with the needed methods will work Like interfaces without the need for an interface (C++ templates do this at compile time) Type errors become apparent at run-time As different types need different storage sizes, must be heap bound
2.3.3 Strong vs Weak Strong detects all type errors at compile or run time Java is strong C/C++ allow aliasing, unsafe casts, and union types are not checked
2.3.4 Type Compatibility Structure type compatibility If the structure is the same, the type is the same. What about degrees Celcius vs Fahrenheit Name type compatibility Type is only compatible with itself 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