Lecture 1 - Intro
Lecture 1 - Intro
ALGORITHMS (113215)
D r. O w a i s H u s s a i n
AGENDA
I n t r o d u c ti o n
D a t a o r g a n i z a ti o n
Algorithms
A s y m p t o ti c n o t a ti o n s
2
Introduction
SAMPLE 2
Data structures can also help you win battles, like the battle of Talafgar in
1805.
In fact, they can help you win wars, like Alan Turing’s cracking of Enigma
code.
Data Organization
SAMPLE 2
An algorithm is a way to express logic. It can be in any language and use any
symbols. It can be in plain English as well.
A set of instructions with a clear meaning that can be performed within a finite
amount of time to solve a problem. It requires an input, a logic to perform some
operations on that input and an output.
A pseudocode is an algorithm written in formal way using standard symbols.
A computer program is written in a formal language to represent an algorithm.
Computers are quite inflexible compared to human mind, so programs need to
contain some more details than algorithms.
Algorithms: Example
SAMPLE 2
All examples covered in this course will be related to the following scenario:
The College of Computing and Information Sciences offers courses in all 3 campuses of
KIET. The students from various programs including CS and SE are identified by a unique
SID. Their courses have unique codes and credit hours. Each student has a grade sheet
containing his/her records of courses enrolled in and marks acquired, which aggregate to
define their grades and a Cumulative GPA.
Our objective is to design a system to manage the students’ information, which can
insert, delete, search and present their data in an efficient manner.
Real life Example
SAMPLE 2
Let’s say there are 5 students in the class; there will be following possibilities:
Highest CGPA is 4.0 and this student is sitting in first bench. In this case the time
will be 1ms, because 4.0 is highest possible value. Therefore, the time
complexity will be 1ms.
Highest CGPA is 4.0, but this student is on the last bench. Now, we must
compare each student’s CGPA. Therefore, the time complexity will be 5ms.
The highest CGPA is 4.0, but this student is on 3 rd bench. Therefore, the time
complexity will be 3ms.
The highest CGPA is 3.8, and this student is on 1 st bench. We must still compare
all other students’ CGPA. Therefore, the time complexity will be 5ms.
After considering all cases, we see that the worst scenario is .
Assignment 1
SAMPLE 2
h tt p s : / / w w w . r e s e a r c h g a t e . n e t / p r o fi l e / O w a i s - H u s s a i n - 3