Greedy algorithms work by making locally optimal choices at each step to arrive at a global optimum. This document discusses the components and process of greedy algorithms. It provides examples of applying greedy approaches to problems like job sequencing with deadlines, optimal storage on tapes, and optimal merge patterns. The optimal merge pattern problem is solved in detail, showing how sorting file sizes and repeatedly merging the smallest files yields the lowest total number of comparisons needed.
P, NP, NP-Complete, and NP-Hard
Reductionism in Algorithms
NP-Completeness and Cooks Theorem
NP-Complete and NP-Hard Problems
Travelling Salesman Problem (TSP)
Travelling Salesman Problem (TSP) - Approximation Algorithms
PRIMES is in P - (A hope for NP problems in P)
Millennium Problems
Conclusions
P, NP, NP-Complete, and NP-Hard
Reductionism in Algorithms
NP-Completeness and Cooks Theorem
NP-Complete and NP-Hard Problems
Travelling Salesman Problem (TSP)
Travelling Salesman Problem (TSP) - Approximation Algorithms
PRIMES is in P - (A hope for NP problems in P)
Millennium Problems
Conclusions
this is a briefer overview about the Big O Notation. Big O Notaion are useful to check the Effeciency of an algorithm and to check its limitation at higher value. with big o notation some examples are also shown about its cases and some functions in c++ are also described.
Merge sort is a sorting technique based on divide and conquer technique. With worst-case time complexity being Ο(n log n), it is one of the most respected algorithms.
Merge sort first divides the array into equal halves and then combines them in a sorted manner.
Design and Analysis of Algorithm help to design the algorithms for solving different types of problems in Computer Science. It also helps to design and analyze the logic of how the program will work before developing the actual code for a program.
this is a briefer overview about the Big O Notation. Big O Notaion are useful to check the Effeciency of an algorithm and to check its limitation at higher value. with big o notation some examples are also shown about its cases and some functions in c++ are also described.
Merge sort is a sorting technique based on divide and conquer technique. With worst-case time complexity being Ο(n log n), it is one of the most respected algorithms.
Merge sort first divides the array into equal halves and then combines them in a sorted manner.
Design and Analysis of Algorithm help to design the algorithms for solving different types of problems in Computer Science. It also helps to design and analyze the logic of how the program will work before developing the actual code for a program.
Array is a container which can hold a fix number of items and these items should be of the same type. Most of the data structures make use of arrays to implement their algorithms. Following are the important terms to understand the concept of array.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
How to Create Map Views in the Odoo 17 ERPCeline George
The map views are useful for providing a geographical representation of data. They allow users to visualize and analyze the data in a more intuitive manner.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
What is the purpose of the Sabbath Law in the Torah. It is interesting to compare how the context of the law shifts from Exodus to Deuteronomy. Who gets to rest, and why?
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
4. Greedy Method
• General Approach
• Given a set of n inputs
• Find a subset called feasible solution of the n inputs
subject to some constraints and satisfying a given
objective function
• If the objective function is maximized or minimized the
feasible solution is optimal
• It is locally optimal method
5. Components of Greedy Algorithm
Greedy algorithms have the following five components −
• A candidate set − A solution is created from this set.
• A selection function − Used to choose the best candidate
to be added to the solution.
• A feasibility function − Used to determine whether a
candidate can be used to contribute to the solution.
• An objective function − Used to assign a value to a
solution or a partial solution.
• A solution function − Used to indicate whether a
complete solution has been reached.
7. Algorithm
• Step 1: Choose an input from the input set, based on some
criterion. If no more input exit.
• Step 2 : Check whether the chosen input yields to a
feasible solution. If no, discard the input and go to step 1
• Step 3 : Include the input into the solution vector and
update the objective function. Go to step 1.
8. Optimal Storage on Tapes
• There are n programs that are to be stored on a computer
tape of length L. Associated with each program i is length Li
• Assume the tape is initially positioned at the front. If the
programs are stored in the order I = i1,i2…in the time tj needed
to retrieve program ij
• If all programs are retrieved equally often, then the
Mean Retrieval Time (MRT) =
• This problem fits the ordering paradigm. Minimizing the MRT
is equivalent to minimizing
• d(I) =
9. Example:
• Let n = 3, (L1, L2, L3) = (5, 10, 3) 6 possible orderings. The
optimal is 3,1,2.
11. Job Sequencing with Deadlines
Problem Statement
• In job sequencing problem, the objective is to find a sequence of
jobs, which is completed within their deadlines and gives
maximum profit.
Solution
• Let us consider, a set of n given jobs which are associated with
deadlines and profit is earned, if a job is completed by its deadline.
• These jobs need to be ordered in such a way that there is
maximum profit.
12. • It may happen that all of the given jobs may not be completed
within their deadlines.
• Assume, deadline of ith job Ji is di and the profit received from
this job is pi.
• Hence, the optimal solution of this algorithm is a feasible
solution with maximum profit.
• Thus, D(i) > 0 for 1⩽i⩽n.
• Initially, these jobs are ordered according to profit,
• i.e. p1⩾ p2⩾ p3⩾...⩾ pn
•
13.
14. Analysis
• In this algorithm, we are using two loops, one is within another.
Hence, the complexity of this algorithm is O(n2).
Example
• Let us consider a set of given jobs as shown in the following table.
• We have to find a sequence of jobs, which will be completed within
their deadlines and will give maximum profit.
• Each job is associated with a deadline and profit.
Job J1 J2 J3 J4 J5
Deadline 2 1 3 2 1
Profit 60 100 20 40 20
15. Solution
• To solve this problem, the given jobs are sorted according to
their profit in a descending order.
• Hence, after sorting, the jobs are ordered as shown in the
following table.
Job J2 J1 J4 J3 J5
Deadline 1 2 2 3 1
Profit 100 60 40 20 20
16. • From this set of jobs, first we select J2, as it can be completed
within its deadline and contributes maximum profit.
• Next, J1 is selected as it gives more profit compared to J4.
• In the next clock, J4 cannot be selected as its deadline is over,
hence J3 is selected as it executes within its deadline.
• The job J5 is discarded as it cannot be executed within its deadline.
• Thus, the solution is the sequence of jobs (J2, J1, J3), which are
being executed within their deadline and gives maximum profit.
• Total profit of this sequence is 100 + 60 + 20 = 180.
17. Optimal Merge Pattern
Problem Statement
• Merge a set of sorted files of different length into a single
sorted file.
• We need to find an optimal solution, where the resultant file
will be generated in minimum time.
• If the number of sorted files are given, there are many ways
to merge them into a single sorted file. This merge can be
performed pair wise. Hence, this type of merging is called
as 2-way merge patterns.
18. • As, different pairings require different amounts of time, in
this strategy we want to determine an optimal way of
merging many files together.
• At each step, two shortest sequences are merged.
• To merge a p-record file and a q-record file requires
possibly p + q record moves, the obvious choice being,
merge the two smallest files together at each step.
• Two-way merge patterns can be represented by binary merge
trees. Let us consider a set of n sorted files {f1, f2, f3, …, fn}.
• Initially, each element of this is considered as a single node
binary tree.
• To find this optimal solution, the following algorithm is used.
19. • At the end of this algorithm, the weight of the root node
represents the optimal cost.
20. Example
• Let us consider the given files, f1, f2, f3, f4 and f5 with 20,
30, 10, 5 and 30 number of elements respectively.
• If merge operations are performed according to the
provided sequence, then
• M1 = merge f1 and f2 => 20 + 30 = 50
• M2 = merge M1 and f3 => 50 + 10 = 60
• M3 = merge M2 and f4 => 60 + 5 = 65
• M4 = merge M3 and f5 => 65 + 30 = 95
• Hence, the total number of operations is
50 + 60 + 65 + 95 = 270
21. • Now, the question arises is there any better solution?
• Sorting the numbers according to their size in an
ascending order, we get the following sequence −
• f4, f3, f1, f2, f5
• Hence, merge operations can be performed on this
sequence
• M1 = merge f4 and f3 => 5 + 10 = 15
• M2 = merge M1 and f1 => 15 + 20 = 35
• M3 = merge M2 and f2 => 35 + 30 = 65
• M4 = merge M3 and f5 => 65 + 30 = 95
• Therefore, the total number of operations is
15 + 35 + 65 + 95 = 210
• Obviously, this is better than the previous one.
22. • In this context, we are now going to solve the problem
using this algorithm.
Initial Set
Step-1