EEM 480 Algorithms and Complexity by Assist. Prof. Dr. Emin Germen.

Slides:



Advertisements
Similar presentations
PROGRAMMING LANGUAGE (JAVA) UNIT 42 BY ROBERT BUTTERFIELD TELEPHONE Data Structures and Algorithms.
Advertisements

Symbol Table.
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
C++ Classes & Data Abstraction
EEM 480 Algorithms and Complexity by Assist. Prof. Dr. Emin Germen.
Introduction and a Review of Basic Concepts
Introduction to Data Structures, Spring 2007 Slide- 1 California State University, Fresno Introduction to Data Structure Object Oriented Programming Concepts.
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.
C++ fundamentals.
1 Review: Two Programming Paradigms Structural (Procedural) Object-Oriented PROGRAM PROGRAM FUNCTION OBJECT Operations Data OBJECT Operations Data OBJECT.
Sayed Ahmed Just E.T.C Technologies Inc. Just E.T.C. Education Inc.
Overview of Previous Lesson(s) Over View  OOP  A class is a data type that you define to suit customized application requirements.  A class can be.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Data Structures Using C++ 2E
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Custom Templatized Data Structures.
EE4E. C++ Programming Lecture 1 From C to C++. Contents Introduction Introduction Variables Variables Pointers and references Pointers and references.
Object Oriented Programming: Java Edition By: Samuel Robinson.
 200 Total Points ◦ 74 Points Writing Programs ◦ 60 Points Tracing Algorithms and determining results ◦ 36 Points Short Answer ◦ 30 Points Multiple Choice.
C++ Review Classes and Object Oriented Programming Parasol Lab, Texas A&M University.
Object Oriented Programming Elhanan Borenstein copyrights © Elhanan Borenstein.
Overloading Binary Operators Two ways to overload –As a member function of a class –As a friend function As member functions –General syntax Data Structures.
1 21 COP 3540 Data Structures with OOP Overview: Chapter 1.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 24P. 1Winter Quarter C++ Lecture 24.
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
Copyright  Hannu Laine C++-programming Part 1 Hannu Laine.
Week 14 - Monday.  What did we talk about last time?  Introduction to C++  Input and output  Functions  Overloadable  Default parameters  Pass.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
OBJECT-ORIENTED PROGRAMMING (OOP) WITH C++ Instructor: Dr. Hany H. Ammar Dept. of Electrical and Computer Engineering, WVU.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
Data Structures Lecture 2: Array Azhar Maqsood NUST Institute of Information Technology (NIIT)
WELCOME to III SEM Date: Class - ECE no of present : no of absent :
OOP using C Abstract data types How to accomplish the task??? Requirements Details Input, output, process Specify each task in terms of input.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
Introduction to Object-Oriented Programming Lesson 2.
Object-Oriented Programming (OOP) What we did was: (Procedural Programming) a logical procedure that takes input data, processes it, and produces output.
OBJECT ORIENTED PROGRAMMING. Design principles for organizing code into user-defined types Principles include: Encapsulation Inheritance Polymorphism.
Java & C++ Comparisons How important are classes and objects?? What mechanisms exist for input and output?? Are references and pointers the same thing??
 Saturday, April 20, 8:30-11:00am in B9201  Similar in style to written midterm exam  May include (a little) coding on paper  About 1.5 times as long.
1 Introduction to Object Oriented Programming Chapter 10.
Programming Fundamentals1 Chapter 7 INTRODUCTION TO CLASSES.
Object-Oriented Programming (OOP) and C++
CSC241 Object-Oriented Programming (OOP) Lecture No. 17.
1 C++ Classes & Object Oriented Programming Overview & Terminology.
CSCE , SPRING 2016 INSTRUCTOR: DR. NANCY M. AMATO 1.
Seventh step for Learning C++ Programming CLASS Declaration Public & Private Constructor & Destructor This pointer Inheritance.
Data Structures Lecture 4: Classes in C++ Azhar Maqsood NUST Institute of Information Technology (NIIT)
Procedural and Object-Oriented Programming
Introduction to Computers Computer Generations
Abstract Data Types Programmer-created data types that specify
Midterm Review.
COMPUTER 2430 Object Oriented Programming and Data Structures I
Review: Two Programming Paradigms
classes and objects review
Chapter 5 Classes.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
(5 - 1) Object-Oriented Programming (OOP) and C++
Object Oriented Analysis and Design
Object Oriented Analysis and Design
CS 2308 Final Exam Review.
CS5253 Workshop I Lecturer: Dr. Lusheng Wang
Indirection.
(5 - 1) Object-Oriented Programming (OOP) and C++
Introduction to Data Structure
Introduction to Classes and Objects
CPS120: Introduction to Computer Science
Presentation transcript:

