The document discusses the knapsack problem, which involves selecting a subset of items that fit within a knapsack of limited capacity to maximize the total value. There are two versions - the 0-1 knapsack problem where items can only be selected entirely or not at all, and the fractional knapsack problem where items can be partially selected. Solutions include brute force, greedy algorithms, and dynamic programming. Dynamic programming builds up the optimal solution by considering all sub-problems.
This presentation discusses the knapsack problem and its two main versions: 0/1 and fractional. The 0/1 knapsack problem involves indivisible items that are either fully included or not included, and is solved using dynamic programming. The fractional knapsack problem allows items to be partially included, and is solved using a greedy algorithm. Examples are provided of solving each version using their respective algorithms. The time complexity of these algorithms is also presented. Real-world applications of the knapsack problem include cutting raw materials and selecting investments.
This document provides an overview of the topics covered in a discrete structures course, including logic, sets, relations, functions, sequences, recurrence relations, combinatorics, probability, and graphs. It defines discrete mathematics as the study of mathematical structures that have distinct, separated values rather than varying continuously. Some examples given are problems involving a fixed number of islands/bridges or connecting a set number of cities with telephone lines. Logic is introduced as the study of valid vs. invalid arguments, and basic logical concepts like statements, truth values, compound statements, logical connectives, negation, and truth tables are outlined.
Chat GPT is an AI chatbot system released by OpenAI in November 2022 that can answer questions using its vast database of internet text. It was trained using reinforcement learning from human feedback on 570GB of text. While Chat GPT can be helpful, it has limitations like occasionally providing incorrect answers and having a limit of 60-70 questions per hour. It marks progress in natural language processing, but still lacks critical thinking skills.
Given weights and values of n items, put these items in a knapsack of capacity W to get the maximum total value in the knapsack. In other words, given two integer arrays val[0..n-1] and wt[0..n-1] which represent values and weights associated with n items respectively. Also given an integer W which represents knapsack capacity, find out the maximum value subset of val[] such that sum of the weights of this subset is smaller than or equal to W. You cannot break an item, either pick the complete item or don’t pick it (0-1 property).
Method 1: Recursion by Brute-Force algorithm OR Exhaustive Search.
Approach: A simple solution is to consider all subsets of items and calculate the total weight and value of all subsets. Consider the only subsets whose total weight is smaller than W. From all such subsets, pick the maximum value subset.
Optimal Sub-structure: To consider all subsets of items, there can be two cases for every item.
Case 1: The item is included in the optimal subset.
Case 2: The item is not included in the optimal set.
Therefore, the maximum value that can be obtained from ‘n’ items is the max of the following two values.
Maximum value obtained by n-1 items and W weight (excluding nth item).
Value of nth item plus maximum value obtained by n-1 items and W minus the weight of the nth item (including nth item).
If the weight of the ‘nth’ item is greater than ‘W’, then the nth item cannot be included and Case 1 is the only possibility.
The document discusses minimum spanning trees (MST) and two algorithms for finding them: Prim's algorithm and Kruskal's algorithm. It begins by defining an MST as a spanning tree (connected acyclic graph containing all vertices) with minimum total edge weight. Prim's algorithm grows a single tree by repeatedly adding the minimum weight edge connecting the growing tree to another vertex. Kruskal's algorithm grows a forest by repeatedly merging two components via the minimum weight edge connecting them. Both algorithms produce optimal MSTs by adding only "safe" edges that cannot be part of a cycle.
Hypermedia is a computer-based information system that allows nonlinear access to different types of media such as text, audio, video, images and graphics. It differs from multimedia in that hypermedia uses hyperlinks to connect pieces of related information. Some key characteristics of hypermedia include learner control, a variety of media types, and a wide range of possible navigation routes. Hypermedia can be used effectively in education by developing students' higher-order thinking and group skills, allowing flexible self-paced learning, and enabling students to explore and construct their own understanding. Potential disadvantages include risks of shallow or fragmented understanding from hurried browsing or getting lost without proper guidance.
The document discusses the 0-1 knapsack problem and how it can be solved using dynamic programming. It first defines the 0-1 knapsack problem and provides an example. It then explains how a brute force solution would work in exponential time. Next, it describes how to define the problem as subproblems and derive a recursive formula to solve the subproblems in a bottom-up manner using dynamic programming. This builds up the solutions in a table and solves the problem in polynomial time. Finally, it walks through an example applying the dynamic programming algorithm to a sample problem instance.
Given two integer arrays val[0...n-1] and wt[0...n-1] that represents values and weights associated with n items respectively. Find out the maximum value subset of val[] such that sum of the weights of this subset is smaller than or equal to knapsack capacity W. Here the BRANCH AND BOUND ALGORITHM is discussed .
The 0-1 knapsack problem involves selecting items with given values and weights to maximize the total value without exceeding a weight capacity. It can be solved using a brute force approach in O(2^n) time or dynamic programming in O(n*c) time. Dynamic programming constructs a value matrix where each cell represents the maximum value for a given item and weight. The cell value is either from the item above or adding the item's value if the weight is less than remaining capacity. The last cell provides the maximum value solution.
it contains the detail information about Dynamic programming, Knapsack problem, Forward / backward knapsack, Optimal Binary Search Tree (OBST), Traveling sales person problem(TSP) using dynamic programming
The document discusses the knapsack problem and greedy algorithms. It defines the knapsack problem as an optimization problem where given constraints and an objective function, the goal is to find the feasible solution that maximizes or minimizes the objective. It describes the knapsack problem has having two versions: 0-1 where items are indivisible, and fractional where items can be divided. The fractional knapsack problem can be solved using a greedy approach by sorting items by value to weight ratio and filling the knapsack accordingly until full.
This document discusses the greedy algorithm approach and the knapsack problem. It defines greedy algorithms as choosing locally optimal solutions at each step in hopes of reaching a global optimum. The knapsack problem is described as packing items into a knapsack to maximize total value without exceeding weight capacity. An optimal knapsack algorithm is presented that sorts by value-to-weight ratio and fills highest ratios first. An example applies this to maximize profit of 440 by selecting full quantities of items B and A, and half of item C for a knapsack with capacity of 60.
Knapsack problem ==>>
Given some items, pack the knapsack to get
the maximum total value. Each item has some
weight and some value. Total weight that we can
carry is no more than some fixed number W.
So we must consider weights of items as well as
their values.
Knapsack problem using dynamic programmingkhush_boo31
The document describes the 0-1 knapsack problem and provides an example of solving it using dynamic programming. Specifically, it defines the 0-1 knapsack problem, provides the formula for solving it dynamically using a 2D array C, walks through populating the C array and backtracking to find the optimal solution for a sample problem instance, and analyzes the time complexity of the dynamic programming algorithm.
We are given n distinct positive numbers (weights)
The objective is to find all combination of weights whose sum is equal to given weights m
State space tree is generated for all the possibilities of the subsets
Generate the tree by keeping weight <= m
The document discusses solving the 8 queens problem using backtracking. It begins by explaining backtracking as an algorithm that builds partial candidates for solutions incrementally and abandons any partial candidate that cannot be completed to a valid solution. It then provides more details on the 8 queens problem itself - the goal is to place 8 queens on a chessboard so that no two queens attack each other. Backtracking is well-suited for solving this problem by attempting to place queens one by one and backtracking when an invalid placement is found.
Divide and Conquer Algorithms - D&C forms a distinct algorithm design technique in computer science, wherein a problem is solved by repeatedly invoking the algorithm on smaller occurrences of the same problem. Binary search, merge sort, Euclid's algorithm can all be formulated as examples of divide and conquer algorithms. Strassen's algorithm and Nearest Neighbor algorithm are two other examples.
The document discusses algorithm analysis and asymptotic notation. It defines algorithm analysis as comparing algorithms based on running time and other factors as problem size increases. Asymptotic notation such as Big-O, Big-Omega, and Big-Theta are introduced to classify algorithms based on how their running times grow relative to input size. Common time complexities like constant, logarithmic, linear, quadratic, and exponential are also covered. The properties and uses of asymptotic notation for equations and inequalities are explained.
This document discusses various problems that can be solved using backtracking, including graph coloring, the Hamiltonian cycle problem, the subset sum problem, the n-queen problem, and map coloring. It provides examples of how backtracking works by constructing partial solutions and evaluating them to find valid solutions or determine dead ends. Key terms like state-space trees and promising vs non-promising states are introduced. Specific examples are given for problems like placing 4 queens on a chessboard and coloring a map of Australia.
Backtracking is a problem-solving technique that incrementally builds candidates to the solutions, and abandons each partial candidate ("backtracks") as soon as it determines that the candidate cannot possibly be completed to a valid solution. This document provides an overview of backtracking algorithms, including their history, how they work, examples of problems they can solve like the n-queens problem, advantages like finding optimal solutions, disadvantages like slow runtimes, and time complexities that depend on the specific problem.
This document presents an overview of the Floyd-Warshall algorithm. It begins with an introduction to the algorithm, explaining that it finds shortest paths in a weighted graph with positive or negative edge weights. It then discusses the history and naming of the algorithm, attributed to researchers in the 1950s and 1960s. The document proceeds to provide an example of how the algorithm works, showing the distance and sequence tables that are updated over multiple iterations to find shortest paths between all pairs of vertices. It concludes with discussing the time and space complexity, applications, and references.
This document provides an overview of dynamic programming. It begins by explaining that dynamic programming is a technique for solving optimization problems by breaking them down into overlapping subproblems and storing the results of solved subproblems in a table to avoid recomputing them. It then provides examples of problems that can be solved using dynamic programming, including Fibonacci numbers, binomial coefficients, shortest paths, and optimal binary search trees. The key aspects of dynamic programming algorithms, including defining subproblems and combining their solutions, are also outlined.
The document discusses minimum spanning trees (MST) and two algorithms for finding them: Prim's algorithm and Kruskal's algorithm. Prim's algorithm operates by building the MST one vertex at a time, starting from an arbitrary root vertex and at each step adding the cheapest connection to another vertex not yet included. Kruskal's algorithm finds the MST by sorting the edges by weight and sequentially adding edges that connect different components without creating cycles.
The document discusses different single-source shortest path algorithms. It begins by defining shortest path and different variants of shortest path problems. It then describes Dijkstra's algorithm and Bellman-Ford algorithm for solving the single-source shortest paths problem, even in graphs with negative edge weights. Dijkstra's algorithm uses relaxation and a priority queue to efficiently solve the problem in graphs with non-negative edge weights. Bellman-Ford can handle graphs with negative edge weights but requires multiple relaxation passes to converge. Pseudocode and examples are provided to illustrate the algorithms.
This document discusses algorithms and their analysis. It defines an algorithm as a step-by-step procedure to solve a problem or calculate a quantity. Algorithm analysis involves evaluating memory usage and time complexity. Asymptotics, such as Big-O notation, are used to formalize the growth rates of algorithms. Common sorting algorithms like insertion sort and quicksort are analyzed using recurrence relations to determine their time complexities as O(n^2) and O(nlogn), respectively.
The document describes the 0-1 knapsack problem and how to solve it using dynamic programming. The 0-1 knapsack problem involves packing items of different weights and values into a knapsack of maximum capacity to maximize the total value without exceeding the weight limit. A dynamic programming algorithm is presented that breaks the problem down into subproblems and uses optimal substructure and overlapping subproblems to arrive at the optimal solution in O(nW) time, improving on the brute force O(2^n) time. An example is shown step-by-step to illustrate the algorithm.
The document discusses the 0-1 knapsack problem and provides an example of solving it using dynamic programming. The 0-1 knapsack problem aims to maximize the total value of items selected from a list that have a total weight less than or equal to the knapsack's capacity, where each item must either be fully included or excluded. The document outlines a dynamic programming algorithm that builds a table to store the maximum value for each item subset at each possible weight, recursively considering whether or not to include each additional item.
The document discusses the 0-1 knapsack problem and how it can be solved using dynamic programming. It first defines the 0-1 knapsack problem and provides an example. It then explains how a brute force solution would work in exponential time. Next, it describes how to define the problem as subproblems and derive a recursive formula to solve the subproblems in a bottom-up manner using dynamic programming. This builds up the solutions in a table and solves the problem in polynomial time. Finally, it walks through an example applying the dynamic programming algorithm to a sample problem instance.
Given two integer arrays val[0...n-1] and wt[0...n-1] that represents values and weights associated with n items respectively. Find out the maximum value subset of val[] such that sum of the weights of this subset is smaller than or equal to knapsack capacity W. Here the BRANCH AND BOUND ALGORITHM is discussed .
The 0-1 knapsack problem involves selecting items with given values and weights to maximize the total value without exceeding a weight capacity. It can be solved using a brute force approach in O(2^n) time or dynamic programming in O(n*c) time. Dynamic programming constructs a value matrix where each cell represents the maximum value for a given item and weight. The cell value is either from the item above or adding the item's value if the weight is less than remaining capacity. The last cell provides the maximum value solution.
it contains the detail information about Dynamic programming, Knapsack problem, Forward / backward knapsack, Optimal Binary Search Tree (OBST), Traveling sales person problem(TSP) using dynamic programming
The document discusses the knapsack problem and greedy algorithms. It defines the knapsack problem as an optimization problem where given constraints and an objective function, the goal is to find the feasible solution that maximizes or minimizes the objective. It describes the knapsack problem has having two versions: 0-1 where items are indivisible, and fractional where items can be divided. The fractional knapsack problem can be solved using a greedy approach by sorting items by value to weight ratio and filling the knapsack accordingly until full.
This document discusses the greedy algorithm approach and the knapsack problem. It defines greedy algorithms as choosing locally optimal solutions at each step in hopes of reaching a global optimum. The knapsack problem is described as packing items into a knapsack to maximize total value without exceeding weight capacity. An optimal knapsack algorithm is presented that sorts by value-to-weight ratio and fills highest ratios first. An example applies this to maximize profit of 440 by selecting full quantities of items B and A, and half of item C for a knapsack with capacity of 60.
Knapsack problem ==>>
Given some items, pack the knapsack to get
the maximum total value. Each item has some
weight and some value. Total weight that we can
carry is no more than some fixed number W.
So we must consider weights of items as well as
their values.
Knapsack problem using dynamic programmingkhush_boo31
The document describes the 0-1 knapsack problem and provides an example of solving it using dynamic programming. Specifically, it defines the 0-1 knapsack problem, provides the formula for solving it dynamically using a 2D array C, walks through populating the C array and backtracking to find the optimal solution for a sample problem instance, and analyzes the time complexity of the dynamic programming algorithm.
We are given n distinct positive numbers (weights)
The objective is to find all combination of weights whose sum is equal to given weights m
State space tree is generated for all the possibilities of the subsets
Generate the tree by keeping weight <= m
The document discusses solving the 8 queens problem using backtracking. It begins by explaining backtracking as an algorithm that builds partial candidates for solutions incrementally and abandons any partial candidate that cannot be completed to a valid solution. It then provides more details on the 8 queens problem itself - the goal is to place 8 queens on a chessboard so that no two queens attack each other. Backtracking is well-suited for solving this problem by attempting to place queens one by one and backtracking when an invalid placement is found.
Divide and Conquer Algorithms - D&C forms a distinct algorithm design technique in computer science, wherein a problem is solved by repeatedly invoking the algorithm on smaller occurrences of the same problem. Binary search, merge sort, Euclid's algorithm can all be formulated as examples of divide and conquer algorithms. Strassen's algorithm and Nearest Neighbor algorithm are two other examples.
The document discusses algorithm analysis and asymptotic notation. It defines algorithm analysis as comparing algorithms based on running time and other factors as problem size increases. Asymptotic notation such as Big-O, Big-Omega, and Big-Theta are introduced to classify algorithms based on how their running times grow relative to input size. Common time complexities like constant, logarithmic, linear, quadratic, and exponential are also covered. The properties and uses of asymptotic notation for equations and inequalities are explained.
This document discusses various problems that can be solved using backtracking, including graph coloring, the Hamiltonian cycle problem, the subset sum problem, the n-queen problem, and map coloring. It provides examples of how backtracking works by constructing partial solutions and evaluating them to find valid solutions or determine dead ends. Key terms like state-space trees and promising vs non-promising states are introduced. Specific examples are given for problems like placing 4 queens on a chessboard and coloring a map of Australia.
Backtracking is a problem-solving technique that incrementally builds candidates to the solutions, and abandons each partial candidate ("backtracks") as soon as it determines that the candidate cannot possibly be completed to a valid solution. This document provides an overview of backtracking algorithms, including their history, how they work, examples of problems they can solve like the n-queens problem, advantages like finding optimal solutions, disadvantages like slow runtimes, and time complexities that depend on the specific problem.
This document presents an overview of the Floyd-Warshall algorithm. It begins with an introduction to the algorithm, explaining that it finds shortest paths in a weighted graph with positive or negative edge weights. It then discusses the history and naming of the algorithm, attributed to researchers in the 1950s and 1960s. The document proceeds to provide an example of how the algorithm works, showing the distance and sequence tables that are updated over multiple iterations to find shortest paths between all pairs of vertices. It concludes with discussing the time and space complexity, applications, and references.
This document provides an overview of dynamic programming. It begins by explaining that dynamic programming is a technique for solving optimization problems by breaking them down into overlapping subproblems and storing the results of solved subproblems in a table to avoid recomputing them. It then provides examples of problems that can be solved using dynamic programming, including Fibonacci numbers, binomial coefficients, shortest paths, and optimal binary search trees. The key aspects of dynamic programming algorithms, including defining subproblems and combining their solutions, are also outlined.
The document discusses minimum spanning trees (MST) and two algorithms for finding them: Prim's algorithm and Kruskal's algorithm. Prim's algorithm operates by building the MST one vertex at a time, starting from an arbitrary root vertex and at each step adding the cheapest connection to another vertex not yet included. Kruskal's algorithm finds the MST by sorting the edges by weight and sequentially adding edges that connect different components without creating cycles.
The document discusses different single-source shortest path algorithms. It begins by defining shortest path and different variants of shortest path problems. It then describes Dijkstra's algorithm and Bellman-Ford algorithm for solving the single-source shortest paths problem, even in graphs with negative edge weights. Dijkstra's algorithm uses relaxation and a priority queue to efficiently solve the problem in graphs with non-negative edge weights. Bellman-Ford can handle graphs with negative edge weights but requires multiple relaxation passes to converge. Pseudocode and examples are provided to illustrate the algorithms.
This document discusses algorithms and their analysis. It defines an algorithm as a step-by-step procedure to solve a problem or calculate a quantity. Algorithm analysis involves evaluating memory usage and time complexity. Asymptotics, such as Big-O notation, are used to formalize the growth rates of algorithms. Common sorting algorithms like insertion sort and quicksort are analyzed using recurrence relations to determine their time complexities as O(n^2) and O(nlogn), respectively.
The document describes the 0-1 knapsack problem and how to solve it using dynamic programming. The 0-1 knapsack problem involves packing items of different weights and values into a knapsack of maximum capacity to maximize the total value without exceeding the weight limit. A dynamic programming algorithm is presented that breaks the problem down into subproblems and uses optimal substructure and overlapping subproblems to arrive at the optimal solution in O(nW) time, improving on the brute force O(2^n) time. An example is shown step-by-step to illustrate the algorithm.
The document discusses the 0-1 knapsack problem and provides an example of solving it using dynamic programming. The 0-1 knapsack problem aims to maximize the total value of items selected from a list that have a total weight less than or equal to the knapsack's capacity, where each item must either be fully included or excluded. The document outlines a dynamic programming algorithm that builds a table to store the maximum value for each item subset at each possible weight, recursively considering whether or not to include each additional item.
The document describes the 0-1 knapsack problem and provides an example of solving it using dynamic programming. The 0-1 knapsack problem involves packing items into a knapsack of maximum capacity W to maximize the total value of packed items, where each item has a weight and value. The document defines the problem as a recursive subproblem and provides pseudocode for a dynamic programming algorithm that runs in O(nW) time, improving on the brute force O(2^n) time. It then works through an example application of the algorithm to a sample problem with 4 items and knapsack capacity of 5.
This Presentation will Use to develop your knowledge and doubts in Knapsack problem. This Slide also include Memory function part. Use this Slides to Develop your knowledge on Knapsack and Memory function
The document discusses the 0-1 knapsack problem and presents a dynamic programming algorithm to solve it. The 0-1 knapsack problem aims to maximize the total value of items selected without exceeding the knapsack's weight capacity, where each item must either be fully included or excluded. The algorithm uses a table B to store the maximum value for each sub-problem of filling weight w with the first i items, calculating entries recursively to find the overall optimal value B[n,W]. An example demonstrates filling the table to solve an instance of the problem.
Longest common sub sequence & 0/1 KnapsackAsif Shahriar
This document describes an algorithm for finding the longest common subsequence between two strings. It initializes a 2D array c with zeros and iterates through the strings, incrementing values in c when characters match based on the longest matching subsequence from the previous strings. The final value in c provides the length of the longest common subsequence.
The document presents an overview of fractional and 0/1 knapsack problems. It defines the fractional knapsack problem as choosing items with maximum total benefit but fractional amounts allowed, with total weight at most W. An algorithm is provided that takes the item with highest benefit-to-weight ratio in each step. The 0/1 knapsack problem requires choosing whole items. Solutions like greedy and dynamic programming are discussed. An example illustrates applying dynamic programming to a sample 0/1 knapsack problem.
This document discusses the 0/1 knapsack problem and provides an example of how it can be solved using dynamic programming. The 0/1 knapsack problem aims to maximize the total value of items placed in a knapsack without exceeding the knapsack's weight capacity. The example shows how to build a 2D table to systematically calculate the maximum value for each weight increment. Dynamic programming is used to break the problem down into overlapping subproblems to efficiently solve the problem in polynomial time.
The document discusses unitizing vectors. In an example, a vector v = <3, 4> is unitized by rescaling it to obtain the unit vector <3/5, 4/5>. In general, to unitize a vector v, we divide it by its length |v| to obtain the unitized vector 1/|v| * v, which geometrically corresponds to shrinking or stretching v to have a length of 1.
The document discusses unitizing vectors. In an example, a vector v = <3, 4> is unitized by rescaling it to obtain the unit vector <3/5, 4/5>. In general, to unitize a vector v, we divide it by its length |v| to obtain the unitized vector 1/|v|*v, which geometrically corresponds to shrinking or stretching v to have a length of 1.
The document discusses unitizing vectors. In an example, a vector v = <3, 4> is unitized by rescaling it to obtain the unit vector <3/5, 4/5>. In general, to unitize a vector v, we divide it by its length |v| to obtain the unitized vector 1/|v| * v, which geometrically corresponds to shrinking or stretching v to have a length of 1.
This paper analyze few algorithms of the 0/1 Knapsack Problem and fractional
knapsack problem. This problem is a combinatorial optimization problem in which one has
to maximize the benefit of objects without exceeding capacity. As it is an NP-complete
problem, an exact solution for a large input is not possible. Hence, paper presents a
comparative study of the Greedy and dynamic methods. It also gives complexity of each
algorithm with respect to time and space requirements. Our experimental results show that
the most promising approaches are dynamic programming.
This document discusses dynamic programming and its application to solve the knapsack problem.
It begins by defining dynamic programming as a technique for solving problems with overlapping subproblems where each subproblem is solved only once and the results are stored in a table.
It then defines the knapsack problem as selecting a subset of items with weights and values that fit in a knapsack of capacity W to maximize the total value.
The document shows how to solve the knapsack problem using dynamic programming by constructing a table where each entry table[i,j] represents the maximum value for items 1 to i with weight ≤ j. It provides an example problem and walks through filling the table and backtracking to find
Re call basic operations in mathematics Nadeem Uddin
The document discusses basic mathematical operations - addition, subtraction, multiplication and division. It provides examples and exercises for performing each operation on numbers and algebraic expressions. It also covers concepts like coefficients, bases and exponents of algebraic terms, polynomials, and the order of operations (BODMAS rule).
☁️ GDG Cloud Munich: Build With AI Workshop - Introduction to Vertex AI! ☁️
Join us for an exciting #BuildWithAi workshop on the 28th of April, 2025 at the Google Office in Munich!
Dive into the world of AI with our "Introduction to Vertex AI" session, presented by Google Cloud expert Randy Gupta.
π0.5: a Vision-Language-Action Model with Open-World GeneralizationNABLAS株式会社
今回の資料「Transfusion / π0 / π0.5」は、画像・言語・アクションを統合するロボット基盤モデルについて紹介しています。
拡散×自己回帰を融合したTransformerをベースに、π0.5ではオープンワールドでの推論・計画も可能に。
This presentation introduces robot foundation models that integrate vision, language, and action.
Built on a Transformer combining diffusion and autoregression, π0.5 enables reasoning and planning in open-world settings.
ELectronics Boards & Product Testing_Shiju.pdfShiju Jacob
This presentation provides a high level insight about DFT analysis and test coverage calculation, finalizing test strategy, and types of tests at different levels of the product.
The role of the lexical analyzer
Specification of tokens
Finite state machines
From a regular expressions to an NFA
Convert NFA to DFA
Transforming grammars and regular expressions
Transforming automata to grammars
Language for specifying lexical analyzers
its all about Artificial Intelligence(Ai) and Machine Learning and not on advanced level you can study before the exam or can check for some information on Ai for project
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxRishavKumar530754
LiDAR-Based System for Autonomous Cars
Autonomous Driving with LiDAR Tech
LiDAR Integration in Self-Driving Cars
Self-Driving Vehicles Using LiDAR
LiDAR Mapping for Driverless Cars
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...Infopitaara
A Boiler Feed Pump (BFP) is a critical component in thermal power plants. It supplies high-pressure water (feedwater) to the boiler, ensuring continuous steam generation.
⚙️ How a Boiler Feed Pump Works
Water Collection:
Feedwater is collected from the deaerator or feedwater tank.
Pressurization:
The pump increases water pressure using multiple impellers/stages in centrifugal types.
Discharge to Boiler:
Pressurized water is then supplied to the boiler drum or economizer section, depending on design.
🌀 Types of Boiler Feed Pumps
Centrifugal Pumps (most common):
Multistage for higher pressure.
Used in large thermal power stations.
Positive Displacement Pumps (less common):
For smaller or specific applications.
Precise flow control but less efficient for large volumes.
🛠️ Key Operations and Controls
Recirculation Line: Protects the pump from overheating at low flow.
Throttle Valve: Regulates flow based on boiler demand.
Control System: Often automated via DCS/PLC for variable load conditions.
Sealing & Cooling Systems: Prevent leakage and maintain pump health.
⚠️ Common BFP Issues
Cavitation due to low NPSH (Net Positive Suction Head).
Seal or bearing failure.
Overheating from improper flow or recirculation.
This paper proposes a shoulder inverse kinematics (IK) technique. Shoulder complex is comprised of the sternum, clavicle, ribs, scapula, humerus, and four joints.
2. What is Dynamic Programming ?
• Dynamic programming is a method for solving
optimization problems.
The idea: Compute the solutions to the sub-
problems once and store the solutions in a table,
so that they can be reused (repeatedly) later.
• It is a Bottom-Up approach.
• Coined by Richard Bellman who described
dynamic programming as the way of solving
problems where you need to find the best
decisions one after another
3. Properties
• Two main properties of a problem suggest
that the given problem can be solved using
Dynamic Programming.
• These properties are overlapping sub-
problems and optimal substructure.
4. Steps of Dynamic Programming Approach
• Dynamic Programming algorithm is designed
using the following four steps −
1. Characterize the structure of an optimal
solution.
2. Recursively define the value of an optimal
solution.
3. Compute the value of an optimal solution,
typically in a bottom-up fashion.
4. Construct an optimal solution from the
computed information.
5. Applications of Dynamic Programming
Approach
• Matrix Chain Multiplication
• Longest Common Subsequence
• Travelling Salesman Problem
• Knapsack Problem
6. The 0-1 Knapsack Problem
(Rucksack Problem)
• Given: A set S of n items, with each item i having
– wi - a positive weight
– bi - a positive benefit (value)
• Goal: Choose items with maximum total benefit but with
weight at most W (weight of Knapsack).
– In this case, we let Tdenote the set of items we take
– Objective: maximize
– Constraint:
Ti
ib
Ti
i Ww
7. Why not Greedy?
• Greedy approach provides the optimal
solution to the fractional knapsack.
• 0-1 Knapsack cannot be solved by Greedy
approach.
• It does not ensure an optimal solution to the
0-1 Knapsack
8. EXAMPLE:
• Capacity 200
• Items :
X1 : v1/w1 = 12, weight : 50
X2 : v2/w2 = 10, weight : 55
X3 : v3/w3 = 8, weight : 10
X4 : v4/w4 = 6, weight : 100
Value of Greedy : 50 * 12 + 55 *10 + 8* 10= 1230
Optimal : 8 * 100 + 55*10 + 8*10= 1430
SO, Greedy Approach does not ensure an optimal solution
to the 0-1 Knapsack
To solve 0-1 Knapsack, Dynamic Programming approach is
required.
9. Recursive formula for sub-problems:
3 cases:
1. There are no items in the knapsack, or the weight of the knapsack is 0 -
the benefit is 0
2. The weight of itemi exceeds the weight w of the knapsack - itemi cannot be
included in the knapsack and the maximum benefit is V[i-1, w]
3. Otherwise, the benefit is the maximum achieved by either not including
itemi ( i.e., V[i-1, w]),
or by including itemi (i.e., V[i-1, w-wi]+bi)
otherwise}],1[],,1[max{
wwif],1[
0or0for0
],[ i
ii bwwiVwiV
wiV
wi
wiV
10. 0-1 Knapsack Algorithm
for w = 0 to W // Initialize 1st row to 0’s
V[0,w] = 0
for i = 1 to n // Initialize 1st column to 0’s
V[i,0] = 0
for i = 1 to n
for w = 0 to W
if wi <= w // item i can be part of the solution
if bi + V[i-1,w-wi] > V[i-1,w]
V[i,w] = bi + V[i-1,w- wi]
else
V[i,w] = V[i-1,w]
else V[i,w] = V[i-1,w] // wi > w
11. Let’s run our algorithm on the
following data:
n = 4 (# of elements)
W = 5 (max weight)
Elements (weight, benefit):
(2,3), (3,4), (4,5), (5,6)
Example
13. for w = 0 to W
V[0,w] = 0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW
Example (2)
14. for i = 1 to n
V[i,0] = 0
0
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW
Example (3)
15. if wi <= w // item i can be part of the solution
if bi + V[i-1,w-wi] > V[i-1,w]
V[i,w] = bi + V[i-1,w- wi]
else
V[i,w] = V[i-1,w]
else V[i,w] = V[i-1,w] // wi > w
0
Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
0
i=1
bi=3
wi=2
w=1
w-wi =-1
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW
0
0
0
Example (4)
16. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
300
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=1
bi=3
wi=2
w=2
w-wi =0
if wi <= w // item i can be part of the solution
if bi + V[i-1,w-wi] > V[i-1,w]
V[i,w] = bi + V[i-1,w- wi]
else
V[i,w] = V[i-1,w]
else V[i,w] = V[i-1,w] // wi > w
Example (5)
17. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
300
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=1
bi=3
wi=2
w=3
w-wi =1
if wi <= w // item i can be part of the solution
if bi + V[i-1,w-wi] > V[i-1,w]
V[i,w] = bi + V[i-1,w- wi]
else
V[i,w] = V[i-1,w]
else V[i,w] = V[i-1,w] // wi > w
3
Example (6)
18. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
300
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=1
bi=3
wi=2
w=4
w-wi =2
if wi <= w // item i can be part of the solution
if bi + V[i-1,w-wi] > V[i-1,w]
V[i,w] = bi + V[i-1,w- wi]
else
V[i,w] = V[i-1,w]
else V[i,w] = V[i-1,w] // wi > w
3 3
Example (7)
19. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
300
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=1
bi=3
wi=2
w=5
w-wi =3
if wi <= w // item i can be part of the solution
if bi + V[i-1,w-wi] > V[i-1,w]
V[i,w] = bi + V[i-1,w- wi]
else
V[i,w] = V[i-1,w]
else V[i,w] = V[i-1,w] // wi > w
3 3 3
Example (8)
20. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
00
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=2
bi=4
wi=3
w=1
w-wi =-2
3 3 3 3
0
if wi <= w // item i can be part of the solution
if bi + V[i-1,w-wi] > V[i-1,w]
V[i,w] = bi + V[i-1,w- wi]
else
V[i,w] = V[i-1,w]
else V[i,w] = V[i-1,w] // wi > w
Example (9)
21. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
00
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=2
bi=4
wi=3
w=2
w-wi =-1
3 3 3 3
3
if wi <= w // item i can be part of the solution
if bi + V[i-1,w-wi] > V[i-1,w]
V[i,w] = bi + V[i-1,w- wi]
else
V[i,w] = V[i-1,w]
else V[i,w] = V[i-1,w] // wi > w
0
Example (10)
22. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
00
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=2
bi=4
wi=3
w=3
w-wi =0
3 3 3 3
0
if wi <= w // item i can be part of the solution
if bi + V[i-1,w-wi] > V[i-1,w]
V[i,w] = bi + V[i-1,w- wi]
else
V[i,w] = V[i-1,w]
else V[i,w] = V[i-1,w] // wi > w
43
Example (11)
23. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
00
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=2
bi=4
wi=3
w=4
w-wi =1
3 3 3 3
0
if wi <= w // item i can be part of the solution
if bi + V[i-1,w-wi] > V[i-1,w]
V[i,w] = bi + V[i-1,w- wi]
else
V[i,w] = V[i-1,w]
else V[i,w] = V[i-1,w] // wi > w
43 4
Example (12)
24. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
00
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=2
bi=4
wi=3
w=5
w-wi =2
3 3 3 3
0
if wi <= w // item i can be part of the solution
if bi + V[i-1,w-wi] > V[i-1,w]
V[i,w] = bi + V[i-1,w- wi]
else
V[i,w] = V[i-1,w]
else V[i,w] = V[i-1,w] // wi > w
73 4 4
Example (13)
25. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
00
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=3
bi=5
wi=4
w= 1..3
3 3 3 3
0 3 4 4
if wi <= w // item i can be part of the solution
if bi + V[i-1,w-wi] > V[i-1,w]
V[i,w] = bi + V[i-1,w- wi]
else
V[i,w] = V[i-1,w]
else V[i,w] = V[i-1,w] // wi > w
7
3 40
Example (14)
26. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
00
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=3
bi=5
wi=4
w= 4
w- wi=0
3 3 3 3
0 3 4 4 7
0 3 4 5
if wi <= w // item i can be part of the solution
if bi + V[i-1,w-wi] > V[i-1,w]
V[i,w] = bi + V[i-1,w- wi]
else
V[i,w] = V[i-1,w]
else V[i,w] = V[i-1,w] // wi > w
Example (15)
27. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
00
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=3
bi=5
wi=4
w= 5
w- wi=1
3 3 3 3
0 3 4 4 7
0 3 4
if wi <= w // item i can be part of the solution
if bi + V[i-1,w-wi] > V[i-1,w]
V[i,w] = bi + V[i-1,w- wi]
else
V[i,w] = V[i-1,w]
else V[i,w] = V[i-1,w] // wi > w
5 7
Example (16)
28. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
00
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=4
bi=6
wi=5
w= 1..4
3 3 3 3
0 3 4 4
if wi <= w // item i can be part of the solution
if bi + V[i-1,w-wi] > V[i-1,w]
V[i,w] = bi + V[i-1,w- wi]
else
V[i,w] = V[i-1,w]
else V[i,w] = V[i-1,w] // wi > w
7
3 40
70 3 4 5
5
Example (17)
29. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
00
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=4
bi=6
wi=5
w= 5
w- wi=0
3 3 3 3
0 3 4 4 7
0 3 4
if wi <= w // item i can be part of the solution
if bi + V[i-1,w-wi] > V[i-1,w]
V[i,w] = bi + V[i-1,w- wi]
else
V[i,w] = V[i-1,w]
else V[i,w] = V[i-1,w] // wi > w
5
7
7
0 3 4 5
Example (18)
31. • This algorithm only finds the max possible
value that can be carried in the knapsack
– i.e., the value in V[n,W]
• To know the items that make this maximum
value, we need to trace back through the
table.
32. How to find actual Knapsack Items
• All of the information we need is in the table.
• V[n,W] is the maximal value of items that can
be placed in the Knapsack.
• Let i=n and k=W
if V[i,k] V[i1,k] then
mark the ith item as in the knapsack
i = i1, k = k-wi
else
i = i1 // Assume the ith item is not in the
knapsack
33. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
00
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=4
k= 5
bi=6
wi=5
V[i,k] = 7
V[i1,k] =7
3 3 3 3
0 3 4 4 7
0 3 4
i=n, k=W
while i,k > 0
if V[i,k] V[i1,k] then
mark the ith item as in the knapsack
i = i1, k = k-wi
else
i = i1
5 7
0 3 4 5 7
Finding the Items
34. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
00
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=4
k= 5
bi=6
wi=5
V[i,k] = 7
V[i1,k] =7
3 3 3 3
0 3 4 4 7
0 3 4
i=n, k=W
while i,k > 0
if V[i,k] V[i1,k] then
mark the ith item as in the knapsack
i = i1, k = k-wi
else
i = i1
5 7
0 3 4 5 7
Finding the Items (2)
35. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
00
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=3
k= 5
bi=5
wi=4
V[i,k] = 7
V[i1,k] =7
3 3 3 3
0 3 4 4 7
0 3 4
i=n, k=W
while i,k > 0
if V[i,k] V[i1,k] then
mark the ith item as in the knapsack
i = i1, k = k-wi
else
i = i1
5 7
0 3 4 5 7
Finding the Items (3)
36. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
00
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=2
k= 5
bi=4
wi=3
V[i,k] = 7
V[i1,k] =3
k wi=2
3 3 3 3
0 3 4 4 7
0 3 4
i=n, k=W
while i,k > 0
if V[i,k] V[i1,k] then
mark the ith item as in the knapsack
i = i1, k = k-wi
else
i = i1
5 7
0 3 4 5 7
7
Finding the Items (4)
37. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
00
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW i=1
k= 2
bi=3
wi=2
V[i,k] = 3
V[i1,k] =0
k wi=0
3 3 3 3
0 3 4 4 7
0 3 4
i=n, k=W
while i,k > 0
if V[i,k] V[i1,k] then
mark the ith item as in the knapsack
i = i1, k = k-wi
else
i = i1
5 7
0 3 4 5 7
3
Finding the Items (5)
38. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
00
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW
3 3 3 3
0 3 4 4 7
0 3 4
i=n, k=W
while i,k > 0
if V[i,k] V[i1,k] then
mark the nth item as in the knapsack
i = i1, k = k-wi
else
i = i1
5 7
0 3 4 5 7
i=0
k= 0
The optimal
knapsack
should contain
{1, 2}
Finding the Items (6)
39. Items:
1: (2,3)
2: (3,4)
3: (4,5)
4: (5,6)
00
0
0
0
0 0 0 0 000
1
2
3
4 50 1 2 3
4
iW
3 3 3 3
0 3 4 4 7
0 3 4
i=n, k=W
while i,k > 0
if V[i,k] V[i1,k] then
mark the nth item as in the knapsack
i = i1, k = k-wi
else
i = i1
5 7
0 3 4 5 7
The optimal
knapsack
should contain
{1, 2}
7
3
Finding the Items (7)
40. for w = 0 to W
V[0,w] = 0
for i = 1 to n
V[i,0] = 0
for i = 1 to n
for w = 0 to W
< the rest of the code >
What is the running time of this algorithm?
O(W)
O(W)
Repeat n times
O(n*W)
Running time
41. Applications of Knapsack Problem
• Resourse allocation with financial constraints
• Construction and Scoring of Heterogenous
test
• Selection of capital investments