1 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich Algorithmen und Datenstrukturen SS 2007 Helmut Schauer.

Slides:



Advertisements
Similar presentations
1 Vorlesung Informatik 2 Algorithmen und Datenstrukturen (Parallel Algorithms) Robin Pomplun.
Advertisements

Chapter 19 Standard Template Library. Copyright © 2006 Pearson Addison-Wesley. All rights reserved Learning Objectives Iterators Constant and mutable.
Chapter 29 Postwar Industry and Agriculture Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter 8 Business Cycles. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 8-2 Figure 8.1 A business cycle.
Chapter 2 Colonial Development Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
IBM Haifa Research Lab © 2007 IBM Corporation Program Sliding A Novel Approach for the Automation of Slicing-Based Refactoring June 2007 Ran Ettinger In.
Presenter Name(s) Issue date National Student.
9 As A Factor By Karen Mastin Challenger Elementary.
1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Syntaxanalyse.
1 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich Algorithmen und Datenstrukturen FS 2008 Hashtabellen.
Source: Financial Times of London Global Banks 1999 – 2009 “Changing of the Guard”
Name ____________________ Date ___________ Period ____.
Chapter 30 To the New Millennium and Beyond Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Graphing Using Intercepts
Line Segment Intersection Computational Geometry, WS 2007/08 Lecture 3 – Supplementary Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut.
1-1 CMPT 225 Data Structures and Programming Instructor: Aaron Hunter Section: E300 Campus: Harbour Centre Semester: Spring 2007.
ICS 201 Course Overview.
1-1 ICS201: Introduction To Computer Science King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer.
Course Material: webcourses.kfupm.edu.sa
1 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich Algorithmen und Datenstrukturen FS 2008 Bäume.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 580 Artificial Intelligence Problem Spaces and Search Fall 2008 Jingsong.
Administrivia- Introduction CSE 373 Data Structures.
CENG 213 Data Structures Department of Computer Engineering Middle East Technical University Fall 2014 CENG 213 Data Structures 1.
© 2002 Franz J. Kurfess References 1 CPE/CSC 481: Knowledge-Based Systems Dr. Franz J. Kurfess Computer Science Department Cal Poly.
1 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich Listen, Stacks und Queues headtail p x.
METU Computer Engineering Department
COMPE 574 Fundamentals of Algorithms Spring Murat KARAKAYA Department of Computer Engineering.
Sorting Algorithms Data Structures & Problem Solving Using JAVA Second Edition Mark Allen Weiss Chapter 8 © 2002 Addison Wesley.
Data Abstraction and Problem Solving with JAVA Walls and Mirrors Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Data Abstraction and Problem.
Stacks and Queues Data Structures & Problem Solving Using JAVA Second Edition Mark Allen Weiss Chapter 16 © 2002 Addison Wesley.
CSE 3358 NOTE SET 1 Data Structures and Algorithms.
Recursion Data Structures & Problem Solving Using JAVA Second Edition Mark Allen Weiss Chapter 7 © 2002 Addison Wesley.
The Disjoint Set Class Data Structures & Problem Solving Using JAVA Second Edition Mark Allen Weiss Chapter 24 © 2002 Addison Wesley.
Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo, Ontario, Canada ece.uwaterloo.ca.
Linked Lists Data Structures & Problem Solving Using JAVA Second Edition Mark Allen Weiss Chapter 17 © 2002 Addison Wesley.
Course Introductions.  Introduction to java  Basics of Java  Classes & Objects  Java Collections and APIs  Algorithms and their analysis  Recursion.
Graphs and Paths Data Structures & Problem Solving Using JAVA Second Edition Mark Allen Weiss Chapter 14 © 2002 Addison Wesley.
1 CENG 707 Data Structures and Algorithms Nihan Kesim Çiçekli Department of Computer Engineering Middle East Technical University Fall 2013.
CENG 213 Data Structures1 Nihan Kesim Çiçekli Department of Computer Engineering Middle East Technical University.
Data Structures & Algorithms Lecturers : Boontee Kruatrachue Room no. 913 Kritawan Siriboon Room no. 913 Lecturers : Boontee Kruatrachue Room no. 913 Kritawan.
Data Structures & Algorithms Lecturer : Kritawan Siriboon, Room no. 913 Text : Data Structures & Algorithm Analysis in C, C++,… Mark Allen Weiss, Addison.
CENG 213 Data Structures Nihan Kesim Çiçekli
CENG 707 Data Structures and Algorithms
Chapter 1 Functions Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
CENG 213 Data Structures Nihan Kesim Çiçekli
©2004 by Pearson Education. ©2004 by Pearson Education.
©2004 by Pearson Education. ©2004 by Pearson Education.
'. \s\s I. '.. '... · \ \ \,, I.
Chapter 14 Graphs and Paths.
Chapter 12 Collections.
CENG 213 Data Structures Nihan Kesim Çiçekli
IT 4043 Data Structures and Algorithms
Chapter 1 Preliminaries
' '· \ ·' ,,,,
Chapter 2: Getting Started
Chapter 5 Algorithm Analysis.
Ալգորիթմներ Stack, Queue, Tree.
Chapter 12 Collections.
Administrivia- Introduction
Introduction: Some Representative Problems
Կարգավորում Insertion Sort, Merge Sort
Data Structures and Algorithms
Chapter 6 Dynamic Programming.
Chapter 4 Greedy Algorithms.
Presentation transcript:

