C++ Program for Dijkstra's Shortest Path Algorithm

sudhir sharma
Updated on 08-Nov-2023 00:13:33

27K+ Views

We are given a graph with a source vertex in the graph. And we have to find the shortest path from the source vertex to all other vertices of the graph. The Dijikstra's algorithm is a greedy algorithm to find the shortest path from the source vertex of the graph to the root node of the graph. Algorithm Step 1 : Create a set shortPath to store vertices that come in the way of the shortest path tree. Step 2 : Initialize all distance values as INFINITE and assign distance values as 0 for source vertex so that it is ... Read More

Construct Predictive Parsing Table and Check String Acceptance

Ginni
Updated on 08-Nov-2023 00:08:09

41K+ Views

Problem − Consider the following grammar − E → TE′ E′ → +TE′|ε T′ → FT′ T′ → FT′|ε F → (E)|id Solution − Step1− Elimination of Left Recursion & perform Left Factoring As there is no left recursion in Grammar so, we will proceed as it is. Also, there is no need for Left Factoring. Step2− Computation of FIRST FIRST(E) = FIRST(T) = FIRST(F) = {(, id} FIRST (E′) = {+, ε} FIRST (T′) = {*, ε} Step3− Computation of FOLLOW FOLLOW (E) = FOLLOW(E′) = {), $} FOLLOW (T) = FOLLOW(T′) = {+, ), $} FOLLOW (F) = ... Read More

Difference Between Relative and Absolute XPath in Selenium

Debomita Bhattacharjee
Updated on 08-Nov-2023 00:02:51

30K+ Views

We can have two ways of creating an xpath – relative and absolute. The absolute xpath has the complete path beginning from the root to the element which we want to identify.An absolute xpath starts with the / symbol. One drawback with the absolute xpath is that if there is any change in attributes beginning from the root to the element, our absolute xpath will become invalid.The relative xpath starts by referring to the element that we want to identify and not from the root node. A relative xpath starts with the // symbol. It is mainly used for automation ... Read More

Use of the & Symbol in C++

Sravani S
Updated on 07-Nov-2023 20:29:43

31K+ Views

The & symbol is used as an operator in C++. It is used in 2 different places, one as a bitwise and operator and one as a pointer address of operator.Bitwise ANDThe bitwise AND operator (&) compares each bit of the first operand to that bit of the second operand. If both bits are 1, the bit is set to 1. Otherwise, the bit is set to 0. Both operands to the bitwise AND operator must be of integral types. Example #include   using namespace std;   int main() {      unsigned short a = 0x5555;      // pattern 0101 ...      unsigned short b = 0xAAAA;      // pattern 1010 ...      cout

Hamiltonian Cycle

Sharon Christine
Updated on 07-Nov-2023 20:21:18

25K+ Views

In an undirected graph, the Hamiltonian path is a path, that visits each vertex exactly once, and the Hamiltonian cycle or circuit is a Hamiltonian path, that there is an edge from the last vertex to the first vertex. In this problem, we will try to determine whether a graph contains a Hamiltonian cycle or not. And when a Hamiltonian cycle is present, also print the cycle. Input and Output Input: The adjacency matrix of a graph G(V, E). Output: The algorithm finds the Hamiltonian path of the given graph. For this case it is (0, 1, 2, 4, ... Read More

Race Condition, Critical Section and Semaphore

Ricky Barnes
Updated on 07-Nov-2023 13:13:31

41K+ Views

Race conditions, Critical Sections and Semaphores are an key part of Operating systems. Details about these are given as follows −Race ConditionA race condition is a situation that may occur inside a critical section. This happens when the result of multiple thread execution in critical section differs according to the order in which the threads execute.Race conditions in critical sections can be avoided if the critical section is treated as an atomic instruction. Also, proper thread synchronization using locks or atomic variables can prevent race conditions.Critical SectionThe critical section in a code segment where the shared variables can be accessed. ... Read More

Network Software

Vikyath Ram
Updated on 07-Nov-2023 13:08:25

30K+ Views

Network software encompasses a broad range of software used for design, implementation, and operation and monitoring of computer networks. Traditional networks were hardware based with software embedded. With the advent of Software – Defined Networking (SDN), software is separated from the hardware thus making it more adaptable to the ever-changing nature of the computer network.Functions of Network SoftwareHelps to set up and install computer networksEnables users to have access to network resources in a seamless mannerAllows administrations to add or remove users from the networkHelps to define locations of data storage and allows users to access that dataHelps administrators and ... Read More

Client-Server Computing

David Meador
Updated on 07-Nov-2023 12:55:51

46K+ Views

In client server computing, the clients requests a resource and the server provides that resource. A server may serve multiple clients at the same time while a client is in contact with only one server. Both the client and server usually communicate via a computer network but sometimes they may reside in the same system.An illustration of the client server system is given as follows −Characteristics of Client Server ComputingThe salient points for client server computing are as follows:The client server computing works with a system of request and response. The client sends a request to the server and the ... Read More

What is a Modem? Different Types of Modem Explained

Bhanu Priya
Updated on 07-Nov-2023 12:43:58

40K+ Views

Modem stands for Modulator and Demodulator. It is a device that modulates signals to encode digital information for transmission and demodulates signals to decode the transmitted information.A modem transmits data in bits per second (bps).It is necessary for communication between digital devices and Analog devices.Modem is necessary because it acts as a translator between the devices and rapidly transmits the information.It converts the digital signal to Analog and vice versa to communicate between devices.It encodes the signal and decodes at the other end and vice versa between the devices.Building blocks of modem are shown in the diagram below −Types of ... Read More

Print Binary Equivalent of an Integer Using Recursion in Java

Way2Class
Updated on 07-Nov-2023 10:28:11

536 Views

Recursion, a potent programming technique, entails the resolution of a problem by decomposing it into smaller, more manageable sub problems and applying the same algorithm to solve them. In the realm of Java programming, recursion proves to be an invaluable tool when it comes to printing the binary representation of an integer. The binary equivalent, expressed in a base-2 numeral system that employs only two digits, 0 and 1, poses a common challenge in the field. In this article, we shall embark to unravel the intricacies of printing the binary equivalent of an integer using recursion in Java. Our ... Read More

Advertisements