Data Structures and Algorithm Analysis Introduction Lecturer: Ligang Dong, egan Tel: 28877721 , 13306517055 Office: SIEE Building.

Slides:



Advertisements
Similar presentations
Lecture 2 Based on Chapter 1, Weiss. Mathematical Foundation Series and summation: ……. N = N(N+1)/2 (arithmetic series) 1 + r+ r 2 + r 3 +………r.
Advertisements

Analysis of Algorithms
CMPT 225 Data Structures and Programming. Course information Lecturer: Jan Manuch (Jano), TASC TAs: Osama Saleh,
1 CENG 707 Data Structures and Algorithms Nihan Kesim Çiçekli Department of Computer Engineering Middle East Technical University Fall 2010.
Complexity Analysis (Part I)
CS2420: Lecture 1 Vladimir Kulyukin Computer Science Department Utah State University.
Lecture 12 Oct 13, 2008 Some simple recursive programs recursive problem solving, connection to induction Some examples involving recursion Announcements.
1 Data Structures A program solves a problem. A program solves a problem. A solution consists of: A solution consists of:  a way to organize the data.
Administrivia- Introduction CSE 373 Data Structures.
EE 220 (Data Structures and Analysis of Algorithms) Instructor: Saswati Sarkar T.A. Prasanna Chaporkar, Programming.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
The Design and Analysis of Algorithms
CSE 220 (Data Structures and Analysis of Algorithms) Instructor: Saswati Sarkar T.A. Dimosthenes Anthomelidis
Induction and recursion
CSCE 3110 Data Structures and Algorithm Analysis.
Data Structures and Programming.  John Edgar2.
Computer Science 102 Data Structures and Algorithms V Fall 2009 Lecture 1: administrative details Professor: Evan Korth New York University 1.
WEEK 1 CS 361: ADVANCED DATA STRUCTURES AND ALGORITHMS Dong Si Dept. of Computer Science 1.
CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.
Data Structures and Programming.  Today:  Administrivia  Introduction to 225, Stacks  Course website: 
Data Structures and Algorithm Analysis Lecturer: Jing Liu Homepage:
Data Structures Lecture 1: Introduction Azhar Maqsood NUST Institute of Information Technology (NIIT)
CS 103 Discrete Structures Lecture 01 Introduction to the Course
Discrete Mathematics, 1st Edition Kevin Ferland
Introduction to Proofs
Reading and Writing Mathematical Proofs
Mathematics Review Exponents Logarithms Series Modular arithmetic Proofs.
CS 3343: Analysis of Algorithms
1 CE 221 Data Structures & Algorithms Chapter 1 Introduction Text: Read Weiss, §1.1 – 1.3 Izmir University of Economics.
Chapter 1 Introduction. Goals Why the choice of algorithms is so critical when dealing with large inputs Basic mathematical background Review of Recursion.
Course Web Page Most information about the course (including the syllabus) will be posted on the course wiki:
CSE 311 Foundations of Computing I Lecture 8 Proofs and Set Theory Spring
Methods of Proof Lecture 3: Sep 9. This Lecture Now we have learnt the basics in logic. We are going to apply the logical rules in proving mathematical.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Week 12 - Wednesday.  What did we talk about last time?  Asymptotic notation.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Course Introduction.
1 Put your name if you want your attendance credit. Please put your as well. CSC 320 is done at 11:30 so I did NOT fill in the box for 11:30 for.
Introduction to Data Structures and Algorithms CS 110: Data Structures and Algorithms First Semester,
Basic Mathematics Chapter 1 (1.2 and 1.3) Weiss. Recursion / Slide 2 Logarithms * Definition: if and only if * Theorem 1.1: n Proof: apply the definition.
Reading and Writing Mathematical Proofs Spring 2015 Lecture 4: Beyond Basic Induction.
Data Structure Introduction.
Algorithm Analysis CS 400/600 – Data Structures. Algorithm Analysis2 Abstract Data Types Abstract Data Type (ADT): a definition for a data type solely.
Recursive Algorithms &
CSC401 – Analysis of Algorithms Lecture Notes 2 Asymptotic Analysis Objectives: Mathematics foundation for algorithm analysis Amortization analysis techniques.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Course Introduction.
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
Chapter 1: Introduction
The Hashemite University Computer Engineering Department
Data Structures and Algorithms in Java AlaaEddin 2012.
1 2/21/2016 MATH 224 – Discrete Mathematics Sequences and Sums A sequence of the form ar 0, ar 1, ar 2, ar 3, ar 4, …, ar n, is called a geometric sequence.
Algorithms JPC and JWD © 2002 McGraw-Hill, Inc. 2 Algorithms 2 An Algorithm is a finite set of precise instructions for performing a computation or for.
Section 1.7. Definitions A theorem is a statement that can be shown to be true using: definitions other theorems axioms (statements which are given as.
TCSS 342 Autumn 2004 Version TCSS 342 Data Structures & Algorithms Autumn 2004 Ed Hong.
Principles of Imperative Computation Lecture 1 January 15 th, 2012.
BITS Pilani Pilani Campus Data Structure and Algorithms Design Dr. Maheswari Karthikeyan Lecture1.
Section 1.7. Section Summary Mathematical Proofs Forms of Theorems Direct Proofs Indirect Proofs Proof of the Contrapositive Proof by Contradiction.
Hubert Chan (Chapters 1.6, 1.7, 4.1)
Introduction toData structures and Algorithms
Introduction to Algorithms
GC211Data Structure Lecture2 Sara Alhajjam.
Hubert Chan (Chapters 1.6, 1.7, 4.1)
CS 583 Fall 2006 Analysis of Algorithms
Introduction CSE 373 Data Structures.
CMPT 438 Algorithms Instructor: Tina Tian.
Introduction to Algorithms
Administrivia- Introduction
Administrivia- Introduction
Basic Concepts of Algorithm
17CS1102 DATA STRUCTURES © 2018 KLEF – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS RESERVED.
Presentation transcript:

Data Structures and Algorithm Analysis Introduction Lecturer: Ligang Dong, egan Tel: , Office: SIEE Building 305

Textbook Mark Allen Weiss, Data Structures and Algorithm Analysis in C, China Machine Press. E-book is available. ata_structure.htm

Scheduling Instruction Lectures: Tuesday 8:05am Programming Practices: Friday 9:50am

Grading Final exam: 55% Weekly Homeworks:45%(15*3%) Posted every Tuesday Due Next Tuesday before class (solution posted after class) If you have difficulties in solving the homework, please ask for help during Programming Practices in Friday. No late submission accepted

Why Learn Data Structures and Algorithms? One of the basic rules concerning programming is to break the program down into modules. Each module is a logical unit and does a specific job. Its size is kept small by calling other modules. Two types of modules “data” module data structure “procedure” module algorithm

Why Learn Data Structures and Algorithms? Modularity has several advantages. It is much easier to debug small routines than large routines; It is easier for several people to work on a modular program simultaneously; A well-written modular program places certain dependencies in only one routing, making changes easier.

What are Data Structures and Algorithms? Data Structures are methods of organizing large amounts of data. An algorithm is a procedure that consists of finite set of instructions which, given an input from some set of possible inputs, enables us to obtain an output through a systematic execution of the instructions.

ADT(Abstract Data Types) Data Structure Algorithms Software Programs Software Engineering Programming Languages

Abstract Data Types (ADTs) An abstract data type (ADT) is a set of objects such as lists, sets, and graphs, along with their operations (e.g., insert, delete) Integers, reals, and booleans are data types. Integers, reals, and booleans have operations associated with them, and so do ADTs. Nowhere in an ADT ’ s definition is there any mention of how the set of operations is implemented.

Example Problem: Given 10 test results (80, 85, 77, 56, 68, 83, 90, 92, 80, 98) of C language programming of Tom, what is the average score?

Example Solution main() { int sum , average; int t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; t1=80;t2=85;t3=77;t4=56;t5=68; t6=83;t7=90;t8=92;t9=80;t10=98; sum= t1+t2+t3+t4+t5+t6+t7+t8+t9+t10; average=sum/10; printf(“Sum=%d\n”,sum); printf(“Average=%d\n”, average); }

Example Better Solution main() { int sum , average ; int i; int t[10] =80 , 85 , 77 , 56 , 68 , 83 , 90 , 92 , 80 , 98} sum=0; for(i=0; i<10; i++) sum=sum+t[i]; average=sum/10; printf(“Sum=%d\n”,sum); printf(“Average=%d\n”, average); } By using an array instead of n variables, with a loop instead of n assignments, the program is simpler.

