The task involves printing leaf nodes of a binary tree at given level k which is specified by the user.Leaf nodes are the end nodes whose left and right pointer is NULL which means that particular node is not a parent node.ExampleInput : 11 22 33 66 44 88 77 Output : 88 77Here, k represents the level of a tree which needs to be printed. The approach used here is traversing every node and checking whether the node is having any pointer. Even if there is one pointer that means either left or right or both than that particular ... Read More
For this, use DATEDIFF() function. Let us first create a table −mysql> create table DemoTable(DOB datetime, CurrentDate datetime); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('1995-01-21', CURDATE()); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('1998-11-01', CURDATE()); Query OK, 1 row affected (0.39 sec) mysql> insert into DemoTable values('2000-10-24', CURDATE()); Query OK, 1 row affected (0.22 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+---------------------+---------------------+ | DOB ... Read More
The task is to print the left nodes of a given binary tree. Firstly user will insert data hence generating binary tree and than print left view of the tree so formed.Every node can have at most 2 child so here the program must traverse only the left pointer associated with a nodeIf left pointer is not null means it will have some data or pointer associated with it if not than it will be the left child to be printed and displayed as an output.ExampleInput : 1 0 3 2 4 Output : 1 0 2here, orange nodes represent ... Read More
The HTML DOM Input Password pattern property is used for setting or returning the pattern attribute of an input password field. It checks the password against a regular expression specified by the pattern property.SyntaxFollowing is the syntax forSetting the pattern property −passwordObject.pattern = regexpHere, regexp is a regular expression against which the password field is checked.ExampleLet us look at an example for the password pattern property − Input Password pattern property The password can either be of three numeric characters or 6 alphabet characters from a to g Password: GET PATTERN ... Read More
For this, use the ORDER BY FIELD() ASC. Let us first create a table −mysql> create table DemoTable(Title varchar(100)); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Java'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('C'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Python'); Query OK, 1 row affected (0.63 sec) mysql> insert into DemoTable values('MongoDB'); Query OK, 1 row affected (0.20 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+---------+ ... Read More
Given an array arr[m] with m number of integers and n, which is the value to be added in an array and r queries are given with some start and end. For each query we have to add value n from the start till the end of the limit in an array.ExampleInput: arr[] = {1, 2, 3, 4, 5} query[] = { { 0, 3 }, { 1, 2 } } n = 2 Output: If we run above program then it will generate following output: Query1: { 3, 4, 5, 6, 5 } Query2: { 3, 6, 7, 6, ... Read More
For this, use REGEXP. Let us first create a table −mysql> create table DemoTable(SubjectCode varchar(100)); Query OK, 0 rows affected (0.89 sec)Insert some records in the table using insert command. The records consists of text, numbers and special characters −mysql> insert into DemoTable values('Java899@22'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('C#'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('~Python232'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('MongoDB%'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('C123456'); Query OK, 1 row affected (0.37 sec)Display all ... Read More
Given with the matrix of n x n the task is to print that matrix of n x n in lower triangular pattern.Lower triangular matrix is a matrix which has elements below the principle diagonal including the principle diagonal elements and rest elements as zero.Let’s understand this with help of a diagram −Above the elements in green are the elements below the principle diagonal and the red elements are the elements above the principle diagonal which are set as zero.ExampleInput: matrix[3][3] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 ... Read More
The HTML DOM Input Password object is associated with the element with type “password”. We can create and access an input element with type password using the createElement() and getElementById() methods respectively.PropertiesFollowing are the properties for the password object −Sr.NoProperty & Description1autocompleteTo set or return the autocomplete attribute value of a password field2autofocusTo set or return if the password field should automatically get focus when the page loads.3defaultValueTo set or return the password field default value.4disabledTo set or return whether the password field is disabled, or not.5formTo return the reference of the form containing the password field6maxLengthTo set or ... Read More
To list temporary table columns in MySQL, let us first create a temporary table.Here’s an example. We have created a temporary table with some columns that includes the details of a student −mysql> CREATE TEMPORARY TABLE DemoTable745 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(100), StudentAge int, StudentAddress varchar(100), StudentCountryName varchar(20) ); Query OK, 0 rows affected (0.00 sec)Following is the query to list temporary table columns in MySQL−mysql> show columns from DemoTable745;This will produce the following output -+--------------------+--------------+------+-----+---------+----------------+ | Field | Type ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP