how to implement quick sort algorithm in C++

Your consideration is wrong. The value of r does not change, since it is given as value to the Quicksort function(not a reference). You handle the ranges with p,q such that p is the first index in the range and q the first index not in the range. Thus, your calls were wrong: Here is the complete example. I used std::swap to change elements and ans std::vector … Read more

What does O(log n) mean exactly?

The most common attributes of logarithmic running-time function are that: the choice of the next element on which to perform some action is one of several possibilities, and only one will need to be chosen. or the elements on which the action is performed are digits of n This is why, for example, looking up … Read more

When is it practical to use Depth-First Search (DFS) vs Breadth-First Search (BFS)? [closed]

That heavily depends on the structure of the search tree and the number and location of solutions (aka searched-for items). If you know a solution is not far from the root of the tree, a breadth first search (BFS) might be better. If the tree is very deep and solutions are rare, depth first search … Read more

What does O(log n) mean exactly?

I cannot understand how to identify a function with a log time. The most common attributes of logarithmic running-time function are that: the choice of the next element on which to perform some action is one of several possibilities, and only one will need to be chosen. or the elements on which the action is … Read more