The document discusses the divide and conquer algorithm design paradigm. It provides examples of using divide and conquer to solve problems like sorting a list, finding the minimum element, and tiling a defective chessboard. The key steps of the divide and conquer approach are to (1) divide the problem into subproblems, (2) solve the subproblems, and (3) combine the solutions to solve the original problem.
Slides for Introductory session on K Means Clustering.
simple and good. ppt
Could be used for taking classes for MCA students on Clustering Algorithms for Data mining.
Prepared By K.T.Thomas HOD of Computer Science, Santhigiri College Vazhithala
Slides for Introductory session on K Means Clustering.
simple and good. ppt
Could be used for taking classes for MCA students on Clustering Algorithms for Data mining.
Prepared By K.T.Thomas HOD of Computer Science, Santhigiri College Vazhithala
K Means Clustering Algorithm | K Means Example in Python | Machine Learning A...Edureka!
** Python Training for Data Science: https://www.edureka.co/python **
This Edureka Machine Learning tutorial (Machine Learning Tutorial with Python Blog: https://goo.gl/fe7ykh ) series presents another video on "K-Means Clustering Algorithm". Within the video you will learn the concepts of K-Means clustering and its implementation using python. Below are the topics covered in today's session:
1. What is Clustering?
2. Types of Clustering
3. What is K-Means Clustering?
4. How does a K-Means Algorithm works?
5. K-Means Clustering Using Python
Machine Learning Tutorial Playlist: https://goo.gl/UxjTxm
K-means Clustering Algorithm with Matlab Source codegokulprasath06
K-means algorithm
The most common method to classify unlabeled data.
Also Checkout: http://bit.ly/2Mub6xP
Any Queries, Call us@ +91 9884412301 / 9600112302
Introductory session for basic matlab commands and a brief overview of K-mean clustering algorithm with image processing example.
NOTE: you can find code of k-mean clustering algorithm for image processing in notes.
K Means Clustering Algorithm | K Means Example in Python | Machine Learning A...Edureka!
** Python Training for Data Science: https://www.edureka.co/python **
This Edureka Machine Learning tutorial (Machine Learning Tutorial with Python Blog: https://goo.gl/fe7ykh ) series presents another video on "K-Means Clustering Algorithm". Within the video you will learn the concepts of K-Means clustering and its implementation using python. Below are the topics covered in today's session:
1. What is Clustering?
2. Types of Clustering
3. What is K-Means Clustering?
4. How does a K-Means Algorithm works?
5. K-Means Clustering Using Python
Machine Learning Tutorial Playlist: https://goo.gl/UxjTxm
K-means Clustering Algorithm with Matlab Source codegokulprasath06
K-means algorithm
The most common method to classify unlabeled data.
Also Checkout: http://bit.ly/2Mub6xP
Any Queries, Call us@ +91 9884412301 / 9600112302
Introductory session for basic matlab commands and a brief overview of K-mean clustering algorithm with image processing example.
NOTE: you can find code of k-mean clustering algorithm for image processing in notes.
Studying community structure has proven efficient in understanding social forms of interactions among people, quantitatively investigating some of the well-known social theories and providing useful recommendations to users in communities based on common interests.
Studying the community structure of Flight MH370 will help us finding patterns that emerge from that structure which can lead to demystify some of the many ambiguous aspects of that flight. The aim of this study is to analyze the mesoscopic and macroscopic features of that community using social network analysis.
Pajek, which is a program for social network analysis, is used to generate a series of social networks that represent the different network communities.
In computer science, divide and conquer (D&C) is an algorithm design paradigm based on multi-branched recursion. A divide and conquer algorithm works by recursively breaking down a problem into two or more sub-problems of the same (or related) type, until these become simple enough to be solved directly. The solutions to the sub-problems are then combined to give a solution to the original problem.
In computer science, merge sort (also commonly spelled mergesort) is an O(n log n) comparison-based sorting algorithm. Most implementations produce a stable sort, which means that the implementation preserves the input order of equal elements in the sorted output. Mergesort is a divide and conquer algorithm that was invented by John von Neumann in 1945. A detailed description and analysis of bottom-up mergesort appeared in a report by Goldstine and Neumann as early as 1948.
In computer science, divide and conquer is an algorithm design paradigm based on multi-branched recursion. A divide-and-conquer algorithm works by recursively breaking down a problem into two or more sub-problems of the same or related type until these become simple enough to be solved directly.
Problem-Solving using Graph Traversals: Searching, Scoring, Ranking, and Reco...Marko Rodriguez
A graph is a data structure that links a set of vertices by a set of edges. Modern graph databases support multi-relational graph structures, where there exist different types of vertices (e.g. people, places, items) and different types of edges (e.g. friend, lives at, purchased). By means of index-free adjacency, graph databases are optimized for graph traversals and are interacted with through a graph traversal engine. A graph traversal is defined as an abstract path whose instance is realized on a graph dataset. Graph databases and traversals can be used for searching, scoring, ranking, and in concert, recommendation. This presentation will explore graph structures, algorithms, traversal algebras, graph-related software suites, and a host of examples demonstrating how to solve real-world problems, in real-time, with graphs. This is a whirlwind tour of the theory and application of graphs.
Recursion occurs when a thing is defined in terms of itself or of its type. Recursion is used in a variety of disciplines ranging from linguistics to logic. The most common application of recursion is in mathematics and computer science, where a function being defined is applied within its own definition. While this apparently defines an infinite number of instances (function values), it is often done in such a way that no loop or infinite chain of references can occur.
In this presentation, I have discussed what divide and conquer is, its advantages, disadvantages and its applications like merge sort, binary search etc.
Mastering Greedy Algorithms: Optimizing Solutions for Efficiency"22bcs058
Greedy algorithms are fundamental techniques used in computer science and optimization problems. They belong to a class of algorithms that make decisions based on the current best option without considering the overall future consequences. Despite their simplicity and intuitive appeal, greedy algorithms can provide efficient solutions to a wide range of problems across various domains.
At the core of greedy algorithms lies a simple principle: at each step, choose the locally optimal solution that seems best at the moment, with the hope that it will lead to a globally optimal solution. This principle makes greedy algorithms easy to understand and implement, as they typically involve iterating through a set of choices and making decisions based on some criteria.
One of the key characteristics of greedy algorithms is their greedy choice property, which states that at each step, the locally optimal choice leads to an optimal solution overall. This property allows greedy algorithms to make decisions without needing to backtrack or reconsider previous choices, resulting in efficient solutions for many problems.
Greedy algorithms are commonly used in problems involving optimization, scheduling, and combinatorial optimization. Examples include finding the minimum spanning tree in a graph (Prim's and Kruskal's algorithms), finding the shortest path in a weighted graph (Dijkstra's algorithm), and scheduling tasks to minimize completion time (interval scheduling).
Despite their effectiveness in many situations, greedy algorithms may not always produce the optimal solution for a given problem. In some cases, a greedy approach can lead to suboptimal solutions that are not globally optimal. This occurs when the greedy choice property does not guarantee an optimal solution at each step, or when there are conflicting objectives that cannot be resolved by a greedy strategy alone.
To mitigate these limitations, it is essential to carefully analyze the problem at hand and determine whether a greedy approach is appropriate. In some cases, greedy algorithms can be augmented with additional techniques or heuristics to improve their performance or guarantee optimality. Alternatively, other algorithmic paradigms such as dynamic programming or divide and conquer may be better suited for certain problems.
Overall, greedy algorithms offer a powerful and versatile tool for solving optimization problems efficiently. By understanding their principles and characteristics, programmers and researchers can leverage greedy algorithms to tackle a wide range of computational challenges and design elegant solutions that balance simplicity and effectiveness.
1. Divide And Conquer
• Distinguish between small and large instances.
• Small instances solved differently from large ones.
2. Small And Large Instance
• Small instance.
Sort a list that has n <= 10 elements.
Find the minimum of n <= 2 elements.
• Large instance.
Sort a list that has n > 10 elements.
Find the minimum of n > 2 elements.
3. Solving A Small Instance
• A small instance is solved using some
direct/simple strategy.
Sort a list that has n <= 10 elements.
• Use count, insertion, bubble, or selection sort.
Find the minimum of n <= 2 elements.
• When n = 0, there is no minimum element.
• When n = 1, the single element is the minimum.
• When n = 2, compare the two elements and
determine which is smaller.
4. Solving A Large Instance
• A large instance is solved as follows:
Divide the large instance into k >= 2 smaller instances.
Solve the smaller instances somehow.
Combine the results of the smaller instances to obtain
the result for the original large instance.
5. Sort A Large List
• Sort a list that has n > 10 elements.
Sort 15 elements by dividing them into 2 smaller lists.
One list has 7 elements and the other has 8.
Sort these two lists using the method for small lists.
Merge the two sorted lists into a single sorted list.
6. Find The Min Of A Large List
• Find the minimum of 20 elements.
Divide into two groups of 10 elements each.
Find the minimum element in each group somehow.
Compare the minimums of each group to determine
the overall minimum.
7. Recursion In Divide And Conquer
• Often the smaller instances that result from the
divide step are instances of the original problem
(true for our sort and min problems). In this case,
If the new instance is a small instance, it is solved
using the method for small instances.
If the new instance is a large instance, it is solved using
the divide-and-conquer method recursively.
• Generally, performance is best when the smaller
instances that result from the divide step are of
approximately the same size.
8. Recursive Find Min
• Find the minimum of 20 elements.
Divide into two groups of 10 elements each.
Find the minimum element in each group
recursively. The recursion terminates when the
number of elements is <= 2. At this time the
minimum is found using the method for small
instances.
Compare the minimums of the two groups to
determine the overall minimum.
10. Our Definition Of A Chessboard
A chessboard is an n x n grid, where n is a
power of 2.
1x1 2x2 4x4 8x8
11. A defective chessboard is a chessboard that
has one unavailable (defective) position.
1x1 2x2 4x4 8x8
12. A Triomino
A triomino is an L shaped object that can
cover three squares of a chessboard.
A triomino has four orientations.
13. Tiling A Defective Chessboard
Place (n2 - 1)/3 triominoes on an n x n
defective chessboard so that all n2 - 1
nondefective positions are covered.
1x1 2x2 4x4 8x8
14. Tiling A Defective Chessboard
Divide into four smaller chessboards. 4 x 4
One of these is a defective 4 x 4 chessboard.
15. Tiling A Defective Chessboard
Make the other three 4 x 4 chessboards
defective by placing a triomino at their common
cRoercnuerrs.ively tile the four defective 4 x 4
chessboards.
17. Complexity
• Let n = 2k.
• Let t(k) be the time taken to tile a 2k x 2k
defective chessboard.
• t(0) = d, where d is a constant.
• t(k) = 4t(k-1) + c, when k > 0. Here c is a
constant.
• Recurrence equation for t().
18. Substitution Method
t(k) = 4t(k-1) + c
= 4[4t(k-2) + c] + c
= 42 t(k-2) + 4c + c
= 42[4t(k-3) + c] + 4c + c
= 43 t(k-3) + 42c + 4c + c
= …
= 4k t(0) + 4k-1c + 4k-2c + ... + 42c + 4c + c
= 4k d + 4k-1c + 4k-2c + ... + 42c + 4c + c
= Theta(4k)
= Theta(number of triominoes placed)
19. Min And Max
Find the lightest and heaviest of n elements
using a balance that allows you to compare
the weight of 2 elements.
Minimize the number of comparisons.
20. Max Element
• Find element with max weight from
w[0:n-1].
maxElement = 0;
for (int i = 1; i < n; i++)
if (w[maxElement] < w[i]) maxElement = i;
• Number of comparisons of w values is n-1.
21. Min And Max
• Find the max of n elements making n-1
comparisons.
• Find the min of the remaining n-1 elements
making n-2 comparisons.
• Total number of comparisons is 2n-3.
22. Divide And Conquer
• Small instance.
n <= 2.
Find the min and max element making at most
one comparison.
23. Large Instance Min And Max
n > 2.
Divide the n elements into 2 groups A and B
with floor(n/2) and ceil(n/2) elements,
respectively.
Find the min and max of each group
recursively.
Overall min is min{min(A), min(B)}.
Overall max is max{max(A), max(B)}.
24. Min And Max Example
• Find the min and max of {3,5,6,2,4,9,3,1}.
• Large instance.
• A = {3,5,6,2} and B = {4,9,3,1}.
• min(A) = 2, min(B) = 1.
• max(A) = 6, max(B) = 9.
• min{min(A),min(B)} = 1.
• max{max(A), max(B)} = 9.
27. Time Complexity
• Let c(n) be the number of comparisons made
when finding the min and max of n elements.
• c(0) = c(1) = 0.
• c(2) = 1.
• When n > 2,
c(n) = c(floor(n/2)) + c(ceil(n/2)) + 2
• To solve the recurrence, assume n is a power of 2
and use repeated substitution.
• c(n) = ceil(3n/2) - 2.
28. Interpretation Of Recursive Version
• The working of a recursive divide-and-conquer algorithm
can be described by a tree—recursion tree.
• The algorithm moves down the recursion tree dividing large
instances into smaller ones.
• Leaves represent small instances.
• The recursive algorithm moves back up the tree combining
the results from the subtrees.
• The combining finds the min of the mins computed at
leaves and the max of the leaf maxs.
29. Iterative Version
• Start with n/2 groups with 2 elements each
and possibly 1 group that has just 1element.
• Find the min and max in each group.
• Find the min of the mins.
• Find the max of the maxs.
30. Iterative Version Example
• {2,8,3,6,9,1,7,5,4,2,8 }
• {2,8}, {3,6}, {9,1}, {7,5}, {4,2}, {8}
• mins = {2,3,1,5,2,8}
• maxs = {8,6,9,7,4,8}
• minOfMins = 1
• maxOfMaxs = 9
31. Comparison Count
• Start with n/2 groups with 2 elements each
and possibly 1 group that has just 1element.
No compares.
• Find the min and max in each group.
floor(n/2) compares.
• Find the min of the mins.
ceil(n/2) - 1 compares.
• Find the max of the maxs.
ceil(n/2) - 1 compares.
• Total is ceil(3n/2) - 2 compares.
32. Initialize A Heap
• n > 1:
Initialize left subtree and right subtree recursively.
Then do a trickle down operation at the root.
• t(n) = c, n <= 1.
• t(n) = 2t(n/2) + d * height, n > 1.
• c and d are constants.
• Solve to get t(n) = O(n).
• Implemented iteratively in Chapter 13.
33. Initialize A Loser Tree
• n > 1:
Initialize left subtree.
Initialize right subtree.
Compare winners from left and right subtrees.
Loser is saved in root and winner is returned.
• t(n) = c, n <= 1.
• t(n) = 2t(n/2) + d, n > 1.
• c and d are constants.
• Solve to get t(n) = O(n).
• Implemented iteratively in Chapter 14.
Editor's Notes
We already have used this method in this class. For example, nearly all the binary tree algorithms studied use this technique. To traverse a binary tree tree small instance == NULL; large instanceevery non empty binary tree; traversal NULL do nothing; non NULL traverse left, traverse right, visit (say).
For the tiling to be possible, (n2 - 1) must be divisible by 3 whenever n is a power of 2. So, the tiling algorithm that follows actually provides a proof the this is so.