14
Algorithms
Every Programmer Should Know
Basic to Advance
1. Searching Algorithms
Linear Search:
Search each and every element of the
array till you find the
required element
Time Complexity: O (n)
Binary Search:
Searches for the element by comparing
it with the middle item
of the sorted array.
If a match occurs, index is returned, else
the
searching area is reduced appropriately to
either the
upper half or lower half of the array
Time Complexity: O (log2n)
1
2. Sorting Algorithms
Bubble Sort:
Works by swapping adjacent elements
in repeated passes, if
they are not in correct
order.High time complexity and not
suitable
for large datasets
Time Complexity: O (n2)
Insertion Sort:
The array is split into sorted and unsorted
parts. Unsorted
elements are picked and
placed at their correct position in
the
sorted part
Time Complexity: O (n2)
Selection Sort:
The smallest value among the unsorted
elements of the array
is selected in every
pass and inserted to its appropriate
position into the array
Time Complexity: O (n2)
2
Heap Sort:
Uses the property of max and min heaps
having largest and
smallest elements at
the root level It is an inplace sorting
algorithm
Time Complexity: O (nlogn)
Merge Sort:
Repeatedly divide the array into half,
sort the halves and then
combine them.
It is a divide and conquer algorithm
Time Complexity: O (nlog(n))
Quick Sort:
A pivot element is picked and the
partitions made around it
are again
recursively partitioned and sorted.
It is a divide and
conquer algorithm.
Time Complexity: O (nlog(n))
Worst Case Time Complexity: O(n2)
3
3. Basic Math Algorithms
Euclid's Algorithm for GCD:
Works by recursively dividing the bigger
number with smaller
number until the
remainder is zero to get the greatest
common divisor
Sieve of Eratosthenes:
Used for finding all prime numbers up
to a given number by
iteratively marking
and removing the multiples of composite
numbers
Bit Manipulations:
Perform operations at the bit-level or to
manipulate bits in
different ways by using
bitwise operators AND, OR, NOT, XOR
4
4. Graph Algorithms
Breadth First Search and
Depth First Search:
Breadth First Search is implemented
using a queue and
starts at one given
vertex and all its adjacent vertices are
visited first before going to the next
verte
Depth First Search is implemented using
a stack and starts
at one given vertex
and continues its search through
adjacent vertices until there are none left
Time complexity for both is O(V + E)
Dijkstra's Algorithm:
Used to find the shortest path between
two vertices in a
graph. It is a greedy
algorithm
5
5. Algorithms
Tree
Inorder Traversal:
Traverse the left
subtree, visit the root node and then the
right
subtree
Preorder Traversal:
Visit the root node,
traverse the left subtree and then the right
subtree
Postorder Traversal:
Traverse the left
subtree, then the right subtree and then
visit
the root node
Time complexity: O(n)
6
Kruskal's Algorithm:
Used for finding the minimum spanning
tree, by sorting the
edges in descending
order and adding the smallest edge not
added yet to form a tree with all the
nodes
7
6. Dynamic Programming
Dynamic Programming works by storing
the result of
subproblems to access when
needed without
recalculation.
It uses memoization which is a top down
approach and
tabulation which is a bottom
up approach
Floyd-Warshall Algorithm is an algorithm
for finding
the shortest path between all
the pairs of vertices in a
weighted graph.
This algorithm is dynamic
programming
based
8
7. Backtracking Algorithms
Solving problems by trying to build a
solution one piece
at a time, removing
those solutions that fail to satisfy
the
constraints of the problem.
Standard questions for backtracking
include. The N-
queens problem, Sum of
Subsets problem, Graph
Colouring and
Hamiltonian cycles.
9
8. Coding
Huffman
Compression Algorithm
It is a technique of compressing data to
reduce its size
without losing any of the
details. Generally useful to
compress data
with frequently occurring characters
Involves two major parts:
Building a Huffman tre
Traversing the tree and assigning codes
to characters
based on their frequency of
occurrence
10
ABOUT BOSSCODER
Bosscoder is an online upskilling platform for techies. We help learners
upskill in tech roles to get them placed at top tech companies.
We do so through our structured & mentored program designed by
industry experts.
USP of our program include:
Structured Curriculum:
Covers everything you need to get placed at top tech companies:
Problem solving in DS & Algo, CS Fundamentals, System Design (HLD +
LLD), Full stack Projects
Live Classes:
An active learning classroom program taught by engineers working at
companies like Microsoft, PayPal, Amazon
1:1 Mentorship & Mock Interviews:
Personal mentors from top tech companies help you provide the right
guidance, feedback, and support.
24/7 Doubt Support:
Through our army of Teaching Assistants
Industry-relevant projects:
Full stack specialization with Industry-relevant projects
Placement Support:
Providing opportunities to tech engineers in eminent startups & top
tech companies.
11
BUILD YOUR CAREER
WITH US
750+ Alumni placed at Top Product-based companies.
Highest package of 86 LPA
Average package of 24 LPA.
Resume reviewed and interview scheduled for 1000+
students
Lakshmi susmitha Dheeraj Barik
Service Based to JP Morgan in 4 System Engineer at Service Based to
months SDE 2 at Amazon
Before After Before After
IBM
JP Morgan
Infosys
Amazon
Application Engineer Software Egineer II Systems Engineer SDE 2
12
Vishal Srivastava Ujesh Nada
Service Based to London Based Business Development Associate to
Bank SDE at Google
Before After
Before After
Cognizant
Barclays
Programmer Analyst
Byju’s
Google
Software Developer
Trainee BDA SDE
Rakesh Kumar Satapathy Harshith Ravinoothala
Bsc. Graduate stuck in service Tier 3 College Student to Product
based to Hashedin Based Company
After Before
After
Before
Hashedin
G Pulla Reddy
Synopsys
Wipro
Senior Python
Engineering College
R&D Engineer
Software Engineer Developer Sudent
13
Sarveshwar Neogi Aarushi Jain
Clueless college student to No interest in coding to SDE at
Consultant at Sprinkler Atlassian
Before After Before After
KIIT
Sprinkler
NIT Delhi
Atlassian
B.Tech in CS Consultant B.Tech in EEE SDE
Sumedha Khandelwal Irshad K
Scared of Technical Interviews to NIT Delhi to SDE in Singapore
Technical Lead
Before After Before After
IHS Markit
Jubilant Foodworks
NIT Delhi
ByteDance
Software Engineer Technical Lead Application Engineer SDE
14
Want to Upskill?
Go through our website, or email us at
ask@bosscoderacademy.com
VISIT WEBSITE
www.bosscoderacademy.com