Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Computer Engineering Articles
Page 2 of 35
Rooted and Binary Tree
A rooted tree G is a connected acyclic graph with a special node called the root, from which every edge directly or indirectly originates. An ordered rooted tree is a rooted tree where the children of each internal vertex are ordered. If every internal vertex has not more than m children, it is called an m-ary tree. If every internal vertex has exactly m children, it is called a full m-ary tree. If m = 2, the rooted tree is called a binary tree. Rooted Tree (root = a) ...
Read MoreRepresentation of Relations using Graph
A relation can be represented visually using a directed graph (digraph). This graphical representation makes it easy to understand which elements are related and in what direction. How to Represent a Relation as a Graph The rules for converting a relation into a directed graph are − The number of vertices equals the number of elements in the set. For each ordered pair (x, y) in the relation R, draw a directed edge from vertex x to vertex y. If there is an ordered pair (x, x), draw a self-loop on vertex x. Example ...
Read MoreRepresentation of Graphs
There are mainly two ways to represent a graph in computer science − Adjacency Matrix − A 2D array showing connections between vertices. Adjacency List − An array of linked lists showing neighbors of each vertex. Adjacency Matrix An adjacency matrix A[V][V] is a 2D array of size V × V where V is the number of vertices. For an undirected graph, if there is an edge between Vx and Vy, then A[Vx][Vy] = 1 and A[Vy][Vx] = 1 (the matrix is symmetric). For a directed graph, if there is an edge from Vx to ...
Read MoreRelations of a Set
A relation describes a connection or association between elements of sets. Relations may exist between objects of the same set or between objects of two or more sets. Definition and Properties A binary relation R from set X to set Y (written as xRy or R(x, y)) is a subset of the Cartesian product X × Y. Each element of R is an ordered pair (x, y) where x ∈ X and y ∈ Y. More generally, an n-ary relation R between sets A1, A2, ..., An is a subset of the Cartesian product A1 × A2 ...
Read MoreThe Predicate Calculus
Predicate Calculus (also called first-order logic) extends propositional logic by dealing with predicates − statements that contain variables. While propositional logic works with fixed true/false statements, predicate calculus allows us to express properties of objects and relationships between them. Predicate A predicate is an expression of one or more variables defined on some specific domain. A predicate with variables can be made a proposition by either assigning a value to the variable or by quantifying the variable. Consider the statement − "Ram is a student." "is a student" is the predicate (P), and "Ram" is ...
Read MorePower Set
The power set of a set S is the set of all subsets of S, including the empty set and S itself. The power set is denoted as P(S). If S has n elements, then its power set has 2n elements. Example For a set S = { a, b, c, d }, let us list all the subsets grouped by size − Subsets with 0 elements: { ∅ } Subsets with 1 element: { a }, { b }, { c }, { d } Subsets with 2 elements: { a, ...
Read MoreIndependent Vertex Set
An independent vertex set of a graph G is a subset of vertices where no two vertices are adjacent (connected by an edge). This concept is the vertex counterpart of the independent line set (matching), and is fundamental to problems like graph coloring and vertex cover. Independent Vertex Set Let G = (V, E) be a graph. A subset S of V is called an independent vertex set of G if no two vertices in S are adjacent − that is, no edge in G connects any pair of vertices in S. Example ...
Read MoreIndependent Line Set
An independent set in a graph is a set of elements (vertices or edges) where no two elements are adjacent to each other. There are two types − Independent line set (edge independent set) − A set of edges where no two edges share a common vertex. Independent vertex set − A set of vertices where no two vertices share a common edge. Independent Line Set Let G = (V, E) be a graph. A subset L of E is called an independent line set (also called a matching) if no two edges in L ...
Read MoreBipartite Graphs
A bipartite graph is a graph whose vertex set can be split into two disjoint sets, V1 and V2, such that every edge connects a vertex in V1 to a vertex in V2. No edge connects two vertices within the same set. Bipartite Graph If the vertex-set of a graph G can be split into two disjoint sets V1 and V2, in such a way that each edge joins a vertex in V1 to a vertex in V2, and there are no edges connecting two vertices within V1 or within V2, then G is called a bipartite graph. ...
Read MoreCenters of a tree
The center of a tree is a vertex with minimal eccentricity. The eccentricity of a vertex X in a tree G is the maximum distance between vertex X and any other vertex of the tree. The maximum eccentricity across all vertices is the diameter of the tree. If a tree has exactly one center, it is called a central tree. If a tree has exactly two centers (connected by an edge), it is called a bi-central tree. Every tree is either central or bi-central. Algorithm to Find Centers of a Tree The algorithm works ...
Read More