Professional Documents
Culture Documents
Introduction
Dr. Ali El Masri
1
Part A
2
Program
Stack space à
Time à
4
Example of a Tree: Evaluating arithmetic expression
5
Example of a Tree: File Systems
6
Example of a Tree: File Systems
7
Example of a Graph: Flight routes among airports
8
Example of a Graph: Computer networks
9
Example of a (1) Graph: Social media – Facebook and (2) Digraph: Social media – Twitter
10
Part B
11
• A data structure is a scheme for organizing data in the memory of a computer
• The way in which the data is organized affects the performance of a program for different tasks
• Computer programmers decide which data structures to use based on the nature of the data and the processes
that need to be performed on that data
• Examples: Commonly used data structures include lists, arrays, stacks, queues, heaps, trees, and graphs
• How to choose a data structure? It depends on your application (as seen in the previous slides)
12
Abstraction
• Anything that hides details & provides only the essentials
• Examples:
• An integer 165 = 1.102+6.101+5.100
• Procedures/Subprograms (a C++ function)
• While designing an ADT, a designer has to deal with two types of questions:
• What values are in the domain? What operations can be performed on the values of a particular data type?
• How is the data type represented? How are the operations implemented?
13
Specifications:
• ADTs specification answers the “what” questions
• Specifications are written first
Implementations:
• Answers the “how” questions
• Done after specification
• Programmer (Implementer) who implements ADT is concerned with specification, representation, and
implementation.
• Example:
• A Stack ADT can be applied based on an array or a linked list (totally different implementations)
• The same main function (program) can be used in both case (the Stack use does not depend on its
implementation)
14
• The Queue ADT stores arbitrary objects
• Insertions are at the rear of the queue and removals are at the front of the queue
• Exceptions
• Attempting the execution of dequeue or front on an empty queue throws an EmptyQueueException
16
• Data Structures and Algorithms in C++, 4th Edition, Adam Drozdek
• Data Structures & Algorithm Analysis in C++, 4th Edition, by M.A. Weiss
• Data Structures and Algorithms in C++, 2nd Edition, by M.T. Goodrich, R. Tamassia, and D.M. Mount
• Data Structures and Algorithms in Java, 6th Edition, by M.T. Goodrich and R. Tamassia
• Data Structures and Program Design in C++, 1st Edition, by R.L. Kruse and A.J. Ryba
17