questions on paper 2 Flashcards
Abstraction
The process of separating ideas from particular instances/reality.
A way of hiding details/only using relevant details.
Representational
Representation of reality using symbols to show real life features.
Irrelevant info left out / excessive details removed so only key features remain
Procedural
Utilising functions and procedures without knowing how they are implemented
Generalisation
Grouping together similarities within a problem and then solving it via a general solution
Data abstraction
Details about how data is being stored are hidden
Differences between abstraction and reality
Abstraction is a simplified representation of reality
Scenery simplified, damage/litter removed
Advantages of abstraction
Reduces programming time, and program size, reduces memory requirements
Keeps focus on core aspects of program – doesn’t detract from main purpose
Disadvantages of abstraction
Too much can make the program too simplistic
Reusable code
Software is modular e.g. functions
Advantages of reusable code
Modules can be transplanted into new software or can be shared at run time through the use of libraries
More reliable as already tested
Save time, money and resources
Teams can work on large projects
How does it help beginners (reusable code)
Hides complex and irrelevant info so they can us the system without knowing how it works
When are lots of layers of abstraction needed and what is this called
Large complex problems
Stepwise refinement/Top down development
What makes a tree a binary tree
Each node has only 2 child nodes
It is ordered to optimise searching
Has no cycles
Edges not directed
Edges
The ‘lines’ and connections that link 2 nodes
How to search a binary tree
Compare required element with root node. If it is less, search the right tree, if more search the right tree. Repeat until you reach leaf or you find the item
Pointers and notes
Advantages
make algorithm easier to trace, can help with testing and maintenance, allows others to understand system
Tree traversal
Systematically visiting every node
Depth first tree traversal
Goes down one branch of the tree as far as possible until it stops at a leaf before trying another branch
Uses a stack
Left, then right, then itself
Breadth first tree traversal
The tree is traversed by sweeping through the breadth of a level before visiting the next level down
Starting from left, visits all children of the start node
Then it visits all nodes directly connected to each of these nodes
Uses a queue
Pre order
Visit node
Pre order of left tree
Pre order of right tree
In order
In order of left tree
Visit node
In order of right tree
Post order
Post order of left tree
Post order of right tree
Visit node
Uses
Binary search trees
in order = access values in ascending order
- reverse in order = descending order
Algorithms
Definition
a set of instructions followed to complete a task
What makes a problem computable
If it can be solved by an algorithm
- impractical when resources or time needed is too much
Graphs
An abstract data type that can be used to represent complex non linear relationships between objects
Similarities between graphs and trees
Both consist of node
Connected by edges
Non linear
Dynamic data structures
Differences between trees and graphs
Tree = 1d, graph = 2d
Tree has root node, graph has no clear root
Trees are not weighted whereas graphs can be
Graphs can have cycles whereas trees cannot
Cycles
A path that starts and ends on the same node
Undirected edge
When there is no direction associated with an edge