Data Structures Algorithms Applications Instructor Babak Alipour Slides

Data Structures, Algorithms, & Applications Instructor: Babak Alipour Slides and book: Sartaj Sahni

Course website s http: //cise. ufl. edu/class/cop 3530 fa 16/ – Presentations – Contact information s Canvas (http: //elearning. ufl. edu/) – Coming soon – Announcements, Assignments, quizzes and Discussion board

Got Questions? s s 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 s s Subject MUST include “cop 3530 fa 16” Include your name and UFID

Got Feedback? s For general course-related issues: – Email me (babak. ap@ufl. edu) – You don’t have to include name and UFID s For specific issues with assignments: – Email Fardad (fardad@ufl. edu)

When in doubt… s ASK –Canvas discussion board –Graders, TA, Instructor s Announcements, requirements, syllabus, anything you find ambiguous, ASK RIGHT AWAY!

Books s 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 s s Once every week 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 s s 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: //cop 3530. cise. ufl. edu/ s 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 s s Familiarize yourself with online judges such as Hacker. Rank, Leet. Code, SPOJ, etc. Some assignments will involve solving problems in these platforms.

Projects s s 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 s s 2 exams Midterm: TBA Final: Group 16 C Non-cumulative BUT the final exam material will depend upon midterm material.

Grading (Tentative) s s s 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 s 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 s Slides only provide bullet points – Read the corresponding section in at least one of the books s Use Wikipedia (and other internet sources) – Some algorithms are explained very well

Tips on studying s s There will be additional/extra readings at the end of some slides, study them PRACTICE, PRACTICE – Use the online judges mentioned – Implement data structures and algorithms discussed in class – Challenge yourself!

Clip Art Sources s s www. barrysclipart. com www. livinggraphics. com www. rad. kumc. edu www. graphicmaps. com

What The Course Is About s s 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.

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 The Course Is About • Perhaps the most important course in Computer Science • We will discuss multiple real world applications as we go along

Prerequisites s C++ / Java s Asymptotic Complexity § Big Oh, Theta, and Omega notations

Web Site For Book s www. cise. ufl. edu/~sahni/dsaac

Source Codes s s 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 s s s 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 s s Rearrange a[0], a[1], …, a[n-1] into ascending order. When done, a[0] Sorting s s Rearrange a[0], a[1], …, a[n-1] into ascending order. When done, a[0]](http://slidetodoc.com/presentation_image/473c49b9e6a49030a09f2cda0e5e7c22/image-25.jpg)
Sorting s s 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

Sort Methods s s s s Insertion Sort Bubble Sort Selection Sort Count Sort Shaker Sort Shell Sort Heap Sort Merge Sort Quick Sort

Insert An Element s s Given a sorted list/sequence, insert a new element Given 3, 6, 9, 14 Insert 5 Result 3, 5, 6, 9, 14

Insert an Element s s s 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 = Insert An Element // insert t into a[0: i-1] int j; for (j =](http://slidetodoc.com/presentation_image/473c49b9e6a49030a09f2cda0e5e7c22/image-29.jpg)
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 s s Start with a sequence of size 1 Repeatedly insert remaining elements

Insertion Sort s s s Sort 7, 3, 5, 6, 1 Start with 7 and insert 3 => 3, 7 Insert 5 => 3, 5, 7 Insert 6 => 3, 5, 6, 7 Insert 1 => 1, 3, 5, 6, 7
![Insertion Sort for (int i = 1; i < n; i++) {// insert a[i] Insertion Sort for (int i = 1; i < n; i++) {// insert a[i]](http://slidetodoc.com/presentation_image/473c49b9e6a49030a09f2cda0e5e7c22/image-32.jpg)
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] Insertion Sort for (int i = 1; i < n; i++) {// insert a[i]](http://slidetodoc.com/presentation_image/473c49b9e6a49030a09f2cda0e5e7c22/image-33.jpg)
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; }
- Slides: 33