EEM 480 Algorithms and Complexity by Assist. Prof. Dr. Emin Germen

What is this Course About Of Course it is about : Of Course it is about :AlgorithmsComplexity

Any More? Algorithms + Complexity = Data Structure Data Structure : Concerns with the representation and manipulation of data. All the programs use and manipulate data IS (Computer Programming == Data Structure) YES OR NO

What is Data Structure Designing the program which modifies data The Key Point Algorithm

What is this Course About Learning and designing algorithms to manipulate the data Learning and designing algorithms to manipulate the data Comparing criteria of different algorithms Comparing criteria of different algorithms Understand what a good program is Understand what a good program is Learning effective utilizations of computer sources Learning effective utilizations of computer sources

Syllabus Review of C++ Review of C++ Classes Classes Encapsulation, Overloading, Inheritance, Overriding Encapsulation, Overloading, Inheritance, Overriding Pointers to objects Pointers to objects Templates Templates Arrays and Linked Lists Arrays and Linked Lists Linear lists Linear lists Formula based representation Formula based representation Linked representations Linked representations Indirect addressing and pointers Indirect addressing and pointers Arrays and Matrices Arrays and Matrices Arrays, Matrices, Special matrices, Sparse matrices Arrays, Matrices, Special matrices, Sparse matrices Stacks Stacks Queues Queues Hash Tables Hash Tables Trees Trees Binary trees Binary trees Tree traversals Tree traversals Priority Queues Priority Queues Search Trees Search Trees Binary search trees Binary search trees AVL trees AVL trees B-trees B-trees

Reference and Evaluation Data Structures, algorithms, and Applications in C++, Sartaj Sahni Data Structures, algorithms, and Applications in C++, Sartaj Sahni Evaluation: Evaluation: Mt 1 10% Mt 1 10% Mt 2 20% Mt 2 20% Projects 30% Projects 30% Final Exam40% Final Exam40%

Object Oriented Programming Object Object Class Class Encapsulation Encapsulation Inheritence Inheritence Polymormhism Polymormhism

Object An object is a bundle of variables and related methods. An object is a bundle of variables and related methods. When an object is mapped into software representation, it consists of 2 parts: When an object is mapped into software representation, it consists of 2 parts: DATA STRUCTURE characteristics of data structure are refered to as ATTRIBUTES DATA STRUCTURE characteristics of data structure are refered to as ATTRIBUTES PROCESSES that may correctly change the data structure processes are refered to as OPERATIONS or METHODS PROCESSES that may correctly change the data structure processes are refered to as OPERATIONS or METHODS

Class A class is a blueprint for an object. A class is a blueprint for an object. Objects with the same data structure (Attributes) and behavior (Methods or Operations) are grouped together (called a class ). Objects with the same data structure (Attributes) and behavior (Methods or Operations) are grouped together (called a class ).

Encapsulation Encapsulation is the procedure of covering up of data and functions into a single unit Encapsulation is the procedure of covering up of data and functions into a single unitClassData1Data2Procedure1(Data1) Data2 = Procedure() Encapsulation hides the implementation away from the user Encapsulation hides the implementation away from the user

Inheritence As objects do not exist by themselves but are instances of a CLASS, a class can inherit the features of another class and add its own modifications. (This could mean restrictions or additions to its functionality). Inheritance aids in the reuse of code. As objects do not exist by themselves but are instances of a CLASS, a class can inherit the features of another class and add its own modifications. (This could mean restrictions or additions to its functionality). Inheritance aids in the reuse of code.

Polymorphism Polymorphism means the ability to request that the same Operations be performed by a wide range of different types of things. Polymorphism means the ability to request that the same Operations be performed by a wide range of different types of things.

