Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

DIVIDE and CONQUER technique, Exercises of Algorithms and Programming

DEFINITION and BRIEF INTRODUCTION

Typology: Exercises

2019/2020

Uploaded on 04/07/2020

hem-chander
hem-chander 🇮🇳

1 document

1 / 15

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Module 2
Divide and Conquer
Prof. Hemachander N,
Dept. of Computer Science & Engineering
Cauvery Institute of Technology,
Mandya
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download DIVIDE and CONQUER technique and more Exercises Algorithms and Programming in PDF only on Docsity!

Module 2 Divide and Conquer Prof. Hemachander N, Dept. of Computer Science & Engineering Cauvery Institute of Technology, Mandya

Contents

  1. General method
  2. Recurrence equation
  3. Algorithm: Binary search
  4. Algorithm: Finding the maximum and minimum
  5. Algorithm: Merge sort
  6. Algorithm: Quick sort
  7. Algorithm: Strassen’s matrix multiplication
  8. Advantages and Disadvantages
  9. Decrease and Conquer Approach
  10. Algorithm: Topological Sort

Divide and Conquer

Control Abstraction for Divide &Conquer

General Time functionm of DandC

Technique:

where f(n) is a function that accounts for the time spent on dividing the problem into smaller ones and on combining their solutions.

  • (^) T(n)=

Finding Time Complexity of DandC

Algorithms

  • (^) Substitution Method
  • (^) Masters Theorem

Master Theorem

  • (^) It states that, in recurrence equation T(n)=aT(n/b) + f(n) Time complexity can be computed based on how the value of a & bd^ relates to each other. Here d is power of n in f(n)

Example

Find the time complexity of the following equation using substitution method and master theorm [assume T(1)= 0 ]

Excercise

  1. T(n)=T(n-1)+n T(1)=
  2. Solve Recurrence Relation a=2, b=2, f(n)=cn
  3. Solve T(n)=T(n/2)+n, T(1)=
  4. T(n)=2 T(n/2)+1, T(1)=