Prof. Amr Goneid, AUC1 CSCE 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part 1. Data Modeling and ADTs.

Slides:



Advertisements
Similar presentations
Data Structures Through C
Advertisements

Data Structures.
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part R4. Disjoint Sets.
Transform and Conquer Chapter 6. Transform and Conquer Solve problem by transforming into: a more convenient instance of the same problem (instance simplification)
1 abstract containers hierarchical (1 to many) graph (many to many) first ith last sequence/linear (1 to 1) set.
©Brooks/Cole, 2003 Chapter 12 Abstract Data Type.
Trees Chapter 8.
CSCE 210 Data Structures and Algorithms
Fall 2007CS 2251 Trees Chapter 8. Fall 2007CS 2252 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information.
Trees Chapter 8. Chapter 8: Trees2 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information To learn how.
©Brooks/Cole, 2003 Chapter 12 Abstract Data Type.
COMP 110 Introduction to Programming Mr. Joshua Stough.
1 abstract containers hierarchical (1 to many) graph (many to many) first ith last sequence/linear (1 to 1) set.
Basic Definitions Data Structures: Data Structures: A data structure is a systematic way of organizing and accessing data. Or, It’s the logical relationship.
INTRODUCTION TO DATA STRUCTURE. Topics To Be Discussed………………………. Meaning of Data Structure Classification of Data Structure Data Structure Operations.
CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
Important Problem Types and Fundamental Data Structures
Chapter 1 Introduction Definition of Algorithm An algorithm is a finite sequence of precise instructions for performing a computation or for solving.
12 Abstract Data Types Foundations of Computer Science ã Cengage Learning.
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
Copyright © Wondershare Software Introduction to Data Structures Prepared by: Eng. Ahmed & Mohamed Taha.
Introduction to Data Structures. Definition Data structure is representation of the logical relationship existing between individual elements of data.
Design and Analysis of Algorithms CSC201 Shahid Hussain 1.
ECE 103 Engineering Programming Chapter 61 Abstract Data Types Herbert G. Mayer, PSU CS Status 6/4/2014 Initial content copied verbatim from ECE 103 material.
Course Web Page Most information about the course (including the syllabus) will be posted on the course wiki:
TECH Computer Science Data Abstraction and Basic Data Structures Improving efficiency by building better  Data Structure Object IN  Abstract Data Type.
Trees Chapter 8. Chapter 8: Trees2 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information To learn how.
Prepared By Ms.R.K.Dharme Head Computer Department.
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part R2. Binary Search Trees.
© 2006 Pearson Addison-Wesley. All rights reserved13 B-1 Chapter 13 (continued) Advanced Implementation of Tables.
Data Structure & File Systems Hun Myoung Park, Ph.D., Public Management and Policy Analysis Program Graduate School of International Relations International.
Chapter 9 (modified) Abstract Data Types and Algorithms Nell Dale John Lewis.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
9-1 Abstract Data Types Abstract data type A data type whose properties (data and operations) are specified independently of any particular implementation.
Chapter 8 Data Abstractions. © 2005 Pearson Addison-Wesley. All rights reserved 8-2 Chapter 8: Data Abstractions 8.1 Data Structure Fundamentals 8.2 Implementing.
Prof. Amr Goneid, AUC1 CSCE 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part 4. Trees.
Prof. Amr Goneid, AUC1 CSCI 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part 5. Dictionaries(2): Hash Tables.
The ADT Table The ADT table, or dictionary Uses a search key to identify its items Its items are records that contain several pieces of data 2 Figure.
Elementary Data Organization. Outline  Data, Entity and Information  Primitive data types  Non primitive data Types  Data structure  Definition 
D ATA S TRUCTURES 1. I NSTRUCTORS Lectures : Dr. Shimaa Ibrahim Hassan Time: 9:45 Sections.
Data Structures Chapter 6. Data Structure A data structure is a representation of data and the operations allowed on that data. Examples: 1.Array 2.Record.
Prof. amr Goneid, AUC1 CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 13. Abstract Data Types (ADT’s)
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part 1. Complexity Bounds.
Prof. Amr Goneid, AUC1 CSCE 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part 6. Dictionaries(3): Binary Search Trees.
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part R3. Priority Queues.
Week 15 – Wednesday.  What did we talk about last time?  Review up to Exam 1.
Prof. amr Goneid, AUC1 CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 15. Dictionaries (1): A Key Table Class.
Data Structures What The Course Is About Data structures is concerned with the representation and manipulation of data.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Prof. Amr Goneid, AUC1 CSCI 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part 5. Dictionaries(2): Hash Tables.
Prof. Amr Goneid, AUC1 CSCE 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part R2. Elementary Data Structures.
CPS120: Introduction to Computer Science Nell Dale John Lewis Abstract Data Types.
CSCE 210 Data Structures and Algorithms
Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision.
Course Developer/Writer: A. J. Ikuomola
Data Structure Interview Question and Answers
CSCI 210 Data Structures and Algorithms
Data Structures Data Structure is a way of collecting and organising data in such a way that we can perform operations on these data in an effective.
Cinda Heeren / Geoffrey Tien
CSCE 210 Data Structures and Algorithms
structures and their relationships." - Linus Torvalds
structures and their relationships." - Linus Torvalds
ITEC 2620M Introduction to Data Structures
Introduction to Data Structures
Introduction to Data Structure
Important Problem Types and Fundamental Data Structures
structures and their relationships." - Linus Torvalds
Presentation transcript:

