Computer Science paper 2

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/60

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

61 Terms

1
New cards

Abstraction

the process of removing unnecessary details of a problem to focus on the important features to implement in a solution

2
New cards

What is the difference between abstraction and reality?

Abstraction is a simplified version of reality

3
New cards

3 questions that need to be asked to be able to develop an abstract model?

What is the specific problem to be solved?
Can the problem be broken down into milestones?
What elements will impact the solution for each milestone?

4
New cards

What are inputs in an algorithm?

Data required for the algorithm to run (e.g., parameters passed to a subroutine).

5
New cards

What are outputs in an algorithm?

Data returned by the algorithm (e.g., results, messages, or device outputs).

6
New cards

Why is it important to explicitly define inputs and outputs?

To avoid errors by specifying type, size, and format (e.g., search algorithm needs sorted array).

7
New cards

What are preconditions in an algorithm?

Conditions that must be true for the algorithm to succeed (e.g., non-empty list, sorted data).

8
New cards

Give an example of a precondition for binary search.

The input list must be sorted; otherwise, the algorithm fails.

9
New cards

How can preconditions be implemented?

Through documentation (user checks) or code validation (automatic checks).

10
New cards

What is caching?

Storing frequently accessed data for faster retrieval.

11
New cards

What are the benefits of caching?

Faster access, reduced processing load.

12
New cards

What are the drawbacks of caching?

Risk of stale data (outdated info) and memory overhead.

13
New cards

Why are reusable program components important?

They promote efficiency, modularity, and reduce redundant code.

14
New cards

How can a subroutine be made reusable?

By clearly defining inputs, outputs, and preconditions (e.g., library functions).

15
New cards

For LinearSearch, what are the inputs?

A list of integers (e.g., my_list = [i1, i2, ...]).

16
New cards

For LinearSearch, what are the ouputs?

The index of the found element (integer).

17
New cards

What is a variable?

A changable memory location that holds data

18
New cards

What is data mining?

When large quantities of data are turned into useful information so that patterns can be found 

19
New cards

Benefits of Data Mining

Data mining can be used to identify patterns and trends that may not be immediately obvious to humans. 

It can help organisations make better future predictions.

Organisations can ensure demand is met during busy
periods to stay ahead of local competition. 

20
New cards

Drawbacks of data mining?

It requires very powerful computers with a lot of processing power.

Inaccurate data can produce inaccurate results.

Although it may spot patterns and trends, it may not explain the reasons why these exist. 

21
New cards

What is heuristics?

Making use of experience to find a solution to a problem quickly

22
New cards

Benefits of Heuristics?

Heuristics can usually find a solution close to the best solution available.

Heuristics save time as you may not to investigate every single possibility to get a definite answer.

Heuristics is very practical and can be easily implemented.

23
New cards

Drawbacks of Heuristics?

It will not guarantee that you will find the ‘best’ solution as it aims to find a solution quickly that is ‘good enough

There needs to be careful consideration to be made between accuracy and time.

The heuristic values may be incorrect which can lead to inaccurate solutions being found. 

24
New cards

What is a global variable?

a variable declared at the outermost level of a program.

25
New cards

Benefits of Global Variables?

The global variable only needs to be declared once.

You don’t need to keep passing parameters between the different modules.

26
New cards

Drawbacks of Global Variables?

The global variables are always stored in memory while the program is running which can use up memory.

Makes the program difficult to maintain as it’s difficult to understand where variables are changed in the program.

Makes it difficult to test a single block of code as the programmer will need run the entire program to setup the global variables.

27
New cards

What is a local variable?

A variable declared within a specific scope, such as a function or a code block

28
New cards

Benefits of Local Variables?

Local variables encapsulate data within a particular function or block, providing data hiding and preventing unintended access from other parts of the program.

Local variables enable you to use the same variable name in different functions or blocks without causing conflicts, as each local variable is confined to its own scope.

Local variables have a limited lifetime, and their memory is automatically reclaimed when the code block ends, making them memory efficient.

29
New cards

Drawbacks of Local Variables?

Repeatedly creating and destroying local variables within a loop or recursive function can incur unnecessary memory overhead.

Excessive use of local variables within deeply nested blocks can lead to code clutter and reduce code readability.

30
New cards

What is Nesting?

Putting one block of code inside another block of code of the same type

31
New cards

Best Time complexity of Linear search

O(1)

32
New cards

Average Best Time complexity of Linear search

O(n)

33
New cards

Worst Time complexity of Linear search

O(n)

34
New cards

Best Time complexity of Binary Array search

O(1)

35
New cards

Worst Time complexity of Binary Array search

O(logn)

36
New cards

Average Time complexity of Binary Array search

O(logn)

37
New cards

Best Time complexity of Binary Tree search

O(1)

38
New cards

Average Time complexity of Binary Tree search

O(logn)

39
New cards

Worst Time complexity of Binary Tree search

O(n)

40
New cards

Best Time complexity of Hashing search

O(1)

41
New cards

Average Time complexity of Hashing search

O(1)

42
New cards

Worst Time complexity of Hashing search

O(n)

43
New cards

Best Time complexity of Bredth/Depth first search

O(1)

44
New cards

Average Time complexity of Bredth/Depth first search

O(V+E) verticies + edges

45
New cards

Worst Time complexity of Bredth/Depth first search

O(V²)

46
New cards

Best time complexity of a bubble sort

O(n)

47
New cards

Average time complexity of a bubble sort

O(n²)

48
New cards

Worst time complexity of a bubble sort

O(n²)

49
New cards

Best time complexity of a insertion sort

O(n)

50
New cards

Average time complexity of a insertion sort

O(n²)

51
New cards

Worst time complexity of a insertion sort

O(n²)

52
New cards

Best time complexity of a merge sort

O(nlogn)

53
New cards

Average time complexity of a merge sort

O(nlogn)

54
New cards

Worst time complexity of a merge sort

O(nlogn)

55
New cards

Best time complexity of a quick sort

O(nlogn)

56
New cards

Average time complexity of a quick sort

O(nlogn)

57
New cards

Worst time complexity of a quick sort

O(n²)

58
New cards

Space complexity of Bubble Sort

O(1)

59
New cards

Space complexity of Insertion Sort

O(1)

60
New cards

Space complexity of Merge Sort

O(n)

61
New cards

Space complexity of Quick Sort

O(log n)