×
IT'S TIME TO WORK A LITTLE HARDER.
--Your friends at LectureNotes
Close

Note for Analysis and Design of Algorithms - DAA by amIndian

  • Analysis and Design of Algorithms - DAA
  • Note
  • Computer Science Engineering
  • B.Tech
  • 355 Views
  • 8 Offline Downloads
  • Uploaded 1 year ago
0 User(s)
Download PDF

Share it with your friends

Leave your Comments

Text from page-2

Algorithm classification ◼ ◼ ◼ ◼ Algorithms that use a similar problem-solving approach can be grouped together We’ll talk about a classification scheme for algorithms This classification scheme is neither exhaustive nor disjoint The purpose is not to be able to classify an algorithm as one type or another, but to highlight the various ways in which a problem can be attacked 2

Text from page-3

A short list of categories ◼ Algorithm types we will consider include: ◼ ◼ ◼ ◼ ◼ ◼ ◼ ◼ Simple recursive algorithms Backtracking algorithms Divide and conquer algorithms Dynamic programming algorithms Greedy algorithms Branch and bound algorithms Brute force algorithms Randomized algorithms 3

Text from page-4

Simple recursive algorithms I ◼ A simple recursive algorithm: ◼ ◼ ◼ ◼ Solves the base cases directly Recurs with a simpler subproblem Does some extra work to convert the solution to the simpler subproblem into a solution to the given problem I call these “simple” because several of the other algorithm types are inherently recursive 4

Text from page-5

Example recursive algorithms ◼ To count the number of elements in a list: ◼ ◼ ◼ ◼ If the list is empty, return zero; otherwise, Step past the first element, and count the remaining elements in the list Add one to the result To test if a value occurs in a list: ◼ ◼ ◼ If the list is empty, return false; otherwise, If the first thing in the list is the given value, return true; otherwise Step past the first element, and test whether the value occurs in the remainder of the list 5

Lecture Notes