C/Data Structure
Expert: Narendra - 9/21/2005
QuestionSir,
Thanks, your answer is very much satisfiable but you have not mentioned anything about BIG O notation? I also requested you for an example.
Please solve my query because it has been a dream to understand time complexity clearly.
-------------------------
Followup To
Question -
I am begginers in programming. I just started doing Data Structure. I found it very useful and interesting too. My question from Data Structure is about Time Complexity.
What is it?
What is Big O Notation?
Please explain in easy manner with examples.
I have gone through many books such as Lipsuiz, Tannenbaum, R.B.Patel etc. but I am unable to claerly grasp the knowledge.
Please solve my query if possible!1
Answer -
There can be 10 different algorithms (or solutions) to a problem. Which one you will follow and there should be some reason to decide so!?
One of the reasons that makes you take up an algorithm is that it takes lesser time to solve the problem.
But, how do you know it takes lesser time.
The only way is to execute all the algorithms on different sets of inputs. For each set of inputs, each of them will finish in different times.
Based on this study, you will have to judge which takes less/more time.
There is no easy way to do that and also easy way to explain this. You will have to take up several examples of your own and then aplly the formulas given in your books and decide.
For example take the example of sorting.
Give different types of inputs:
1. Fully unsorted list.
2. Sorted (in ascending order) list
3. Sorted (in descending order) list
4. sorted somewhere in the middle.
5. alternate units are sorted.
Like this you can have many sets. Apply the algorithm to each of these sets. While applying the algorithm, how to say which takes more time? So, usually loops take up most of the time. So, find out which algorithm spends more/ess time in loops? This will help you to get an approximate estimate of time spent.
Hope this gives you some idea on the subject.
-Narendra
AnswerThis is not a platform where I can do the teaching.
I can help you in coding related problems.
Nowadays I am very budy with my office work.
I would suggest you to get hold of a good book and study it again. You will definitely understand.
-Narendra