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
Server Side Programming Articles - Page 1951 of 2650
398 Views
Program DescriptionA sine wave or sinusoid is a mathematical curve that describes a smooth periodic oscillation. A sine wave is a continuous wave. It is named after the function sine, of which it is the graph. It occurs often in pure and applied mathematics, as well as physics, engineering, signal processing and many other fields.Print the Mirror Image of Sine-Wave Pattern based on the Wave Height and Wave LengthAlgorithmAccept the Wave Height and Wave LengthPrint the Wave Sign for the Wave Height and the Wave Length.Example/* Program to print the mirror image of Sine Wave*/ #include int main(){ int wave_height; int wave_length; int i, j, k; clrscr(); /*Clears the ... Read More
688 Views
Program DescriptionPrint the elements of the squared matrix in Z formA square matrix is a matrix with the same number of rows and columns. An n-by-n matrix is known as a square matrix of order AlgorithmTo print the elements of the Square Matrix in Z form We need to print the first row of matrix then diagonal and then last row of the square matrix.Example/* Program to print a square matrix in Z form */ #include int main(){ int rows, cols, r, c, matrix[10][10]; clrscr(); /*Clears the Screen*/ printf("Please enter the number of rows for the Square matrix: ... Read More
13K+ Views
Program DescriptionWrite a program to print lower triangular matrix and upper triangular matrix of an Array.Triangular MatrixA Triangular matrix is one that is either lower triangular or upper triangular.Lower Triangular MatrixA square matrix is called lower triangular if all the entries above the main diagonal are zero.Upper Triangular MatrixA square matrix is called upper triangular if all the entries below the main diagonal are zero.A matrix of the form$${\displaystyle L={\begin{bmatrix}\ell _{1, 1}&&&&0\\ell _{2, 1}&\ell _{2, 2}&&&\\ell _{3, 1}&\ell _{3, 2}&\ddots &&\\vdots &\vdots &\ddots &\ddots &\\ell _{n, 1}&\ell _{n, 2}&\ldots &\ell _{n, n-1}&\ell _{n, n}\end{bmatrix}}}$$is called a lower triangular matrix or left triangular matrix, and analogously a matrix of the form$${\displaystyle U={\begin{bmatrix}u_{1, 1}&u_{1, 2}&u_{1, ... Read More
6K+ Views
Pascal’s triangle is an array of binomial coefficients. The top row is numbered as n=0, and in each row are numbered from the left beginning with k = 0. Each number is found by adding two numbers which are residing in the previous row and exactly top of the current cell. It is also being formed by finding (𝑛𝑘) for row number n and column number k.Suppose the input is 10, then the output will be like − 1 1 1 ... Read More
712 Views
Suppose we have one tree and a sum. We have to find one path such that if we follow that path, we will get the sum that will be matched with the given sum. Suppose the tree is like [0, -3, 9, -10, null, 5] and the sum is 14, then there is a path 0 → 9 → 5To solve this, we will follow these steps.If the root is null, then return Falseif left and right subtree are empty, then return true when sum – root.val = 0, otherwise falsereturn solve(root.left, sum – root.val) or solve(root.right, sum – root.val)Let ... Read More
2K+ Views
Suppose we have one sorted array A. We have to generate one height-balanced binary search. In this problem, a height-balanced binary tree is actually a binary tree in which the depth of the two subtrees of every node never differs by more than 1. Suppose the array is like [-10, -3, 0, 5, 9]. So one possible output will be like: [0, -3, 9, -10, null, 5]To solve this, we will follow these steps.If A is empty, then return Nullfind the mid element, and make it rootDivide the array into two sub-arrays, left part of the mid element, and right ... Read More
2K+ Views
Suppose we have one binary tree. We have to find the maximum depth of that tree. The maximum depth of a tree is the maximum number of nodes that are traversed to reach the leaf from the root using the longest path. Suppose the tree is like below. The depth will be 3 here.To solve this, we will follow these steps.Here we will use the recursive approach. The method is solve(root, depth = 0)if the root is empty, then return depthotherwise return max of solve(left, depth + 1) and solve(left, depth + 1)Let us see the following implementation to get ... Read More
731 Views
Suppose we have one binary tree. We have to check whether the tree is a symmetric tree or not. A tree will be said to be symmetric if it is the same when we take the mirror image of it. From these two trees, the first one is symmetric, but the second one is not.To solve this, we will follow these steps.We will call following steps recursively. The function will be solve(root, root)if the node1 and node2 are empty, then return trueif either node1 or node2 is empty, then return falsereturn true when node1.val = node2.val and solve(node1.left, node2.right) and ... Read More
2K+ Views
Suppose we have two sorted arrays A and B. We have to merge them and form only one sorted array C. The size of lists may different.For an example, suppose A = [1, 2, 4, 7] and B = [1, 3, 4, 5, 6, 8], then merged list C will be [1, 1, 2, 3, 4, 4, 5, 6, 7, 8]To solve this, follow these steps −define i := 0, j := 0 and end := length of A – 1while end >= 0 and not A[end], end := end – 1while j < length of Bif i > end ... Read More
754 Views
There are n stairs. One person will go to 1st to nth stairs. Maximum how many stairs he/she can cross in one step is also given. With this information, we have to find possible ways to go to the nth stairs. Let us consider one can cross a maximum two stairs in each step. So we can find recursive relations to solve this problem. One can move to nth stair, either from (n-1)th stair or from (n-2)th stair. So ways(n) = ways(n-1) + ways(n-2).Suppose the number of stairs, say 10, the maximum number of stairs that can be jumped in ... Read More