1 / 30

EEM 480 Algorithms and Complexity

EEM 480 Algorithms and Complexity. by Assist. Prof. Dr. Emin Germen. What is this Course About. Of Course it is about : Algorithms Complexity. Any More?. Algorithms + Complexity = Data Structure Data Structure : Concerns with the representation and manipulation of data.

avak
Download Presentation

EEM 480 Algorithms and Complexity

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 : Algorithms Complexity

  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 • Comparing criteria of different algorithms • Understand what a good program is • Learning effective utilizations of computer sources

  6. Syllabus • Review of JAVA • Platforms • Classes • Encapsulation, Overloading, Inheritance, Overriding • Pointers to objects • Templates • Algoritm Analysis • Necessary math review • Complexity definitions • Running time calculations • Arrays and Linked Lists • Linear lists • Formula based representation • Linked representations • Indirect addressing and pointers • Arrays and Matrices • Arrays, Matrices, Special matrices, Sparse matrices • Stacks • Queues • Trees • Binary trees • Tree traversals • B trees • Hash Tables • Priority Queues • Sorting algorithms • Basic Data Structure Implementations • Path compression • Union/Find Implementations

  7. Reference and Evaluation • 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/books/tutorial/getStarted/intro/definition.html • Evaluation: • Mt 1 10% • Mt 2 20% • Projects 30% • Final Exam 40%

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

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

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

  11. Encapsulation • Encapsulation is the procedure of covering up of data and functions into a single unit Class Data1 Data2 Procedure1(Data1) Data2 = Procedure() • 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.

  13. Polymorphism • 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???? • How can I use them??????? • 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?

  15. Why JAVA • 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: • Simple • Architecture neutral • Object oriented • Portable • Distributed • High performance • Multithreaded • Robust • 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.

  17. How JAVA Technology works

  18. What is necessary to run JAVA programs • The Java platform has two components: • The Java Virtual Machine • 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.

  19. What is necessary to run JAVA programs • 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??????) Write the code Compile and RUN Compile and Run the code

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

  22. NetBeans

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

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

  25. Program 1 Every program has its class public class program1 { /** * @param args the command line arguments */ public static void main(String[] args) { System.out.println("This is my first program!"); // TODO code application logic here } } 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 • Insert Functions into the Struct • Some important functions • Constructor • 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)); } } CONSTRUCTOR 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(); } } POLYMORPHISM

  29. Inheritance public class CSphere extends CCircle { public void display_area(){ float SphereArea; SphereArea = (float) 4 * (float) 3.14 * getRadius()*getRadius(); System.out.println(" The area of the sphere :" + 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

More Related