0% found this document useful (0 votes)
10 views6 pages

Downloadfile 2

Dynamic Programming (DP) is a method for solving problems by breaking them into smaller subproblems and storing their results to avoid redundant calculations. The 0/1 Knapsack Problem is a combinatorial optimization problem that aims to maximize total value without exceeding a weight limit, where each item can either be taken whole or left out. Backtracking is another algorithmic technique that explores all potential solutions and abandons those that fail to meet constraints, with applications in problems like the N-Queens and Sudoku Solver.

Uploaded by

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

Downloadfile 2

Dynamic Programming (DP) is a method for solving problems by breaking them into smaller subproblems and storing their results to avoid redundant calculations. The 0/1 Knapsack Problem is a combinatorial optimization problem that aims to maximize total value without exceeding a weight limit, where each item can either be taken whole or left out. Backtracking is another algorithmic technique that explores all potential solutions and abandons those that fail to meet constraints, with applications in problems like the N-Queens and Sudoku Solver.

Uploaded by

demoharshit1106
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

‭Dynamic Programming‬ ‭0/1 Knapsack Problem‬

‭●‬ D ‭ ynamic Programming (DP) is a method to solve problems by‬ ‭●‬ T‭ he 0/1 Knapsack Problem is a combinatorial optimization‬
‭breaking them into smaller subproblems‬ ‭problem where the goal is to select a subset of items with given‬
‭●‬ ‭s olving each subproblem once, and reusing their results to‬ ‭weights and values to maximize the total value without‬
‭avoid repeating work.‬ ‭exceeding a weight limit.‬
‭●‬ ‭Unlike the Fractional Knapsack Problem, where items can be‬
Seen
‭ ‬ ‭divided, in the 0/1 Knapsack Problem, each item can either be‬
‭“Instead of solving the same problem repeatedly (like in recursion), DP‬ ‭taken whole or left out.‬
‭stores the results of solved subproblems in a table (array) and uses‬
‭them when needed.”‬ ‭Example‬

‭Steps:‬ ‭weight[] = {1, 2, 3}, profit[] = {10, 15, 40}, Capacity = 6‬