Prof. Amr Goneid, AUC1 CSCE 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part 1. Data Modeling and ADTs

Prof. Amr Goneid, AUC2 Data Modeling and ADTs Data Modeling Abstract Data types (ADTs) A Classification of Abstract Structures Another Classification Special Data Structures OOP and Classes Examples on Modeling

Prof. Amr Goneid, AUC3 1. Data Modeling Real-world applications need to be reduced to a small number of existing problems (top- down design) Real-world data need to be described in an abstract way in terms of fundamental structures

Prof. Amr Goneid, AUC4 Data Modeling The collection of data in some organization is called a “Data Structure” The sequences of operations to be done on the data are called “Algorithms”

Prof. Amr Goneid, AUC5 Data Modeling The word Algorithm comes from the name of Abu Ja’afar Mohamed ibn Musa Al Khowarizmi (c. 825 A.D.) An Algorithm is a procedure to do a certain task An Algorithm is supposed to solve a general, well- specified problem

Prof. Amr Goneid, AUC6 Data Modeling A real-world application is basically Data Structures + Algorithms

Prof. Amr Goneid, AUC7 Data Modeling Data and the Operations on that data are parts of an object that cannot be separated. These two faces of an object are linked. Neither can be carried out independently of the other.

Prof. Amr Goneid, AUC8 The Data Cone Real-world Data ADTs Data Structures Fundamental Data Types

Prof. Amr Goneid, AUC9 2. Abstract Data Types (ADTs) The most important attribute of data is its type. Type implies certain operation. It also prohibits other operations. For example, + - * / are allowed for types int and double, but the modulus (%) is allowed for int and prohibited for double. When a certain data organization + its operations are not available in the language, we build it as a new data type. To be useful to many applications, we build it as an Abstract Data Type.

Prof. Amr Goneid, AUC10 Abstract Data Types (ADTs) An ADT represents the logical or conceptual level of the data. It consists of: 1. A collection of data items in some Data Structure 2. Operations (algorithms) on the data items For example, a Stack supports retrieval in LIFO (Last In First Out) order. Basic operations are push and pop. It can be implemented using arrays (static or dynamic) or linked lists

