Sunidhi Bansal

Sunidhi Bansal

809 Articles Published

Articles by Sunidhi Bansal

Page 50 of 81

Product of lengths of all cycles in an undirected graph in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 270 Views

We are given with the undirected as well as unweighted graph as an input and the task is to find the product of the cycles that are formed in the given and display the result.ExampleInputIn the given figure, there are 8 nodes and out of that 5 nodes are forming cycle including 1, 6, 3, 5, 8 and rest of the node are not included in the cycle. So, the length of the cycle is 5 as it includes 5 node therefore product is 5In the given figure, there are 12 nodes and out of that 11(5 +6) nodes are ...

Read More

C Program for Round Robin scheduling

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 9K+ Views

We are given with the n processes with their corresponding burst time and time quantum and the task is to find the average waiting time and average turnaround time and display the result.What is Round Robin Scheduling?Round robin is a CPU scheduling algorithm that is designed especially for time sharing systems. It is more like a FCFS scheduling algorithm with one change that in Round Robin processes are bounded with a quantum time size. A small unit of time is known as Time Quantum or Time Slice. Time quantum can range from 10 to 100 milliseconds. CPU treat ready queue ...

Read More

Product of all Subsequences of size K except the minimum and maximum Elements in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 245 Views

Given an array arr[n], containing n number of integers and an integer k for defining the size; the task is to print the product of all the subsequences of size k except the minimum and maximum elements.Let us assume we have a set of 4 elements {1, 2, 3, 4} and k as 2 so its subsets will be − {1, 2}, {2, 3}, {3, 4}, {1, 4}, {1, 3}, {2, 4}So excluding the maximum element 4, and minimum element 1, the remaining elements will be −2, 3, 3, 3, 2, product of which will be −2 * 3 * ...

Read More

Copysign() function in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 155 Views

Given the task is to show the working of copysign() in C++.The copysign() function is a part of the C++ standard template library. It takes two arguments and produces the result by combining the magnitude of the first value and the sign of the second value. or header file should be included to call this function.SyntaxThe syntax is as follows −copysign(x, y)ExampleInput: copysign(4, -5) Output: -4Explanation − The following example demonstrates how we can copy the sign of one value to the magnitude of another value. The sign of the second argument, that is “-“and the magnitude of the ...

Read More

iswlower() function in C++ STL

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 179 Views

In C++ standard template library(STL), iswlower() function is used to check if the given wide character is in lowercase or not, if not then the function will return a zero value. The characters with ASCII value from 97 to 122 i.e. a-z are the lowercase alphabetic letters. Iswlower() function is present in cctype header file in C/C++.Syntax of iswlower () is as followsint iswlower (wint_t c)Parameters − c is a wide character to be checked, casted to a wint_t, or WEOF where wint_t is an integral type.Return Value − islower() function return non-zero value when the string is in lowercase ...

Read More

const_cast in C++ - Type casting operators

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 2K+ Views

Given the task is to show the working of const_cast in c++. const_cast is one of the type casting operators. It is used to change the constant value of any object or we can say it is used to remove the constant nature of any object. const_cast can be used in programs that have any object with some constant value which need to be changed occasionally at some point. Syntax The syntax is as follows − const_cast(expression) Example Input: const int x = 50; const int* y = &x; cout

Read More

Probability of getting at least K heads in N tosses of Coins in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 606 Views

Probability is the chances of getting the desired output from the set of data available. The range of probability lie between 0 and 1 where an integer 0 shows the chances of impossibility and 1 indicates certainty.What is probability?Probability in mathematics gives us the tools that tell the uncertainty of the events and reasons. In other words we can say probability deals with calculating the likelihood of a given event’s occurrence, which can be expressed as a number between 1 and 0. For example: the probability of getting a head’s when an unbiased coin is tossed, or getting a 3 ...

Read More

Program to build DFA that starts and end with ‘a’ from input (a, b) in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 1K+ Views

Given a DFA string of characters ‘a’ and ‘b’, which should start and end with the character ‘a’ the task is to find whether the string starts and ends with ‘a’ through a DFA.What is DFA(Deterministic Finite Automata)?In theory of computation, a branch of theoretical computer science, Deterministic Finite Automata is a finite state machine which accepts or reject strings of symbols. Deterministic refers to the uniqueness of the computation to run.For finding the string by a DFA and the string should start and end with ‘a’ from the input (a, b). Since there is no concept of memory and ...

Read More

Product of every K’th prime number in an array in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 213 Views

Given an array arr[n] containing n prime numbers and k; the task is to find the product of every k’th prime number in an array.Like, we have an array arr[] = {3, 5, 7, 11} and k = 2 so the prime number after every k i.e 5 and 11 we have to find their product which will be 5x11 = 55 and print the result as output.What are prime numbers?A prime number is a natural number which can’t be divided by any other number except 1 or the number itself. Some of the prime numbers are 2, 3, 5, ...

Read More

Printing Items in 0/1 Knapsack in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 1K+ Views

Given weights and values of n items; the task is to print the items according to 0/1 knapsack for the following weights and values in a knapsack of capacity W, to get the maximum total value in the knapsack.What is 0/1 Knapsack?Knapsack is like a bag with only a fixed size or a bag which can handle a certain amount of weight. Each item which is included in a knapsack have some value(profit) and some weight to it. We have to add those weights which will get us the maximum profit according to the total weight a knapsack could hold.So ...

Read More
Showing 491–500 of 809 articles
« Prev 1 48 49 50 51 52 81 Next »
Advertisements