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 1651 of 2646
3K+ Views
Given coordinates of three points in 2D plane, and the task is to check whether the points are collinear or not. For Example, // Input: Coordinates of three points points = {{2, 3}, {4, 6}, {6, 9}}; // Output The points are collinear. What are Collinear Points? Points are said to be collinear if they lie on the same line and they are not collinear if they are on the different lines. Given below is the figure of collinear and non-collinear points. Checking Collinearity with Area of Triangle To form a triangle, we ... Read More
1K+ Views
Given with a number ‘n’ and the task is to determine whether the given positive integer is a buzz number or not and display the result as an output.What is Buzz Number?For being a buzz number there are two conditions either of which must be true −Number should end with digit 7 e.g. 27, 657, etc.Number should be divisible by 7 e.g 63, 49, etc.Inputnumber: 49Outputit’s a buzz numberExplanation − since the number is divisible by 7 so it’s a buzz numberInputnumber: 29Outputit’s not a buzz numberExplanation − since the number is neither divisible by 7 nor end with digit ... Read More
900 Views
Given with a number ‘n’ and the task is to determine whether the given positive integer is a proth or not and display the result as an output.What is Proth Number?A proth number is given by$$N=k\cdot\:2^{n}+1$$Where, n is a positive integer and k is a odd positive integerThe first few proth numbers are given below −3, 5, 9, 13, 17, 25, 33, 41, 49, 57, 65, 81, 97.......Inputnumber: 17Outputits a proth numberInputnumber: 18Outputits not a proth numberApproach used in the given program is as followsInput the number to check for the conditionApply the given formula to check whether its a ... Read More
503 Views
Given an array arr[N] of N integers, the task is to check whether the given array is bitonic or not. If the given array is bitonic then print “Yes its a bitonic array”, else print “No its not a bitonic array”.A Bitonic array is when the array is in strictly increasing order first and then in strictly decreasing order.Like this array arr[] = {1, 2, 3, 4, 2, -1, -5} is a bitonic array, because till 4 it is in strictly increasing order and after 4 it is in strictly decreasing order.Input arr[] = {1, 3, 5, 4, 2, 0}Output Yes its ... Read More
2K+ Views
Given an array of N integers arr[N], the task is to find the average of arr[N]. To achieve the result we can either use iterative approach or the recursive approach. We will be showing both in the given solution.Average of an array will be sum of all the elements of an array divided by the number of elements.Iterative methodIn iterative approach, we use loops like for-loop, while-loop or do-while loop which executes the statements till the condition holds true which means 1.Let’s take an example and then discuss how it can be obtained using iterative approach.Input arr[] = {1, 2, 4, ... Read More
12K+ Views
In this problem, we are given two binary strings, and we need to find their sum and return the result as a binary string. A binary string is a string that contains only the characters '0' and '1', where 0 and 1 are binary numbers. While adding two binary numbers, we follow the binary addition rules given below - 1 + 0 = 1 0 + 1 = 1 0 + 0 = 0 1 + 1 = 0 with a carry of 1 ... Read More
337 Views
Given with n nodes and the task is to print the product of all the prime nodes in a linked list. Prime nodes are the ones that will have prime values as their count locations.Input 10 20 30 40 50Output 4, 00, 000Explanation − 10 is at index value 1 which is non-prime so it will be skipped. Moving to 20 with index value 2 which is a prime number so it will be considered. Similarly, 40 and 50 are at prime index locations.Product − 20*40*50 = 4, 00, 000In the above diagram, red coloured nodes represents the prime nodesApproach used below ... Read More
290 Views
Given with a binary tree containing nodes and the task is to find the product of all the nodes of a given binary tree.In a binary tree, there is a root node which is the master node of all the nodes in a tree. A node contains data part, left pointer which will further create left subdirectory and a right pointer which will help in creating right subdirectory. So to traverse the tree, we can take a temporary pointer that will associate with left pointer to traverse left subdirectory or right pointer to traverse the right sub directory.Input Output Nodes are-: 10, ... Read More
538 Views
Given with a binary tree containing nodes and the task is to find the product of all the leaf nodes of a given binary tree.Leaf nodes are the end nodes which don’t have any children. In a tree, a node can act as a parent node or child node except the root node which can only be a parent node. So the nodes with right and left pointer as NULL are the leaf nodes.Input Output Leaf nodes are -: 23, 34, 25 Product-: 23*34*25 = 19550ApproachInput the node dataTraverse all the nodes starting from the root node and going to either left ... Read More
165 Views
Given with the tree of nodes with data in a string format and the task is to find the product of the nodes at k-th level in a binary tree. Every node of a tree contains three things i.e. data part, left pointer for left subtree and right pointer for right subtree.Level of binary tree starts from number 0 and it can go till ‘n’ which can be any positive number. So, we are given with the level ‘k’ and program must calculate the product of the nodes at given ‘k’ level.In the binary tree, if let’s say we are ... Read More