
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 26504 Articles for Server Side Programming

887 Views
Suppose we have a number n. We have to check whether the number is the power of 2 or not. So is n = 16, then the output will be true, if n = 12, it will be false.To solve this we will use logical operations. If we see the numbers that are the power of two then in the binary representation of that number will be the MSb is 1, and all other bits are 0. So if we perform [n AND (n – 1)], this will return 0 if n is the power of 2. If we see ... Read More

979 Views
Suppose we have a binary tree. our task is to create an inverted binary tree. So if the tree is like below −The inverted tree will be likeTo solve this, we will use a recursive approachif the root is null, then returnswap the left and right pointersrecursively solve left subtree and right subtreeExample (Python)Let us see the following implementation to get a better understanding − Live Democlass TreeNode: def __init__(self, data, left = None, right = None): self.data = data self.left = left self.right = right def make_tree(elements): Tree = ... Read More

524 Views
Suppose we have a linked list, we have to reverse it. So if the list is like 1 → 3 → 5 → 7, then the new reversed list will be 7 → 5 → 3 → 1To solve this, we will follow this approach −Define one procedure to perform list reversal in a recursive way as to solve(head, back)if the head is not present, then return headtemp := head.nexthead.next := backback = headif temp is empty, then return headhead = tempreturn solve(head, back)ExampleLet us see the following implementation to get a better understanding − Live Democlass ListNode: def __init__(self, ... Read More

924 Views
Program DescriptionPrint Square inside a Square as shown belowAlgorithmAccept the number of rows the outer Square to be drawn Display the Outer Square with the number of rows specified by the User. Display another square inside the outer square.Example/* Program to print Square inside Square */ #include int main() { int r, c, rows; clrscr(); printf("Enter the Number of rows to draw Square inside a Square: "); scanf("%d", &rows); printf(""); for (r = 1; r

846 Views
Program DescriptionIn geometry, a square is a regular quadrilateral, which means that it has four equal sides and four equal angles.Solid and Hollow Square will appear as shown belowAlgorithmFor Solid Square −Accept the Number of Rows from the user to draw the Solid Square For each Row, Print * for each Column to draw the Solid SquareFor Hollow Square −Accept the Number of Rows from the user to draw the Hollow Square For the First and Last Row, Print * for each Column For the Remaining Rows, Print * for the first and Last Column.Example/* Program to print hollow and ... Read More

1K+ Views
Suppose there is a city, and each house in the city has a certain amount. One robber wants to rob the money in one single night. The city has one security system, that is as if two consecutive houses are broken on the same night, then it will automatically call the police. So we have to find how the maximum amount the robber can rob?One array is provided, at index i, the A[i] is the amount that is present in i-th house. Suppose the array is like: A = [2, 7, 10, 3, 1], then the result will be 13. ... Read More

622 Views
Program DescriptionPrint the Solid and Hollow Rhombus Patterns as show belowAlgorithmFor Hollow Rhombus −Accept the Number of Rows for Hollow Rhombus from the User Create a Hollow Rhombus containing the same number of Rows specified by the User. Print the first row containing the number of stars same as the number of rows. Print the second row containing the first and last star as show in the output and leave the spaces between first and the last star. Do the same till you reach the last Row. Print the last row containing the number of stars same as the number ... Read More

717 Views
Suppose we have an array A. We have to rotate right it k steps. So if the array is A = [5, 7, 3, 6, 8, 1, 5, 4], and k = 3, then the output will be [1, 5, 4, 5, 7, 3, 6, 8]. The steps are like[4, 5, 7, 3, 6, 8, 1, 5][5, 4, 5, 7, 3, 6, 8, 1][1, 5, 4, 5, 7, 3, 6, 8]To solve this, we will follow these steps.let n is the size of the arrayk = k mod nA = subarray of A from n – k to end + ... Read More

665 Views
Program DescriptionPrint the Right and Left arrow PatternsAlgorithmAccept the number of rows to print the Left and Right Arrow Pattern.Print Upper Part of the Arrow with Stars Patterns Print Inverted Right Triangle with Stars Patterns Print Bottom Part of the Arrow with Stars Patterns Print the Right Triangle with Stars PatternsExample/*Program to print the Left and right arrow pattern*/ #include int main() { int r, c, rows; //Left Arrow Pattern int r1, c1, rows1; //Right Arrow Pattern clrscr(); printf("Enter number of rows to print the Left Arrow Pattern: "); scanf("%d", &rows); printf(""); printf("The ... Read More

267 Views
Here we will see how to calculate the number of trailing 0s for the result of factorial of any number. So if the n = 5, then 5! = 120. There is only one trailing 0. For 20! it will be 4 zeros as 20! = 2432902008176640000.The easiest approach is just calculating the factorial and count the 0s. But this approach fails for a large value of n. So we will follow another approach. The trailing zeros will be there if the prime factors are 2 and 5. If we count the 2s and 5s we can get the result. ... Read More