Sunidhi Bansal has Published 1078 Articles

Priority queue of pairs in C++ (Ordered by first)

Sunidhi Bansal

Sunidhi Bansal

Updated on 23-Dec-2019 11:40:06

3K+ Views

Priority queue is an abstract data type for storing a collection of prioritized elements that supports insertion and deletion of an element based upon their priorities, that is, the element with first priority can be removed at any time. The priority queue doesn’t stores elements in linear fashion with respect ... Read More

Problem with scanf() when there is fgets()/gets()/scanf() after it in C

Sunidhi Bansal

Sunidhi Bansal

Updated on 23-Dec-2019 11:37:34

583 Views

The problem states that what will be the working or the output if the scanf is followed by fgets()/gets()/scanf().fgets()/gets() followed by scanf()Example Live Demo#include int main() {    int x;    char str[100];    scanf("%d", &x);    fgets(str, 100, stdin);    printf("x = %d, str = %s", x, str);    return ... Read More

C Program for Muller Method

Sunidhi Bansal

Sunidhi Bansal

Updated on 23-Dec-2019 11:33:33

1K+ Views

We are given with a function f(x) on a floating number x and we can have three initial guesses for the root of the function. The task is to find the root of the function where f(x) can be any algebraic or transcendental function.What is Muller Method?Muller method was first ... Read More

Process Synchronization in C/C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 23-Dec-2019 11:33:09

7K+ Views

Process synchronization is the technique to overcome the problem of concurrent access to shared data which can result in data inconsistency. A cooperating process is the one which can affect or be affected by other process which will lead to inconsistency in processes data therefore Process synchronization is required for ... Read More

Program for power of a complex number in O(log n) in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 23-Dec-2019 11:18:15

1K+ Views

Given a complex number in the form of x+yi and an integer n; the task is calculate and print the value of the complex number if we power the complex number by n.What is a complex number?A complex number is number which can be written in the form of a ... Read More

Printing Items in 0/1 Knapsack in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 23-Dec-2019 11:12:36

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 ... Read More

Program for K Most Recently Used (MRU) Apps in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 23-Dec-2019 11:12:31

1K+ Views

Given a number k and an array arr[n], containing n number of integer elements which are storing the id’s of the opened apps in a system; the task is to show k number of most recently used apps, like when we press alt+tab shows all the recent apps and most ... Read More

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

Sunidhi Bansal

Sunidhi Bansal

Updated on 23-Dec-2019 11:04:17

191 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 ... Read More

Printing source of a C program itself

Sunidhi Bansal

Sunidhi Bansal

Updated on 23-Dec-2019 11:01:17

678 Views

Given the task is to print the written C program itself.We have to write a C program which will print itself. So, we can use file system in C to print the contents of the file of which we are writing the code, like we are writing the code in ... Read More

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

Sunidhi Bansal

Sunidhi Bansal

Updated on 23-Dec-2019 10:56:18

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 ... Read More

Advertisements