* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download CSE 2320 Algorithms and Data Structures
Stream processing wikipedia , lookup
Algorithm characterizations wikipedia , lookup
Reactive programming wikipedia , lookup
Multidimensional empirical mode decomposition wikipedia , lookup
Genetic algorithm wikipedia , lookup
Abstraction (computer science) wikipedia , lookup
Data-intensive computing wikipedia , lookup
CSE 2320 Algorithms and Data Structures Introduction Dimitrios Kosmopoulos General info • Dimitrios Kosmopoulos [email protected] • Office: ERB644 (to change) • Hours: TuTh 12:30pm-2:30pm • GTA: 2B announced • web page http://heracleia.uta.edu/~dkosmo/ General info Textbook: R. Sedgewick, Algorithms in Java, Parts 1-5, 3rd ed., Addison-Wesley, 2003. References: Al Aho and Jeff Ullman, Foundations of Computer Science, http://infolab.stanford.edu/~ullman/focs.html S. Baase and A. Van Gelder, Computer Algorithms: Introduction to Design and Analysis, 3rd ed., Addison-Wesley, 2000. Cormen, Leiserson, Rivest, Stein, Introduction to Algorithms, 2nd ed., MIT Press, 2001. J. Lewis and W. Loftus, Java Software Solutions: Foundations of Program Design, 6th ed., Pearson Education, 2009. Prerequisites • C programming (CSE 1320) • Java programming (CSE 1325) (a) problem-> (b) algorithm-> (c) program-> (d) executable So far: (b)->(c)->(d) Here: (a)->(b) Objectives • To become capable of developing, applying, and evaluating algorithmic solutions. • Intuition about particular algorithms and data structures that have wide applicability. • Understanding of classic approaches to algorithm design – decomposition, dynamic programming, and greedy methods. • Understanding of basic algorithm analysis concepts by applying math skills to worst-case and expected time using recurrences and asymptotic notation. • Improved programming skills - especially data structures, recursion, and graphs. Grading Based on the following weights: Exams: 65% divided evenly among 3 exams. Programs: 15% divided evenly among three assignments. Homework assignments: 10% Practice homeworks with answers, will be available on the course web page ABET Outcome B (Experimentation) Assessment Project: 10% Grading (cont.) • Students achieving a semester grade of C or better, but failing the experimentation assessment (below 60%) and documenting their circumstances will be assigned a semester grade of I (incomplete) and may re-attempt the assessment in the next semester. If the assessment is then passed, the semester grade will be changed from I to the achieved grade. Policies (selection) • Regular attendance expected • Surprise quizzes an option, each quiz being 2% of the semester grade taken from the 65% allocated to exams • Lecture notes and sample code for various algorithms are on the course web page http://heracleia.uta.edu/~dkosmo • Cheating - You Are Expected To Know University Policies Policies (selection) • Labs are due at 10:45 am on the due date, not midnight. Homeworks are due before class. After the due time, assistance will not be provided. • Degree of lateness penalty – Up to 10:45 next day 10 pts – Up to 10:45 two days 30 pts – Up to 10:45 three days 60 pts • Resubmissions before the due time are penalized 10 points each. No resubmissions after the due time. Lab grading a. Output/Code 60% b. Internal Comments 6% c. Modularity 6% d. Structure 6% e. Names 6% f. Spacing 6% g. Generality 10% Lab submission • All programs must be written in Java to compile and execute using a recent version of the JDK. • Details for program submission will be included with each assignment. • You are responsible for correctly sending each programming assignment to the GTA as an attachment. (cc: yourself) • No points will be awarded for programs that do not compile. Points for b-g will not be awarded to submissions that are not substantially complete. Lecture structure • • • • Abstraction Data models Data structures Algorithms Abstraction Computer science: The science of abstraction: creating the right model for thinking about a problem and devising the appropriate mechanizable solution to solve it Different degrees of complexity: Digital electronic circuit Behavior of robotic agent Example 1 • abstraction: directed graph • Knowledge can be inferred through “formal logic” If Fluffy is a cat then Fluffy is an animal Example 2 • Exams scheduling: assignment to time slots, avoid conflict • No student takes both exams => can have the same time slot • Model: graph – Node<-course – edge<-student in common Example 2 (cont.) Algorithm: a. Find the maximum set of courses with no common students (maximal independent set) b. Assign to first slot c. Continue until no courses are left Solution not optimal, but close to optimal, and simple More complex representations possible (e.g. constraints in number of student’s sequential exams) Important concepts • Data models: the abstractions to describe the real world or specific problems (e.g., a mathematical model) • Data structures: programming language constructs used to represent data models (e.g., pointers, trees) • Algorithms: the techniques to solve problems by manipulating data structures • Program: the implementation of an algorithm in a programming language How are these related to the course? • New data structures • How these can be used by various algorithms • Typical applications Data model- Data structure • The data model has two aspects: • The values that it can assume (properties) – static aspect • The operations that can be executed on these data – dynamic aspect / behavior – Can be, e.g., the boolean algebra, the algebra of sets, or any other mathematical theory • The data structure is the computer language-specific implementation Example 1 AND- gate Data model: Static: the values 0,1 Operation: “and” as defined in the truth table Data structure: variables in java: boolean x, y, z; Operator “&&” Example 2 • Data model List: (a1,a2,…,an) – Values: sets of integers in specific order – Operation: merge (a1,a2)+(a3)=(a1,a2,a3) • Data structure class Node { int a; Node next; Node merge(Node node1, Node node2) { …}; } Algorithm • A problem solving method suitable for implementation as a computer program • How are the algorithm related to the data structures? – They organize and generally use the data structures • Algorithms and data structures go together Greatest Common Divider Algorithm • The GCD of two numbers is the largest number that divides both of them without leaving a remainder. • The algorithm is based on the principle that the greatest common divisor of two numbers does not change if the smaller number is subtracted from the larger number. • For example, 21 is the GCD of 252 and 105 (252 = 21 × 12; 105 = 21 × 5); since 252 − 105 = 147, the GCD of 147 and 105 is also 21. • Since the larger of the two numbers is reduced, repeating this process gives successively smaller numbers until one of them is zero. When that occurs, the GCD is the remaining nonzero number. Algorithmic problem Specification of input ? Specification of output as function of input • Infinite number of input instances satisfying the specification • e.g., a sorted non-decreasing sequence of integers of finite length • -12, -5, -3, 15, 40, 56, 12454 • -19, 2 Algorithmic problem Specification of input Algorithm Specification of output as function of input • Algorithm describes the processing of the input instances • Many algorithms may solve the same problem in a different way • -12, -5, -3, 15, 40, 56, 12454 • -19, 2 What is a good algorithm? • Efficient – Space – Time running • Efficiency measured as function of input – Number of data elements How do we measure efficiency? • Write a program that implements the algorithm • Run the program with input of various values and size • Measure the time using system routines What are the limitations? • The algorithm has to be implemented • Experiments can be done on a limited set of data • The hardware/software configuration must be the same • Generic analysis methodology will be discussed in this course