Login
Register
@
Dark Mode
Profile
Edit my Profile
Messages
My favorites
Register
Activity
Q&A
Questions
Unanswered
Tags
Subjects
Users
Ask
Previous Years
Blogs
New Blog
Exams
Dark Mode
Algorithms time Complexity
gauravkc
asked
in
Algorithms
Apr 5, 2018
retagged
Jul 13, 2022
by
makhdoom ghaya
897
views
2
votes
2
votes
What is the time complexity of this code?
time-complexity
algorithms
asymptotic-notation
test-series
gauravkc
asked
in
Algorithms
Apr 5, 2018
retagged
Jul 13, 2022
by
makhdoom ghaya
by
gauravkc
897
views
answer
comment
Follow
share this
share
2 Comments
by
Jason
commented
Apr 5, 2018
reply
Follow
share this
A) ??
0
0
by
gauravkc
commented
Apr 5, 2018
reply
Follow
share this
How?
0
0
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
1
Answer
1
vote
1
vote
Best answer
k and h will give n+logn complexity
J , k and h will give n(n+logn) complexity
I , j ,k and h will give
logn base 3(n^2+nlogn) complexity
Finally, n^2 logn base 3 + nlogn lognbase 3
Remove the negligibity and we get o(n^2) as complexity.
$ruthi
answered
Apr 5, 2018
selected
Apr 5, 2018
by
gauravkc
by
$ruthi
comment
Follow
share this
3 Comments
by
gauravkc
commented
Apr 5, 2018
reply
Follow
share this
Thanks :)
0
0
by
Sivarama Subramanian
commented
Apr 6, 2018
reply
Follow
share this
I can't properly understand this step
I ,J ,K and H will give $\log_{3}n* (n^2 + n log n)$complexity
and then
I thought it will become $\log_{3}n* (n^2 )$ + $\log_{3}n* (nlog n )$
which will be O($n^2 log_3 n$) and that equals O($n^2 log n)$.
Please correct me where I'm wrong
0
0
by
himgta
commented
Apr 6, 2018
reply
Follow
share this
for comparing ,remove the common terms thus logn base3 got cancelled out,remaing is n^2 and nlogn..... most significant term is n^2.
0
0
Please
log in
or
register
to add a comment.
← Previous
Next →
← Previous in category
Next in category →
Related questions
0
votes
0
votes
1
answer
1
Beyonder
asked
in
Algorithms
Apr 11, 2018
576
views
time complexity
Beyonder
asked
in
Algorithms
Apr 11, 2018
by
Beyonder
576
views
time-complexity
algorithms
asymptotic-notation
programming-in-c
test-series
3
votes
3
votes
1
answer
2
pranab ray
asked
in
Algorithms
Jan 15, 2018
639
views
time complexity
pranab ray
asked
in
Algorithms
Jan 15, 2018
by
pranab ray
639
views
time-complexity
algorithms
asymptotic-notation
test-series
0
votes
0
votes
3
answers
3
pranab ray
asked
in
Algorithms
Jan 13, 2018
412
views
time complexity
i am getting t.c as O(n^5) but given answer as O(n^4) what should be the answer
pranab ray
asked
in
Algorithms
Jan 13, 2018
by
pranab ray
412
views
time-complexity
algorithms
asymptotic-notation
test-series
0
votes
0
votes
1
answer
4
Parshu gate
asked
in
Algorithms
Sep 17, 2017
637
views
time complexity
Parshu gate
asked
in
Algorithms
Sep 17, 2017
by
Parshu gate
637
views
time-complexity
algorithms
asymptotic-notation
programming-in-c
test-series
Subscribe to GATE CSE 2024 Test Series
Subscribe to GO Classes for GATE CSE 2024
Quick search syntax
tags
tag:apple
author
user:martin
title
title:apple
content
content:apple
exclude
-tag:apple
force match
+apple
views
views:100
score
score:10
answers
answers:2
is accepted
isaccepted:true
is closed
isclosed:true
Recent Posts
Post GATE 2024 Guidance [Counseling tips and resources]
GATE CSE 2024 Result Responses
[Project Contest] Pytorch backend support for MLCommons Cpp Inference implementation
Participating in MLCommons Inference v4.0 submission (deadline is February 23 12pm IST)
IIITH PGEE 2024 Test Series by GO Classes
Subjects
All categories
General Aptitude
(3.5k)
Engineering Mathematics
(10.4k)
Digital Logic
(3.6k)
Programming and DS
(6.2k)
Algorithms
(4.8k)
Theory of Computation
(6.9k)
Compiler Design
(2.5k)
Operating System
(5.2k)
Databases
(4.8k)
CO and Architecture
(4.0k)
Computer Networks
(4.9k)
Artificial Intelligence
(79)
Machine Learning
(48)
Data Mining and Warehousing
(25)
Non GATE
(1.4k)
Others
(2.7k)
Admissions
(684)
Exam Queries
(1.6k)
Tier 1 Placement Questions
(17)
Job Queries
(80)
Projects
(11)
Unknown Category
(870)
64.3k
questions
77.9k
answers
244k
comments
80.0k
users
Recent Blog Comments
category ?
Hi @Arjun sir, I have obtained a score of 591 in ...
download here
Can you please tell about IIT-H mtech CSE self...
Please add your admission queries here:...
Twitter
WhatsApp
Facebook
Reddit
LinkedIn
Email
Link Copied!
Copy