The Common Complexities Handout http://HiredInTech.com Algorithms Algorithm Time Complexity π(log π) Binary Search in a sorted array of N elements Reversing a string of N elements π(π) Linear search in an unsorted array of N elements π(π) Compare two strings with lengths L1 and L2 π(πππ(πΏ1, πΏ2)) Computing the Nth Fibonacci number using dynamic programming π(π) Checking if a string of N characters is a palindrome π(π) Finding a string in another string using the Aho-Corasick algorithm π(π) Sorting an array of N elements using Merge Sort/Quick Sort/Heap Sort π(π β log π) Sorting an array of N elements using Bubble sort π(π ! ) Two nested loops from 1 to N π(π ! ) The Knapsack problem of N elements with capacity M π(π β π) Finding a string in another string β the naive approach π(πΏ1 β πΏ2) Three nested loops from 1 to N π(π ! ) Twenty-eight nested loops β¦ you get the idea π(π !" ) Generating all subsets of a set of N elements π(2! ) Copyright © 2014 HiredInTech Data Structures vοΆ Stack Operation Time Complexity Adding a value to the top of a stack π(1) Removing the value at the top of a stack π(1) Reversing a stack π(π) Data Structures vοΆ Queue Operation Time Complexity Adding a value to end of the queue π(1) Removing the value at the front of the queue π(1) Reversing a queue π(π) Data Structures vοΆ Heap Operation Time Complexity Adding a value to the heap π log π Removing the value at the top of the heap π(log π) Data Structures vοΆ Hash Operation Time Complexity Adding a value to a hash π(1) Checking if a value is in a hash π(1) Copyright © 2014 HiredInTech
© Copyright 2026 Paperzz