0% found this document useful (0 votes)
31 views

Assignment 01 Computing

This document outlines an assignment on algorithm design. It discusses the definition of an algorithm and what makes a good algorithm. Specific algorithms are described, including bubble sort, linear search, quicksort. Bubble sort and linear search algorithms are explained with pseudocode. Implementation of algorithms into programs is also covered. Big O notation is introduced as a way to analyze an algorithm's efficiency.

Uploaded by

Ngân Hà
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Assignment 01 Computing

This document outlines an assignment on algorithm design. It discusses the definition of an algorithm and what makes a good algorithm. Specific algorithms are described, including bubble sort, linear search, quicksort. Bubble sort and linear search algorithms are explained with pseudocode. Implementation of algorithms into programs is also covered. Big O notation is introduced as a way to analyze an algorithm's efficiency.

Uploaded by

Ngân Hà
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

ASSIGNMENT 01:

ALGORITHM DESIGN
NGUYEN TRAN NHAT VU
BKC1903
BTEC-C01K11
OUTLINE

I. ALGORITHM

II.IMPLEMENTING ALGORITHMS INTO THE

PROGRAM
I. ALGORITHM

“AN ALGORITHM MUST BE SEEN TO BE BELIEVED”


DONALD KNUTH
DEFINITION OF ALGORITHM

An algorithm is a set of instructions designed to perform a specific task.


This can be a simple process, such as multiplying two numbers, or a
complex operation, such as playing a compressed video file.

The study of algorithms is one of the key foundations


of computer science
WHAT MAKE A “GOOD” ALGORITHM?

Producing the correct outputs for any set


of legal input

Executing with the fewest number of


steps, minimum memory usage, and the
fastest time

Easy for others to understand


BUBBLE SORT ALGORITHM BEGIN

YES NO
j=i i< n i=0 arr [n]

YES NO
j< n i += 1 END

arr[j] > YES swap (arr[j],


j += 1
arr[j + 1] arr[j + 1])
NO
BUBBLE SORT ALGORITHM

BubbleSort(list)
for i = 0 to len(list) – 1 do:
swapped = false
for k = i to len(list) – 1 do:
if list[k] > list[k+1]
swap(list[k], list[k+1])
swapped = true
//No swapped means sorted
if (!swapped)
break
return list
LINEAR SEARCH ALGORITHM START

arr [n],
END i=0
item

NO
i< n i += 1

YES

YES
arr[i] == NO
item
CODING LINEAR
SEARCH
ALGORITHM
II. IMPLEMENTING
ALGORITHMS INTO THE
PROGRAM
“IDEALS ARE DANGEROUS THINGS. REALITIES ARE
BETTER. THEY WOUND, BUT THEY'RE BETTER.”
OSCAR WILDE, LADY WINDERMERE'S FAN
QUICK SORT ALGORITHM

13 21 15 3 12 9 14 7 6

3 9 7 6 12 13 21 15 14

3 6 7 9 12 13 14 15 21

3 6 7 9 12 13 14 15 21

3 6 7 9 12 13 14 15 21
QUICK SORT ALGORITHM

Advantages
• High performance
• Easy implementation
Disadvantages
• Unstable
• Heavily decrease in speed in worse cases
QUICK SORT ALGORITHM
QUICK SORT ALGORITHM
CODING QUICK SORT
ALGORITHM
LINEAR SEARCH ALGORITHM

Advantages
• Easy to understand and implement
• No sorting required
• Suitable for small list sizes

Disadvantages
• Time inefficient compared to other algorithms
• Not suitable for large-sized lists
III. BIG-O NOTATION

A MEMBER OF A FAMILY OF NOTATIONS INVENTED BY PAUL


BACHMANN, EDMUND LANDAU, AND OTHERS
BIG-O NOTATION

Big O notation tells you the number of operations an


algorithm will make. It gets its name from the literal "Big
O" in front of the estimated number of operations.
BIG-O NOTATION

f(n) = 3
BIG-O NOTATION

f(n) = 3n + 2
THANK YOU FOR
LISTENING
ASSIGNMENT 01: ALGORITHM DESIGN

You might also like