Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "EEM 480 Algorithms and Complexity by Assist. Prof. Dr. Emin Germen."— Presentation transcript:

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

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

3 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

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

5 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

6 Syllabus Review of JAVA Review of JAVA Platforms Platforms Classes Classes Encapsulation, Overloading, Inheritance, Overriding Encapsulation, Overloading, Inheritance, Overriding Pointers to objects Pointers to objects Templates Templates Algoritm Analysis Algoritm Analysis Necessary math review Necessary math review Complexity definitions Complexity definitions Running time calculations Running time calculations 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 Trees Trees Binary trees Binary trees Tree traversals Tree traversals B trees B trees Hash Tables Hash Tables Priority Queues Priority Queues Sorting algorithms Sorting algorithms Basic Data Structure Implementations Basic Data Structure Implementations Path compression Path compression Union/Find Implementations Union/Find Implementations Review of JAVA Review of JAVA Platforms Platforms Classes Classes Encapsulation, Overloading, Inheritance, Overriding Encapsulation, Overloading, Inheritance, Overriding Pointers to objects Pointers to objects Templates Templates Algoritm Analysis Algoritm Analysis Necessary math review Necessary math review Complexity definitions Complexity definitions Running time calculations Running time calculations 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 Trees Trees Binary trees Binary trees Tree traversals Tree traversals B trees B trees Hash Tables Hash Tables Priority Queues Priority Queues Sorting algorithms Sorting algorithms Basic Data Structure Implementations Basic Data Structure Implementations Path compression Path compression Union/Find Implementations Union/Find Implementations

7 Reference and Evaluation Data Structures and Algorithm Analyses in JAVA 2’nd Ed. by Mark Allen Weiss Data Structures and Algorithm Analyses in JAVA 2’nd Ed. by Mark Allen Weiss Pearson International Ed. http://java.sun.com/docs/white/langenv/ http://java.sun.com/docs/white/langenv/ http://java.sun.com/docs/white/langenv/ http://java.sun.com/docs/books/tutorial/getStarted/intro/defi nition.html http://java.sun.com/docs/books/tutorial/getStarted/intro/defi nition.html Evaluation: Evaluation: Mt 1 10% Mt 1 10% Mt 2 20% Mt 2 20% Projects 30% Projects 30% Final Exam40% Final Exam40%

8 Object Oriented Programming Object Object Class Class Encapsulation Encapsulation Inheritance Inheritance Polymorphism Polymorphism

9 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 referred to as ATTRIBUTES DATA STRUCTURE characteristics of data structure are referred to as ATTRIBUTES PROCESSES that may correctly change the data structure processes are referred to as OPERATIONS or METHODS PROCESSES that may correctly change the data structure processes are referred to as OPERATIONS or METHODS

10 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 ).

11 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

12 Inheritance 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.

13 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.

14 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 programming techniques? Why should I use OOP? I can write good programs using structural programming techniques? Why should I use OOP?

15 Why JAVA Java technology is both a programming language and a platform. Java technology is both a programming language and a platform. The Java programming language is a high-level language that can be characterized by all of the following buzzwords: The Java programming language is a high-level language that can be characterized by all of the following buzzwords: Simple Simple Architecture neutral Architecture neutral Object oriented Object oriented Portable Portable Distributed Distributed High performance High performance Multithreaded Multithreaded Robust Robust Dynamic Dynamic

16 How JAVA Technology works In the Java programming language, all source code is first written in plain text files ending with the.java extension. Those source files are then compiled into.class files by the javac compiler. A.class file does not contain code that is native to your processor; it instead contains bytecodes — the machine language of the Java Virtual Machine1 (Java VM). The java launcher tool then runs your application with an instance of the Java Virtual Machine. In the Java programming language, all source code is first written in plain text files ending with the.java extension. Those source files are then compiled into.class files by the javac compiler. A.class file does not contain code that is native to your processor; it instead contains bytecodes — the machine language of the Java Virtual Machine1 (Java VM). The java launcher tool then runs your application with an instance of the Java Virtual Machine.1

17 How JAVA Technology works