Prof. Amr Goneid, AUC11 Abstract Data Types (ADTs) The Data Structure used in implementing an ADT is usually dependent on the language. In contrast, the definition of the ADT is separated from its implementation (Data Abstraction). (e.g. ADT Stack can be implemented using a static array, a dynamic array or a linked list. An ADT can be used in more than one application.

Prof. Amr Goneid, AUC12 Using ADT’s ADT Application Standard Types/LibrariesUser Built ADT’s

Prof. Amr Goneid, AUC13 3. A Classification of Abstract Structures According to the relationship between members Abstract Structures SetsLinearTreesGraphs

Prof. Amr Goneid, AUC14 Sets Order of elements does not matter. Only that they are members of the same set ({1,3,4} is identical to {1,4,3}). Can be implemented using arrays or linked lists. Used in problems seeking: groups collection selection packaging

Prof. Amr Goneid, AUC15 Linear Structures Sequential, one-to-one relationship. Examples: Tables, Stacks, Queues, Strings and Permutations. Can be implemented using arrays and linked lists (structs and pointers). Used in problems dealing with: Searching, Sorting, stacking, waiting lines. Text processing, character sequences, patterns Arrangements, ordering, tours, sequences.

Prof. Amr Goneid, AUC16 Trees Non-Linear, hierarchical one-to-many. Examples: Binary Trees, Binary Search Trees (BST) Can be implemented using arrays, structs and pointers Used in problems dealing with: Searching Hierarchy Ancestor/descendant relationship Classification

Prof. Amr Goneid, AUC17 Graphs Non-Linear, many-to-many. Can be implemented using arrays or linked lists Used to model a variety of problems dealing with: Networks Circuits Web Relationship Paths

Prof. Amr Goneid, AUC18 4. Another Classification of Abstract Structures According to their functionsSpecial Abstract Structures Containers Dictionaries Priority Queues Disjoint Sets Graphs Strings Geometric DS

Prof. Amr Goneid, AUC19 Containers Permit storage and retrieval of data items independent of content (access by location only). Support two basic operations: Put (x,C): Insert item x in container C Get (C): Retrieve next item from C.

Prof. Amr Goneid, AUC20 Containers Examples: Stacks: Last-In-First-Out (LIFO) structures Queues: First-In-First-Out (FIFO) structures Tables: Retrieval by position.

Prof. Amr Goneid, AUC21 Dictionaries A form of container that permits access by content. Support the following main operations: Insert (D,x): Insert item x in dictionary D Delete (D,x): Delete item x from D Search (D,k): search for key k in D

Prof. Amr Goneid, AUC22 Dictionaries Examples: Unsorted arrays and Linked Lists: permit linear search Sorted arrays: permit Binary search Ordered Lists: permit linear search Binary Search Trees (BST): fast support of all dictionary operations. Hash Tables: Fast retrieval by hashing key to a position.

Prof. Amr Goneid, AUC23 Priority Queues Allow processing items according to a certain order (Priority) Support the following main operations: Insert (Q,x): Insert item x in priority queue Q Remove (Q): Return and remove item with Highest/Lowest Priority

Prof. Amr Goneid, AUC24 Priority Queues Examples: Heaps and Partially Ordered Trees (POT) Major DS in HeapSort

Prof. Amr Goneid, AUC25 Disjoint Sets  Disjoint sets are collections of elements with no common elements between the sets.  A set can be identified by a parent node and children nodes.

Prof. Amr Goneid, AUC26 Disjoint Sets Support the following main operations: Find (i): Find Parent (set) containing node (i) Union (i,j): make set (i) the child of set (j) Examples: Representation of disjoint collections of data Representation of Trees, Forests and Graphs

Prof. Amr Goneid, AUC27 Graphs Can be used to represent any relationship and a wide variety of structures.

Prof. Amr Goneid, AUC28 Graphs Can be used to represent any relationship and a wide variety of structures. Well-known graph algorithms are the basis for many applications. Examples of such algorithms are: Minimum Spanning Trees Graph traversal (Depth-First and Breadth-First) Shortest Path Algorithms

Prof. Amr Goneid, AUC29 5. Special Data Structures Strings: Typically represented as arrays of characters. Various operations support pattern matching and string editing

Prof. Amr Goneid, AUC30 5. Special Data Structures Geometric Data Structures: Represent collections of data points and regions. Data points can represent segments. Segments can represent polygons that can represent regions.

Prof. Amr Goneid, AUC31 6. OOP & Classes The first step in creating an ADT is the process of Data Abstraction Data Abstraction provides a complete description of the following items independent of the way it will be implemented: A definition of the ADT. Elements or members of that ADT. Relationship between the members. The fundamental operations on the members.

Prof. Amr Goneid, AUC32 ADT Implementation Usually, an ADT can be implemented in different ways. To the applications, such implementation should be completely hidden. The Implementation part will describe: how the ADT will be implemented using native Data Structures or other pre-defined ADT’s in C++. how the relationships and fundamental operations on the members will be implemented as C++ functions. In Object Oriented Programming, ADTs are created as Classes

Prof. Amr Goneid, AUC33 OOP and Classes Object-Oriented Programming (OOP) focuses on creating ADT’s called “Classes” that identify “objects” and how they work together. A class contains “data members” + “function members” in one object. A member function tells an object to “operate on itself” in some way. Objects are “self-contained”, carrying their own operations.

Prof. Amr Goneid, AUC34 Data Encapsulation, Classes and Objects A Class of objects is a user-defined Abstract Data Type (ADT) An object is an instance of the class Once a class is defined, an object can be declared to be of that type. For example, we have encountered the string class before. Since it has been defined, we can declare: string message; So, now message is an object of that class Classes can be used by more than one program.

Prof. Amr Goneid, AUC35 Sharing Classes Class Program Standard ClassesUser Classes

Prof. Amr Goneid, AUC36 Classes & Encapsulation C++ classes are similar to structs, with the main difference being that classes can have member functions, or methods, as well as variables, or data members in their definitions. Combining data and operations (methods) together in an object is called encapsulation. An object of a class can operate on itself by the methods or member functions of that class. e.g., an object of class string can operate by:.find.length.at.erase etc

Prof. Amr Goneid, AUC37 7. Examples on Modeling Problem: In Encryption problems, we need to do arithmetic on very large integers (e.g. 300 digits or more) ADTs: List Data Structures: 1-D array or Linked List

Prof. Amr Goneid, AUC38 Examples on Modeling Problem: (Knapsack Problem) We have (n) objects each with a weight and a price and a container with maximum capacity (m). Select whole or fractions of the objects such that the total weight does not exceed (m) and the total price is maximum ADTs: List Data Structures: 1-D array or Linked List

Prof. Amr Goneid, AUC39 Examples on Modeling Problem: (Chess Games) 8-Queens problem, Knight’s Tour problem, etc ADTs: Board ADT Data Structures: 2-D array

Prof. Amr Goneid, AUC40 Examples on Modeling Problem: (Dictionary) We would like to build and use a small dictionary of words that translates from language (A) to language (B) ADTs: Key Table or List Data Structures: 1-D array or linked list

Prof. Amr Goneid, AUC41 Examples on Modeling Problem: (Small and fast Directory) We would like to build and use a small and fast directory to check username and pass word logins ADTs: Hash Table Data Structures: 1-D array

Prof. Amr Goneid, AUC42 Examples on Modeling Problem: (Large and fast Directory) We would like to build and use a large and fast telephone directory. ADTs: Binary Search Tree Data Structures: Linked Structure (Nodes)

Prof. Amr Goneid, AUC43 Examples on Modeling Problems: Evaluation of arithmetic expressions The Hanoi Towers game ADTs: Stack Data Structures: 1-D array or Linked List

Prof. Amr Goneid, AUC44 Examples on Modeling Problem: We would like to simulate the waiting process for airplanes to land in an airport. ADTs: Queue Data Structures: 1-D array or Linked List

Prof. Amr Goneid, AUC45 Examples on Modeling Problem: Sorting a set of elements Selection of the k th smallest (largest) element ADTs: Priority Queue Data Structures: 1-D array

Prof. Amr Goneid, AUC46 Examples on Modeling Problem: Find the shortest path between a source and a destination Find the exit in a Maze ADTs: Graph Data Structures: 2-D array or Linked list

Prof. Amr Goneid, AUC47 Examples on Modeling Problem: Find a wiring scheme for electrical power with minimum cost of wiring ADTs: Graph Priority Queue Disjoint Sets Data Structures: 1-D arrays, 2-D array, Linked list