‭●‬ B ‭ reak the Problem‬‭:Divide the problem into smaller‬
‭s ubproblems.‬
‭●‬ ‭Store Results‬‭:Save the results of the subproblems‬‭i n a table (so‬
‭you don't calculate them again).‬
‭●‬ ‭Build the Solution‬‭:Use the stored results to build‬‭the solution‬
‭for the bigger problem‬‭.‬

‭Example: Fibonacci Numbers‬


‭Without DP (Slow and Repeated Work):‬
‭int‬‭fib‬‭( ‬‭int‬‭n‬‭) ‬‭{‬
‭if‬‭( ‬‭n‬‭<=‬‭1‬‭) ‬‭return‬‭n;‬‭//‬‭B ase case‬ ‭Maximum Profit : 65‬
‭return‬‭fib‬‭( ‬‭n‬‭-‬‭1‬‭) ‬‭+‬‭fib‬‭( ‬‭n‬‭-‬‭2‬‭) ‬‭;‬‭//‬‭Recursive calls‬
‭}‬ ‭Algorithm‬
I‭nput‬‭:‬‭n items‬‭with‬‭weights‬‭[]‬‭and‬‭values‬‭[],‬‭capacity‬‭W‬
‭With DP (Fast and Efficient):‬ ‭Output‬‭:‬‭Maximum value‬‭in‬‭knapsack of capacity W‬
‭int‬‭fib‬‭( ‬‭int‬‭n‬‭,‬‭vector‬‭<‬‭int‬‭>&‬‭m emo‬‭) ‬‭{‬
‭if‬‭( ‬‭n‬‭<=‬‭1‬‭) ‬‭return‬‭n;‬‭//‬‭B ase cases‬ ‭1‬‭.‬‭I ni tia l i ze dp‬‭[][]‬‭a s ‬‭a ‬‭2D‬‭a rray of s i ze‬‭( ‬‭n ‬‭+‬‭1‬‭) ‬‭x‬‭( ‬‭W‬‭+‬‭1‬‭) ‬‭w i th‬‭all‬‭zeros ‬‭.‬
‭if‬‭( ‬‭m emo‬‭[‬‭n‬‭]‬‭!=‬‭-‬‭1‬‭) ‬‭return‬‭m emo‬‭[‬‭n‬‭]‬‭;‬‭//‬‭Use stored‬‭value‬‭if‬‭available‬
‭m emo‬‭[‬‭n‬‭]‬‭= fib‬‭( ‬‭n‬‭-‬‭1‬‭,‬‭m emo‬‭) ‬‭+‬‭fib‬‭( ‬‭n‬‭-‬‭2‬‭,‬‭m emo‬‭) ‬‭;‬‭//‬‭Store result‬ ‭2‬‭.‬‭for‬‭i ‬‭=‬‭1‬‭to n‬‭:‬ ‭/ /‬‭I terate over i tems ‬
‭return‬‭m emo‬‭[‬‭n‬‭]‬‭;‬ ‭for‬‭w ‬‭=‬‭1‬‭to W‬‭:‬ ‭/ /‬‭I terate over wei ghts ‬‭from‬‭1‬‭to W‬
‭}‬ ‭i f‬‭wei ght‬‭[‬‭i ‬‭-‬‭1‬‭]‬‭<=‬‭w ‬‭:‬
‭Why Use DP?‬ ‭d p‬‭[‬‭i ‬‭][‬‭w ‬‭]‬‭=‬‭max‬‭( ‬‭d p‬‭[‬‭i ‬‭-‬‭1‬‭][‬‭w ‬‭],‬‭va l ue‬‭[‬‭i ‬‭-‬‭1‬‭]‬‭+‬‭d p‬‭[‬‭i ‬‭-‬‭1‬‭][‬‭w ‬‭-‬
I‭ t makes solving problems faster by avoiding repeated calculations,‬ ‭wei ght‬‭[‬‭i ‬‭-‬‭1‬‭]])‬
‭e l s e‬‭:‬
‭which saves time.‬ ‭d p‬‭[‬‭i ‬‭][‬‭w ‬‭]‬‭= dp‬‭[‬‭i ‬‭-‬‭1‬‭][‬‭w ‬‭]‬

Seen
‭ ‬ ‭3‬‭.‬‭Return dp‬‭[‬‭n ‬‭][‬‭W‬‭]‬
‭“Dynamic Programming avoids redundant calculations by storing‬
‭results, while recursion may repeatedly solve the same subproblems‬
‭without storing results.”‬
Quantum 4.17
‭ ‬
Seen
‭ ‬
‭“Dynamic Programming ensures global optimality by solving all‬
‭Approaches in Dynamic Programming (DP):‬
‭subproblems, while Greedy focuses on local optimality, which may not‬
‭ .Top-Down Approach (Memoization)‬
1 ‭guarantee the best solution.”‬
‭Solve the problem recursively and store the results of subproblems‬
‭i n a cache (usually an array or hash table) to reuse later.‬ ‭Floyd Warshal Alogrithm‬
‭int‬‭fib‬‭( ‬‭int‬‭n‬‭,‬‭vector‬‭<‬‭int‬‭>&‬‭m emo‬‭) ‬‭{‬
‭●‬ I‭ t is a dynamic programming algorithm used to discover the‬
‭if‬‭( ‬‭n‬‭<=‬‭1‬‭) ‬‭return‬‭n;‬‭//‬‭B ase cases‬
‭s hortest paths in a weighted graph‬
‭if‬‭( ‬‭m emo‬‭[‬‭n‬‭]‬‭!=‬‭-‬‭1‬‭) ‬‭return‬‭m emo‬‭[‬‭n‬‭]‬‭;‬‭//‬‭Use stored‬‭value‬‭if‬‭available‬
‭m emo‬‭[‬‭n‬‭]‬‭= fib‬‭( ‬‭n‬‭-‬‭1‬‭,‬‭m emo‬‭) ‬‭+‬‭fib‬‭( ‬‭n‬‭-‬‭2‬‭,‬‭m emo‬‭) ‬‭;‬‭//‬‭Store result‬ ‭●‬ ‭I n which includes both positive & negative weight cycles.‬
‭return‬‭m emo‬‭[‬‭n‬‭]‬‭;‬ ‭●‬ ‭I t is also called all pair shortest path algorithm‬
‭}‬ ‭●‬ ‭Time complexity‬‭: O(N‬‭3‬‭) &‬‭space complexity:‬‭O(V‬‭2‭)‬ ‬
‭ .Bottom-Up Approach (Tabulation)‬
2 ‭Algorithm‬
‭Solve smaller subproblems first iteratively, then use these solutions‬ ‭ ‬‭.‬‭Create a matri x‬‭'‬‭d i st‬‭'‬‭o f s i ze VxV‬‭( ‬‭V‬‭i s ‬‭n umber‬‭o f vertices ‭)‬ ‬
1
‭to build up the solution to the main problem.‬ ‭a nd‬‭i ni tia l i ze i t‬‭w i th‬‭the wei ghts of the edges ‬‭i n‬‭the gra ph‬‭.‬
‭-‬‭I f there‬‭i s ‬‭n o di rect edge between vertices ‬‭i ‬‭a nd‬‭j‬‭,‬‭set‬
‭int‬‭fib‬‭( ‬‭int‬‭n‬‭) ‬‭{‬
‭d i st‬‭[‬‭i ‬‭][‬‭j‬‭]‬‭to i nfini ty‬‭.‬
‭int‬‭dp‬‭[‬‭n‬‭+‬‭1‬‭]‬‭;‬‭//‬‭Create a table‬
‭-‬‭I f there‬‭i s ‬‭a di rect edge between vertices ‬‭i ‬‭a nd‬‭j‬‭w i th‬‭wei ght‬
‭dp‬‭[‬‭0‬‭]‬‭=‬‭0‬‭;‬‭//‬‭B ase case‬
‭w ‬‭,‬‭set‬‭d i st‬‭[‬‭i ‬‭][‬‭j‬‭]‬‭to w‬‭.‬
‭dp‬‭[‬‭1‬‭]‬‭=‬‭1‬‭;‬‭//‬‭B ase case‬
‭2‬‭.‬‭For ea ch vertex‬‭'‬‭k ‭'‬‬‭from‬‭1‬‭to‬‭V‬‭:‬
‭a ‬‭.‬‭For ea ch pa i r of vertices ‬‭'‬‭i ‬‭'‬‭a nd‬‭'‬‭j‬‭':‬
‭for‬‭( ‬‭int‬‭i =‬‭2‬‭; i‬‭<=‬‭n; i‬‭++‬‭) ‬‭{‬
‭i ‬‭.‬‭I f di st‬‭[‬‭i ‬‭][‬‭k ‬‭]‬‭+‬‭d i st‬‭[‬‭k ‬‭][‬‭j‬‭]‬‭i s ‬‭l es s tha n di st‬‭[‬‭i ‬‭][‬‭j‬‭],‬
‭dp‬‭[‬‭i‬‭]‬‭= dp‬‭[‬‭i‬‭-‬‭1‬‭]‬‭+‬‭dp‬‭[‬‭i‬‭-‬‭2‬‭]‬‭;‬‭//‬‭B uild the‬‭result using stored values‬
‭u pdate di st‬‭[‬‭i ‬‭][‬‭j‬‭]‬‭to di st‬‭[‬‭i ‬‭][‬‭k ‬‭]‬‭+‬‭d i st‬‭[‬‭k ‬‭][‬‭j‬‭]‬
‭}‬
‭3‬‭.‬‭The fina l ‬‭'‬‭d i st‬‭'‬‭m atri x conta i ns the s hortest path‬‭d i sta nces ‬
‭return‬‭dp‬‭[‬‭n‬‭]‬‭;‬‭//‬‭F inal result‬
‭b etween‬‭all‬‭p a i rs of vertices ‭.‬‬
‭}‬
‭Backtracking‬
‭ acktracking is an algorithmic technique for solving problems by‬
B
‭exploring all potential solutions and abandoning those that fail to‬
‭s atisfy constraints or fail to reach the desired goal (partial‬
‭s olutions).‬

‭Concepts of Backtracking:‬
‭●‬ E‭ xploration‬‭:Incrementally builds a solution by trying‬‭a ll‬
‭possibilities.‬
‭●‬ ‭Constraint Satisfaction‬‭:Checks if the current partial‬‭s olution is‬
‭valid; if not, discards it and backtracks.‬
‭●‬ ‭Backtrack‬‭:Removes the last added element (or undoes‬‭the last‬
‭choice) and tries the next option.‬

‭Applications of Backtracking:‬
‭●‬ N ‭ -Queens Problem‬‭: Place N queens on an NxN chessboard‬‭s o‬
‭that no two queens attack each other.‬
‭●‬ ‭Sudoku Solver:‬‭Solve Sudoku puzzles by filling empty‬‭cells‬
‭following constraints.‬
‭●‬ ‭Permutations and Combinations:‬‭Generate all permutations‬‭or‬
‭combinations of a set.‬
‭●‬ ‭Graph Problems‬‭: Find paths, such as in the Hamiltonian‬‭Path‬
‭problem.‬
‭●‬ ‭Knapsack Problem:‬‭Solve optimization problems with‬
‭constraints.‬

‭Pseudocode for Backtracking‬


‭function‬‭b a cktra ck‬‭( ‬‭s ol ution‬‭) :‬
‭i f‬‭s ol ution‬‭i s ‬‭compl ete‬‭:‬
‭print‬‭( ‬‭s ol ution‬‭) ‬‭/ /‬‭Proces s the s ol ution‬
‭return‬
‭for‬‭e a ch‬‭ca ndi date‬‭i n‬‭current state‬‭:‬
Quantum 4.10‬
‭ ‭i f‬‭ca ndi date‬‭i s ‬‭va l i d‬‭:‬
‭a dd ca ndi date to s ol ution‬
‭Resource Allocation Problem‬ ‭b a cktra ck‬‭( ‬‭s ol ution‬‭) ‬‭/ /‬‭Recur‬
‭remove ca ndi date‬‭from‬‭s ol ution‬‭/ /‬‭B a cktra ck‬
T‭ he Resource Allocation Problem involves distributing limited‬
‭resources among tasks or entities to optimize an objective (e.g.,‬ ‭N-Queens Problem‬
‭minimize cost, maximize profit) under given constraints (e.g.,‬ ‭●‬ T‭ he N-Queens problem is a classic backtracking problem where‬
‭resource limits, dependencies)‬ ‭the goal is to place N queens on an N×N chessboard such that‬
‭no two queens attack each other.‬
‭Approaches:‬ ‭●‬ ‭Queens attack each other if they are on the same:‬
‭●‬ G ‭ reedy Algorithm: A‬‭s sign resources step-by-step for‬‭i mmediate‬ ‭●‬ ‭Row‬ ‭Column‬ ‭Diagonal‬
‭benefit.‬
‭●‬ ‭Dynamic Programming:‬‭Solve overlapping subproblems‬‭for‬
‭optimal allocation.‬
‭●‬ ‭Linear Programming:‬‭Optimize allocation using linear‬‭equations‬
‭a nd inequalities.‬
‭●‬ ‭Backtracking:‬‭Explore all possible allocations, discarding‬
‭i nvalid ones.‬

‭Example:‬
‭●‬ K ‭ napsack Problem:‬‭Allocate resources to maximize profit‬‭within‬
‭a weight limit.‬
‭●‬ ‭Key Uses:‬‭Project management, supply chains, cloud‬‭computing,‬
‭healthcare, etc.‬
‭Solution to 4-Queens problem :‬ ‭Algorithm‬
‭●‬ ‭Basically, we have to ensure 4 things :‬ ‭F unction SubsetSum‬‭(‭n
‬ ums‬‭,‬‭target‬‭,‬‭n‬‭):‬
‭●‬ ‭No two queens share a column.‬ ‭Create a dp ta bl e of s i ze‬‭( ‬‭n x‬‭( ‬‭ta rget‬‭+‬‭1‬‭) )‬‭a nd‬‭i ni tia l i ze‬‭a l l ‬‭va l ues ‬
‭●‬ ‭No two queens share a row.‬ ‭to‬‭-‬‭1‬
‭●‬ ‭No two queens share a top-right to left-bottom diagonal.‬
‭F unction Sol ve‬‭( ‬‭i ndex‬‭,‬‭ta rget‬‭) :‬
‭●‬ ‭No two queens share a top-left to bottom-right diagonal.‬
‭I f ta rget‬‭==‬‭0‬‭:‬‭Return‬‭True‬
‭I f i ndex‬‭==‬‭0‬‭:‬‭Return nums ‭[‬ ‬‭0‬‭]‬‭==‬‭ta rget‬
‭N-Queens Problem Pseudocode‬
‭function‬‭s ol veNQueens ‭(‬ ‬‭b oa rd‬‭,‬‭col ‭)‬ :‬ ‭I f dp‬‭[‬‭i ndex‬‭][‬‭ta rget‬‭]‬‭!=‬‭-‬‭1‬‭:‬‭Return dp‬‭[‬‭i ndex‬‭][‬‭ta rget‬‭]‬
‭i f‬‭col ‬‭>=‬‭N‬‭:‬
‭print‬‭( ‬‭b oa rd‬‭) ‬‭/ /‬‭Found a s ol ution‬ i‭ ncl ude‬‭=‬‭Fa l s e‬
‭return‬ ‭I f nums ‬‭[‬‭i ndex‬‭]‬‭<=‬‭ta rget‬‭:‬
‭i ncl ude‬‭=‬‭S ol ve‬‭( ‬‭i ndex‬‭-‬‭1‬‭,‬‭ta rget‬‭-‬‭n ums ‬‭[‬‭i ndex‬‭])‬
‭for‬‭row‬‭=‬‭0‬‭to N‬‭-‬‭1‬‭:‬
‭i f‬‭i s Safe‬‭( ‬‭b oa rd‬‭,‬‭row‬‭,‬‭col ‬‭) :‬ ‭e xcl ude‬‭=‬‭S ol ve‬‭( ‬‭i ndex‬‭-‬‭1‬‭,‬‭ta rget‬‭) ‬
‭p l a ceQueen‬‭( ‬‭b oa rd‬‭,‬‭row‬‭,‬‭col ‭)‬ ‬
‭s ol veNQueens ‬‭( ‭b ‬ oa rd‬‭,‬‭col ‬‭+‬‭1‬‭) ‬‭/ /‬‭Recur‬‭to pl a ce‬‭next‬‭q ueen‬ ‭ p‬‭[‬‭i ndex‬‭][‬‭ta rget‬‭]‬‭=‬‭i ncl ude‬‭OR‬‭e xcl ude‬
d
‭removeQueen‬‭( ‭b ‬ oa rd‬‭,‬‭row‬‭,‬‭col ‭)‬ ‬‭/ /‬‭B a cktra ck‬ ‭Return dp‬‭[‬‭i ndex‬‭][‬‭ta rget‬‭]‬
T‭ ime Complexity:‬ ‭
O(N×N!)‬
‭Space Complexity:‬ ‭ 2‬

O(N‬)‬
‭ ‭Return Sol ve‬‭( ‬‭n ‬‭-‬‭1‭,‬‬‭ta rget‬‭) ‬

‭Graph Coloring‬ ‭Hamiltonion Circuit /cycle‬


‭●‬ I‭ t is a concept from graph theory that refers to a cycle in a graph‬
‭●‬ G ‭ raph Coloring is a way of assigning colors to the vertices of a‬
‭that:‬
‭graph such that:‬
‭●‬ ‭Visits every vertex exactly once‬‭: The circuit passes‬‭through‬
‭●‬ ‭No two adjacent vertices share the same color (vertex‬
‭each vertex of the graph precisely once without revisiting‬
‭coloring).‬
‭a ny vertex.‬
‭●‬ ‭The minimum number of colors required to achieve this is‬
‭●‬ ‭Returns to the starting vertex:‬‭The circuit forms‬‭a closed‬
‭called the chromatic number of the graph.‬
‭l oop, ending at the same vertex where it started.‬
‭●‬ ‭Purpose‬‭: Used to solve problems like scheduling, register‬
‭a llocation in compilers, and map coloring.‬

‭Types of Graph Coloring:‬


‭●‬ V ‭ ertex Coloring:‬‭Assign colors to vertices such that‬‭no two‬
‭a djacent vertices have the same color.‬
‭●‬ ‭Edge Coloring:‬‭Assign colors to edges such that no‬‭two edges‬
‭s haring a vertex have the same color.‬
‭●‬ ‭Face Coloring:‬‭Assign colors to regions (faces) in‬‭a planar graph‬
‭(like map coloring).‬

‭Sum of Subset‬ ‭Algorithm‬


‭●‬ T‭ he Sum of Subsets problem involves finding all possible‬ ‭F unction HamiltonianCircuit‬‭(‬‭graph‬‭,‬‭path‬‭,‬‭position‬‭):‬
‭s ubsets of a given set of integers whose elements sum up to a‬ ‭# Base Case: If all vertices are in the path and‬‭path forms a cycle‬
‭s pecific target value.‬ ‭If position‬‭==‬‭number_of_vertices‬‭:‬
‭If graph‬‭[‬‭path‬‭[‬‭position‬‭-‬‭1‬‭]][‬‭path‬‭[‬‭0‬‭]]‬‭==‬‭1‬‭:‬ ‭# Check if last vertex‬
‭ .Solve the subset sum problem using backtracking, where n = 4, m‬
Q ‭connects to start‬
‭= 18, w[4] = {5, 10, 8, 13}‬ ‭Return‬‭True‬
‭Else‬‭:‬
‭Sorted order : w{4} = {5, 8, 10, 13}‬ ‭Return‬‭False‬

#‭ Try different vertices as the next candidate‬‭in the path‬


‭For vertex‬‭in‬‭range‬‭(‬‭1‬‭,‬‭number_of_vertices‬‭):‬
‭If isSafe‬‭(‬‭vertex‬‭,‬‭graph‬‭,‬‭path‬‭,‬‭position‬‭):‬ ‭# Check if vertex can be added‬
‭path‬‭[‬‭position‬‭]‬‭=‬‭vertex‬
‭If HamiltonianCircuit‬‭(‬‭graph‬‭,‬‭path‬‭,‬‭position‬‭+‬‭1‬‭):‬ ‭# Recursive call‬
‭Return‬‭True‬
‭# Backtrack if adding the vertex doesn't‬‭lead to a solution‬
‭path‬‭[‬‭position‬‭]‬‭=‬‭-‬‭1‬
‭Return‬‭False‬

‭F unction isSafe‬‭(‬‭vertex‬‭,‬‭graph‬‭,‬‭path‬‭,‬‭position‬‭):‬
‭# Check if there's an edge from the previous vertex‬‭to this vertex‬
‭If graph‬‭[‬‭path‬‭[‬‭position‬‭-‬‭1‬‭]][‬‭vertex‬‭]‬‭==‬‭0‬‭:‬
‭Return‬‭False‬
#‭ Check if the vertex is already in the path‬ ‭Numerical‬
‭For i‬‭in‬‭range‬‭(‬‭position‬‭):‬
‭If path‬‭[‬‭i‬‭]‬‭==‬‭vertex‬‭:‬
‭Return‬‭False‬
‭Return‬‭True‬

#‭ Driver function to find Hamiltonian Circuit‬


‭F unction FindHamiltonianCircuit‬‭(‬‭graph‬‭):‬
‭number_of_vertices‬‭=‬‭Length‬‭(‬‭graph‬‭)‬
‭path‬‭=‬‭[-‬‭1‬‭]‬‭*‬‭number_of_vertices‬
‭path‬‭[‬‭0‬‭]‬‭=‬‭0‬ ‭# Start from the first vertex‬

‭If HamiltonianCircuit‬‭(‭g‬ raph‬‭,‬‭path‬‭,‬‭1‬‭):‬


‭Print‬‭("‬‭H amiltonian Circuit exists:‬‭",‬‭path‬‭)‬
‭Return‬‭True‬
‭Else‬‭:‬
‭Print‬‭("‬‭No Hamiltonian Circuit found‬‭")‬
‭Return‬‭False‬
‭Travelling Salesman Problem‬
‭●‬ (‭ TSP) is a classic optimization problem in computer science,‬
‭mathematics, and operations research.‬
‭●‬ ‭I t involves finding the shortest possible route that visits a set of‬
‭cities (or nodes) exactly once and returns to the starting city.‬
‭●‬ ‭I t is widely used in logistics, planning, and other fields.‬

‭Problem Statement‬
‭●‬ ‭Given‬‭:‬
‭●‬ ‭A set of N cities.‬
‭●‬ ‭The cost/distance matrix representing the distances or‬
‭costs between every pair of cities.‬
‭●‬ ‭Find‬‭:‬
‭●‬ ‭The shortest route (Hamiltonian circuit) that visits each‬
‭city exactly once and returns to the starting city.‬

Quantum 4.15‬

You might also like