Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.
Transcript of Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.
![Page 1: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/1.jpg)
Data Structures and Algorithms
Dr. Manuel E. Bermudez
Alter ego to
Dr. Sartaj Sahni
![Page 2: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/2.jpg)
Clip Art Sources
www.barrysclipart.com www.livinggraphics.com www.rad.kumc.edu www.graphicmaps.com
![Page 3: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/3.jpg)
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.
![Page 4: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/4.jpg)
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.
![Page 5: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/5.jpg)
Prerequisites
Asymptotic Complexity
Big Oh, Theta, and Omega notations
C++ (huh ?)
![Page 6: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/6.jpg)
Web Site
www.cise.ufl.edu/~manuel Follow link to COP-3530.
READ ALL OF IT.
Syllabus, text, source codes, exercise solutions, lectures, assignments, past exams, past exam solutions, TAs, etc.
![Page 7: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/7.jpg)
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).
![Page 8: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/8.jpg)
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
![Page 9: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/9.jpg)
Grades
40% for assignments (weekly) 20% midterm 1. 20% midterm 2. 20% final exam.
![Page 10: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/10.jpg)
Grades (Rough Cutoffs)
NOTE:
These differ from those in Dr. Sahni’s course !
Grade Points
A 92-100
A- 90-91
B+ 87-89
B 83-86
B- 80-82
C+ 77-79
C 73-76
C- 70-72
D+ 67-69
D 63-66
D- 60-62
E 0-59
![Page 11: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/11.jpg)
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
![Page 12: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/12.jpg)
Sort Methods
Insertion Sort Bubble Sort Selection Sort Count Sort Shaker Sort Shell Sort Heap Sort Merge Sort Quick Sort
![Page 13: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/13.jpg)
Insert An Element
Given a sorted list/sequence, insert a new element
Given 3, 6, 9, 14 Insert 5 Result 3, 5, 6, 9, 14
![Page 14: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/14.jpg)
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
![Page 15: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/15.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;
![Page 16: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/16.jpg)
Insertion Sort
Start with a sequence of size 1 Repeatedly insert remaining elements
![Page 17: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/17.jpg)
Insertion Sort
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
![Page 18: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/18.jpg)
Insertion Sort
for (int i = 1; i < n; i++)
{// insert a[i] into a[0:i-1]
// code to insert comes here
}
![Page 19: Data Structures and Algorithms Dr. Manuel E. Bermudez Alter ego to Dr. Sartaj Sahni.](https://reader036.fdocuments.us/reader036/viewer/2022070415/5697c02b1a28abf838cd8589/html5/thumbnails/19.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;}