Contents Chapter 1 Introduction ( 0.5 Week ) C Review ( 1.5 Week ) Chapter 2 Algorithm Analysis ( 1 Week ) Chapter 3 Lists, Stacks, and Queues ( 1 Week ) Chapter 4 Trees ( 2 Weeks ) Chapter 5 Hashing ( 1 Week ) Chapter 6 Priority Queues (Heaps) ( 1 Week ) Chapter 7 Sorting ( 2 Weeks ) Chapter 8 Disjoint Set ADT ( 1 Week ) Chapter 9 Graph Algorithms ( 2 Weeks ) Chapter 10 Algorithm Design Techniques ( 2 Weeks )

Mathematical Foundation Series and summation: ……. N = N(N+1)/2 (arithmetic series) 1 + r 2 + r 3 +………r N-1 = (1- r N )/(1-r), (geometric series)  1/(1-r), r < 1, large N Sum of squares: ………N 2 = N(N + 1)(2N + 1)/6

Mathematical Foundation log x a = b if x b = a we will use base 2 mostly, but may use other bases occasionally Will encounter log functions again and again! log (ab ) = log a + log b log (a/b ) = log a - log b log a b = b log a log b a = log c a/ log c b a log n = n log a a mn = (a m ) n = (a n ) m a m+n = a m a n (2  n) 0.5 (n/e) n  n   (2  n) 0.5 (n/e) n + (1/12n)

