This example is actually maybe a little bit easier and probably a little bit more useful and interesting. What we’d like to do is count the number of steps that it takes to run naive as a function of a. Just as before, I’d like you to write your answer as a function time that […]

# Tag: algorithms

## Measuring Time – Intro to Algorithms

One of the things we’d like to do is have a way of comparing algorithms in terms of the time it takes to run them without actually having to go and do all the hard work of running them. Instead what we’re going to try to do is analyze what the running time is in […]

## Reversal algorithm for array rotation | GeeksforGeeks

Hi and welcome to GeeksforGeeks. Today we will discuss how to write a function “rotate” that rotates an array of size n by d elements. Let us look at an example. We have an array with elements – 1,2,3,4,5,6 and 7. We want to rotate this by a factor of 2 i.e. by 2 places. […]

## Finding Bridge Edges – Intro to Algorithms

Alright, so I’ve redrawn the graph from the previous examples just to make a little bit more room and what we’ve got so far is the original graph and the – a tree version of the graph that we built by search, some kind of data depth-first, breadth-first – any kind of search actually will […]

## Check if a given array can represent Preorder Traversal of Binary Search Tree | GeeksforGeeks

Hi friends and welcome to GeeksforGeeks, in this tutorial we will discuss how to check if a given array can represent Preorder Traversal of BST. Here’s the problem, given an array of numbers, return true if given array can represent preorder traversal of BST else return false Let’s discuss the efficient solution to this problem. […]

## Check if a Binary Tree (not BST) has duplicate values | GeeksforGeeks

Hello friends! And, welcome to another tutorial on GeeksforGeeks. In this video we are going to understand the program which Check if a Binary Tree (not BST) has duplicate valuest. FIrst, let us take an example A simple solution is to store inorder traversal of given binary tree in an array. Then check if array […]

## C++ Bitsets in Competitive Programming

Bitsets in C++ are a powerful and convenient tool which will often speed up your program around 30 times This first problem doesn’t require bitsets, but in a moment, we will move to a harder version Let’s say you hire N workers, for each of them you know their schedule for a month For example, […]

## Determine if a binary tree is height-balanced | GeeksforGeeks

Hello friends! And, welcome to another tutorial on GeeksforGeeks. In this video we are going to understand the program which helps us in determining if a binary tree is height balanced. First, let us understand what exactly a height balanced binary tree mean. A height balanced tree is one where no leaf is much farther […]

## Introducing The Algorithm Factory

Your company makes use of algorithms to operate more efficiently, Automate processes and to realize new business models. It helps you to grow. So the more algorithms, the better. But what if that means you end up with hundreds of algorithms? Demanding a lot of time and energy? Because in order for them to operate […]

## Greedy Algorithm – Introduction (Arabic)(English Subtitles)

Peace be upon you Today we’ll talk about another technique an optimization technique like Dynamic Programming, and strongly related to it This technique is called Greedy Algorithm or Greedy Technique Quickly, let’s remember what Dynamic Programming is, to figure out with what Greedy is Dynamic Programming is also optimization: minimization or maximization, according to the […]