Skip to main content

Posts

Showing posts from July, 2021

Tutorial 05: General Rules to determine the Running Time

 1). Loop:-      for (int i=0; i<=n; i++)              ----------> n     {                                                      a = a+b;    //Constant           ------------->c      } c*n = c.n = O(n) 2). Nested Loop:-                           multiplication        for(int i=0; i<=n; i++)         ------ >    n       {                                                                            ...

Tutorial 04: Analysis of Time Complexity

Tutorial 04: Analysis of Time Complexity Running time depends many factor but we compute it based on input size. So, we need to calculate the rate of growth of time w.r.t input. Assumptions:- All arithmetic and logical operations taking 1 unit of time. All return statement also taking 1 unit of time. Example of Constant Time:- int sumOfNumber(a,b) { c = a + b; —–> 1 +1 = 2 unit of time return c; —–> 1 unit of time } Total cost 2 +1 = 3 unit of time it means constant unit of time Example of Linear Time:- int sumOfArray(a[ ], n) Cost Number of Time { int sum=0; 1 1 for(int i = 0; i < n; i++ ) 2 n+1 { sum=sum+a[i]; 1 n } return sum; 1 1 } Total Cost = 1+2(n+1)+2(n)+1 = 4n+4 This is called Linear Time Analysis of Time Complexity T(n) = 3 unit = constant = O(1) T(n) of sumOfArray = 4n+4 = linear = O(n) T(n) of Matrix Multiplication = an^2 + bn +c = quadratic = O(n^2) big Oh, big omega and big theta are asymptotic notation Asymptotic Notations:- Asymptotic analysis of an algorithm r...

Tutorial 3: How to write an Algorithm and its Basic

Tutorial 3: How to write an Algorithm and its Basic There are no well-defined standards for writing algorithms. It is problem or resource dependent. All programming languages share basic code constructs like loops (do, for and while), flow controls (if-else), etc. These common constructs can be used to write an algorithm. Algorithm writing is a process and is executed after the problem domain is well-defined. Problem:- Design an algorithm to add two numbers and display the result step 1: START step 2: declare three integers a, b & c step 3: define values of a & b step 4: add values of a & b step 5: store  step 4   to c step 6: print c step 7: STOP Other Way:- step 1: START ADD step 2: get values of a & b step 3: c < — a & b step 4: display c step 5: STOP Algorithm Complexity:-               Two main factor which decide the efficiency of X Time Factor:-  Time is measured by counting the number of key operation such ...

Tutorial 2 : Characteristic & Basic Terminologies of Data Structure

Tutorial 2 : Characteristic & Basic Terminologies of Data Structure Interface and Implementation Data Structure is a systematic way to organize data in order to use it efficiently. Following terms of data structure we should know. Interface  – Interface represents the set of operations that a data structure supports. An interface only provides the list of supported operations, type of parameters they can accept and return type of these operations. Implementation  – Implementation provides the internal representation of a data structure. Implementation also provides the definition of the algorithms used in the operations of the data structure. Characteristics of a Data Structure Correctness  – Data Structure implementation should implement its interface correctly. Time Complexity  – Running time or a Execution time of operations of data structure must be as small as possible. Space Complexity  – Memory usage of a data structure operation should be as little a...

Tutorial 01: Introduction to Data Structure and Algorithm

Tutorial 01: Introduction to Data Structure and Algorithm What is Algorithm ? Step by Step procedure design to perform an operation, and which (lie a map or flowchart) will lead to the sought result if followed correctly. Algorithm have a definite beginning and definite end. A finite number of steps. An algorithm produces the same output information given the same input information and several short algorithms can be combined to perform complex tasks such as writing a computer programs. What is Data Structure ? Data Structure are the programmatic way of storing data so that data can be used efficienty. → "Tutorial 01: Introduction To Data Structure And Algorithm" Expand/Collapse Content Area Customize: Content Area General → Content Area Content Area → Animation Content Area → Colors Site → Layout Edit Left Sidebar
  Let’s be Professional in the field of Computer Science This website is created by Salar Muavia for the purpose of free education. This website is helpful for the beginner’s and also for the students of Computer Science in different universities  Professional In The Field Of Computer Science" Expand/Collapse Content Area Customize: Content Area General → Content Area Content Area → Animation Content Area → Colors Site → Layout Edit Left Sidebar Search