Data Structures, Algorithms, & Applications Instructor: Babak Alipour Slides and book: Sartaj Sahni
Course website http://cise.ufl.edu/class/cop3530sp17/ Presentations Contact information Canvas (http://elearning.ufl.edu/) Coming soon Announcements, Assignments, quizzes and Discussion board
Got Questions? Use the Canvas discussion board for most questions Ask the graders (TBA) Ask the Teaching TA (fardad@ufl.edu) Ask the Instructor (babak.ap@ufl.edu) IF YOUR REQUEST CONTAINS SENSITIVE ACADEMIC INFORMATION, EMAIL Fardad or myself ONLY!
Email format Subject MUST include “cop3530sp17” (No spaces, no caps) Include your name and UFID
Got Feedback? For general course-related issues: Email me (babak.ap@ufl.edu) You don’t have to include name and UFID For specific issues with assignments: Email Fardad (fardad@ufl.edu)
When in doubt… ASK Canvas discussion board Graders, TA, Instructor Announcements, requirements, syllabus, anything you find ambiguous, ASK RIGHT AWAY!
Books Data Structures, Algorithms, and Applications in C++ by Sartaj Sahni Introduction to Algorithms by Charles E. Leiserson, Clifford Stein, Ronald Rivest, and Thomas H. Cormen (Widely known as CLRS book) Algorithms by Robert Sedgewick
Quizzes Once every week (or so) Online (through Canvas) 5 to 10 minutes (starting at the beginning of the class) Also acts as attendance roll call (access code announced in class) Graded automatically
Assignments Up to 6 assignments Graded automatically by a judge (based on correctness of output and timeliness of algorithm, using several input test cases) Address will be: http://cop3530.cise.ufl.edu/ ONLY last submission counts WARNING: If output is incorrect or output format is not adhered to or timer runs out, you get NO CREDIT for the test case. (e.g. if you pass 3 out of 5 test cases, you get a 60)
Online judges Familiarize yourself with online judges such as HackerRank, LeetCode, SPOJ, etc. Some assignments will involve solving problems in these platforms.
Projects Two projects TBA Involves thinking A LOT (and coding a bit) Grading based on judge test cases AND demo in front of a TA/grader in person
Exams 2 exams Midterm: TBA Final: Group 27B Non-cumulative BUT the final exam material will depend upon midterm material.
Grading (Tentative) Quizzes 10% Assignments 10% Exams 40% Projects 40% Subject to change depending on the progression of the course and feedback from class
Grading – The perks I will announce some perks to help you with graders Everyone is A(wesome)++, for now. Focus on learning, a good grade follows naturally.
Tips on studying Slides only provide bullet points Read the corresponding section in at least one of the books Use Wikipedia (and other internet sources) Some algorithms are explained very well
Tips on studying There will be additional/extra readings at the end of some slides, study them PRACTICE, PRACTICE, PRACTICE Use the online judges mentioned Implement data structures and algorithms discussed in class Challenge yourself!
Clip Art Sources www.barrysclipart.com www.livinggraphics.com www.rad.kumc.edu www.graphicmaps.com
What The Course Is About Data structures is concerned with the representation and manipulation of data. All programs manipulate data. So, all programs represent data in some way. Data manipulation requires an algorithm. Data: Streets in a city. Mapquest. Manipulation: Do something with the data. Add a new street. Close a street. Make a street one way. Find route from your home to nearest gas station. Input/output data. Data representation: simple variables…int, float array variables… int [], float [] Others to be studied in this course. Algorithm…sequence of steps that results in the performance of a specific task (find nearest gas station to home).
What The Course Is About Algorithm design methods needed to develop programs that do the data manipulation. The study of data structures and algorithms is fundamental to Computer Science. What we do in this course will be used in most of the follow-up courses you will take. Essential to become expert in what we do this semester. Else, you will be handicapped in later courses. Foundation material.
What The Course Is About Perhaps the most important course in Computer Science We will discuss multiple real world applications as we go along
Prerequisites C++ Asymptotic Complexity Big Oh, Theta, and Omega notations Java review … Chapter 1 Performance Analysis … Chapter 2 Asymptotic complexity … Chapter 3
Web Site For Book www.cise.ufl.edu/~sahni/dsaac
Source Codes Download source codes from Web site and make sure you can compile and execute at least one code. Use the readme file to map text programs to file names. X.cpp is C++ program; X.output is output generated by X.cpp; and X.input is the input data (if any is required). Must be able to compile code on CISE Ubuntu machines (Ubuntu 14.04 as of August 2016)
Organization of Text Three parts Part I … Chapters 1-4, Background Part 2 … Chapters 5-16, Data Structures Part 3 … Chapters 17-21, Algorithms Each chapter … concepts + applications
Sorting Rearrange a[0], a[1], …, a[n-1] into ascending order. When done, a[0] <= a[1] <= … <= a[n-1] 8, 6, 9, 4, 3 => 3, 4, 6, 8, 9 Strictly speaking, nondecreasing order: 2, 2, 3, 6, 8, 8, 10.
Sort Methods Insertion Sort Bubble Sort Selection Sort Count Sort Shaker Sort Shell Sort Heap Sort Merge Sort Quick Sort First 5 are simple (conceptually and to program). First 4 done in chapters 2 and 3. Shaker sort and shell sort are in the enrichment section of the text’s Web site. The remaining three are done in the algorithm design chapters of the text.
Insert An Element Given a sorted list/sequence, insert a new element Result 3, 5, 6, 9, 14
Insert an Element 3, 6, 9, 14 insert 5 Compare new element (5) and last one (14) Shift 14 right to get 3, 6, 9, , 14 Shift 9 right to get 3, 6, , 9, 14 Shift 6 right to get 3, , 6, 9, 14 Insert 5 to get 3, 5, 6, 9, 14
Insert An Element // insert t into a[0:i-1] int j; for (j = i - 1; j >= 0 && t < a[j]; j--) a[j + 1] = a[j]; a[j + 1] = t;
Insertion Sort Start with a sequence of size 1 Repeatedly insert remaining elements
Insertion Sort Sort 7, 3, 5, 6, 1 Start with 7 and insert 3 => 3, 7
Insertion Sort for (int i = 1; i < n; i++) {// insert a[i] into a[0:i-1] // code to insert comes here }
Insertion Sort for (int i = 1; i < n; i++) {// insert a[i] into a[0:i-1] int t = a[i]; int j; for (j = i - 1; j >= 0 && t < a[j]; j--) a[j + 1] = a[j]; a[j + 1] = t; }