Find Longest Prefix Matching of a Given Sequence in C++

Anvi Jain
Updated on 30-Jul-2019 22:30:26

576 Views

Here we shall discuss a C++ program to find the Longest Subsequence Common to All Sequences in a Set of Sequences.AlgorithmsBegin Take the array of strings as input. function matchedPrefixtill(): find the matched prefix between string s1 and s2 :    n1 = store length of string s1.    n2 = store length of string s2.    for i = 0, j = 0 to i

Types of Tags Involved in JavaScript

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

1K+ Views

Html taga) The tag is used to define a client-side script.b) The tag  contains scripting statements or an external script file.JavaScript code must be keep in script tag.Let's see the use of the tag. For suppose declare the variable outside the script tag. Live DemoExample var a = 1;    var b = 2;    var c = a + b; document.getElementById("tag").innerHTML = c; Outputvar a = 1For suppose, let the variable be declared inside the script tag. Live DemoExample    var a = 1;    var b = 2;    var c = a + b; document.getElementById("tag").innerHTML = c; Output3

Position JButtons Vertically in Java Swing

Chandu yadav
Updated on 30-Jul-2019 22:30:26

671 Views

Position buttons vertically one after another using the Box class. Use the createVerticalBox() method that displays components from top to bottom −JButton button1 = new JButton("One"); JButton button2 = new JButton("Two"); JButton button3 = new JButton("Three"); Box box = Box.createVerticalBox(); box.add(button1); box.add(button2); box.add(button3);The following is an example to position buttons vertically one after another −Examplepackage my; import javax.swing.Box; import javax.swing.JButton; import javax.swing.JFrame; public class SwingDemo {    public static void main(String[] args) {       JButton button1 = new JButton("One");       JButton button2 = new JButton("Two");       JButton button3 = new JButton("Three");       ... Read More

Concatenate Two Tables in MySQL with a Condition

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

739 Views

To concatenate two tables, UNION ALL in MySQL. Let us create a table −mysql> create table DemoTable1    (    Id int,    FirstName varchar(20)    ); Query OK, 0 rows affected (1.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values(10, 'John'); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable1 values(20, 'Carol'); Query OK, 1 row affected (0.28 sec)Display all records from the table using select statement −mysql> select *from DemoTable1;Output+------+-----------+ | Id | FirstName | +------+-----------+ | 10 | John | ... Read More

Pointers, Smart Pointers and Shared Pointers in C++

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

6K+ Views

PointersPointers are used to store the address of variable.SyntaxType *pointer;InitializationType *pointer; Pointer = variable name;Functionspointers are used to store address of variable.pointers can have a null value assigned.pointer can be referenced by pass by reference.a pointer has its own memory address and size on the stack.Example Live Demo#include using namespace std; int main() {    // A normal integer variable    int a = 7;    // A pointer variable that holds address of a.    int *p = &a;    // Value stored is value of variable "a"    cout

Copy Objects in Java

Venkata Sai
Updated on 30-Jul-2019 22:30:26

9K+ Views

In Java you can copy an object in several ways, among them, copy constructor and the clone method are the mostly used.Using copy constructorGenerally, the copy constructor is a constructor which creates an object by initializing it with an object of the same class, which has been created previously. Java does support for copy constructors but you need to define them yourself.ExampleIn the following Java example, we a have a class with two instance variables name and age and a parameterized constructor initializing these variables.Then, we have another constructor which accepts an object of the current class and initializes the ... Read More

HTML DOM Input Number StepUp Method

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

150 Views

The DOM input number stepUp() method increments the value of input number field by a specified value.SyntaxFollowing is the syntax −object.stepUp(number)Here, if number parameter is omitted then it increments the value by 1.ExampleLet us see an example of HTML DOM input number stepUp() method − Live Demo HTML DOM stepUp()/stepDown() Demo    body{       text-align:center;       background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%)       center/cover no-repeat;       height:100vh;       color:#fff;    }    p{       font-size:1.5rem;    }    input{       width:40%; ... Read More

HTML DOM Links Collection

AmitDiwan
Updated on 30-Jul-2019 22:30:26

210 Views

The links Collection returns a list/collection of all the links corresponding to and/or elements.SyntaxFollowing is the syntax −Returning links collectiondocument.linksPropertiesHere, “links” collection can have the following properties and methods −Property/MethodDescriptionlengthIt returns the number of  and  elementsnamedItem()It returns the  or/and  element with the specified idExampleLet us see an example for links collection length property − Live Demo Links Collection length    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {   ... Read More

Functions That Can't Be Overloaded in C++

Anvi Jain
Updated on 30-Jul-2019 22:30:26

418 Views

In C++, we can overload the functions. But sometimes the overloading is not done. In this section, we will see what are the different cases, in which we cannot overload the functions.When function signatures are same, only the return type is different, then we cannot overload the function.int my_func() {    return 5; } char my_func() {    return 'd'; }When the member functions have the same name and same parameter list in a class, then they cannot be overloaded.class My_Class{    static void func(int x) {       //Something    }    void func(int x) {     ... Read More

Find Number of Ways to Partition a Word into Palindromes in C++

Smita Kapse
Updated on 30-Jul-2019 22:30:26

224 Views

Here we shall discuss a C++ Program to find number of ways to Partition a word in such a way that each word is a Palindrome.AlgorithmsBegin    Take the word as input.    Function partitionadd(vector &u, string &s, vector &tmp, int index):    if (index == 0)       tmp.clear()    for i = index to length-1       st = st + s[i]       if (checkPalin(st))          tmp.push_back(st)          if (i+1 < length)             partitionadd(u, s, tmp, i+1)          else   ... Read More

Advertisements