ANALYSIS OF ALGORITHMS Dr inż. ZDZISŁAW PÓLKOWSKI Polkowice, 2015 University of Pitesti Dolnośląska Wyższa Szkoła Przedsiębiorczości i Techniki w Polkowicach.

Slides:



Advertisements
Similar presentations
Algorithm Design Techniques
Advertisements

CSC 421: Algorithm Design & Analysis
Types of Algorithms.
Anany Levitin ACM SIGCSE 1999SIG. Outline Introduction Four General Design Techniques A Test of Generality Further Refinements Conclusion.
Algorithms + L. Grewe.
Lecture 12: Revision Lecture Dr John Levine Algorithms and Complexity March 27th 2006.
Introduction to Algorithms
Algorithm Strategies Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Chapter 19: Searching and Sorting Algorithms
Lecture 8 Jianjun Hu Department of Computer Science and Engineering University of South Carolina CSCE350 Algorithms and Data Structure.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Chapter 10: Algorithm Design Techniques
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
Divide and Conquer The most well known algorithm design strategy: 1. Divide instance of problem into two or more smaller instances 2. Solve smaller instances.
Backtracking.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Design and Analysis of Algorithms - Chapter 11 Algorithm An algorithm is a.
TK3043 Analysis and Design of Algorithms Introduction to Algorithms.
Dynamic Programming Introduction to Algorithms Dynamic Programming CSE 680 Prof. Roger Crawfis.
Design & Analysis of Algorithms Introduction. Introduction Algorithms are the ideas behind computer programs. An algorithm is the thing which stays the.
Teaching Teaching Discrete Mathematics and Algorithms & Data Structures Online G.MirkowskaPJIIT.
HOW TO SOLVE IT? Algorithms. An Algorithm An algorithm is any well-defined (computational) procedure that takes some value, or set of values, as input.
Recursion Chapter 7. Chapter Objectives  To understand how to think recursively  To learn how to trace a recursive method  To learn how to write recursive.
CHAPTER 09 Compiled by: Dr. Mohammad Omar Alhawarat Sorting & Searching.
CSCE350 Algorithms and Data Structure Lecture 17 Jianjun Hu Department of Computer Science and Engineering University of South Carolina
Dynamic Programming. Well known algorithm design techniques:. –Divide-and-conquer algorithms Another strategy for designing algorithms is dynamic programming.
Chapter 12 Recursion, Complexity, and Searching and Sorting
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
Complexity of algorithms Algorithms can be classified by the amount of time they need to complete compared to their input size. There is a wide variety:
Fundamentals of Algorithms MCS - 2 Lecture # 7
Algorithms  Al-Khwarizmi, arab mathematician, 8 th century  Wrote a book: al-kitab… from which the word Algebra comes  Oldest algorithm: Euclidian algorithm.
CMPT 438 Algorithms. Why Study Algorithms? Necessary in any computer programming problem ▫Improve algorithm efficiency: run faster, process more data,
Analysis of algorithms Analysis of algorithms is the branch of computer science that studies the performance of algorithms, especially their run time.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Design & Analysis of Algorithms Lecture 1 Introduction.
Christopher Moh 2005 Competition Programming Analyzing and Solving problems.
Design and Analysis of Algorithms - Chapter 11 Algorithm b An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining.
Types of Algorithms. 2 Algorithm classification Algorithms that use a similar problem-solving approach can be grouped together We’ll talk about a classification.
1 Dynamic Programming Topic 07 Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program, Image and Vision Computing Lab. School of Information and Computer Technology.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Data Structures and Algorithms Instructor: Tesfaye Guta [M.Sc.] Haramaya University.
BITS Pilani Pilani Campus Data Structure and Algorithms Design Dr. Maheswari Karthikeyan Lecture1.
Design and Analysis of Algorithms Faculty Name : Ruhi Fatima Course Description This course provides techniques to prove.
 Problem Analysis  Coding  Debugging  Testing.
