Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
1
190050084-190050085-git12337
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Pokala Mohith
190050084-190050085-git12337
Commits
d6ed47b7
Commit
d6ed47b7
authored
Aug 29, 2020
by
Preetham Poluparthi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change implementation to binary-search
parent
ac7cd519
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
5 deletions
+27
-5
searching.cpp
searching.cpp
+27
-5
No files found.
searching.cpp
View file @
d6ed47b7
#include "main.cpp"
bool
search_custom
(
vector
<
int
>
a
,
int
num
){
for
(
int
i
=
0
;
i
<
a
.
size
();
i
++
){
if
(
a
[
i
]
==
num
)
return
true
;
}
return
false
;
int
n
=
a
.
size
();
int
i
=
0
,
f
=
n
-
1
;
while
(
true
)
{
if
(
i
==
f
)
{
if
(
a
[
i
]
==
num
)
return
true
;
return
false
;
}
if
(
f
==
i
+
1
)
{
if
(
a
[
i
]
==
num
)
return
true
;
if
(
a
[
f
]
==
num
)
return
false
;
return
false
;
}
int
c
=
(
i
+
f
)
/
2
;
if
(
a
[
c
]
==
num
)
return
true
;
if
(
a
[
c
]
>
num
)
{
f
=
c
-
1
;
}
else
{
i
=
c
+
1
;
}
}
return
false
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment