
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

644 Views
We are given, an array of non-negative integers denoting the maximum number of steps that can be made forward from that element. The pointer is initially positioned at the first index [0 index] of the array. Your goal is to reach the last index of the array in the minimum number of steps. If it is not possible to reach the end of the array then print the maximum integer.naive approach is to begin from initial{the primary} component and recursively call for all the components accessible from the first element. The minimum range of jumps to reach the end from ... Read More

888 Views
Here, we will solve the minimum cost path problem in C. The implication is done on a 2D-matrix where each cell has a cost to travel. We have to find a path from the left top corner to the bottom right corner with minimum travel cost. You can only traverse down and right lower cells from a given cell.To solve this particular problem dynamic programming is much better to approach than recursion.Given cost matrix cost[ ][ ] and a position (m, n), we have to write a function that returns cost of minimum path to reach (m, n) from (0, ... Read More

234 Views
In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given pos form we need to convert it into its equivalent sop formThe conversion can be done by first counting the number of alphabets in the pos form and then calculating all the max and the minterms.Now let’s observe the concept in the implementation below−Example# Python code to convert standard POS form # to standard SOP form # to calculate number of variables def count_no_alphabets(POS): i = 0 no_var = 0 # total no. of alphabets before will be ... Read More

533 Views
In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given an interval we need to compute all the prime numbers in a given rangeHere we will be discussing a brute-force approach to get the solution i.e. the basic definition of a prime number. Prime numbers are the number which has 1 and itself as a factor and rests all the numbers are not its factors.Each time the condition of a prime number is evaluated to be true computation is performed.Now let’s observe the concept in the implementation below−Example Live Demostart = 1 ... Read More

732 Views
In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a list, we need to swap the last element with the first element.There are 4 approaches to solve the problem as discussed below−Approach 1 − The brute-force approachExample Live Demodef swapLast(List): size = len(List) # Swap operation temp = List[0] List[0] = List[size - 1] List[size - 1] = temp return List # Driver code List = ['t', 'u', 't', 'o', 'r', 'i', 'a', 'l'] print(swapLast(List))Output['t', 'u', 't', 'o', 'r', 'i', 'a', 'l']Approach 2 − The ... Read More

1K+ Views
In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a list, we need to insert an element in a list without changing sorted orderThere are two approaches as discussed below−Approach 1: The brute-force methodExample Live Demodef insert(list_, n): # search for i in range(len(list_)): if list_[i] > n: index = i break # Insertion list_ = list_[:i] + [n] + list_[i:] return list_ # Driver function list_ = ['t', 'u', 't', 'o', 'r'] n = ... Read More

913 Views
In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a set, we need to list all the subsets of size nWe have three approaches to solve the problem −Using itertools.combinations() methodExample Live Demo# itertools module import itertools def findsubsets(s, n): return list(itertools.combinations(s, n)) #main s = {1, 2, 3, 4, 5} n = 4 print(findsubsets(s, n))Output[(1, 2, 3, 4), (1, 2, 3, 5), (1, 2, 4, 5), (1, 3, 4, 5), (2, 3, 4, 5)]Using map() and combination() methodExample# itertools module from itertools import combinations def findsubsets(s, n): return ... Read More

2K+ Views
In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a number, we need to check that the number is a power of two or not.We can solve this using two approaches as discussed below.Approach 1: Taking the log of the given number on base 2 to get the powerExample Live Demo# power of 2 def find(n): if (n == 0): return False while (n != 1): if (n % 2 != 0): return False n = ... Read More

1K+ Views
In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a dictionary, and we need to print the 3 highest value in a dictionary.Three approaches to the problem statement are given below:Approach 1 − Calculating sum from the dictionary iterableExample Live Demo# sum function def Sum(myDict): sum_ = 0 for i in myDict: sum_ = sum_ + myDict[i] return sum_ # Driver Function dict = {'T': 1, 'U':2, 'T':3, 'O':4, 'R':5} print("Sum of dictionary values :", Sum(dict))OutputSum of dictionary values : 14Approach 2 − Calculating the ... Read More

3K+ Views
Priority queue is an abstract data type for storing a collection of prioritized elements that supports insertion and deletion of an element based upon their priorities, that is, the element with first priority can be removed at any time. The priority queue doesn’t stores elements in linear fashion with respect to their locations like in Stacks, Queues, List, etc. The priority queue ADT(abstract data type) stores elements based upon their priorities.Priority Queue supports the following functions −Size() − it is used to calculate the size of the priority queue as it returns the number of elements in it.Empty() − it return ... Read More