Docsity

Introduction to complexity - Data Structures - Lecture Slides, Slides of Data Structures and Algorithms

Partial preview of the text

Download Introduction to complexity - Data Structures - Lecture Slides and more Slides Data Structures and Algorithms in PDF only on Docsity!

Introduction to complexity

An Introduction

  • In the 1930โ€™s before computers were used, mathematicians worked hard to formalize and study the concept of the algorithm. - But what exactly is an algorithm?

An algorithm is a precise set of instructions that leads to a solution. In other words, an algorithm is a precisely stated method for solving a problem.

7

The subject was founded by Knuth (who coined the term "analysis of algorithms" in the mid-sixties) and is well illustrated by his monumental series, The Art of Computer Programming The field entertains close ties with a number of areas like discrete mathematics, combinatorial analysis, probability theory, analytic number theory, asymptotic analysis, complexity theory, and sometimes statistical physics.

Analysis of Algorithms is a field in computer science whose overall goal is an understanding of the complexity of algorithms. While an extremely large amount of research is devoted to worst-case evaluations,

Data Structures and Algorithms

  • A data structure defines the admissible atomic steps and a control structure determines how these steps are to be combined to yield the desired algorithm. This view is stated very succinctly in the well known slogan ``algorithm = data structure + control''.

Mathematical Examples

  • factorial function

factorial(0) = 1 factorial(n) = n * factorial(n-1) [for n>0]

  • Let's compute factorial(3). factorial(3) = 3 * factorial(2) = 3 * ( 2 * factorial(1) ) = 3 * ( 2 * ( 1 * factorial(0) )) = 3 * ( 2 * ( 1 * 1 ) )) = 6

Fibonacci function:

  • fibonacci(0) = 1
  • fibonacci(1) = 1
  • fibonacci(n) = fibonacci(n-1) + fibonacci(n-2) [for n>1]
  • This definition is a little different than the previous ones because It has two base cases, not just one; in fact, you can have as many as you like.
  • In the recursive case, there are two recursive calls, not just one. There can be as many as you like.