BITS Pilani
CS F364: Design and Analysis of Algorithms

Introduction to Algorithms

Lecture 1 |2026-05-21

Introduction

  • Introduction
  • Wrap-up

Design and Analysis of Algorithms

  • Algorithm: A well-defined procedure that transfers an input to an output.
    • Not a program: An algorithm can be implemented in several ways.
  • Design: We will study methods/ideas/tricks for developing (fast!) algorithms.
  • Analysis: Abstract/mathematical comparison of algorithms (without actually implementing them).

Math is needed in three ways:

  1. For the formal definition of the problem.
  2. For the analysis of correctness of algorithms.
  3. For the analysis of efficiency (time, memory, …).

Algorithms are fundamental

Algorithms are useful

  • Foundational Knowledge: Algorithms are the backbone of Computer Science.
  • Enhances problem solving skills: We learn how to break down complex problems into simpler ones and design efficient solution.
  • Adaptability across domains: Algorithmic thinking is applicable beyond coding in the fields like biology (understanding gene), finance (risk modeling), and logistics (route optimization). This adaptability makes it a versatile skill.
  • Career Advancements: Algorithms are indispensable components in technical interviews. Excelling in algorithms can help secure roles in software development, data science, and other technical careers.

Warm-up Problem - Integer multiplication

Integer Multiplication

  • About n^2 one-digit operations.
    • At most n^2 multiplications.
    • At most n^2 additions.
    • Add n different 2n digit numbers.

Complexity of multiplying two n digit numbers

Can we improve the complexity using Algorithmic toolkit?

Divide and conquer

Break the problem into smaller (simpler) subproblems.

Divide and conquer for multiplication

Break up an integer: 1234 = 12 \times 100 + 34.

More generally..

Break up an n digit integer

[x_1x_2\cdots x_n] = [x_1x_2\cdots x_{n/2}]\times 10^{n/2} + [x_{n/2+1}x_{n/2+2}\cdots x_n]

Divide and conquer algorithm

How long does this take?

An Example

  • Claim: There are n^2 one-digit problems.
  • Every pair of digits still gets multiplied together separately.
  • The running time is still at least n^2.

Another way of looking this example

  • If we cut n in half \log_2{n} times, we get down to 1.
  • So, we do this \log_2{n} times and get 4^{\log_2{n}} = n^2 problems of size 1.

Yet another way to see this

  • Let T(n) be the time to multiply two n-digit numbers.
  • Recurrence: T(n) = 4T(n/2) + \text{(time for adding things up)}

Let us solve the recurrence:

Can we improve the time complexity from n^2?

  • Karatsuba figured out the following:
  • If we only recurse three times instead of four!

Karatsuba algorithm for integer multiplication

Another way of looking this example

  • If we cut n in half \log_2{n} times, we get down to 1.
  • So, we do this \log_2{n} times and get 3^{\log_2{n}} = n^{1.6} problems of size 1.

This is much better

Wrap-up

  • Introduction
  • Wrap-up

Discussion Time!

Thank You!

Let’s discuss questions, clarifications, or any topics from today’s lecture.