Time Complexity of Binary Search?

user7776022

If I divide array size by 3 what will the running time of Binary search.

bitmask

With binary search you typically search in a sorted random access data structure like an array, by discarding half of the array with each comparison. Hence, in k steps you effectively cover 2^k entries. This yields a complexity of at most log2(n) of n elements.

With landau symbols, the base of the logarithm disappears because it is a constant: O(log2(n)) = O(log(n) / log(2)) = O(log(n)).

Now, if you, for some reason, can not only discard half of the values, but two thirds, by always knowing in which third the needle will end up in, this means you cover 3^k many entries in k steps.

Hence, you get log3(n). But this again reduces to the same time complexity as log(3) is a constant: O(log3(n)) = O(log(n)/log(3)) = O(log(n)).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

What is the time-complexity in a binary search?

From Dev

Running time complexity for binary search tree

From Dev

Time complexity of deletion in binary search tree

From Dev

GATE 2008: Time Complexity of Binary Search Tree

From Dev

Time complexity of deletion in binary search tree

From Dev

What would be time Complexity of binary search algorithm?

From Dev

Time complexity for rebuilding binary search tree / quadtree / octtree?

From Dev

Why does assignment in a binary search algorithm not add to the time complexity?

From Dev

NSDictionary Search Time Complexity

From Dev

Binary Max Heap Time Complexity

From Dev

Average complexity of binary search for an unsuccessful search

From Dev

What's time complexity of algorithm for finding all Unique Binary Search Trees?

From Dev

Search time complexity of this sql query

From Dev

Space complexity of validation of a binary search tree

From Dev

Complexity for Binary Search (Insertion) for an ordered list

From Dev

Space complexity of validation of a binary search tree

From Java

Time complexity of testing if a binary tree is balanced

From Dev

Time complexity of deleting a leaf from a binary heap

From Dev

Time complexity of checking if a binary tree is balanced

From Dev

Time complexity for sorting an array of binary numbers

From Dev

Space/Time complexity of Binary Tree Equality

From Dev

Binary tree level order traversal time complexity

From Dev

time complexity of binary tree to DLL conversion

From Dev

Breadth First Search time complexity analysis

From Dev

Time complexity of Uniform-cost search

From Dev

Time and Space Complexity for Breadth First Search

From Dev

Time/Space Complexity of Depth First Search

From Dev

Time and Space Complexity for Breadth First Search

From Dev

Time complexity in search of a list within a tree

Related Related

  1. 1

    What is the time-complexity in a binary search?

  2. 2

    Running time complexity for binary search tree

  3. 3

    Time complexity of deletion in binary search tree

  4. 4

    GATE 2008: Time Complexity of Binary Search Tree

  5. 5

    Time complexity of deletion in binary search tree

  6. 6

    What would be time Complexity of binary search algorithm?

  7. 7

    Time complexity for rebuilding binary search tree / quadtree / octtree?

  8. 8

    Why does assignment in a binary search algorithm not add to the time complexity?

  9. 9

    NSDictionary Search Time Complexity

  10. 10

    Binary Max Heap Time Complexity

  11. 11

    Average complexity of binary search for an unsuccessful search

  12. 12

    What's time complexity of algorithm for finding all Unique Binary Search Trees?

  13. 13

    Search time complexity of this sql query

  14. 14

    Space complexity of validation of a binary search tree

  15. 15

    Complexity for Binary Search (Insertion) for an ordered list

  16. 16

    Space complexity of validation of a binary search tree

  17. 17

    Time complexity of testing if a binary tree is balanced

  18. 18

    Time complexity of deleting a leaf from a binary heap

  19. 19

    Time complexity of checking if a binary tree is balanced

  20. 20

    Time complexity for sorting an array of binary numbers

  21. 21

    Space/Time complexity of Binary Tree Equality

  22. 22

    Binary tree level order traversal time complexity

  23. 23

    time complexity of binary tree to DLL conversion

  24. 24

    Breadth First Search time complexity analysis

  25. 25

    Time complexity of Uniform-cost search

  26. 26

    Time and Space Complexity for Breadth First Search

  27. 27

    Time/Space Complexity of Depth First Search

  28. 28

    Time and Space Complexity for Breadth First Search

  29. 29

    Time complexity in search of a list within a tree

HotTag

Archive