George John

George John

789 Articles Published

Articles by George John

Page 49 of 79

Palindrome Partitioning

George John
George John
Updated on 17-Jun-2020 567 Views

In this algorithm, the input is a string, a partitioning of that string is palindrome partitioning when every substring of the partition is a palindrome.In this algorithm, we have to find the minimum cuts are needed to palindrome partitioning the given string.Input and OutputInput: A string. Say “ababbbabbababa” Output: Minimum cut to partition as palindrome. Here 3 cuts are needed. The palindromes are: a | babbbab | b | ababaAlgorithmminPalPart(str)Input: The given string.Output: Minimum number of palindromic partitioning from the string.Begin    n := length of str    define cut matrix and pal matrix each of order n x n ...

Read More

Maximum Sum Increasing Subsequence

George John
George John
Updated on 17-Jun-2020 640 Views

Maximum Sum Increasing subsequence is a subsequence of a given list of integers, whose sum is maximum and in the subsequence, all elements are sorted in increasing order.Let there is an array to store max sum increasing subsequence, such that L[i] is the max sum increasing subsequence, which is ending with array[i].Input and OutputInput: Sequence of integers. {3, 2, 6, 4, 5, 1} Output: Increasing subsequence whose sum is maximum. {3, 4, 5}.AlgorithmmaxSumSubSeq(array, n)Input: The sequence of numbers, number of elements.Output: Maximum sum of the increasing sub sequence.Begin    define array of arrays named subSeqLen of size n.    add ...

Read More

Largest Independent Set Problem

George John
George John
Updated on 16-Jun-2020 507 Views

The Independent Set is the subset of all binary tree nodes when there is no edge between any two nodes in that subset. Now from a set of elements, we will find the longest independent set. i.e. If the elements are used to form a binary tree, then all largest subset, where no elements in that subset are connected to each other.Input and OutputInput: A binary tree. Output: Size of the Largest Independent Set is: 5AlgorithmlongSetSize(root)In this algorithm Binary tree will be formed, each node of that tree will hold data and setSize.Input − Root node of the binary tree.Output − ...

Read More

Longest Increasing Subsequence

George John
George John
Updated on 16-Jun-2020 2K+ Views

Longest Increasing Subsequence is a subsequence where one item is greater than its previous item. Here we will try to find Longest Increasing Subsequence length, from a set of integers.Input and OutputInput: A set of integers. {0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15} Output: The length of longest increasing subsequence. Here it is 6. The subsequence is 0, 2, 6, 9, 13, 15.AlgorithmlongestSubSeq(subarray, n)Input − The sub array and the size of sub array.Output − Longest increasing sub sequence length.Begin    define array length of size n    initially set 0 ...

Read More

Snake and Ladder Problem

George John
George John
Updated on 16-Jun-2020 2K+ Views

We know about the famous game Snake and Ladder. In this game, some rooms are present on the board, with the room number. Some rooms are connected with a ladder or with snakes. When we get a ladder, we can climb up to some rooms to reach near to the destination without moving sequentially. Similarly, when we get some snake, it sends us to a lower room to start the journey again from that room.In this problem, we have to find the minimum number of the dice throw is required to reach start to destination.Input and OutputInput: The starting and ...

Read More

Transitive closure of a Graph

George John
George John
Updated on 16-Jun-2020 21K+ Views

Transitive Closure it the reachability matrix to reach from vertex u to vertex v of a graph. One graph is given, we have to find a vertex v which is reachable from another vertex u, for all vertex pairs (u, v).The final matrix is the Boolean type. When there is a value 1 for vertex u to vertex v, it means that there is at least one path from u to v.Input and OutputInput: 1 1 0 1 0 1 1 0 0 0 1 1 0 0 0 1 Output: The matrix of transitive closure 1 1 1 ...

Read More

How to replace values of a Python dictionary?

George John
George John
Updated on 15-Jun-2020 11K+ Views

You can assign a dictionary value to a variable in Python using the access operator []. For example,Examplemy_dict = {    'foo': 42,    'bar': 12.5 } new_var = my_dict['foo'] print(new_var)OutputThis will give the output −42This syntax can also be used to reassign the value associated with this key. For example,Examplemy_dict  =  {    'foo': 42,    'bar': 12.5 } my_dict['foo']  =  "Hello" print(my_dict['foo'])OutputThis will give the output −Hello

Read More

Mobile First Bootstrap

George John
George John
Updated on 12-Jun-2020 1K+ Views

Bootstrap has become mobile first since Bootstrap 3. It means 'mobile first' styles can be found throughout the entire library instead of them in separate files. You need to add the viewport meta tag to the element, to ensure proper rendering and touch zooming on mobile devices.Here, width property controls the width of the device. Setting it to device-width will make sure that it is rendered across various devices (mobiles, desktops, tablets...) properly.initial-scale = 1.0 ensures that when loaded, your web page will be rendered at a 1:1 scale and no zooming will be applied out of the boxAdd ...

Read More

Set typography and link styles in Bootstrap

George John
George John
Updated on 12-Jun-2020 186 Views

Bootstrap sets a basic global display (background), typography, and link styles.Basic Global display − Sets background-color: #fff; on the element.Typography − Uses the @font-family-base, @font-size-base, and @line-height-base attributes as the typographic base.Link styles − Sets the global link color via attribute @link-color and apply link underlines only on :hover.

Read More

How to Solve Quadratic Equation using Python?

George John
George John
Updated on 05-Mar-2020 524 Views

You can use the cmath module in order to solve Quadratic Equation using Python. This is because roots of quadratic equations might be complex in nature. If you have a quadratic equation of the form ax^2 + bx + c = 0, then,Exampleimport cmatha = 12 b = 8 c = 1 # Discriminent d = (b**2) - (4*a*c) root1 = (-b - cmath.sqrt(d)) / (2 * a) root2 = (-b + cmath.sqrt(d)) / (2 * a) print(root1) print(root2)OutputThis will give the output(-0.5+0j) (-0.16666666666666666+0j)

Read More
Showing 481–490 of 789 articles
« Prev 1 47 48 49 50 51 79 Next »
Advertisements