Category Archives: 1.17-Algorithms

A+B Problem

Problem Calculate the result of a + b Input: a and b Output: result of addition of a and b i.e. a+b Solution using System; namespace ProblemSolving { class Program { static void Main(string[] args) { Console.WriteLine(“Enter Your Inpur”); string[] input = Console.ReadLine().Split(‘ ‘); Console.WriteLine(“The result is: ” + (int.Parse(input[0]) + int.Parse(input[1]))); Console.ReadKey(); } }… Read More »

Selection Sort

->. Selection sort is a sorting algorithm uses to sorting an array. ->. During sorting it =>. Repeatedly find the minimum element from unsorted part and put it at the beginning. ->. To do that this algorithm maintain two sub-arrays for a given array =>. One is for store those elements that’s already sorted =>.… Read More »

Binary Search

->. We have a sorted array arr[ ] of n elements ->. We have to write a function to search a the element “x” from arr[ ]. First approach ->. First of all we will use a simple approach for search “x” from arr[ ] ->. So we will use linear search. =>. This will… Read More »

Performance Comparison between different basic Data Structures

->. We already know the term algorithm complexity ->. Now we’ll compare the performance between different basic data structures =>. To do that we’ll measure the complexity of different operations e.g. addition, searching, deletion and access by index and easily judge when to use a particular data structure. ->. The complexities of the operations of… Read More »

Determining the complexity of an algorithm

->. Complexity is a rough approximation of the number of steps necessary to execute an algorithm. ->. When we evaluate complexity we speak of order of operation count, not of their exact count. =>. For example if we have an order of N^2 operations to process N elements, then N^2/2 and 3*N^2 are in same… Read More »

Asymptotic Notations

->. We can measure the efficiency of algorithms using asymptotic analysis. ->. In that case =>. The algorithms doesn’t depends on machine specific constants =>. Also the algorithms don’t need to implement and compare in order to find out the execution time. ->. We will measure the efficiency of an algorithm based on Asymptotic Notations.… Read More »

Worst Case, Average Case, Best Case Analysis of Algorithms

->.To understand how good or bad an algorithm is, we must know how it works in all instances. ->.To understand the notions of the best, worst, and average-case complexity consider following Linear Search example: int Search(int[] arr, int n, int x) { for (int i = 0; i < n; i++) { if (arr[i] ==… Read More »

Asymptotic Analysis

What is Asymptotic Analysis? ->. Asymptotic Analysis is the idea for analyzing algorithms. ->. By Asymptotic Analysis we can =>. Evaluate the performance of an algorithm based on input size i.e. measure of the amount of time required by an algorithm and space i.e. amount of memory required by an algorithm to run for a given input that’s size is… Read More »