1 Data Structures and Programming 資料結構與程式設計. 2 Instructor: 顏嗣鈞 Web: Time: 9:10-12:00 AM, Tuesdaay.

Slides:



Advertisements
Similar presentations
Priority Queues  MakeQueuecreate new empty queue  Insert(Q,k,p)insert key k with priority p  Delete(Q,k)delete key k (given a pointer)  DeleteMin(Q)delete.
Advertisements

1 Greedy 2 Jose Rolim University of Geneva. Algorithmique Greedy 2Jose Rolim2 Examples Greedy  Minimum Spanning Trees  Shortest Paths Dijkstra.
CSCE 210 Data Structures and Algorithms
CS 315 March 24 Goals: Heap (Chapter 6) priority queue definition of a heap Algorithms for Insert DeleteMin percolate-down Build-heap.
DAST, Spring © L. Joskowicz 1 Data Structures – LECTURE 1 Introduction Motivation: algorithms and abstract data types Easy problems, hard problems.
1 7-MST Minimal Spanning Trees Fonts: MTExtra:  (comment) Symbol:  Wingdings: Fonts: MTExtra:  (comment) Symbol:  Wingdings:
1 Graphs ORD DFW SFO LAX Many slides taken from Goodrich, Tamassia 2004.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Administrivia- Introduction CSE 373 Data Structures.
Dijkstra/Prim 1 make-heap |V| insert |V| delete-min |E| decrease-key Priority Queues make-heap Operation insert find-min delete-min union decrease-key.
CS 206 Introduction to Computer Science II 04 / 29 / 2009 Instructor: Michael Eckmann.
© 2004 Goodrich, Tamassia Shortest Paths1 Shortest Paths (§ 13.6) Given a weighted graph and two vertices u and v, we want to find a path of minimum total.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2005 Lecture 1 Introduction/Overview Text: Chapters 1, 2 Wed. 9/7/05.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 11 Instructor: Paul Beame.
Data Structures, Spring 2004 © L. Joskowicz 1 DAST – Final Lecture Summary and overview What we have learned. Why it is important. What next.
0 Course Outline n Introduction and Algorithm Analysis (Ch. 2) n Hash Tables: dictionary data structure (Ch. 5) n Heaps: priority queue data structures.
Prim’s Algorithm and an MST Speed-Up
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
© 2004 Goodrich, Tamassia Shortest Paths1 C B A E D F
Chapter 9: Graphs Spanning Trees Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Lydia Sinapova, Simpson College.
DAST, Spring © L. Joskowicz 1 Data Structures – LECTURE 1 Introduction Motivation: algorithms and abstract data types Easy problems, hard problems.
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne Binary and Binomial Heaps These lecture slides are adapted from CLRS, Chapters.
1 Minimum Spanning Trees Longin Jan Latecki Temple University based on slides by David Matuszek, UPenn, Rose Hoberman, CMU, Bing Liu, U. of Illinois, Boting.
CSCE 3110 Data Structures and Algorithm Analysis.
1 Minimum Spanning Trees Longin Jan Latecki Temple University based on slides by David Matuszek, UPenn, Rose Hoberman, CMU, Bing Liu, U. of Illinois, Boting.
Computer Science 102 Data Structures and Algorithms V Fall 2009 Lecture 1: administrative details Professor: Evan Korth New York University 1.
Instructor: Dr. Sahar Shabanah Fall Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.
Lecture20: Graph IV Bohyung Han CSE, POSTECH CSED233: Data Structures (2014F)
Weighted Graphs In a weighted graph, each edge has an associated numerical value, called the weight of the edge Edge weights may represent, distances,
CS112A1 Spring 2008 Practice Final. ASYMPTOTIC NOTATION: a)Show that log(n) and ln(n) are the same in terms of Big-Theta notation b)Show that log(n+1)
1 Shortest Path Problem Topic 11 ITS033 – Programming & Algorithms C B A E D F Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program,
Data Structures Lecture 1: Introduction Azhar Maqsood NUST Institute of Information Technology (NIIT)
CSCA48 Course Summary.
CS-2851 Dr. Mark L. Hornick 1 CS-2852 Data Structures Dr. Mark L. Hornick Office: L341 Phone: web: people.msoe.edu/hornick/
Spring 2007Graphs1 ORD DFW SFO LAX
CS Data Structures II Review & Final Exam. 2 Topics Review Final Exam.
Today: Office hours –No tomorrow. M/T- 3-on. Overloading operators Inheritance Review.
Data Structures Lecture 1: Introduction. Course Contents Data Types   Overview, Introductory concepts   Data Types, meaning and implementation  
Shortest Paths and Dijkstra’s Algorithm CS 105. SSSP Slide 2 Single-source shortest paths Given a weighted graph G and a source vertex v in G, determine.
CS223 Advanced Data Structures and Algorithms 1 Review for Midterm Neil Tang 03/06/2008.
Data Structures and Algorithm Analysis Introduction Lecturer: Ligang Dong, egan Tel: , Office: SIEE Building.
1 BIM304: Algorithm Design Time: Friday 9-12am Location: B4 Instructor: Cuneyt Akinlar Grading –2 Midterms – 20% and 30% respectively –Final – 30% –Projects.
CSC 213 – Large Scale Programming. Today’s Goals  Discuss what is meant by weighted graphs  Where weights placed within Graph  How to use Graph ’s.
1 Binomial Tree Binomial tree. n Recursive definition: B k-1 B0B0 BkBk B0B0 B1B1 B2B2 B3B3 B4B4.
Review for Final Exam Non-cumulative, covers material since exam 2 Data structures covered: –Treaps –Hashing –Disjoint sets –Graphs For each of these data.
CSE 326 Course Review David Kaplan Dept of Computer Science & Engineering Autumn 2001.
Data Structures and Algorithms in Java AlaaEddin 2012.
 Saturday, April 20, 8:30-11:00am in B9201  Similar in style to written midterm exam  May include (a little) coding on paper  About 1.5 times as long.
