
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 1339 Articles for C

167 Views
Here we will see one interesting problem, where we will add greater values to every node in one given binary search tree. So the initial and final tree will be look like below −AlgorithmbstUpdate(root, sum) −Begin if root is null, then stop bstUpdate(right of room, sum) sum := sum + value of root update root value using sum bstUpdate(left of room, sum) EndExample#include using namespace std; class Node { public: int data; Node *left, *right; }; Node *getNode(int item) { Node *newNode = ... Read More

4K+ Views
Here we will see different types of polymorphism. The types are −Ad-HocInclusionParametricCoercionThe Ad-Hoc polymorphism is called as overloading. This allows function with same name to act in different manner for different types. The function and the operator both can be overloaded. Some language does not support operator overloading, but function overloading is common.Example#include using namespace std; int add(int a, int b) { return a + b; } string add(string a, string b) { return a + b; //concatenate } int main() { cout

687 Views
Here we will see one C puzzle question. Suppose we have two numbers 48 and 96. We have to add the first number after the second one. So final result will be like 9648. But we cannot use any logical, arithmetic, string related operations, also cannot use any pre-defined functions. So how can we do that?This is easy. We can do by using Token Pasting operator(##) in C. The Token Pasting operator is a preprocessor operator. It sends commands to compiler to add or concatenate two tokens into one string. We use this operator at the macro definition.Example#include #define MERGE(x, ... Read More

2K+ Views
Here we will see the quicksort technique but we will use three-way quicksort. The basic quicksort technique is just finding an element as pivot then partition the array around pivot, after that, recur for sub arrays on left and right of the pivot.The three-way quicksort is similar, but there are three sections. array arr[1 to n] is divided into three parts.arr[1 to i]arr[i + 1, j]arr[j + 1, n]Algorithmpartition(arr, left, right, i, j) −begin if right – left

227 Views
Here we will see one space optimized approach for LCS problem. The LCS is the longest common subsequence. If two strings are “BHHUBC” and “HYUYBZC”, then the length of the subsequence is 4. One dynamic programming approach is already their, but using the dynamic programming approach, it will take more space. We need table of order m x n, where m is the number of characters in first string, and n is the number of characters in the second string.Here we will see how to implement this algorithm using O(n) amount of auxiliary space. If we observe the old approach ... Read More

305 Views
Suppose we have one graph like below. That graph is Peterson graph. The vertices are numbered from 0 through 9. Each vertex has some letters. Let consider one walk W, in that graph, where L vertices are used. A string S with L letters is realized by the walk W when the letter sequence in W and S are same. We can visit the vertices multiple times.For example, one string S is like “ABBECCD”, this is realized by the walk (0, 1, 6, 9, 7, 2, 3). Our task is to find such walk, and if that walk is present, ... Read More

392 Views
Suppose we have one integer variable whose size is 4 byte, another pointer variable is there, whose size is 8 bytes. So what will be the output of the following?Example#include using namespace std; main() { int a[4][5][6]; int x = 0; int* a1 = &x; int** a2 = &a1; int*** a3 = &a2; cout

159 Views
Here we will see the Osiris number. An Osiris number is such kind of number that are equal to the sum of permutations of sub-samples of their own digits. Suppose the number is 132. Then if we calculate {12 + 21 + 13 + 31 + 23 + 32} this is also 132. So the number is Osiris number. We have to check whether the given number is Osiris number or not.Approach is simple. If we analyze the numbers, each digit is occurring twice so they are in ones position and tens position. So we can check by multiplying 11 ... Read More

267 Views
For this problem, to add elements of two given arrays we have some constraints based on which the added value will get changed. the sum of two given arrays a[] & b[] is stored into to third array c[]in such a way that they gave the some of the elements in single digit. and if the number of digits of the sum is greater than 1, then the element of the third array will split into two single-digit elements. For example, if the sum occurs to be 27, the third array with store it as 2, 7.Input: a[] = {1, ... Read More

259 Views
A BST or binary search tree is a form of binary tree that has all left nodes smaller and all right nodes greater than the root value. For this problem, we will take a binary tree and add all the values greater than the current node to it. the problem “ add all greater values to every node in BST” is simplified as for a BST add all the node values that are greater than the current node value to that node value.Add all greater values to each node in the BST Problem Statement:Given a Binary Search Tree (BST), we ... Read More