CS 3304 Analysis of Algorithm Unit 1, Term 2 Discussion Forum
CS 3304 Analysis of Algorithm Unit 1, Term 2 Discussion Forum
Question: In your own words describe both brute force algorithms and branch and bound
algorithms and identify the differences between the two. As part of your description, you must
discuss the Asymptotic behavior of each and discuss why this is important and how this might
factor into the decision to use either algorithm design. (Uopeople CS AY2023-T2).
My Answer Submission
Brute force algorithms: means consistent trial, that is going through all possible means or
repeatable solution extensively to achieve an aim; For example, hackers apply many password or
encryption keys go through all possible combination of moves trying to find a perfect match to
login into web page or site to defraud, we called it brute force attack. ( GeeksforGeeks 2022)
Branch and bound algorithm is a systematic methodological concept set out for solving
combinatorial optimization problems such as algorithm problem which uses combinatorial
techniques “Alphabets, strings, and languages” for analysis and design, that is “to compute a
function f: Σ∗ → Σ∗ over strings of a finite alphabet” in a mathematical programming criteria
(Lecture 2: Strings, Languages, DFAs 2008) (10.1.1 What is an algorithmic problem)
Practically, Branch and bound is usually an optimization technique used when finding an optimal
solution for combinatory mathematical optimization problems in a situation where greedy
method and dynamic programming fail. (Branch and Bound Algorithm: Baeldung 2022) (Greedy
Algorithm – Programiz n.d)
Meanwhile, the circumstances surrounding branch and bound is always slower which leads to
exponential time complexities in a worst case but if carefully applied it can also lead to algorithm
run fast in an average case but in analysis more emphasis are laid on worst case because average
are rare
A perfect example, or concept of branch and bound is like “Breadth-First Search (BFS)” they
both involve backtracking except the different of performing a breadth-first search instead of
depth-first search which we can see in 0-1 Knapsack Problem where we see that items are either
completely or no items are filled in a knapsack, searching for optimal solution we know that not
all nodes generate children or expand, so carefully selected criterion determines which node or
element to expand and when, breadth-first search removed nonpromising branches by the
process of backtracking algorithm rules and in algorithm search breadth-first search uses queue
but queue replace with stack implement depth-first search. (Clifford, 2010) (GeeksForGeeks
2022) (Branch and bound strategy Ques10 n.d)
Comparison of brute force algorithm and branch and bound algorithm.
Comparisons in them can be seeing in their implementation using “Traveling Salesman Problem
(TSP) as an example: According to “TechTarget explanation, ‘TSP is an algorithmic problem
tasked with finding the shortest route between a set of points and locations that must be visited,
‘following TSP method, brute-force algorithm check every possible paths in a larger time
consuming while branch-and-bound algorithm start from 0 which is the optimal path, and filter
out all other paths that start by alternating between the nodes on the left and the nodes on the
right more than once in a lesser time consuming. (TSP WhatIs.com)
In solving 0/1 knapsack problem as I mentioned above, we see differences between brute force
algorithm and branch and bound algorithm, four values are provided in array format to solve 0/1
Knapsack problem using brute force and branch and bound algorithm: -
1. N = Number of items.
2. V[] = Value of each item equally know as vector.
3. Wt[] = Weight of every item.
4. W = capacity of knapsack
Here, we are required to find subset larger value of v[] to determine that weights sum of items
are less than capacity of knapsack or W, then for brute force algorithm, with n items, O(2^n) and
Ω(2^n) solutions will be generated because it has no form of optimization. (GeeksforGeeks,
2022)
Branch and bound work better than the less going by 0/1 knapsack problem, assume bound is
known, node can be ignored with its subtree that is worse than current best or bound and carry on
with our best scenario of calculating one path of the tree Ω(n). But, in worst case, we need to
fully calculate entire tree O(2^n) as I stated earlier. (GeeksforGeeks, 2022)
Reference:
1. Branch and Bound Algorithm – GeeksforGeeks 2022 Retrieved from
https://www.geeksforgeeks.org › branch-and-bound-alg
2. Lecture 2: Strings, Languages, DFAs 2008 Retrieved from
https://courses.engr.illinois.edu › lectures › lect_02
3. 10.1.1 What is an algorithmic problem? (n.d) Retrieved from
https://courses.engr.illinois.edu › lec_prerec
4. Branch and Bound Algorithm | Baeldung on Computer Science 2022 Retrieved from
https://www.baeldung.com › branch-and-bound
5. Greedy Algorithm – Programiz (n.d) Retrieved from https://www.programiz.com › dsa ›
greedy-algorithm
6. Dynamic Programming vs Branch and Bound – CodeCrucks 2022 Retrieved from
https://codecrucks.com › dynamic-programming-vs-bra
7. Breadth First Search or BFS for a Graph – GeeksforGeeks 2022 Retrieved from
https://www.geeksforgeeks.org › breadth-first-search-or
8. DAA | 0/1 Knapsack Problem – Javatpoint (n.d) Retrieved from
https://www.javatpoint.com › 0-1-knapsack-problem.
Discussion Question 2
Exercise 1, Working on the low order and constant through deleting.
1) f ( n ) = n6 + 3n deleting low order terms, we get n6 + 3n ∈ Θ ( 3n )
2) f ( n ) = 2n + 12 deleting constant you get 2n + 12 ∈ Θ ( 2n )
3) f ( n ) = 3n + 2n same as number 1, low order terms will be kill the we get 3n + 2n ∈ Θ ( 3n )
4) f ( n ) = nn + n same with 1 & 3 low other terms will be remove then you get nn + n ∈ Θ ( nn )
Exercise 2
1) Θ ( 1 )
I can say that since we cannot go lower than 1 for Ω, and we have no non-tight bounds in the
function, the only thing is to do a tight bound of Ω ( 1 ). As O has an upper bound, so to have a
tight bound of O (1) and O ( n ).
2) Θ ( √n )
Learning that Θ represent tight bounds, I assume that both the tight bounds will be O ( ) and Ω
likewise 1 above, then upper non-tight bounds will be represented as O ( n ), and Ω ( 1 ) stands
as the lowest non-tight bound since nothing can go lower than Ω ( 1 ).
3) Θ ( n )
We can see that tight bounds are both O ( n ) and Ω ( n ), while non-tight bounds are Ω ( 1 ) and
O ( n m ), technically, we assume that non-tight O bound can assume any value since it can still
tactically fits within the definitions of a bound.
4) Θ ( n2 )
Tight bounds is same as O ( n2 ) and Ω ( n2 ), similarly non-tight bounds relate to 3 above with
Ω( 1 ) and O ( nm ).
5) Θ ( n3 )
Likewise 3, and 4, above, tight bounds are O ( n3 ) and Ω ( n3 ), while non-tight bounds are Ω
( n2 ) and O ( n3 ).
Reference
CSE 326: Lecture 2, Asymptotic Analysis – Washington (n.d) Retrieved from
https://courses.cs.washington.edu › courses › lectu
Analysis of Algorithms: Lecture 3 (n.d) Retrieved from https://people.engr.tamu.edu › djimenez ›
utsa › lecture3
Section 02: Solutions – Washington (n.d) Retrieved from https://courses.cs.washington.edu ›
files › sections
Lower and Upper Bound Theory – GeeksforGeeks 2022 Retrieved from
https://www.geeksforgeeks.org › lower-and-upper-bou.
Big-Ω (Big-Omega) notation (article) - Khan Academy (n.d) Retrieved from
https://www.khanacademy.org › ... › Asymptotic notation
Asymptotic Analysis 2018 Retrieved from https://personal.utdallas.edu › lectures › asymptotics