Principles of Imperative Computation Lecture 1 January 15 th, 2012.
1 Data Structures and Programming 資料結構與程式設計. 2 Instructor: 顏嗣鈞 Web: Time: 9:10-12:00 AM, Tuesdaay.
Graphs 10/24/2017 6:47 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and.
CSCE 210 Data Structures and Algorithms
Lecture 1 Introduction/Overview Text: Chapters 1, 2 Wed. 1/28/04
Shortest Path 6/18/2018 4:22 PM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Shortest Paths C B A E D F Shortest Paths 1
CS 315 Data Structures B. Ravikumar Office: 116 I Darwin Hall Phone:
Minimum Spanning Trees
Data Structures and Programming
Review for Final Exam Non-cumulative, covers material since exam 2
Graphs CSE 2011 Winter November 2018.
Shortest Paths C B A E D F Shortest Paths
Chapter 13 Graph Algorithms
Minimum Spanning Trees
Single-source shortest paths
Administrivia- Introduction
Administrivia- Introduction
Priority Queues Supports the following operations. Insert element x.
CSCE156: Introduction to Computer Science II
COMP 122 – Design and Analysis of Algorithms
Presentation transcript:

1 Data Structures and Programming 資料結構與程式設計

2 Instructor: 顏嗣鈞 Web: Time: 9:10-12:00 AM, Tuesdaay Place: BL 113 Office hours: by appointment Class web page:

3 PREREQUISITES Familiarity in PASCAL, C, C++, or JAVA.

4 Required textbook: Data Structures & Algorithm Analysis in C++ (3 nd Ed.), Mark Weiss, Addison Wesley.

5 TOPICS PRELIMINARIES: Introduction. Algorithm analysis. ABSTRACT DATA TYPES: Stacks. Queues. Lists. List operations. List representations. List traversals. Doubly linked lists. TREES: Tree operations. Tree representations. Tree traversals. Threaded trees. Binary trees. AVL trees. 2-3 trees. B-trees. Red-black trees. Binomial trees. Splay trees, and more. HASHING: Chaining. Open addressing. Collision handling. PRIORITY QUEUES: Binary heaps. Binomial heaps. Fibonacci heaps. Min-max heaps. Leftist heaps. Skew heaps. SORTING: Insertion sort. Selection sort. Quicksort. Heapsort. Mergesort. Shellsort. Lower bound of sorting. INTRODUCTION TO PARALLEL PROGRAMMING DISJOINT SETS: Set operations. Set representations. Union-find. Path compression. GRAPHS: Graph operations. Graph representations. Basic graph algorithms. AMORTIZED ANALYSIS. Binomial heaps, Skew heaps. Fibonacci heaps. ADVANCED DATA STRUCTURES: Tries. Top-down splay trees, and more.

6 Grading Homework + Prog. Assignments: 25-30% Midterm exam.: 35-40% Final exam.: 35-40%

