Download presentation
Presentation is loading. Please wait.
Published byAmy West Modified over 8 years ago
2
Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni
3
Clip Art Sources s www.barrysclipart.com s www.livinggraphics.com s www.rad.kumc.edu s www.graphicmaps.com
4
What The Course Is About s Data structures is concerned with the representation and manipulation of data. s All programs manipulate data. s So, all programs represent data in some way. s Data manipulation requires an algorithm.
5
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.
6
Prerequisites s Asymptotic Complexity Big Oh, Theta, and Omega notations s C++ (huh ?)
7
Web Site s www.cise.ufl.edu/~manuel Follow link to COP-3530. www.cise.ufl.edu/~manuel s READ ALL OF IT. s Syllabus, text, source codes, exercise solutions, lectures, assignments, past exams, past exam solutions, TAs, etc.
8
Source Codes s Download source codes from Web site and make sure you can compile and execute at least one code. s Use the readme file to map text programs to file names. s X.cpp is C++ program; X.output is output generated by X.cpp; and X.input is the input data (if any is required).
9
Organization of Text s Three parts s Part I … Chapters 1-4, Background s Part 2 … Chapters 5-16, Data Structures s Part 3 … Chapters 17-21, Algorithms s Each chapter … concepts + applications
10
Grades s 40% for assignments (weekly) s 20% midterm 1. s 20% midterm 2. s 20% final exam.
11
Grades (Rough Cutoffs) NOTE: These differ from those in Dr. Sahni’s course ! GradePoints A92-100 A-90-91 B+87-89 B83-86 B-80-82 C+77-79 C73-76 C-70-72 D+67-69 D63-66 D-60-62 E0-59
12
Sorting s Rearrange a[0], a[1], …, a[n-1] into ascending order. When done, a[0] <= a[1] <= … <= a[n-1] s 8, 6, 9, 4, 3 => 3, 4, 6, 8, 9
13
Sort Methods s Insertion Sort s Bubble Sort s Selection Sort s Count Sort s Shaker Sort s Shell Sort s Heap Sort s Merge Sort s Quick Sort
14
Insert An Element s Given a sorted list/sequence, insert a new element s Given 3, 6, 9, 14 s Insert 5 s Result 3, 5, 6, 9, 14
15
Insert an Element s 3, 6, 9, 14 insert 5 s Compare new element (5) and last one (14) s Shift 14 right to get 3, 6, 9,, 14 s Shift 9 right to get 3, 6,, 9, 14 s Shift 6 right to get 3,, 6, 9, 14 s Insert 5 to get 3, 5, 6, 9, 14
16
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;
17
Insertion Sort s Start with a sequence of size 1 s Repeatedly insert remaining elements
18
Insertion Sort s Sort 7, 3, 5, 6, 1 s Start with 7 and insert 3 => 3, 7 s Insert 5 => 3, 5, 7 s Insert 6 => 3, 5, 6, 7 s Insert 1 => 1, 3, 5, 6, 7
19
Insertion Sort for (int i = 1; i < n; i++) {// insert a[i] into a[0:i-1] // code to insert comes here }
20
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; }
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.