Arithmetic Left shift time complexity

社会主义新天地 提交于 2019-12-08 07:14:24

问题


What is the time complexity of * Arithmetic left shift* / * Arithmetic right shift* operators of a n bit operand for example doing x = y << 2; whow much time will it take ?


回答1:


Complexity, with the O(…) notation, is an asymptotic characterization of the time an algorithm takes when the input size becomes larger and larger. It is meaningless for algorithms that can take only a finite number of inputs. << can take 2^32 * 32 different inputs, hence a finite number of inputs, therefore it is constant-time (O(1)).



来源:https://stackoverflow.com/questions/18470210/arithmetic-left-shift-time-complexity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!