whhhhhhhhhhhhhhhhhhhhhhhhhhhhheek 8 Cc.pdf

6
whhhhhhhhhhhhhhhhhhhhhhhhhhhhheek 8 Cc.pdf


whhhhhhhhhhhhhhhhhhhhhhhhhhhhheek 8 Cc.pdf

Design and
Analysis of
Algorithm

whhhhhhhhhhhhhhhhhhhhhhhhhhhhheek 8 Cc.pdf

  • 5. Introduction to Brute Force
    Algorithm
    “Data is the new oil” this is the new mantra that is ruling the global economy. We live in the digital world,
    and every business revolves around data, which translates into profits and helps the industries stay ahead
    of their competition. With the rapid digitization, an exponential increase in the app-based business
    model, cyber-crimes is a constant threat. One such common activity that hackers perform is Brute force.
    Brute Force is a trial and error approach where attackers use programs to try out various combinations to
    break into any websites or systems. They use automated software to repetitively generate the User id
    and passwords combinations until it eventually
    generates the right combination.
  • 6. Brute-Force Search
    Brute force
    search is the most common search algorithm as it does not require any domain knowledge; all
    that is required is a state description, legal operators, the initial state and the description of a goal state.
    It does not improve the performance and completely relies on the computing power to try out possible
    combinations.
  • 7. Brute-Force Search
    The brute
    force algorithm searches all the positions in the text between 0 and n-m, whether the
    occurrence of the pattern starts there or not. After each attempt, it shifts the pattern to the right by
    exactly 1 position. The time complexity of this algorithm is O(m*n). If we are searching for n characters in
    a string of m characters, then it will take n*m tries.
  • 8. Brute-Force Search
    Let’s see
    a classic example of a travelling salesman to understand the algorithm in an easy manner.
    Suppose a salesman needs to travel 10 different cities in a country, and he wants to determine the
    shortest possible routes out of all the possible combinations. Here brute force algorithm simply calculates
    the distance between all the cities and selects the shortest one.
    Another example is to make an attempt to break the 5 digit password; then brute force may take up to
    105
    attempts to crack the code.
  • 9. Closest Pair
    Problem statement:
    To find out the two closest points
    in a set of n points in the two-dimensional cartesian
    plane. There is n number of scenarios where this
    problem arises. A real-life example might be in an air
    traffic control system where you have to monitor the
    planes flying near to each other, and you have to find
    out the safest minimum distance these planes should
    maintain.
  • 10. Convex Hull
    Problem Statement:
    A convex hull
    is the smallest polygon that
    contains all the points. The
    convex hull of a set s of the point
    is the smallest convex polygon
    containing s.
  • 11. Convex Hull
    The convex
    hull for this set of points is the convex polygon with vertices at P1, P5, P6, P7, P3.
    A line segment P1 and Pn of a set of n points is a part of the convex hull if and only if all the other points
    of the set lies inside the polygon boundary formed by the line segment.
    Let’s relate it with the rubber band,
    Point (x1, y1), (x2,y2) make the line ax+by = c
    When a = y2-y1, b = x2-x1 and c = x1*y2 – x2*y1 and divides the plane by ax+by-c < 0 and ax+by-c > 0
    So we need to check ax+by-c for the other points.
    Brute force solve this problem with the time complexity of O(n 3
    )
  • 12. Exhaustive Search
    or discrete
    problems in which there is no known efficient solution, it becomes necessary to test each and
    every possible solution sequentially.
    Exhaustive search is an activity to find out all the possible solutions to a problem in a systematic manner.
    Let’s try to solve the Travelling salesman problem (TSP) using a Brute exhaustive search algorithm.
  • 13. Exhaustive Search
    Problem Statement:
    There are n cities that salesmen need to travel, he wants to find out the shortest
    route covering all the cities.
    We are considering Hamilton Circuit to solve this problem. If a circuit exists, then any point can start
    vertices and end vertices. Once the start vertices are selected, then we only need the order for the
    remaining vertices, i.e. n-1
    Then there might be (n-1)! Possible combinations and the total cost for calculating the path might be
    O(n). thus the total time complexity might be O(n!).
  • 14. Knapsack problem
    The knapsack
    problem is a problem in combinatorial optimization: Given a set of items, each with a weight
    and a value, determine the number of each item to include in a collection so that the total weight is less
    than or equal to a given limit and the total value is as large as possible.
  • 16. Knapsack problem
    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.
  • 17. Knapsack problem
    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 ‘nth’ item is greater than ‘W’, then the nth item cannot be included and Case 1 is the only
    possibility.

Our team at Inergency is excited to announce our partnership with @Disasters Expo Europe, the leading event in disaster management.

Join us on the 15th &16th of May at the Messe Frankfurt to explore the latest solutions shaping disaster preparation, response and recovery.

To all our members, followers, and subscribers in the industry, This is YOUR opportunity to explore the intersection of sustainability and disaster management, connect with industry leaders, and stay at the forefront of emergency preparedness.

Don't miss out! Secure your complimentary tickets now and be part of the conversation driving innovation in disaster resilience. ➡️ https://lnkd.in/dNuzyQEh

And in case you missed it, here is our ultimate road trip playlist is the perfect mix of podcasts, and hidden gems that will keep you energized for the entire journey

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More