Tree is a discrete structure that represents hierarchical relationships between individual elements or nodes. A tree in which a parent has no more than two children is called a binary tree.Tree and its PropertiesDefinition − A Tree is a connected acyclic undirected graph. There is a unique path between every pair of vertices in G. A tree with N number of vertices contains (N-1) number of edges. The vertex which is of 0 degree is called root of the tree. The vertex which is of 1 degree is called leaf node of the tree and the degree of an internal ... Read More
Hamiltonian graph - A connected graph G is called Hamiltonian graph if there is a cycle which includes every vertex of G and the cycle is called Hamiltonian cycle. Hamiltonian walk in graph G is a walk that passes through each vertex exactly once.Dirac's Theorem - If G is a simple graph with n vertices, where n ≥ 3 If deg(v) ≥ {n}/{2} for each vertex v, then the graph G is Hamiltonian graph.Ore's Theorem - If G is a simple graph with n vertices, where n ≥ 2 if deg(x) + deg(y) ≥ n for each pair of non-adjacent ... Read More
There are various types of graphs depending upon the number of vertices, number of edges, interconnectivity, and their overall structure. We will discuss only a certain few important types of graphs in this chapter.Null GraphA graph having no edges is called a Null Graph.ExampleIn the above graph, there are three vertices named 'a', 'b', and 'c', but there are no edges among them. Hence it is a Null Graph.Trivial GraphA graph with only one vertex is called a Trivial Graph.ExampleIn the above shown graph, there is only one vertex 'a' with no other edges. Hence it is a Trivial graph.Non-Directed ... Read More
Let us first create a table −mysql> create table DemoTable649 (Value text); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into DemoTable649 values('1903'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable649 values('9321010'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable649 values('983032023393'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable649 values('1234567892'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable649 values('989898989'); Query OK, 1 row affected (0.20 sec)Display all records from the table using select statement −mysql> select *from DemoTable649;This will ... Read More
The inverse of a one-to-one corresponding function f: A → B, is the function g: B → A, holding the following property −f(x) = y ⇔ g(y) = xThe function f is called invertible if its inverse function g exists.ExampleA Function f : Z → Z, f(x)=x+5, is invertible since it has the inverse function g : Z → Z, g(x)= x-5.A Function f : Z → Z, f(x)=x2 is not invertiable since this is not one-to-one as (-x)2=x2.
Let us first create a table. One of the columns is set as TIMESTAMP −mysql> create table DemoTable648( UserId int NOT NULL AUTO_INCREMENT, UserLoginTime TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARYKEY(UserId) ); Query OK, 0 rows affected (0.66 sec)Insert some records in the table using insert command. Here, we have set the current date and time to timestamp column using the NOW() method −mysql> insert into DemoTable648(UserLoginTime) values(NOW()); Query OK, 1 row affected (0.22 sec)Display all records from the table using select statement −mysql> select *from DemoTable648;This will produce the following output −+--------+---------------------+ | UserId | UserLoginTime ... Read More
Two graphs G1 and G2 are said to be homomorphic, if each of these graphs can be obtained from the same graph 'G' by dividing some edges of G with more vertices. Take a look at the following example −Divide the edge 'rs' into two edges by adding one vertex.The graphs shown below are homomorphic to the first graph.If G1 is isomorphic to G2, then G is homeomorphic to G2 but the converse need not be true.Any graph with 4 or less vertices is planar.Any graph with 8 or less edges is planar.A complete graph Kn is planar if and ... Read More
Use RAND() for random, whereas LIMIT 3 for the number of values i.e. 3 here −select yourColumnName from yourTableName order by rand() limit 3;Let us first create a table −mysql> create table DemoTable646 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(100) ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable646(FirstName) values('John'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable646(FirstName) values('Bob'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable646(FirstName) values('Chris'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable646(FirstName) ... Read More
For this, use UNION. Let us first create a table −mysql> create table DemoTable645 (Id int, FirstName varchar(100)); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command −mysql> insert into DemoTable645 values(100, 'Chris'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable645 values(101, 'Robert'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable645 values(101, 'Bob'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable645 values(102, 'Carol'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable645 values(100, 'John'); Query OK, 1 row affected (0.12 sec) mysql> insert ... Read More
Graphs come with various properties which are used for characterization of graphs depending on their structures. These properties are defined in specific terms pertaining to the domain of graph theory. In this chapter, we will discuss a few basic properties that are common in all graphs.Radius of a Connected GraphThe minimum eccentricity from all the vertices is considered as the radius of the Graph G. The minimum among all the maximum distances between a vertex to all other vertices is considered as the radius of the Graph G.Notation − r(G)From all the eccentricities of the vertices in a graph, the ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP