Instructor: Dr. Sahar Shabanah Fall 2010. Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich...

16
Data Structures 1 Instructor: Dr. Sahar Shabanah Fall 2010

Transcript of Instructor: Dr. Sahar Shabanah Fall 2010. Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich...

Page 1: Instructor: Dr. Sahar Shabanah Fall 2010. Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.

Data Structures 1Instructor: Dr. Sahar Shabanah

Fall 2010

Page 2: Instructor: Dr. Sahar Shabanah Fall 2010. Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.

LecturesST, 9:30 pm-11:00 pm

Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms

in Java”, 4th Edition, 2005, Wiley, ISBN: 978-0471738848

Lecture slides will be posted on the course page before each lecture.

Read thru the lecture notes and the assigned readings before class.

Be prepared to ask questions.

Class website:

http://groups.yahoo.com/group/CPCS204_F10/

Page 3: Instructor: Dr. Sahar Shabanah Fall 2010. Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.

Grading20% Lab & Assignments20% Mid-Term Exam 20% Final Project 40% Final exam

Page 4: Instructor: Dr. Sahar Shabanah Fall 2010. Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.

Course ContentObject Oriented DesignArrays & Linked ListsAnalysis toolsStacks & QueuesListsTreesHeapsMaps & TablesSorting & Searching Algorithms

Page 5: Instructor: Dr. Sahar Shabanah Fall 2010. Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.

Data StructuresA data structure in computer science is a

way of storing data to be used efficiently. A data structure is a representation of a

finite data set [2]. Data Structures examples are Array, List,

Linked list, Doubly linked list, Stack, Queue, Hash table, Graph, Heap, Tree, Binary Search tree, Red-Black tree, etc

Page 6: Instructor: Dr. Sahar Shabanah Fall 2010. Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.

Data Structure Basic OperationsQueries operations get information about the data structure.

Search (data structure, key): searches for a given key in a data structure.

Sort (data structure): sorts elements of a data structure.

Minimum(datastructure): finds the element with the minimum value in a

data structure.

Page 7: Instructor: Dr. Sahar Shabanah Fall 2010. Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.

Data Structure Basic OperationsMaximum (data structure):

finds the element with the maximum value in a data structure.

Successor (data structure, element): finds the element that succeeds the given

element in a data structure.Predecessor (data structure, element):

finds the element that precedes the given element in a data structure.

Page 8: Instructor: Dr. Sahar Shabanah Fall 2010. Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.

Data Structures Basic OperationsModifying operations:

Change the status of a data structure.

Insert (data structure, element): inserts an element into a data

structure. Delete (data structure, element):

deletes an element from a data structure.

Page 9: Instructor: Dr. Sahar Shabanah Fall 2010. Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.

AlgorithmsAn algorithm is a sequence of

computational steps that transform the input into the output .

Algorithms can be classified according to the problem-solving approach that they use or the problems that they solve.

Page 10: Instructor: Dr. Sahar Shabanah Fall 2010. Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.

Algorithms with similar problem-solving approachRecursive Algorithms: convert the

problem into sub-problems, then solve each one using recursion.

Backtracking Algorithms: return a solution if found or recur through the problem with every possible choice until solution or failure is reached.

Brute Force Algorithms: try all possibilities until a satisfactory solution is found.

Page 11: Instructor: Dr. Sahar Shabanah Fall 2010. Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.

Algorithms with similar problem-solving approachDivide and Conquer Algorithms: divide the

problem into smaller sub-problems of the same type, and solve these sub-problems recursively, then combine the solutions to the sub-problems into a solution to the original problem.

Dynamic Programming Algorithms: find the best solution of multiple exist solutions. Examples are Knapsack and Activity Selection Problem. Brute Force Algorithms: try all possibilities until a satisfactory solution is found.

Page 12: Instructor: Dr. Sahar Shabanah Fall 2010. Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.

Algorithms with similar problem-solving approachGreedy Algorithms: get the best solution at the

moment, without regard for future consequences. By choosing a local optimum at each step, it will end up at a global optimum. Examples are Prim’s and Dijkstra’s algorithms.

Branch and Bound Algorithms: a tree of sub-problems is formed.

Randomized Algorithms: use a random number at least once during the computation to make a decision.

Page 13: Instructor: Dr. Sahar Shabanah Fall 2010. Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.

Algorithms solve similar problemsSorting Algorithms: Bubble Sort, Selection

Sort, Insertion Sort, Shell Sort, Merge Sort, Heap Sort, Quick Sort, Bucket Sort, etc.

Linear-Time Sorting: Counting Sort, Radix Sort, Bucket Sort, etc.

Graph Algorithms: Breadth First Search (Bfs), Depth First Search (Dfs), Topological Sort, Strongly Connected Components, Generic Minimum Spanning Tree, Kruskal’S, Prim’S, Sin- gle Source Shortest Path, Dijkstra’S, etc.

Page 14: Instructor: Dr. Sahar Shabanah Fall 2010. Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.

Algorithms solve similar problemsSearching Algorithms:

List Search: Linear Search, Binary Search, etc. Tree Search: Breadth First Search, Depth First

Search, etc.Informed Search: Best-First Search, A*, etc.

String Matching: Naïve String Matching, Knuth-Morris-Pratt, Boyer-Moore, etc.

Page 15: Instructor: Dr. Sahar Shabanah Fall 2010. Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.

Java Programming Basics Base Types:ObjectsEnum TypesMethodsExpressionsControl flowArraysSimple Input and Output

Page 16: Instructor: Dr. Sahar Shabanah Fall 2010. Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.

Object-Oriented DesignIntroInheritancePolymorphismExceptionsInterfaces and abstract ClassesCastingGenerics