Docsity

Data Structures and Algorithms: Introduction, Algorithms, Recursion, Sorting, Study notes of Data Structures and Algorithms

Partial preview of the text

Download Data Structures and Algorithms: Introduction, Algorithms, Recursion, Sorting and more Study notes Data Structures and Algorithms in PDF only on Docsity!

Data Structures and Algorithms

Werner Nutt

Acknowledgments

  • The course follows the book Introduction to Algorithms, by Cormen, Leiserson, Rivest and Stein , MIT Press [CLRST]. Many examples displayed on these slides are taken from their book.
  • These slides are based on those developed by Michael Böhlen for his course. (See http://www.inf.unibz.it/dis/teaching/DSA/)
  • The slides also include a number of additions made by Roberto Sebastiani and Kurt Ranalter when they taught later editions of this course (See http://disi.unitn.it/~rseba/DIDATTICA/dsa2011_BZ/)

DSA, Chapter 1:

  • Introduction, syllabus, organisation
  • Algorithms
  • Recursion (principle, trace, factorial, Fibonacci)
  • Sorting (bubble, insertion, selection)

Learning Outcomes

The main things we will learn in this course:

  • To distinguish between a problem and an algorithm that solves it
  • To get to know a toolbox of classical algorithms
  • To think algorithmically and get the spirit of how algorithms are designed
  • To learn a number of algorithm design techniques (such as divide-and-conquer)
  • To analyze (in a precise and formal way) the efficiency and the correctness of algorithms.

Literature

Cormen, Leiserson, Rivest and Stein (CLRS), Introduction to Algorithms , Second Edition, MIT Press and McGraw-Hill, 2001 and Third Edition, MIT Press, 2009 (See http://mitpress.mit.edu/algorithms/) Course is based on this book

Other Literature

Kurt Mehlhorn and Peter Sanders Algorithms and Data Structures - The Basic Toolbox Offers alternate presentation of topics of the course Free download from http://www.mpi-inf.mpg.de/~mehlhorn/ftp/Mehlhorn-Sanders-Toolbox.pdf

Assignments

The assignments are a crucial part of the course

  • Roughly each week an assignment has to be solved
  • The schedule for the publication and the handing in of the assignments will be announced at the next lecture.
  • A number of assignments include programming tasks. It is strongly recommended that you implement and run all programming exercises.
  • Assignments will be marked. The assignment mark will count towards the course mark.
  • Any attempt at plagiarism (copying from the web or copying from other students) leads to a 0 mark for all assignments.

Assignments, Midterm Exam,

Final Exam, and Course Mark

  • There will be
    • one written exam at the end of the course
    • one mock exam around the middle of the course
    • assignments
  • To pass the course, one has to pass the written exam.
  • Students who do not submit exercises and do not take part in the mock exam (or fail the mock exam) will be marked on the final exam alone.
  • For students who submit all assignments, and take part in the midterm, the final mark will be a weighted average 50% exam mark + 5% mock exam
  • 45% assignment mark

Organisation of Labs

  • You will attend always the lab of the same teaching assistant (TA) during the course
  • The TA will mark your assignments and be your first contact person for questions on the assignments
  • To help us organize the labs, send an email by Wednesday evening to [email protected] containing a group of students that would like to attend the same lab
  • One mail per group is enough
  • The mail should contain for each student of the group
    • name
    • email address
    • student number
  • All members of the group to be registered must appear in the cc

General Remarks

  • Algorithms are first designed on paper … and later keyed in on the computer.
  • The most important thing is to be simple and precise.
  • During lectures:
    • Interaction is welcome; ask questions (I will ask you anyway J )
    • Additional explanations and examples if desired
    • Speed up/slow down the progress

What are Algorithms About?

There are problems we solve in everyday life

  • Travel from Bolzano to Berlin
  • Cook Spaghetti alla Bolognese (I know, not in Italy,…)
  • Register for a Bachelor thesis at FUB For all these problems, there are
  • instructions
  • recipes
  • procedures, which describe a complex operation in terms of
  • elementary operations (  beat well …  )
  • control structures and conditions (  … until fluffy  )

Algorithms

Problems involving numbers, strings, mathematical objects:

  • for two numbers, determine their sum, product, …
  • for two numbers, compute their greatest common divisor
  • for a sequence of strings, find an alphabetically sorted permutation of the sequence
  • for two arithmetic expressions, find out if they are equivalent
  • for a program in Java, create an equivalent program in byte code
  • on a map, find for a given house the closest bus stop We call instructions, recipes, for such problems algorithms What have algorithms in common with recipes? How are they different?

Data Structures, Algorithms, and Programs

  • Data structure
    • Organization of data to solve the problem at hand
  • Algorithm
    • Outline, the essence of a computational procedure, step-by-step instructions
    • Specify transitions of the data structures
  • Program
    • implementation of an algorithm in some programming language

Overall Picture

Using a computer to help solve problems:

  • Precisely specifying the problem
  • Designing programs
    • architecture
    • algorithms
  • Writing programs
  • Verifying (testing) programs Data Structure and Algorithm Design Goals Implementation Goals Correctness (^) Efficiency Robustness Reusability Adaptability