Mathematical Foundation Proof Method1: Proof By Induction Prove that a property holds for input size 1 Assume that the property holds for input size n. Show that the property holds for input size n+1. Then, the property holds for all input sizes, n.

Mathematical Foundation Example of Proof By Induction: Prove that the sum of 1+2+…..+n = n(n+1)/2 Holds for n = 1 Let it hold for n 1+2+….+n = n(n+1)/2 When n ….+n+(n+1) = n(n+1)/2 + (n+1) = (n+1)(n+2)/2.

Mathematical Foundation Proof Method2: Proof By Counter Example Want to prove something is not true! Give an example to show that it does not hold!

Mathematical Foundation Proof Method3: Proof By Contradiction Suppose, you want to prove something. Assume that what you want to prove does not hold. Then show that you arrive at an impossiblity.

Mathematical Foundation Example of Proof By Contradiction:The number of prime numbers is not finite! Suppose there are finite number of primes, k primes. (we do not include 1 in primes here) We know k  2. Let the primes be P 1, P 2, ……… P k Z = P 1 P 2 ……… P k + 1 Z is not divisible by P 1, P 2, ……… P k Z is greater than P 1, P 2, ……… P k Thus Z is not a prime. We know that a number is either prime or divisible by primes. Hence contradiction. So our assumption that there are finite number of primes is not true.

Homework #1 At least complete two of the following: 1.1 Prove the following formulas 1.2 Write a program to solve the selection problem. (Suppose you have a group of n numbers and would like to determine the kth largest.) 1.3 Based on 1.2, let k = n/2, show the original location of kth largest. And draw a table showing the running time of your program for various values of n (4<=n<=20).

Hint You should submit the homework using the WS Word file through . Your program must be submitted with output. DO NOT write any code until you understand what the program does, the design of the program, and the output that it produces. Writing code before understanding the program will simply be a waste of your time, and will result in a program that does not work!! As with any large program, it is probably a good idea to finish the easy parts first and then slowly complete the harder parts. Develop your code in small pieces, and test each part of your code as you write it. Your program is graded according to correctness, readability, robustness, efficiency.