Category Archives: Algorithms

Person left at the end

Given the value of N which represents the number of people standing in the queue, Each person has an id equivalent to their position. Now from this queue, the people who are at even locations are removed and made a separate queue. This process continues till 1 person left. The task is to determine the id of the… Read More »

Nth number whose sum of digits is 10

Given, write a program that prints the Nth number whose sum of digits is 10. Examples: Input : 2 Output : 28 Explanation : the first number is 19, whose digit sum is 10. Input : 5 Output : 55 Explanation : the first four numbers whose digit sum is 10 are 19,28,37,46. Approach: In order to obtain… Read More »

Snake and Ladder Pattern Formation

Design the pattern as represented in the famous snake and ladders game. Your task is to print the pattern as represented in snake and ladders game for a given integer input N, where N denotes the number of rows and columns of the pattern array. Note: N given will be always even. Examples: Input: N=4 Output: 7 8… Read More »

Why to Learn Data Structure and Algorithms ?

Programming is all about data structures and algorithms. Data structures are used to hold data while algorithms are used to solve the problem using that data. Data structures and algorithms (DSA) goes through solutions to standard problems in detail and gives you an insight into how efficient it is to use each one of them. It also teaches… Read More »

Linear Search

In this tutorial, you will learn about linear search. Linear search is a very simple and basic search algorithm. It is basically a sequential search algorithm. We have to write a C Program which finds the position of an element in an array using Linear Search Algorithm. Examples : Input : arr[] = {40, 60, 10, 20, 50,… Read More »

Choosing a Sorting Algorithm in Practice

There are many fundamental and advanced sorting algorithms. All sorting algorithms are problem-specific, which means they work well on some specific problem but do not work well for all the problems. All sorting algorithms apply to specific kinds of problems. Some sorting algorithms apply to a small number of elements, some are suitable for floating point numbers, some… Read More »