
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

347 Views
We are given with the sum and the number of times the pair of dice is thrown as an input and the task is to determine the probability of getting the given sum on throwing a pair of dice N times.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.ExampleInput-: sum = 12, N = 1 Output-: Probability = 1/36 Explanation-: if a pair of dice is thrown once then the combinations will ... Read More

732 Views
We are given with the data and the priority as an integer value and the task is to create a doubly linked list as per the priority given and display the result.Queue is a FIFO data structure in which the element which is inserted first is the first one to get removed. A Priority Queue is a type of queue in which elements can be inserted or deleted depending upon the priority. It can be implemented using queue, stack or linked list data structure. Priority queue is implemented by following these rules −Data or element with the highest priority will ... Read More

216 Views
Problem statementGiven a matrix A of integers of size NxN. The task is to find the minimum sum of a falling path through A.A falling path will start at any element in the first row and ends in last row.It chooses one element from each next row. The next row’s choice must be in a column that is different from the previous row’s column by at most onesExampleIf N = 2 and matrix is: { {5, 10}, {25, 15} } then output will be 20 as element 5 and 15 are selectedExample Live Demo#include #define MAX 2 using ... Read More

202 Views
Problem statementGiven a binary string, the task is to count the minimum steps to remove substring 010 from this binary stringExampleIf input string is 010010 then 2 steps are requiredConvert first 0 to 1. Now string becomes 110010Convert last 0 to 1. Now final string becomes 110011Algorithm1. Iterate the string from index 0 sto n-2 2. If in binary string has consecutive three characters ‘0’, ‘1’, ‘0’ then any one character can be changed Increase the loop counter by 2Example Live Demo#include using namespace std; int getMinSteps(string str) { int cnt = 0; for (int i = ... Read More

19K+ Views
Given process, the burst time of a process respectively and a quantum limit; the task is to find and print the waiting time, turnaround time and their respective average time using Shortest Job First Scheduling preemptive method.What is the shortest job first scheduling?Shortest job first scheduling is the job or process scheduling algorithm that follows the nonpreemptive scheduling discipline. In this, scheduler selects the process from the waiting queue with the least completion time and allocate the CPU to that job or process. Shortest Job First is more desirable than FIFO algorithm because SJF is more optimal as it reduces ... Read More

472 Views
Problem statementGiven an array of size n, the task iss to find the minimum number of steps required to make all the elements of the array divisible by 4. A step is defined as removal of any two elements from the array and adding the sum of these elements to the arrayExampleIf input array is {1, 2, 0, 2, 4, 3} then 3 operations are required −1 + 3 = 4 2 + 2 = 4 0 + 4 = 4Algorithm1. Sum of all the elements of the array should be divisible by If not, this task is not possible ... Read More

936 Views
Problem statementGiven a string containing characters as integers only. We need to delete all character of this string in a minimum number of steps where in one step we can delete the substring which is a palindrome. After deleting a substring remaining parts are concatenated.ExampleIf input string is 3441213 then minimum 2 steps requiredFirst remove 121 from string. Now remaining string is 3443Remove remaining string as it’s palindromeAlgorithmWe can use dynamic programming to solve this problem1. Let dp[i][j] denotes the number of steps it takes to delete the substring s[i, j] 2. Each character will be deleted alone or as ... Read More

310 Views
Problem statementGiven a string, we need to find the minimum number of rotations required to get the same stringExampleIf input string is “bbbbb” then minimum 1 rotation is requiredAlgorithm1. Initialize result = 0 2. Make a temporary string equals to original string concatenated with itself. 3. Take the substring of temporary string of size same as original string starting from second character i.e. index 1 4. Increment the counter 5. Check whether the substring becomes equal to original string. If yes, then break the loop. Else go to step 2 and repeat it from the next indexExample Live Demo#include using ... Read More

271 Views
In this article, we have an array arr[] of N integers. Our task is to write a program to find the minimum number of elements needed to be removed from the given array so that the sum of the remaining elements is odd. Example The following example demonstrates the minimum number of elements we need to remove from the array for the sum to be odd: Input: arr = {12, 23, 40, 53, 17} Output: 0 Input: arr = {20, 11, 13, 40, 24} Output: 1 The explanation of the above example is ... Read More

7K+ Views
Given process, the burst time of a process respectively and a quantum limit; the task is to find and print the waiting time, turnaround time and their respective average time using Shortest Job First Scheduling non-preemptive method.What is the shortest job first scheduling?Shortest job first scheduling is the job or process scheduling algorithm that follows the nonpreemptive scheduling discipline. In this, scheduler selects the process from the waiting queue with the least completion time and allocate the CPU to that job or process. Shortest Job First is more desirable than FIFO algorithm because SJF is more optimal as it reduces ... Read More