Posts

Showing posts from February, 2018
ScaleFree

DS & A (Algorithm Analysis - Faster Computer OR Faster Algorithm)

Image
|  CHAPTER 6  | Till now we have been talking about various concepts in Data Structures & Algorithms but in this chapter, we will be focusing more on a question rather than some concept. So, let's get started. Since we are already familiar with the basics of algorithms and it's running time, I would like to ask you guys a question, what contributes more to reducing the running speed of a program?  A faster computer? Or a faster algorithm? Pick One: Faster Algorithm or Faster Computer Before you guys come to an answer, I would like to remind you guys that how fast a program runs depends on the running time of an algorithm and the machine it is running on as well. I know you guys will try to think out of the box and ask why not both? But in this chapter, we will be focusing more on picking the better choice out of the two given options.  Now, before picking our answer let us analyze both the available options. Suppose, there are two algorithms for a sin

DS & A (Algorithm Analysis - Best, Worst and Average Case)

Image
|  CHAPTER 5  | Note: If it's your first time visiting this website I strongly recommend you to read the previous chapter before reading this chapter. Till now we learned about what Data Structures and Algorithms are, some basic terminologies and a few  concepts  of Algorithm analysis.   And continuing our ongoing journey of Data Structures and Algorithms, today we will discuss the Best Case, Average Case and Worst Case of an algorithm. Algorithm Case Analysis In the last chapter, we learned that every algorithm has running time[T(n)] and a growth rate. But that's not the end of it, an algorithm's running time and growth rate are not the only factors that we should consider while designing an algorithm. For some algorithms, different inputs result in different running time. And that brings forth the necessity of the concept of Best, Average, and Worst Case of algorithms. Example Consider we have four boxes tagged 1,2,3 & 4, and the boxes con

DS & A (Algorithm Analysis - Asymptotic Analysis)

Image
|  CHAPTER 4  | In the field of Computer Science  Asymptotic Analysis  is the branch that deals with measuring algorithm efficiency. In Asymptotic Analysis, we estimate how the time required( or space required ) by an algorithm increases with the increase in problem size. Typically, we focus on the time required by an algorithm(or a program) but at times we need to consider the required space too. Time Complexity   Time Complexity is the quantification of the time taken by an algorithm or a program to execute as a function of the size of input/problem. It is generally denoted by  T(n),  where n is the size of the input/problem and  T is the time taken by the algorithm to run as a function of n.  i.e. Time complexity = T(n) = function(n)  Note: T(n) is always positive How to calculate the Time Complexity? In order to calculate the time complexity of an algorithm, at first, we need to determine the basic operations required by the algorithm to process an input/problem

Share on Social Media