You are on page 1of 19

Design and Analysis

of Algorithms
Course Structure
• 3 hours Lectures
• 1 hour Tutorial
• 4 hours Practical
Geekforgeeks for practising questions and
assignments.

Abdul Bari Algo lectures (initial introduction for


beginners).
Extra MIT opencourseware, NPTEL for intermediate
resources we to advanced levels.

can follow: Coursera algorithms part I and II for extra


courses.

Project only if other subjects are also offering


it.

Textbook: Cormen, Thomas H., et al.


Introduction to algorithms. MIT press, 2009.
quiz 10

Mid term 20
Marking
Scheme end term 30
(First Draft)
lab continuous eval 20

Assignment : 20
Lab • Programming language to follow: C,C++, Python?

Assignments
Foundation of the course (Prerequisite)

Data Structures. Programming.


One of the core courses of
Computer Science.

Introduction Foundational course, important


to Algorithms for placements and GATE.

Algorithmic problem solving.


Broad list of topics to be covered in the
course
Divide and
Basic of algorithms. Sorting algorithms.
Conquer paradigm.

Dynamic
Greedy algorithms. Graph algorithms.
programming.

Computational
classes.
In data structures, you were
introduced to the notion of organizing
the data.

Here, we will use those foundations to


Introduction solve problems.
to algorithm • Algorithmic problem solving.
design • Efficient problem solving
• Optimized problem solving.

To accomplish the previous things, we


will look at a variety of situations and
paradigms of problem solving.
Basic definition of algorithms

• It is an abstract computational procedure


that takes as input a value (or values) and
produces as output value (or values).
• Values could a simply number, character,
or any data structure.
• What is a program?
• A program is an instantiation of an
algorithm.
• What does the language do?
• It helps us to realize the particular
NOTE 1

• In this course, we will be using a lot of


pseudocodes.
• We will not focus on only one language,
rather we will discuss things from a
general programming independent
point of view.
• Pseudocodes has a lot of primitive
operations—Operation independent of
programming languages.
First of all, it has to minimize the overall
running time.

How do you measure it?


• Use procedures like clocks.
What is an • Issue here is: It is experimental.

efficient • Solution could be: Design a general method that


takes into account all possible inputs and scenarios.
Moreover, the general method has to be
algorithm independent of the underlying hardware constraints.

Second, it should optimize the overall


space used.
• Here, we should try to minimize the space
requirement by reusing the already allocated part of
the memory.
• First, the paradigm should be
platform independent.
• Second, the procedure should be
language independent.
• Third, the procedure should be
“general” input oriented.
Next question is: • Lastly, the performance of the
How to look at the algorithms should be analysed by
looking at the Best, Average and
performance of Worst case.
• Why?
the algorithm?
This is where the
asymptotic analysis
comes into picture
• It is programming, platform, and
hardware independent.
• It gives a mathematical way to
look at the performance of
algorithms.
• It is input oriented.
• We will study the asymptotic
analysis in the next class!
Image Source: http://courses.csail.mit.edu/6.006/spring11

Algorithmic Problem • Lets try one exercise---- We will try our hand at peak finding problem.
Solving.
Example (Taken from
GeekforGeeks)
• Input: array[]= {5, 10, 20, 15}
• Output: 20

• Input: array[] = {10, 20, 15, 2, 23, 90, 67}


• Output: 20 or 90

• Goal is to find a peak.


Simple Way
Algo_for_peak (int array[])
{
n=array.length()
if (array[0] >= array[1])
return 0; //simple first element is the peak
if (array[n - 1] >= array[n - 2])
return n - 1; //last element is the peak

for (int i = 1; i < n - 1; i++)


{

if (array[i] >= array[i - 1] && array[i] >= array[i + 1])


return i; //here “i” is a (infact the first) peak in the array.
}
Try to find the smart way
on your own today

NOTE: Use you “brain”.

Google is not your BRAIN.


Thank You

You might also like