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
Find the Time Complexity
Naveen Kumar 3
asked
in
Algorithms
Nov 3, 2018
969
views
0
votes
0
votes
Suppose, we have an array of n elements. find the time complexity to search two elements x, y such that:-
a) x+y < 100
b) x+y > 1000
Also, state the algorithm/approach for the same.
algorithms
time-complexity
Naveen Kumar 3
asked
in
Algorithms
Nov 3, 2018
by
Naveen Kumar 3
969
views
answer
comment
Follow
share this
share
4 Comments
Show 5 previous comments
by
MiNiPanda
commented
Nov 4, 2018
reply
Follow
share this
Yes @Prateek right..
0
0
by
Naveen Kumar 3
commented
Nov 4, 2018
reply
Follow
share this
so, for the 1st part also we can apply 2 passes bubble sort(descending order code) & last 2 min. can be checked in
(n-1)+(n-2) comparisons. so, O(n). right??
0
0
by
Prateek Raghuvanshi
commented
Nov 7, 2018
reply
Follow
share this
Yeah right
0
0
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
0
Answers
← Previous
Next →
← Previous in category
Next in category →
Related questions
1
vote
1
vote
1
answer
1
Akriti sood
asked
in
Algorithms
Jan 23, 2017
1,299
views
find the time complexity
What is the time complexity of the following function foo() void foo() { int i, j; for(i = 1; i <= n ; i++) for(j = i; j <= log(i); j++) printf(“gate”); } what is the time complexity? the answer given is nlogn. but I think it should be O(n)
Akriti sood
asked
in
Algorithms
Jan 23, 2017
by
Akriti sood
1.3k
views
algorithms
time-complexity
2
votes
2
votes
1
answer
2
Akriti sood
asked
in
Algorithms
Jan 23, 2017
790
views
find the time complexity|testbook livetest
please tell the time complexity?i was getting O(2n)
Akriti sood
asked
in
Algorithms
Jan 23, 2017
by
Akriti sood
790
views
time-complexity
algorithms
recurrence-relation
testbook-test-series
1
vote
1
vote
0
answers
3
Akriti sood
asked
in
Algorithms
Dec 22, 2016
683
views
find the time complexity
Consider the following function int foo(int n) { int count1=0, count2=0; if (n < 0) n = -n; if (n == 0) return 1; If (n == 1) return 0; while (n) { if (n & 1) count1++; n = n >> 1; if (n & 1) count2++; n = n>>1; } return foo(abs(count1 - count2)); } What is the time complexity for the above function?
Akriti sood
asked
in
Algorithms
Dec 22, 2016
by
Akriti sood
683
views
time-complexity
algorithms
1
vote
1
vote
2
answers
4
sh!va
asked
in
Algorithms
Dec 4, 2016
972
views
Find the time complexity of given loops
for (int i = 1; i <=m; i += c) { ---do something ---} for (int i = 1; i <=n; i += c) { ---do something --- } What will the the tiem complexity of given code pseudococde? A. O (max(m,n)) B. O(min(m,n)) C. O( m+n) D. O(mn)
sh!va
asked
in
Algorithms
Dec 4, 2016
by
sh!va
972
views
algorithms
time-complexity
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