0% found this document useful (0 votes)
22 views5 pages

Computational Thinking and Problem

Big O notation is a mathematical concept used to describe the efficiency of algorithms in terms of time and space complexity. It allows for the comparison of different algorithms, although two algorithms with the same Big O notation may perform differently in practice. The document also discusses various sorting algorithms, including Merge Sort, Insertion Sort, and Bubble Sort, as well as the concept of recursion.

Uploaded by

waseem sabri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views5 pages

Computational Thinking and Problem

Big O notation is a mathematical concept used to describe the efficiency of algorithms in terms of time and space complexity. It allows for the comparison of different algorithms, although two algorithms with the same Big O notation may perform differently in practice. The document also discusses various sorting algorithms, including Merge Sort, Insertion Sort, and Bubble Sort, as well as the concept of recursion.

Uploaded by

waseem sabri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

MUHAMMAD WASEEM SABRI

Computational thinking and problem-

solving

Big O Notation

What is Big O Notation?

Big O notation is used used as a tool to describe the growth rate of a function in terms of the

number of instructions that need to be processed (time complexity) or the amount of memory

required (space complexity).

This allows different algorithms to be compared in terms of their efficiency.

Note: Two algorithms can have the same Big O notation but in practice have wildly different

execution times in practice. This is because the Big O describes the growth rate of complexity,

not the actual complexity itself.

 Time Complexity

Time complexity refers to the growth in the number of instructions executed (and therefore the

time taken) as the length of the array to be searched increases.

 Space Complexity

Space complexity refers to the growth in the size of memory space that is required as the

length of the array is increased.

1
MUHAMMAD WASEEM SABRI

 Algorithm Performance

There are a number of factors that affect the performance of search / sorting algorithms. Some

algorithms perform well with high entropy (randomness) data, other algorithms work better

when the data is partially sorted in some manner. This means that no one algorithm works best

in every situation and the nature of the data being sorted needs to considered.

Advertisement

Search Algorithms

Merge Sort

Divide and Conquer Paradigm

 Divide the problem into smaller sub-problems

 Divide the list into sub-lists each of length 1

 Conquer (solve) each sub-problem and combine the results

 Repeatedly merge sub-lists to produce new sorted sub-lists until there is only one sorted list

2
MUHAMMAD WASEEM SABRI

Insertion Sort

At each iteration, insertion sort

removes one element from the input data, finds the location it belongs within the sorted list,

and inserts it there. It repeats until no input elements remain.

Bubble Sort

3
MUHAMMAD WASEEM SABRI

Lighter bubbles rise to the top, Heavier ones sink to the bottom.

Recursion

 Recursion is a function which it call itself

 Solve a large problem by solving a sub-problems

 Sub-problems are the same kind as the original problem and they can be solved with the same

algorithm Simpler to solve: sub-problems are so simple that they can be solved without further

reductions (base case)

 It needs at least one base case to stop recursive calls otherwise the program will crash.

4
MUHAMMAD WASEEM SABRI

You might also like