Top "Algorithm" questions

An algorithm is a sequence of well-defined steps that defines an abstract solution to a problem.

How do I create a URL shortener?

I want to create a URL shortener service where you can write a long URL into an input field and …

algorithm url
Determine if two rectangles overlap each other?

I am trying to write a C++ program that takes the following inputs from the user to construct rectangles (between 2 …

c++ algorithm geometry overlap rectangles
What is the difference between tree depth and height?

This is a simple question from algorithms theory. The difference between them is that in one case you count number …

algorithm data-structures tree nodes terminology
What is an NP-complete in computer science?

What is an NP-complete problem? Why is it such an important topic in computer science?

algorithm language-agnostic mathematical-optimization theory np-complete
How to reverse a singly linked list using only two pointers?

I wonder if there exists some logic to reverse a singly-linked list using only two pointers. The following is used …

c algorithm data-structures linked-list singly-linked-list
Difference between Big-O and Little-O Notation

What is the difference between Big-O notation O(n) and Little-O notation o(n)?

algorithm time-complexity big-o asymptotic-complexity little-o
How to check if a number is a power of 2

Today I needed a simple algorithm for checking if a number is a power of 2. The algorithm needs to be: …

c# algorithm math
When is it practical to use Depth-First Search (DFS) vs Breadth-First Search (BFS)?

I understand the differences between DFS and BFS, but I'm interested to know when it's more practical to use one …

algorithm graph-algorithm graph-theory depth-first-search breadth-first-search
Finding height in Binary Search Tree

I was wondering if anybody could help me rework this method to find the height of a binary search tree. …

algorithm recursion binary-search-tree
Java, Shifting Elements in an Array

I have an array of objects in Java, and I am trying to pull one element to the top and …

java arrays algorithm shift