Discussion
An algorithm is made up of 2 modules M1 and M2 . If time complexity of modules M1 and M2 are h(n) and g(n) respectively, the time complexity of the algorithm is
Answer: B
The time complexity is the maximum of h(n) and g(n). When an algorithm is made of two modules run one after the other, its running time is the sum h(n) + g(n), and for the order of growth the sum is dominated by the larger term, so it is of the order of max(h(n), g(n)). The minimum would ignore the slower module and the product would apply only if one module were run inside the other, so those are wrong.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development