Docsity

Introduction to Data Structures: Types, Operations, and Management, Lecture notes of Data Structures and Algorithms

Partial preview of the text

Download Introduction to Data Structures: Types, Operations, and Management and more Lecture notes Data Structures and Algorithms in PDF only on Docsity!

Introduction to Data Structures

and It’s Operations

Course: Data Structures & Algorithms

Data Structures & Algorithms Last Lecture Summary Last Lecture Summary

  • (^) Computer Program
  • (^) What Data Structures (DS)?
  • (^) Why DS?
  • (^) DS Operations
    • (^) Traversing
    • (^) Searching
    • (^) Insertion
    • (^) Deletion
    • (^) Sorting
    • (^) Merging

Data Structures & Algorithms Steps – Computer ProgramSteps – Computer Program Steps – Computer Program Steps – Computer Program

  • (^) Steps involved in writing a computer program:
    • (^) Problem formulation & specification
    • (^) Design of solution
    • (^) Implementation
    • (^) Testing
    • (^) Documentation
    • (^) Evaluation of the solution

Data Structures & Algorithms AlgorithmAlgorithm Algorithm Algorithm

  • (^) An algorithm is a definite procedure for solving a problem in finite number of steps
  • (^) Algorithm is a well defined computational procedure that takes some value(s) as input, and produces some value(s) as output
  • (^) Algorithm is finite number of computational statements that transform input into the output
  • (^) Algorithm Definition : A finite set of statements that guarantees an optimal solution in finite interval of time

Data Structures & Algorithms Efficient AlgorithmEfficient Algorithm Efficient Algorithm Efficient Algorithm

  • (^) Consumes lesser amount of resources while solving a problem of size n - (^) Memory - (^) Time
  • (^) So do we just measure the processor time?

Data Structures & Algorithms Measuring EfficiencyMeasuring Efficiency Measuring Efficiency Measuring Efficiency

  • (^) The efficiency of an algorithm is a measure of the amount of resources (time and memory) consumed in solving a problem of size n.
  • (^) It would seem that the most obvious way to measure the efficiency of an algorithm is to run it and measure how much processor time is needed.

Data Structures & Algorithms Analyzing an AlgorithmAnalyzing an Algorithm Analyzing an Algorithm Analyzing an Algorithm

Calculating Running time of an Algorithm

  • (^) Running time is measured by number of steps / primitive operations performed
  • (^) Steps means elementary operation
    • (^) For example: +, *,<, =, A[i] etc
  • (^) Measure the number of steps taken in term of size of input

Data Structures & Algorithms Simple ExampleSimple Example Simple Example Simple Example // Input: int A[N], array of N integers // Output: Sum of all numbers in array A int Sum(int A[], int N) { int s=0; for (int i=0; i< N; i++) s = s + A[i]; return s; } How should we analyse this?

Data Structures & Algorithms Simple Example – Cont…Simple Example – Cont… Simple Example – Cont… Simple Example – Cont… Growth of 5N+

  • (^) Estimated running time for different values of N:
    • (^) N = 10 => 54 steps
    • (^) N = 100 => 504 steps
    • (^) N = 1,000 => 5004 steps
    • (^) N = 1,000,000 => 5,000,004 steps
  • (^) As N grows, the number of steps grow in linear proportion to N for this function “ Sum ”

Data Structures & Algorithms SummarySummary Summary Summary

  • (^) Program Efficiency & Complexity
  • (^) Steps – Computer Program
  • (^) Algorithm
    • (^) Favorite Algorithm
    • (^) Efficient Algorithm
    • (^) Measuring Efficiency
    • (^) Running Time of an Algorithm
    • (^) Analyzing an Algorithm
  • (^) Simple Example