1 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich Algorithmen und Datenstrukturen SS 2007 Helmut Schauer

2 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich Inhalt Listen, Stacks und Queues Suchen und Sortieren Bäume Graphen Geometrische Algorithmen Textverarbeitung

3 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich Literatur Sedgewick, R.: Algorithms in Java (1-4) Algorithms in Java (5): Graph Algorithms Addison-Wesley, 2003

4 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich Literatur Baase, S.: Computer Algorithms Addison-Wesley, 1988

5 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich Literatur Ottmann, T.; Widmayer, P.: Algorithmen und Datenstrukturen Spektrum Akad. Verlag, 1996

6 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich Literatur Saake, G.; Sattler, K.: Algorithmen und Datenstrukturen Eine Einführung mit Java dpunkt.lehrbuch, 2001

7 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich Literatur Weiss, M.: Data Structures and Algorithm Analysis in Java Pearson, 2007

8 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich Literatur Drake, P.: Data Structures and Algorithms in Java Pearson, 2006

9 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich Literatur Solymosi, A.; Grude, U.: Grundkurs Algorithmen und Datenstrukturen in Java Vieweg, 2000

10 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich Insertion Sort (1) for (i=1;i 0)&&(x<a[k-1])) a[k--]=a[k]; a[k]=x; {All j:1ji:a[j-1]a[j] ordered(a[0..i])} } {All j:1j<N:a[j-1]a[j] ordered(a[0..N-1])}

11 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich Insertion Sort (2) Vergleiche: best case (sortiert): N worst case (verkehrt sortiert): N 2 /2 average case: N 2 /4 Bewegungen: best case (sortiert): 0 worst case (verkehrt sortiert): N 2 /2 average case: N 2 /4

12 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich Selection Sort (1) for (i=0;i<N,i++) { {All j:1j<i:a[j-1]a[j] ordered(a[0..i-1])} min=i; for (k=i+1;k<N,k++) if (a[k]<a[min]) min=k; swap(i,min); {All j:1ji:a[j-1]a[j] ordered(a[0..i])} } {All j:1j<N:a[j-1]a[j] ordered(a[0..N-1])}

13 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich Selection Sort (2) N 2 /2 Vergleiche N Vertauschungen

14 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich Bubble Sort N 2 /2 Vergleiche N 2 /2 Vertauschungen

15 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich QuickSort divide et impera Worst Case:A(N) = N(N-1)/2 O(N 2 ) Best Case:A(N) = N ld N O(N log N) Average Case:A(N) = 2N ln N O(N log N)

16 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich MergeSort A(N) = N ld N O(N log N)

17 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich HeapSort (1) p q1q1 q2q2 Heap-Bedingung für Maximum Heap: All p,q: p ist predecessor von q: pq Heap-Bedingung für Minimum Heap: All p,q: p ist predecessor von q: pq

18 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich HeapSort (2) p q1q1 q2q2 Speicherung als Array a[0..N-1]: p... a[i] q 1...a[2i+1] q 2...a[2i+2] Heap-Bedingung für Maximum Heap: heap(N) All i: 1i<N: a[(i-1)/2] a[i]

19 Helmut Schauer Educational Engineering Lab Department for Informatics University of Zurich HeapSort (3) 1)heap(N) herstellen O(N log N) 2)for (i=N-1; i>0, i--) { swap(0,i); O(1) heap(i) wiederherstellen; O(log N) } A(N) = 2N ld N O(N log N)