Part of the Mathematics glossary: An algorithm (pronounced AL-go-rith-um) is a procedure or formula for solving a problem. The word derives from the name.
CMPT 438 Algorithms.
Advanced Algorithms Analysis and Design
Recursion Topic 5.
Algorithms and Problem Solving
CSC 421: Algorithm Design & Analysis
CSC 421: Algorithm Design & Analysis
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
CSC 421: Algorithm Design & Analysis
Types of Algorithms.
Objective of This Course
Types of Algorithms.
Algorithms and Problem Solving
CSC 421: Algorithm Design & Analysis
Lecture 3: Environs and Algorithms
Lecture 6 Architecture Algorithm Defin ition. Algorithm 1stDefinition: Sequence of steps that can be taken to solve a problem 2ndDefinition: The step.
Backtracking and Branch-and-Bound
DYNAMIC PROGRAMMING.
Types of Algorithms.
Major Design Strategies
INTRODUCTION TO ALOGORITHM DESIGN STRATEGIES
CSC 421: Algorithm Design & Analysis
Major Design Strategies
Algorithm Course Algorithms Lecture 3 Sorting Algorithm-1
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Presentation transcript:

ANALYSIS OF ALGORITHMS Dr inż. ZDZISŁAW PÓLKOWSKI Polkowice, 2015 University of Pitesti Dolnośląska Wyższa Szkoła Przedsiębiorczości i Techniki w Polkowicach Ion Paul Mihai

 What is Algorithm ?  What is Algorithm Design ?  How to Design an Algorithm ?  Graph Algorithm  Flow Chart  Importance of Algorithm Design  Conclusion TOPICS MENU

An algorithm (pronounced AL-go-rith-um) is a procedure or formula for solving a problem. The word derives from the name of the mathematician, Mohammed ibn-Musa al-Khwarizmi, who was part of the royal court in Baghdad and who lived from about 780 to 850. Al-Khwarizmi's work is the likely source for the word algebra as well. A computer program can be viewed as an elaborate algorithm. In mathematics and computer science, an algorithm usually means a small procedure that solves a recurrent problem. What is algorithm ?

What is algorithm-design ? Algorithm design is a creative activity that is not subject to recipes. The existence of many important problems for which no efficient algorithms are known is an evidence of this fact. In practice, the space of choices to develop algorithms is enormous. For this reason, and in opposition to the development from scratch, the task of solving algorithmic problems can be broached applying more abstract design techniques. These techniques offer common solving strategies for different problems. A design technique is often expressed in pseudocode as a template that can be particularized for concrete problems. Let us name this template algorithm schemas.

How to design algorithm ?? There are four FAMOUS techniques of algorithm design: GGreedy Algorithm DDivide and Conquer DDynamic Programming BBack Tracking How to design algorithm ?

Greedy Algorithm A greedy algorithm is a mathematical process that looks for simple, easy- to-implement solutions to complex, multi-step problems by deciding which next step will provide the most obvious benefit. Such algorithms are called greedy because while the optimal solution to each smaller instance will provide an immediate output, the algorithm doesn’t consider the larger problem as a whole. Once a decision has been made, it is never reconsidered. Greedy algorithms work by recursively constructing a set of objects from the smallest possible constituent parts. Recursion is an approach to problem solving in which the solution to a particular problem depends on solutions to smaller instances of the same problem. The advantage to using a greedy algorithm is that solutions to smaller instances of the problem can be straightforward and easy to understand. The disadvantage is that it is entirely possible that the most optimal short- term solutions may lead to the worst possible long-term outcome.

 Image of greedy algorithm

 Divide and Conquer Divide and Conquer Algorithm Divide-and-conquer is a top-down technique for designing algorithms that consists of dividing the problem into smaller subproblems hoping that the solutions of the subproblems are easier to find and then composing the partial solutions into the solution of the original problem. Little more formally, divide-and-conquer paradigm consists of following major phases: -Breaking the problem into several sub-problems that are similar to the original problem but smaller in size, -Solve the sub-problem recursively (successively and independently), -Combine these solutions to subproblems to create a solution to the original problem. Binary Search (simplest application of divide-and-conquer) Binary Search is an extremely well-known instance of divide-and-conquer paradigm. Given an ordered array of n elements, the basic idea of binary search is that for a given element we "probe" the middle element of the array. We continue in either the lower or upper segment of the array, depending on the outcome of the probe until we reached the required (given) element.

 Image of Divide and Conquer

 Dynamic Programming Example: Fibonacci numbers computed by iteration. Warshall ’s algorithm implemented by iterations. Dynamic Programming Algorithm Dynamic programming is a fancy name for using divide-and-conquer technique with a table. As compared to divide-and-conquer, dynamic programming is more powerful and subtle design technique. Let me repeat, it is not a specific algorithm, but it is a meta-technique (like divide-and- conquer). This technique was developed back in the days when "programming" meant "tabular method" (like linear programming). It does not really refer to computer programming. Here in our advanced algorithm course, we'll also think of "programming" as a "tableau method" and certainly not writing code. Dynamic programming is a stage-wise search method suitable for optimization problems whose solutions may be viewed as the result of a sequence of decisions.

 Images of Dynamic Programming Fibonacci_dynamic_programming.svg.png

Example: Eight queens puzzle. Traveling salesman problem. Back Tracking Algorithm Backtracking is a general algorithmic technique that considers searching every possible combination in order to solve an optimization problem. Backtracking is also known as depth-first search or branch and bound. By inserting more knowledge of the problem, the search tree can be pruned to avoid considering cases that don't look promising. While backtracking is useful for hard problems to which we do not know more efficient solutions, it is a poor solution for the everyday problems that other techniques are much better at solving.However, dynamic programming and greedy algorithms can be thought of as optimizations to backtracking, so the general technique behind backtracking is useful for understanding these more advanced concepts. Learning and understanding backtracking techniques first provides a good stepping stone to these more advanced techniques because you won't have to learn several new concepts all at once.

Image of back tracking Backtracking-no-backjumping.svg.png

 Graph Algorithm Graph Algorithm What is a graph? It's an abstract notion, used to represent the idea of some kind of connection between pairs of objects. A graph consists of: -A collection of "vertices", which I'll usually draw as small circles on the blackboard, -A collection of "edges", each connecting some two vertices. I'll usually draw these as curves on the blackboard connecting the given pair of vertices. For this definition it doesn't matter what the vertices or edges represent -- that will be different depending on what application the graph comes from. It also doesn't matter how I draw the graph, the only part that matters is which pairs of vertices are connected with each other. There are two different types of graph that we'll commonly see.

-In the other type of graph, known as a directed graph, an edge goes from one of the vertices, towards the other. In this case I'll draw an arrowhead at the vertex towards which the edge is going. If we drew a graph like the handshake graph described above, but instead connected two people if one had written a letter to the other, the result would be directed: if I've written a letter to you, you may not have written a letter back to me.In one type, known as an undirected graph it doesn't matter which end of the graph is which -- the relation between the two is symmetric. In that case I'll just draw the edges as an undecorated curve. -For instance, suppose we draw a graph with one vertex for every person in the U.S., and one edge connecting any two people who have shaken hands with each other. If I've shaken hands with you, you've shaken hands with me, so each edge is symmetric. It seems to be true that graphs like this have very small {\em diameter}: you can connect any two people with a very short chain of handshakes. -In the other type of graph, known as a directed graph, an edge goes from one of the vertices, towards the other. In this case I'll draw an arrowhead at the vertex towards which the edge is going.

 Image of Graph Algorithm

 Flow chart A flowchart is a type of diagram that represents an algorithm, workflow or process, showing the steps as boxes of various kinds, and their order by connecting them with arrows. Flowcharts are used in analyzing, designing, documenting or managing a process or program in various fields. Flow chart

Symbols of Flow Chart

It is used to store and access large quantities of data efficiently. It is used to solve complex computational problems and to design of good programs It is important to justify an algorithm correctness mathematically It provides clear, simple and unambiguous description Importance of algorithm design

Conclusion Usually a given problem can be solved using various approaches however it is not wise to settle for the first that comes to mind. More often than not, some approaches result in much more efficient solutions than others. Consider again the Fibonacci numbers computed recursively using the decrease-and-conquer approach, and computed by iterations using dynamic programming. In the first case the complexity is O(2n), while in the second case the complexity is O(n). On the other hand, consider sorting based on decrease-and-conquer (insertion sort) and brute force sorting. For almost sorted files insertion sort will give almost linear complexity, while brute force sorting algorithms have quadratic complexity. The basic question here is: How to choose the approach? First, by understanding the problem, and second, by knowing various problems and how they are solved using different approaches.