big o notataion

Post on 25-Sep-2015

215 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

Explain the best and worst case and big O notation of algorithms for traverse, insert, delete, linear search, binary search and finding max value in a given array..

TRANSCRIPT

BEST CASE, Worst Case And Big O Notation

TransverseInsert DeleteMax valueLinear searchBinary search

ComplexityBest case No best caseIf we want to insert an element at the last position of an array.If we want to delete the last element of an array.When our array is arranged in descending order i.e. the first element of an array is the largest.When we found the element at the first position of an array.When the value we want to find is at the middle of an array.

Worst caseNo worst caseIf we want to insert an element at the first position of an array.If we want to delete the first element of an array.When our array is arranged in ascending order i.e. the last element of an array is the largest.When we found the element at the last position of an array.When the value we want to find is at the first or at the last position of an array.

Big oO(n)O(n)O(n)O(n)O(n)O(log n)

top related