So What??????? What are those things???? What are those things???? How can I use them??????? How can I use them??????? I have searched OOP in the Internet and find ABSTRACTION. What does it mean???? I have searched OOP in the Internet and find ABSTRACTION. What does it mean???? I can write good programs using structural proggramming techniques? Why should I use OOP? I can write good programs using structural proggramming techniques? Why should I use OOP?

Intoduction to OOP with C++ Object Oriented Programming Object Oriented Programming Class Class The structure which keeps data and function Interitance Interitance Inheritance is also called derivation. The new class inherits the functionality of an existing class. The existing class is called the base class, and the new class is called the derived class. A similar inheritance can be derived for animals, mammals, and dogs. Polymorphisim Overloading Polymorphisim Overloading Ability to have more than one function with the same name that differ in their parameter lists.

Program 1 #include #include void main(void) { cout << "This is not my first program"; cout << "\n"; } Header for the basic C++ procedures Streaming functions

Program 2 // Workspace: Triangle // Program name: Area.cpp // The area of a triangle is half its base times height // Area of triangle = (Base length of triangle * Height of triangle)/2 #include // Precompiled header double base,height,area; // Declaring the variables double Area(double,double); // Function Prototype/declaration int main() { cout << "\nEnter Height of Triangle: "; // Enter a number cin >> height; // Store the input in variable cout << "\nEnter Base of Triangle: "; // Enter a number cin >> base; // Store the input in variable area = Area(base,height);// Store the result from the Area function // in the variable area cout << "The Area of the Triangle is: "<< area << endl ; return 0; } double Area (double base, double height) // Function definition { area = (0.5*base*height); return area; } The Output

Program 3 Polymorphism # include # include double base,height,radius; // Global variables double Area_of_triangle,Area_of_circle; // Global variables int choice; // Global variable double Area (double,double); // Function prototype double Area (double); // Function prototype const double pi = 3.14; // Constant variable void main() // main function { cout << "To find the area of a Triangle, input 1 \n"; cout << "To find the area of a Circle, input 2 \n"; cin >> choice; if (choice == 1) { cout << "Enter the base of the triangle: "; cin >> base; cout << "Enter the height of the triangle: "; cin >> height; Area_of_triangle = Area(base,height); cout << "The Area of the Triangle is: " << Area_of_triangle<<endl; } if (choice == 2) { cout << "Enter radius of the Circle: "; cin >> radius; Area_of_circle = Area(radius); cout << "The area of the Circle is: " << Area_of_circle<<endl; } if (choice != 1 && choice != 2) { cout << "Sorry! You must enter either 1 or 2 \n"; } double Area (double base, double height) { return (0.5*base*height); } double Area(double radius) { return (pi*radius*radius); } The Output

Defining Class in C++ Almost same as defining Struct Almost same as defining Struct Insert Functions into the Struct Insert Functions into the Struct Some important functions Some important functions Constructor Constructor Destructor Destructor

Object Oriented C++ Class #include class CCircle { public: CCircle(int r); void SetRadius(int r); void DisplayArea(void); ~CCircle(); private: float CalculateArea(void); int m_radius; int m_color; }; CCircle::CCircle(int r) { m_radius = r; } CCircle::~CCircle() {} void CCircle::DisplayArea(void) { float fArea; fArea = CalculateArea(); cout << "The Arae of the circle : " << fArea << "\n"; } float CCircle::CalculateArea(void) { float f; f = (float) (3.14 * m_radius * m_radius); return f; } CONSTRUCTOR DESTRUCTOR

Dynamic Memory Allocation new int *y //pointer y = new int; // creates place *y = 10 // OK Or int *y = new int(10)

OOP in C++ Simple example of defining object and class Simple example of defining object and class Programming Example Programming Example Programming Example Programming Example Overloading Overloading Programming Example Programming Example Programming Example Programming Example Inheritance Inheritance Programming Example Programming Example Programming Example Programming Example Templates Templates Programming Example Programming Example Programming Example Programming Example

One Dimensional Array and Exception Handling float *x = new float [n] Or better float *x try { x = new float [n];} catch (xalloc) { cerr << “Out of memory << endl; cerr << “Out of memory << endl; exit(1); } exit(1); }

Delete delete y; //free the memory allocated by *y delete [] x // free the one dimensional array