Paper 2 Flashcards

1
Q

Features of good algorithm

A

-Allow invalid input
-Terminates
-clear steps
-execute correctly and efficiently

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

All types of complexities O() best to worst

A

-constant
-Logarithmic
-linear
-quadratic
-Polynomial
-Exponential
-Factorial

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define time complexity/How to reduce time complexity

A

-How execution time scales with size of input

-use divide and conquer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Define space complexity/ how to improve

A

-How amount of memory space scales with size of input

-Update variables on original data don’t create copies

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Space-Run on cheaper Ram
Time-less power used / more tasks in a period of time

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Depth First Traversal

A

Uses stack / visited list
-Go as down as possible before backtracking

-Start popping to backtrack and search for neighbors
If stack is empty stop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Breadth Firtst Traversal

A

-use queue
- explore all the neighbors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Graph/Tree Difference and Similarity

A

Graph: edges and vertices and weights
Tree:hierarchy / root /leaf/edges/branches

Trees don’t have cycles
Trees are not weighted

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Advantage/Disadvante of DFS

A

+= stack uses less memory/ quick to find deeper parts

-= DFS may not find shortest path all the time

-= May get stuck in infinite loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Give some features of IDE and definition of IDE

A

Set of tools to help develop/debug code

Watch Window
Stepping
Breakpoint
Code Editor stuff like highlighting auto completion/ auto indent
Debugging Tools

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is concurrent processing/ how to implement it

A

Multiple processes happening at the same time

Break into threads-> multi threading

Concurrent vs Parallel

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Possible problems with Concurrent Processes

A

Simultaneous access to variables may cause inconsistencies/use record locking

Not everything is parallelisable. Sometimes if output of one thing depends on next .

Also x processors don’t mean 1/x time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you read from a file and write it to other

A

file1=openRead(“1.txt”)
file2=openWrite(“2.txt”)

while NOT file1.endOfFile()
a=file1.readLine()
file2.writeLine(a)

file1.close()
file2.close()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you find length of string and find the character of index 2

A

1)string.length
2)string.substring(2,1)

substring(startindex,numofchar)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is casting?

A

int(“3”)
Or
float(“3.14”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Computational Methods

A

-Problem Recognition
-Backtracking
-Heuristics
-Performance Modelling
-Pipelining
-Visualisation

17
Q

Computable Problems

A

Intractable-practical to solve
1)Clearly defined problem
2)every instance of problem can be solved in finite number of steps

18
Q

Advantages of Decomposition

A

Breaking into sub problems allows:

-speed up and simplify
-split between programmers
-problem easier to manage and easy to modify
-easy to test/debug individual parts
-Modular programming

19
Q

DFS(post-order) for a tree

A

1)Go left as much as possible
2)If no more left child, go right
3)When no more child nodes, backtrack to root node to check for further nodes.

20
Q

Symbols and labels are used / example of abstraction

21
Q

Advantage Disadvantage of Abstraction

A

+reduce time and resources -> less computational resources cheaper
+focus on core aspects don’t get distracted with details
+too much abstraction can make game simple and boring

22
Q

Advantages of OOP over Procedural

A

code reusability, data encapsulation, and improved code maintenance and modularity

23
Q

Encapsulation and Advantages

A

Daha hiding setters/getters. Protects the data from being unintentionally changed by other subroutines

24
Q

Advantage/ Disadvantage of Linked Lists

A

Easy to add delete
Hard to search

25
Djikstra
Shortest path to every node Use priority queue or Node/Distance/visited/Previous Node Table
26
A* Algorithm
Focus on reaching the goal node 2 Cost functions-Real Cost and Heuristic Cost Heuristic Cost must be less than or equal to real cost
27
What is problem recognition/decomposition
Decomposition-splitting down a problem into sub problems Recognition- Identify there is a problem to be solved and what it is
28
What is performance Modelling and how to use it?
Performance Modelling- simulate/test the system without using it Application- can be used for a stress test to see how it handles too much users etc
29
Difference between tree and graph
Graphs have cycles/ can be directed or undirected. Trees have a hierarchy
30
Benefits of visualisation
Visualisation benefits humans not computers. Present information in a simpler form to understand. Visualizations can best explain complex situations
31
Advantages/Disadvantages of Abstraction
+Saves time and resources +Focus on core aspects don’t get distracted -If too simple may be boring
32
In a recursive function why use passing by value
Passing by value means that the original value doesn’t change. Also byRef wouldn’t work it would crash.
33
Advantages of IDEs
-Spot errors easier make less errors -Reduce time / errors better code quality
34
Advantages of Local and Global variables
Global +Easier to code -Not a good programming practice-uses more memory Local +After subroutine finishes memory space freed+ better use of memory -Harder to code