
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

192 Views
Let us first define our binary tree using a class containing int data, btree_node * rightChild, btree_node * leftChild. The leftChild and rightChild are pointers to btree_node. All the members in our class are public.class btree_node { public: int data; btree_node* leftChild; btree_node* rightChild;For creating a new node we have the constructor function that takes the int value as parameter to assign it to the newly created node value. The leftChild and rightChild are set to null.btree_node(int data){ this->data = data; this->leftChild = NULL; this-> = NULL; ... Read More

232 Views
Let us first define our linked list that contains data and the pointer to the next node.struct Node { int data; struct Node* next; };We then create our createList(Node ** headPtr, int new_data) function which takes a doublePointer to the Node and an int value. Inside the function we assign the newly created node next pointer to the headptr and then the headptr to the newly created node.void createList(Node ** headPtr, int new_data){ Node* newNode = new Node(); newNode->data = new_data; newNode->next = (*headPtr); (*headPtr) = newNode; }The deleteNnodesAfterM(Node *head, int M, int N) ... Read More

407 Views
Let us first define our linked list that contains data and the pointer to the next node.struct Node { int data; struct Node* next; };Next we create our createNode(int data) function that takes int data as parameter and returns the newly created node after assigning the parameter value. The next pointer to the node will be null.Node* createNode(int data){ struct Node* newNode = new Node; newNode->data = data; newNode->next = NULL; return newNode; }Now we have our deleteMiddle(struct Node* head) function which takes the root node. If the root node isn’t null then it ... Read More

142 Views
Let us first define the struct that would represent a tree node that contains the data and its left and right node child. If this is the first node to be created then it’s a root node otherwise a child node.struct Node { int data; struct Node *leftChild, *rightChild; };Next we create our newNode(int data) function that takes an int value and assign it to the data member of the node. The function returns the pointer to the created struct Node. Also, the left and right child of the newly created node are set to null.struct Node* newNode(int ... Read More

207 Views
Let us first define the struct that would represent a tree node that contains the data and its left and right node child. If this is the first node to be created then it’s a root node otherwise a child node.struct Node { int data; struct Node *leftChild, *rightChild; };Next we create our newNode(int data) function that takes an int value and assign it to the data member of the node. The function returns the pointer to the created struct Node. Also the left and right child of the newly created node are set to null.struct Node* newNode(int ... Read More

568 Views
Let us first define the original array and the exclusive range for deletion of the array elements and also find the original array length −int arr[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20}; int L = 2, R = 6; int length = sizeof(arr) / sizeof(arr[0]);Now we loop in the array and if index position (i) is greater than L or R we increment the variable k which will be used to shift positions(delete) of array element once the index value (i) lies between the range L and R. Also, the new length of the ... Read More

390 Views
Suppose we have two strings s and t of same size. We have to check whether s and t are equivalent or not. There are few conditions to check:They both are equal. Or, If we divide the s into two contiguous substrings of same size and the substrings are s1 and s2 and also divide t same like, s into t1 and t2, then one of the following should be valid:s1 is recursively equivalent to t1 and s2 is recursively equivalent to t2s1 is recursively equivalent to t2 and s2 is recursively equivalent to t1So, if the input is like ... Read More

422 Views
Suppose we have two strings s and t we have to check whether they are anagram of each other or not.So, if the input is like s = "bite" t = "biet", then the output will be True as s ad t are made of same characters.To solve this, we will follow these steps −if size of s is not same as size of t, thenreturn Falsesort characters of s and treturn true if s is exactly same as t, otherwise falseLet us see the following implementation to get better understanding −Example CodeLive Demodef solve(s, t): if len(s) != ... Read More