
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 33676 Articles for Programming

183 Views
Suppose we have one size variable N, we also have one variable SUM this is the total sum of all elements available in the array and another variable K such that there is no element in array is greater than K, We have to find one orthogonal array where all elements in the array are distinct. If there is no solution return -1.So, if the input is like N = 4, SUM = 16 K = 9, then the output will be [1, 2, 4, 9]To solve this, we will follow these steps −minimum_sum := (N *(N + 1)) / ... Read More

650 Views
Here we will see how we can construct a pandas dataframe using string type data. Pandas supports csv files, but we can do the same using string also. For string type data, we have to use one wrapper, that helps to simulate as the data is taken as csv reader.Here we are using a string that takes data and separated by semicolon.ExampleLet us see the following implementation to get better understanding −import pandas as pd from io import StringIO str_data = StringIO("""Id;Subject;Course_Fee 10;DBMS;3000 11;Basic Maths;2000 12;Data Science;40000 13;Algorithm;5000 """) df = pd.read_csv(str_data, sep =";") print(df)OutputId ... Read More

258 Views
Suppose we have one postorder traversal of a binary search tree; we have to find the binary search tree from it.So, if the input is like [6, 12, 10, 55, 45, 15], then the output willTo solve this, we will follow these steps −Define a function solve() . This will take postordern := size of postorderroot := make a new tree node with last element of postorderstk := a stackinsert root into stki := n - 2while i >= 0, dox := make a new node with value postorder[i]while stk is not empty and postorder[i] < value of top of ... Read More

655 Views
Suppose we have the inorder and postorder traversal sequence of a binary tree. We have to generate the tree from these sequences. So if the postorder and inorder sequences are [9, 15, 7, 20, 3] and [9, 3, 15, 20, 7], then the tree will be −Let us see the steps −Define a method build_tree(), this will take inorder, postorder −If inorder list is not empty −root := make a tree node with the last value of postorder, then delete that elementind := index of root data in inorder listright of root := build_tree(inorder from index ind to end, postorder)left ... Read More

294 Views
Suppose we have the postorder traversal sequence of a binary search tree. We have to generate the tree from these sequences. So, if the postorder sequences is [9, 15, 7, 20, 3], then the tree will be −To form a tree we need inorder traversal also, but for binary search tree, the inorder traversal will be in the sorted form.Let us see the steps −Inorder = sorted list of postorder traversal.Define a method build_tree(), this will take inorder, postorder −If inorder list is not empty −root := make a tree node with the last value of postorder, then delete that ... Read More

370 Views
Here we will see the concept of the user-defined literals in C++. From C++ version 11, the User Defined Literals (UDL) are added in C++. C++ also provides literals for a variety of built-in types but these are limited.Built-in Literals −31 (Integer)3.5 (Double)4.2F (Float)'p' (Character)31ULL (Unsigned Long Long)0xD0 (Unsigned Hexadecimal Integer)"pq" (String)Apart from the built-in literals, sometimes we need user defined literals. There are few reasons behind that. Let us see with few examples −Suppose we want to define one weight variable, but we cannot specify the units, like if we define as follows −long double Weight = 3.5;We have ... Read More

319 Views
In this section we will see when we declare a variable that is un-initialized, then which value they hold in C or C++ language.What Happens When You Don’t Initialize Variables? In C and C++, when a variable is declared inside a function (i.e., as a local variable) but not explicitly initialized, it holds an undefined or garbage value. This means the variable may contain any value that is present at that memory location.Unlike some high-level languages where variables are automatically initialized (e.g., 0 for integers, false for booleans), C and C++ do not initialize local variables by default. So, assuming ... Read More

1K+ Views
Here we will discuss about the uniform initialization in C++. This is supported from C++11 version. The uniform initialization is a feature that permits the usage of a consistent syntax to initialize variables and objects which are ranging from primitive type to aggregates. In other words, it introduces brace-initialization that applies braces ({}) to enclose initializer values.Syntaxtype var_name{argument_1, argument_2, .... argument_n}Initialize Dynamically allocated arraysExample (C++)Let us see the following implementation to get better understanding − Live Demo#include using namespace std; int main() { int* pointer = new int[5]{ 10, 20, 30, 40, 50 }; cout

2K+ Views
Here we will see the map container and its use in C++. The maps are defined as associative containers that store elements in a hash-mapped fashion. Each element is associated with a key and value. No two mapped values can have identical keys. These are some fundamental methods that are present inside the map container in C++.begin(): This returns an iterator to the first element in the map.end()− This returns an iterator to the theoretical element that follows last element in the map.size() − This returns the number of elements in the map.max_size() − This returns the maximum number of ... Read More

2K+ Views
In this section we will see the heap data structure present in C++ STL. This permits faster input into heap and retrieval of a number always results in the largest number i.e. largest number of the remaining numbers is popped out each time. Other elements of the heap are arranged which depends on the implementation. The heap operations are as follows −make_heap() − This converts a range in a container to a heap.front() − This returns first element of heap which is the largest number.ExampleLet us see the following implementation to get better understanding − Live Demo#include using namespace std; int ... Read More