Comments (5)
Good to know, which language/languages can this be an issue?
from grokking_algorithms.
C/C++, Java, etc
from grokking_algorithms.
C/C++, Java, etc
Is there any example?
from grokking_algorithms.
You have to round the mid number down manually
from grokking_algorithms.
Maybe it's better to use binary shift operator instead of dividing by two and type conversions? I guess most of all programmic languages have it.
I used it, during the grokking binary search algorythm:
$mid = ($low + $high) -shr 1
(0 + 5) -shr 1 # 2, ok
(0 + 7) -shr 1 # 3, ok
There is a problem with the conversion from float to integer, for example, PoSh round a float to nearest even, not to down:
[int]( (0 + 5) / 2 ) # 2, ok
[int]( (0 + 7) / 2 ) # 4, expect 3
from grokking_algorithms.
Related Issues (20)
- spelling mistake HOT 1
- Typo in load factor (Chapter #5 hash tables)
- selection sort implementation HOT 2
- Грокаем алгоритмы
- grokking_algorithms/01_introduction_to_algorithms/java/01_binary_search/src/main/BinarySearch.java HOT 3
- Книги
- Providing code examples for data structures
- Dijkstra Algorithm Golang Issue HOT 1
- Algorithms
- 分类算法
- Leetcode专题
- Hacktoberfest Inclusion
- solve problem in 03_recursion/python/05_binary_search_recursive.py
- грокаем алгоритмы
- Problem with max definition on Python in chapter_4/quick_sort/max_recursive HOT 1
- Longest common substring wrongly coded.
- Typescript solution is missing
- Grok HOT 1
- Algo
- Java Chapter 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grokking_algorithms.