0% found this document useful (0 votes)
17 views31 pages

Daa

Ha it is very useful

Uploaded by

2021it.r58
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
17 views31 pages

Daa

Ha it is very useful

Uploaded by

2021it.r58
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 31
An algorithm is a set of steps of operations to solve a problem performing calculation, data processing, and automated reasoning tasks. An algorithm is an efficient method that can be expressed within finite amount of time and space. What is the characteristics of an algorithm? The 5 properties of an algorithm are well- defined inputs, well-defined outputs, unambiguity, finiteness, language independence, and feasibility. With these properties, algorithms can become powerful tools that can be used for innovations and efficient problem-solving across different fields. 01-Aug-2 What is performance measurement in algorithm? Notation of Performance Measurement It's the total amount of time an algorithm takes for all input values. It indicates an algorithm's worst-case time complexity. Performance evaluation can be loosely divided into two major phases: * aprior estimates (performance analysis) ¢ a Posterior testing(performance measurement) It means to expand the recurrence and express it as a summation of terms of n and initial condition. T (n) =T (n-1) +1 and T (1) = 8 (1). Vv] https://www.javatpoint.com > daa-re DAA Recurrence Relation - Javatpoint There are mainly three asymptotic notations: ¢ Big-O Notation (O-notation) ¢ Omega Notation (Q-notation) e Theta Notation (©-notation) A feasible solution is a set of values for the decision variables that satisfies all of the constraints in an optimization problem. The set of all feasible solutions defines the feasible region of the problem. Differentiate Greedy and Divide-and-Conquer Pee A ete A. Many deciions and sequences are guaranteed and all the overlapping sub- Hnibiaced ane considered, 2. Follows Bottom-up technique 3.SpHi the input at every possibbe pxiets Father than a4 a partiowar point 4. Sub probleme are dependent on the main Problers: 5. Tima taken by this eppeowch Is net that much efficient when companed with DAC 6.Space requirement bt less when compared DAC approach, Ua a) ‘A Divide the given probileen ita macy sub problems, Find the indevidual dOhvlon: and combine them to get the: aohation for the main peoblern 2. Fallows top down techmaque 2,Spit the input only af speci#ic paints midpoint), each peoblem is independent. 4, Sub problems are iedependent on the main Probler 5, Tine taken by this approneh eficignt when compared with Greedy Algecithms, 6.$pace requirement i wery much high when compared GA appecach, Greedy vs Divide & Conquer vs Dynamic Programming Greedy Divide & Conquer Dynamic Programming Optimises by making the best | Optimises by breaking down | Same as Divide and Conquer, choice at the moment. a subproblem into simpler versions of itself and using multi-threading & recursion to solve. but optimises by caching the answers to each subproblem as not to repeat the calculation twice. Doesn't always find the ‘optimal solution, but is very fast. Always finds the optimal solution, but is slower than Greedy. Always finds the optimal solution, but may be pointless on small datasets. Requires almost no memory. Requires some memory to remember recursive calls. Requires a lot of memory for memoisation / tabulation SS Greedy Approach Dynamic Programming | Choosing the best option that Main Concept gives the best profit for the current step Optimizing the recursive backtracking solution Only if we can prove that Optimality local optimality leads to Gives an optimal solution global optimality ‘olynomial, but usually Time Complexity Polynomial worse than the greedy approach More efficient Requires a DP table Memory Complexity | because we never look back to store the answer of to other options calculated states Examples Dijkstra and 0/1 Knapsack and | Prim’s algorithm Longest Increasing Subsequence The real-valued function whose value is to be either minimized or maximized subject to the constraints. The objective function is needed to solve the optimization problems. An objective function is a linear function represented by Z =a x +b y, where are constraints and are variables. Dynamic Programming Characteristics ¢ Optimal Substructure. The problem should have optimal substructure properties. ... ¢ Fib(n) = Fib(n-1) + Fib(n-2) We can see that a problem of size “n” can be broken down into sub- problems of size “n-1” and “n-2”.... ¢ Overlapping subproblems. Advantages of Backtracking Backtracking has a brute-force nature; due to this reason, it can solve maximum problems. Backtracking problems are very intuitive to code. The step-by-step representation of the backtracking solution is straightforward to understand. You can easily debug backtracking code. A Hamiltonian cycle (or Hamiltonian circuit) is a cycle that visits each vertex exactly once. A Hamiltonian path that starts and ends at adjacent vertices can be completed by adding one more edge to forma Hamiltonian cycle, and removing any edge from a Hamiltonian cycle produces a Hamiltonian path. An articulation point (or cut vertex) is defined as a vertex which, when removed along with associated edges, makes the graph disconnected (or more precisely, increases the number of connected components in the graph). The task is to find all articulation points in the given graph. 17-4; The chromatic number can be described as the minimum number of colors required to properly color any graph. In other words, the chromatic number can be described as a minimum number of colors that are needed to color any graph in such a way that no two adjacent vertices of a graph will be assigned the same color. Connected Component Definition A connected component or simply component of an undirected graph is a subgraph in which each pair of nodes is connected with each other via a path. 25-Nov-2022 6. The traveling salesman problem (TSP) is a problem in combinatorial optimization and has several applications, such as vehicle routing problems, logistics, planning and scheduling. What are the applications of string matching? Applications of string matching String matching is a useful technique in Natural Language Processing (NLP) for various tasks, including information retrieval, text mining, text processing, and natural language generation. What is the general method of branch and bound? A branch-and-bound algorithm consists of a systematic enumeration of candidate solutions by means of state space search: the set of candidate solutions is thought of as forming a rooted tree with the full set at the root. The algorithm explores branches of this tree, which represent subsets of the solution oie What is the general method backtracking and branch bound? The Backtracking technique is an algorithm used to solve the decision problem whereas the Branch-N-Bound technique is an algorithm used to solve the optimization problem. Both techniques follow the brute force method and are used to generate the State Space tree. 10-May- Class P and Class NP *Class P contains problems which are solvable in polynomial time. —The problems have algorithms in O(n‘) time, where n is the input size and & is a constant. *Class NP consists of those problem that are verifiable in polynomial time. we can verify that the solutionis correct in time polynomial in the input size to the problem. salgorithms produce an answer by a series of “correct guesses” *Example: Hamilton Circuit: given an order of the n distinct vertices (v y,), we can test if (v, v ;.,) isan edgein G fori=/, 2, ..., n-J and (v,, v)) edge in G in time O/7) (polynomial in the input size). Definition of Decision Based Problem: - A problem is called a decision problem if its output is a simple "yes" or "no" (or you may need this of this as true/false, 0/1, accept/reject.) We will phrase many optimization problems as decision problems. State-Space Tree. A space state tree isa tree that represents all of the possible states of the problem, from the root as an initial state to the leaf as a terminal state. 30-Jan-2023 The NP problems set of problems whose solutions are hard to find but easy to verify and are solved by Non-Deterministic Machine in polynomial time. NP-Hard Problem: A Problem X is NP-Hard if there is an NP-Complete problem Y, such that Y is reducible to X in polynomial time. 05-Jan-2023 SAT (Satisfiability):- A Boolean function is said to be SAT if the output for the given value of the input is true/high/1. F=X+YZ (Created a Boolean function by CIRCUIT SAT) Assuming P != NP Assuming P = NP NP-H This is true... Decision vs. Optimization Problems ° Decision Problems * Any problem for which the answer is either zero or one is called a decision problem. » An algorithm for a decision problem is termed a decision algorithm. * Optimization Problems * Any problem that involves the identification of an optimal (either minimum or maximum) value of a given cost function is known as an optimization problem. » An optimization algorithm is used to solve an optimization problem. A Minimum Spanning Tree (MST) is a subset of edges of a connected weighted undirected graph that connects all the vertices together with the minimum possible total edge weight. What are tree traversal techniques? Tree traversal involves searching a tree data structure one node at a time, performing functions like checking the node for data or updating the node. There are two common classifications for tree traversal algorithms: Depth-first search (DFS) and breadth-first search (BFS). 16-Mar-2

You might also like