Mathematical analysis of
non-recursive algorithm
General plan
• Decide the input size.
• Identify basic operations.
• Check how many time basic operations is
executed & determine best,worst,avg case
analyzed seperately.
• Set up sum for basic operation.
• Simplifying the sum using std formula &
rules.
• The input size is n.
• The basic operation is comparison in loop for
finding largest value.
• Comparison made for each value for n.
• C(n) be the no.of.times comparison is executed.
• C(n)=one comparison.
• Simplify the sum.
Mathematical analysis
Mathematical analysis
• The input size of the problem is n
• The basic operation is if A[i]==A[j]
• The outer loop will be executed first to last but one
element and inner loop is executed 2 to n array
index.
• C(n) no.of.comparison statement is executed in
worstcase.
mathematical  nonrecursive algorithm.pptx

mathematical nonrecursive algorithm.pptx

  • 1.
  • 2.
    General plan • Decidethe input size. • Identify basic operations. • Check how many time basic operations is executed & determine best,worst,avg case analyzed seperately. • Set up sum for basic operation. • Simplifying the sum using std formula & rules.
  • 4.
    • The inputsize is n. • The basic operation is comparison in loop for finding largest value. • Comparison made for each value for n. • C(n) be the no.of.times comparison is executed. • C(n)=one comparison. • Simplify the sum. Mathematical analysis
  • 7.
    Mathematical analysis • Theinput size of the problem is n • The basic operation is if A[i]==A[j] • The outer loop will be executed first to last but one element and inner loop is executed 2 to n array index. • C(n) no.of.comparison statement is executed in worstcase.