18 What is necessary to run JAVA programs The Java platform has two components: The Java platform has two components: The Java Virtual Machine The Java Virtual Machine The Java Application Programming Interface (API) The Java Application Programming Interface (API) You've already been introduced to the Java Virtual Machine; it's the base for the Java platform and is ported onto various hardware-based platforms. The API is a large collection of ready-made software components that provide many useful capabilities. It is grouped into libraries of related classes and interfaces; these libraries are known as packages. You've already been introduced to the Java Virtual Machine; it's the base for the Java platform and is ported onto various hardware-based platforms. The API is a large collection of ready-made software components that provide many useful capabilities. It is grouped into libraries of related classes and interfaces; these libraries are known as packages.

19 What is necessary to run JAVA programs The Total Solution is JRE (?) The Total Solution is JRE (?) The Java Runtime Environment (JRE) is a set of library files and the java executable that is kicked off in order to run any java program. The Java Virtual Machine (JVM) is created, like a separate program, whenever a java program is executed. The JVM essentially runs between the computer and the java program. Java is designed so that any java program can run on any machine. This is because the JVM will interpret the Operating System independent java code and execute the commands needed for the particular Operating System you are trying to run the program on at the time. Java Program --- Execute some command ---> JVM --- Translate the command for this computer ---> Computer

20 Where do I write my programs Notepad (WHHHHHAAAAAAT??????) Notepad (WHHHHHAAAAAAT??????) Write the code Compile and RUN Compile and Run the code

21 Where do I write my programs Use IDE (Integrated DevelopmentEnvironment) Use IDE (Integrated DevelopmentEnvironment) NetBeans (We will use it) NetBeans (We will use it) Eclipse Eclipse Jikes Jikes JBuilder Foundation JBuilder Foundation JCreator LE JCreator LE etc. etc. etc. etc.

22 NetBeans

23 Do Practice Follow http://www.netbeans.org/kb/60/java/quickstart.html Follow http://www.netbeans.org/kb/60/java/quickstart.html

24 Intoduction to OOP with JAVA Object Oriented Programming Object Oriented Programming Class Class The structure which keeps data and function Inheritance Inheritance 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. Polymorphism Overloading Polymorphism Overloading Ability to have more than one function with the same name that differ in their parameter lists.

25 public class program1 { /** /** * @param args the command line arguments * @param args the command line arguments */ */ public static void main(String[] args) { public static void main(String[] args) { System.out.println("This is my first program!"); System.out.println("This is my first program!"); // TODO code application logic here // TODO code application logic here }} Program 1 Every program has its class Comments The main class is the beginning portion of your program

26 Program 2

27 Defining Class in Java Almost same as defining Struct in C language Almost same as defining Struct in C language Insert Functions into the Struct Insert Functions into the Struct Some important functions Some important functions Constructor Constructor Destructor (2 -3 weeks later ) Destructor (2 -3 weeks later )

28 public class CCircle { private float radius; private float area; public CCircle(float rad){ area = rad * rad * (float) 3.14; print_area(area); } public CCircle() { radius = (float) 20.0; } public void get_radius(){ String instr; BufferedReader inputstr = new BufferedReader( new InputStreamReader(System.in)); System.out.print("Enter the radius : "); try { instr = inputstr.readLine(); radius = Float.parseFloat(instr); } catch(IOException ie) { System.err.println("IO Exception has occured "); } public void calc_area(){ area = radius * radius * (float) 3.14; } public void print_area(float area) { System.out.println(Float.toString(area)); } public void print_area() { calc_area(); System.out.println(Float.toString(area)); } public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here CCircle mycircle = new CCircle(10); CCircle yourcircle = new CCircle(); yourcircle.get_radius(); yourcircle.print_area(); mycircle.get_radius(); mycircle.print_area(); } CONSTRUCTOR POLYMORPHISM

29 Inheritance public class CSphere extends CCircle { public void display_area(){ public void display_area(){ float SphereArea; float SphereArea; SphereArea = (float) 4 * (float) 3.14 * getRadius()*getRadius(); SphereArea = (float) 4 * (float) 3.14 * getRadius()*getRadius(); System.out.println(" The area of the sphere :" System.out.println(" The area of the sphere :" + Float.toString(SphereArea)); + Float.toString(SphereArea)); }} public static void main(String[] args) { CCircle mycircle = new CCircle(10); CCircle yourcircle = new CCircle(); yourcircle.get_radius(); yourcircle.print_area(); mycircle.get_radius(); mycircle.print_area(); CSphere mysphere = new CSphere(); System.out.println("Now sphere time "); mysphere.get_radius(); mysphere.display_area(); }

30 OOP in Java


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

Similar presentations


Ads by Google