7 Academic Integrity ● With the exception of group assignments, the work (including homework, programming assignments, tests) must be the result of your individual effort. This implies that one student should never have in his/her possession a copy of all or part of another student's homework. It is your responsibility to protect your work from unauthorized access. Academic dishonesty has no place in a university, in particular, in NTUEE. It wastes our time and yours, and it is unfair to the majority of students. Any form of cheating will automatically result in a failing grade in the course and will be reported to the Dean's office.

8 Data Structures vs. Programming Data Structures ProgramsAlgorithms +=

9 Motivating Example: Minimum Spanning Tree Given an undirected graph G = (V, E) with weights on the edges, a minimum spanning tree (MST) of G is a subset T  E such that –T is connected and has no cycles, –T covers (spans) all vertices in V, and –sum of the weights of all edges in T is minimum.

10 Prim's MST Algorithm

11 Another Example: Shortest Path Given a weighted graph and two vertices u and v, we want to find a path of minimum total weight between u and v. –Length of a path is the sum of the weights of its edges. Applications: Internet packet routing, Flight reservations, Driving directions ORD PVD MIA DFW SFO LAX LGA HNL

12 Dijkstra’s algorithm CB A E D F  C B A E D F C B A E D F C B A E D F

13 Example (cont.) CB A E D F CB A E D F

14 Questions Operations performed? CB A D Find neighbors CB E D F  Find/remove minimum C B E D F Update neighbors

15 Key steps C B E D F 4 8   2 C B E D F 4 8   2 Find/remove minimum B E D F Update

16 Straightforward approach BCDEF 824  Find min: scan thru the array; Remove item BDEF Update: a left-right scan again Questions: 1.Is the above efficient? 2.Can we do better?

17 Dijkstra/Prim 1 make-heap |V| insert |V| delete-min |E| decrease-key Priority Queues make-heap Operation insert find-min delete-min union decrease-key delete 1 Binary log N 1 N 1 Binomial log N 1 Fibonacci * 1 1 log N Relaxed 1 1 log N Linked List 1 N N 1 1 N is-empty11111 Heaps O(|E| + |V| log |V|)O(|E| log |V|)O(|V| 2 )

18 Life Cycle of Software Development

19 Is this program correct? —How do we know? int Find(float[] a, int m, int n, float x) { while (m < n) { int j = (m+n) / 2 ; if (a[j] < x) { m = j+ 1 ; } else if (x < a[j]) { n = j-1; } else { return j; } } return - 1 ; }

20 Making sense of programs Program semantics defines programming language –e.g., Hoare logic, Dijkstra's weakest preconditions Specifications record design decisions –bridge intent and code Tools amplify human effort –manage details –find inconsistencies –ensure quality

21 Program Correctness (Example) if (x != null) { n = x.f; } else { n = z-1; z++; } a = new char[n]; true n >= 0 z-1 >= 0 x != null && x.f >= 0 (x != null ==> x != null && x.f >= 0) && (x == null ==> z-1 >= 0)

22 Data “Structures” General areas include: ● Sequential storage ● Hierarchical storage ● Adjacency storage

23 Goal Learn to write efficient and elegant software –How to choose between two algorithms Which to use?bubble-sort, insertion-sort, merge-sort –How to choose appropriate data structures Which to use?array, vector, linked list, binary tree

24 Why should you care? Complex data structures and algorithms are used in every real program –Data compression uses trees: MP3, Gif, etc… –Networking uses graphs: Routers and telephone networks –Security uses complex math algorithms: GCD and large decimals –Operating systems use queues and stacks: Scheduling and recursion Many problems can only be solved using complex data structures and algorithms

25 In this course, we will look at: –different techniques for storing, accessing, and modifying information on a computer –algorithms which can efficiently solve problems We will see that all data structures have trade-offs – there is no ultimate data structure... The choice depends on our requirements

26 What this course is NOT about This course is not about C++ –Although we will use C++ to implement some of the concepts This course is not about MATH –Although we will use math to formalize many of the concepts Competency in both math and C++ is therefore welcomed. –C++: inheritance, overloading, overriding, files, linked-lists, multi- dimensional arrays –Math: polynomials, logarithms, inductive proofs, logic

27 The Big Idea Definition of Abstract Data Type –A collection of data along with specific operations that manipulate that data –Has nothing to do with a programming language! Two fundamental goals of algorithm analysis –Correctness: Prove that a program works as expected –Efficiency: Characterize the run-time of an algorithm

28 The Big Idea Alternative goals of algorithm analysis –Characterize the amount of memory required –Characterize the size of a programs code –Characterize the readability of a program –Characterize the robustness of a program

29 Why study data structures? Clever ways to organize information in order to enable efficient computation Systems Theory AI Graphics Applications DataStructures Databases NetworkingGames