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
Programming Articles - Page 2370 of 3363
2K+ Views
Flip-Flops are sequential digital circuits. There are few different types of flip-flops. Here we will see the types of flip-flops and the conversion rules from one flip-flop to another.There are basically four types of flip-flops −SR Flip-FlopD Flip-FlopJK Flip-FlopT Flip-FlopSR Flip-flopSR flip-flop operates with only positive clock transitions or negative clock transitions. Whereas, SR latch operates with enable signal. The circuit diagram of SR flip-flop is shown in the following figure.This circuit has two inputs S & R and two outputs Q(t) & Q(t)’. The operation of SR flipflop is similar to SR Latch. But, this flip-flop affects the outputs ... Read More
280 Views
We have one circle (center coordinate and radius), we have to find the quadrant of another given point (x, y) lies with respect to the center of the circle, if this is present in the circle, print quadrant, otherwise print error as the point is present outside.Suppose the center of the circle is (h, k), the coordinate of the point is (x, y). We know that the equation of the circle is −(𝑥−ℎ)2+(𝑦−𝑘)2+𝑟2=0Now there are few conditions, based on which we can decide the result.𝑖𝑓 (𝑥−ℎ)2+(𝑦−𝑘)2> 𝑟, 𝑡ℎ𝑒𝑛 𝑡ℎ𝑒 𝑝𝑜𝑖𝑛𝑡 𝑖𝑠 𝑜𝑢𝑡𝑠𝑖𝑑𝑒 𝑡ℎ𝑒 𝑐𝑖𝑟𝑐𝑙𝑒𝑖𝑓 (𝑥−ℎ)2+(𝑦−𝑘)2= 0, 𝑡ℎ𝑒𝑛 𝑡ℎ𝑒 𝑝𝑜𝑖𝑛𝑡 𝑖𝑠 ... Read More
367 Views
Consider we have a set of points. We have to find a simple closed path covering all points. Suppose the points are like below, and the next image is making a closed path on those points.To get the path, we have to follow these steps −Find the bottom left point as PSort other n – 1 point based on the polar angle counterclockwise around P, if polar angle of two points are same, then put them as the distance is shortestTraverse the sorted list of points, then make the pathExample Live Demo#include using namespace std; class Point { public: ... Read More
532 Views
Here we will see how to get the minimum and maximum value from one singly circular linked linear list. The basic concept is very simple. The next part of the last node will be pointed to the first node, the first node will also be pointed using start pointer. When we insert some element into the list, after inserting the next part of the newly inserted node will be updated with the address of the start node.Initially the min is assigned with positive infinity, and max is assigned with negative infinity. Now traverse the list from left to right. If ... Read More
374 Views
Suppose we have a set of points. Our task is to find K points which are closest to the origin. Suppose the points are (3, 3), (5, -1) and (-2, 4). Then the closest two (K = 2) points are (3, 3), (-2, 4).To solve this problem, we will sort the list of points based on their Euclidean distance, after that take the top most K elements from the sorted list. Those are the K nearest points.Example Live Demo#include #include using namespace std; class Point{ private: int x, y; public: Point(int x = 0, int y = 0){ this->x = x; this->y = y; } void display(){ cout
1K+ Views
Suppose there are few friends. They have borrowed money from each other. So there will be some cash flow on the network. Our task is to minimize the cash flow in the network. Suppose there are three friends P1, P2, and P3. The cash flow among them is like below −This cash flow is not minimum; we have to minimize it. Then the final diagram will be like −To solve this problem we will use the greedy approach. Here in each step settle all amounts of one person and recur for remaining n-1 persons. Now the question comes, how to ... Read More
391 Views
Suppose, one parabola is given (the vertex coordinate (h, k) and distance from focus and vertex is a), another point is also given. We have to find whether the point is inside the parabola or not. To solve it, we have to solve the following equation for the given point (x, y)\left(y-k\right)^2=4a\left(x-h\right)If the result is less than 0, then this is present inside the parabola if it is 0, then it is on the parabola, and if greater than 0, then outside of the parabola.Example Live Demo#include #include using namespace std; int isInsideParabola(int h, int k, int x, int ... Read More
805 Views
Suppose, one ellipse is given (the center coordinate (h, k) and semi-major axis a, and semi-minor axis b), another point is also given. We have to find whether the point is inside the ellipse or not. To solve it, we have to solve the following equation for the given point (x, y).$$\frac{\left(x-h\right)^2}{a^2}+\frac{\left(y-k\right)^2}{b^2}\leq1$$If the result is less than one, then the point is inside the ellipse, otherwise not.Example Live Demo#include #include using namespace std; bool isInsideEllipse(int h, int k, int x, int y, int a, int b) { int res = (pow((x - h), 2) / pow(a, 2)) + ... Read More
245 Views
Here we will see a program, if one number is given, another value k is also given, we have to check whether the number is power of k or not. But we have to perform the base changing method to solve this problem. Suppose a number is 27, and k = 3. Then by base changing method, the 27 will be 10003. Here after changing the base if there is only one occurrence of digit 1, and others are 0, then the number is power of k.To solve this problem, we will follow these steps.Steps −define flag := falsewhile number > ... Read More
530 Views
In this section, we will see, if a number is the power of 8 or not using some easier method. If a number like 4096 is there, then the program will return true, as this is the power of 8.The trick is simple. we will calculate log8(num). If this is an integer, then n is the power of 8. Here we will use the tranc(n) function to find the closest integer of the double value.Example Live Demo#include #include using namespace std; bool isPowerOfEight(int n) { double val = log(n)/log(8); //get log n to the base 8 return ... Read More