Design And Analysis of Algorithm | Lecture2 | Faraz Khan — Transcript
Full transcript
- 0:00in today's lecture we will discuss the
- 0:02cases of algorithm
- 0:04We have basically four cases of
- 0:07algorithm number one is test case
- 0:13now what is best case
- 0:16suppose we have an array of size n equal
- 0:20to 50.
- 0:22and there is a key element which will be
- 0:25going to find
- 0:27or we have to find in that specific area
- 0:33so as you can see that
- 0:36the best case would be
- 0:39while searching the key element of an
- 0:42array
- 0:44best case is the case when we find the
- 0:48key element
- 0:50at first location
- 0:54or the first index of an array
- 0:57example
- 1:00we have an array of size n equal to 50.
- 1:05and the key element key element is the
- 1:08element which we are going to find
- 1:12in a given area
- 1:14so if we find that special element which
- 1:17is 10 the key element which is 10 so if
- 1:21we find that key element
- 1:23throughs ABC algorithm we will call it
- 1:28it's a best case
- 1:30right
- 1:31so whenever we find a key element at the
- 1:35very first index we will call it a test
- 1:38case right
- 1:41the second one
- 1:45second one worst case
- 1:49what is worst case while searching the
- 1:52key element of an array worst case is
- 1:55the case when we find the key element at
- 1:59last location of an array
- 2:02what does that mean let me elaborate it
- 2:05for example
- 2:09we have a same array
- 2:12of size n equal to 50 and the element we
- 2:16are going to find in that array is again
- 2:2010. so now you can see that if we find
- 2:24that element
- 2:27at the very last index of an array we
- 2:31will call it a worst case
- 2:34worst case scenario if we find at first
- 2:37index we will call it a best case
- 2:39scenario and if we find it
- 2:42at the last index we call it a worst
- 2:45case got it
- 2:47let's move on
- 2:53the third one is
- 2:57while selecting the key element of an
- 2:59array average case is the case when we
- 3:03find the key element in between
- 3:06second and second last location or index
- 3:10of an error
- 3:12what does that mean let me elaborate it
- 3:15for example we have a same array of size
- 3:18n equal to 50
- 3:20and the key element we are going to find
- 3:22is 10 just like previous two examples
- 3:27same array
- 3:29find that element here you can see that
- 3:31see the mouse closely
- 3:33this is index number
- 3:36second
- 3:37and this is you can see the movement of
- 3:40the mouse this is the second last index
- 3:45of an array
- 3:47so if we find an element
- 3:50in between second
- 3:52and second last index or location of an
- 3:56array we will call it average case
- 4:01I hope you have understood let's move on
- 4:06now asymptotic case
- 4:10asymptotic case
- 4:13asymptotic notations was developed to
- 4:16provide the universal way to measure the
- 4:19speed and efficiency of an algorithm
- 4:23asymptotic algorithm precisely refers
- 4:26for large input we measure the behavior
- 4:29of algorithm when input size reaches
- 4:33Infinity
- 4:35what does that mean it means whenever we
- 4:38want to analyze the large data we want
- 4:41to analyze the infinite data so we would
- 4:45rather prefer asymptotic notations
- 4:49got it
- 4:50so here we have three different
- 4:53asymptotic notations
- 4:56the first one is
- 4:58Big O N
- 5:02we call it a big O
- 5:06and it's a upper bound
- 5:11what does that mean
- 5:14it means whenever we find the key
- 5:19element
- 5:21in a given array
- 5:23at
- 5:26the very last index
- 5:29so we will call it a
- 5:32upper bound
- 5:34Big O and the complexity would be o n
- 5:38Square in asymptotic notation
- 5:41I repeat for example we have a given
- 5:44array and if we find a key element at
- 5:48the very last index of an array we will
- 5:51call it a upper bound
- 5:54and its complexity would be o n Square
- 5:58right
- 6:02let's move on to the end
- 6:06we call it a Theta
- 6:14what is the Theta
- 6:16V represent Theta for
- 6:19tight bound what does that mean
- 6:24for example n is less than 3 n
- 6:28and 3n is less than 5.
- 6:31so n would be the lower bound 5 n would
- 6:36be the upper bound and 3n would be the
- 6:40tide bound
- 6:42right so
- 6:45we can even say that we can represent
- 6:48the average case with the help of a
- 6:50Theta n in asymptotic notations i o you
- 6:54have understood
- 6:58here is w n
- 7:03you can see that w n
- 7:05or Omega n
- 7:08we call it Omega
- 7:11and it represents a lower bound
- 7:15so whenever we
- 7:18find the key element at the very first
- 7:22index of an array
- 7:25so we will call it
- 7:27lower bound
- 7:29in asymptotic notation
- 7:32and V represents lower bound with
- 7:36Omega n or
- 7:39T down
- 7:43I hope you have understood
- 7:47so at the end if we conclude
- 7:51the asymptotic notations
- 7:54while finding the
- 7:56efficiency of algorithm we are always
- 7:59interested in worst case which means for
- 8:03analyzing the complexity of algorithm we
- 8:06only care about the highest power and
- 8:08ignore the rest
- 8:10that is why for example we have a given
- 8:14expression n k power 5
- 8:17and having power 5 plus 4 n Cube plus 3
- 8:21n plus five so the ultimate complexity
- 8:24of the above expression is
- 8:26and five
- 8:28right
- 8:29because one thing is damn sure but we
- 8:33have discussed in lecture number one
- 8:35whenever we find the complexity of an
- 8:39algorithm
- 8:40we are always interested in the worst
- 8:43case
- 8:44and
- 8:46that is the reason whenever we have an
- 8:49expression whenever we have a complexity
- 8:51in the form of expression just like this
- 8:56so we only care about the highest power
- 8:59why
- 9:00the simple answer is the highest power
- 9:04represents the worst case and whenever
- 9:08we find the complexity of algorithm we
- 9:10are always always interested in the
- 9:13worst case because worst case represents
- 9:18the whole area
- 9:20worst case represents the highest power
- 9:24in worst case we go for the maximum
- 9:29computational steps
- 9:31right so with this I conclude lecture
- 9:35number two
About this transcript
This page contains the full transcript of Design And Analysis of Algorithm | Lecture2 | Faraz Khan by Faraz Khan, generated from the public captions YouTube serves with the video. The transcript has 995 words across 181 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.