Learn Data Structures and Algorithms
This section lists out the syllabus, the learning resources and Mock Tests to help you prepare for the data structures and algorithms Certification test. The resources that we list here are references that we have collected over the internet and some of them from our own website. While we do recommend these resources based on the inputs of our user community, we do not claim that these are the most authoritative Learning Resources about any topic in data structures and algorithms. Please feel free to find out what suits best to you.
We have also prepared a Mock Test for each level. A Mock Test is an open assessment contest that will help you assess yourself after you are ready with the topics. For each level we have different Mock Tests. These DSA contests will run forever.
Update:
If you are new to programming, you should start with our learn to code paths. They have curated
content with lessons and practical problems to practice.
If you already know programming, start from our problem-solving or DSA learning paths from the learn catalog page.
Syllabus:
The syllabus for Foundation level is mentioned below:
- Basic Data Structures: Arrays, Strings, Stacks, Queues
- Asymptotic analysis (Big-O notation)
- Basic math operations (addition, subtraction, multiplication, division, exponentiation)
- Sqrt(n) primality testing
- Euclid’s GCD Algorithm
- Basic Recursion
- Greedy Algorithms
- Basic Dynamic Programming
- Naive string searching
- O(n logn) Sorting
- Binary Searching
Learning Resources:
- Asymptotic analysis (Big-O notation)
- Basic
- youtube.com - Time complexity of a computer program
- youtube.com - Big-O notation in 5 minutes - The basics
- youtube.com - Definition Of Big O Notation - Intro to Theoretical Computer Science
- youtube.com - Algorithms Lecture 1 -- Introduction to asymptotic notations
- iarcs.org.in - Measuring the efficiency of algorithms
- runestone.academy - Particularly for Big-O notation
- Advanced
- rob-bell.net - A beginner's guide to Big O notation
- youtube.com - Big O Notation, Gayle Laakman McDowell
- web.mit.edu - Big O notation
- youtube.com - Time and space complexity analysis of recursive programs - using factorial
- A very nice tutorial with examples
- Practice Problems
- Check some MCQs on space and time complexity here.
- You can see some problems with solutions here: Time complexity of an algorithm
- Basic
- Arrays
- Resources
- codechef.com - Data Structure Tutorial: Array
- cs.cmu.edu - Arrays
- geeksforgeeks.org - Arrays Data Structure
- Practice Problems
- Resources
- Strings
- Resources
- tutorialspoint.com - C++ strings
- guru99.com - Java strings
- docs.python.org - Python strings
- tutorialspoint.com - Python strings
- geeksforgeeks.org - Many string questions
- Practice Problems
- Resources
- Stack and Queue
- Resources
- geeksforgeeks.org - Stack Data Structure
- geeksforgeeks.org - Introduction and Array Implementation
- tutorialspoint.com - Data Structures Algorithms
- cs.cmu.edu - Stacks
- viterbi-web.usc.edu - Stacks and Queues
- cs.cmu.edu - Stacks and Queues
- Practice Problems
- spoj.com - JNEXT
- spoj.com - STPAR
- spoj.com - ONP
- codechef.com - COMPILER
- spoj.com - MMASS
- spoj.com - HISTOGRA
- codeforces.com - D. Maximum Xor Secondary
- spoj.com - ANARC09A
- codeforces.com - C. Minimal string
- codeforces.com - B. Alternating Current
- codeforces.com - C. Longest Regular Bracket Sequence
- Resources
- Basic math operations (addition, subtraction, multiplication, division, exponentiation)
- codechef.com - A tutorial on Fast Modulo Multiplication
- Euclid’s GCD Algorithm
- Resources
- youtube.com - Mycodeschool video
- khanacademy.org - The Euclidean Algorithm
- geeksforgeeks.org - Example program to find gcd in c++:
- Resources
- Prime Numbers, divisibility of numbers
- Resources:
- Only O(sqrt(n)) algorithm for finding whether a number is a prime, factorization of a number.
- Finding prime factors by taking the square root
- Practice Problems:
- community.topcoder.com - DivisorInc
- community.topcoder.com - Prime Polynom
- community.topcoder.com - Prime Anagrams
- community.topcoder.com - Refactoring
- Resources:
- Basic Recursion
- Resources
- topcoder.com - An Introduction to Recursion, Part 1
- topcoder.com - An Introduction to Recursion: Part 2
- geeksforgeeks.org - Recursion ;(along with questions)
- web.mit.edu - Recursion
- csee.umbc.edu - Recursion ;(Examples with exercises)
- loveforprogramming.quora.com - Backtracking, Memoization & Dynamic Programming
- byte-by-byte - Recursion for Coding Interviews
- Practice Problems
- Resources
- Greedy Algorithms
- Resources
- iarcs.org.in - Greedy Algorithms
- iarcs.org.in - Greedy Algorithms
- topcoder.com - Greedy Algorithms
- Greedy Algorithms
- Practice Problems
- codechef.com - TACHSTCK, editorial
- codechef.com - CIELRCPT, editorial
- codechef.com - MAXDIFF, editorial
- codechef.com - CHEFST, editorial
- codechef.com - CAKEDOOM, editorial
- codechef.com - CLETAB, editorial
- codechef.com - TADELIVE, editorial
- codechef.com - MANYCHEF, editorial
- codechef.com - MMPROD, editorial
- codechef.com - CHEFTMA, editorial
- codechef.com - STICKS, editorial
- spoj.com - BAISED
- spoj.com - BALIFE
- spoj.com - GCJ101BB
- codechef.com - FGFS
- codechef.com - KNPSK
- codechef.com - LEMUSIC
- spoj.com - ARRANGE
- spoj.com - FASHION
- Resources
- Dynamic programming (Basic DP)
- Resources
- medium.freecodecamp.org - Demystifying Dynamic Programming
- iarcs.org.in - Dynamic Programming - Tiling
- topcoder.com - Dynamic Programming – From Novice to Advanced
- illinois.edu - Dynamic Programming ;(Exercises are recommended)
- codechef.com - Dynamic Programming
- geeksforgeeks.org - Dynamic Programming ;(Contains a lot of practice sessions)
- MIT OCW (Contains some Advanced topics as well)
- Practice Problems
- codechef.com - ALTARAY, editorial
- codechef.com - DELISH, editorial
- codechef.com - DBOY, editorial
- codechef.com - XORSUB, editorial
- codechef.com - GRID, editorial
- codechef.com - TADELIVE, editorial
- codechef.com - FROGV, editorial
- codechef.com - MATRIX2, editorial
- codechef.com - AMSGAME2, editorial
- spoj.com - MDOLLS
- spoj.com - MSTICK
- spoj.com - MCARDS
- spoj.com - MIXTURES
- spoj.com - SAMER08D
- spoj.com - AIBOHP
- Resources
- Naive string searching
- Resources
- geeksforgeeks.org - Naive Pattern Searching
- Resources
- Sorting
- khanacademy.org
- visualgo.net
- iarcs.org.in
- Merge sort
- youtube.com - Merge sort algorithm
- Practice Problems
codechef.com -MRGSRT
- Quick sort
- youtube.com - Quicksort algorithm
- Practice Problems
codechef.com -TSORT
- Counting sort
- geeksforgeeks.org - Counting Sort
- Practice Problems
- Binary Search
- Resources
- topcoder.com (Try solving problems of Simple and Moderate level as mentioned in the end of the link)
- codechef.com
- usfca.edu
- khanacademy.org
- Detailed Theoretical analysis
- cmu.edu (A theoretical analysis)
- Problems
- geeksforgeeks.org - Binary Search (Contains some solved problems)
- codechef.com - STRSUB, editorial
- codechef.com - ASHIGIFT, editorial
- codechef.com - STACKS, editorial
- codechef.com - DIVSET, editorial
- codechef.com - LOWSUM, editorial
- codechef.com - SNTEMPLE, editorial
- codechef.com - SNAKEEAT, editorial
- codechef.com - SCHEDULE, editorial
- codechef.com - RIGHTTRI, editorial
- codechef.com - FORESTGA, editorial
- codechef.com - CHEFHCK2,editorial
- spoj.com - ABCDEF
- spoj.com - NOTATRI
- spoj.com - SCALE
- spoj.com - SUMFOUR
- spoj.com - SUBSUMS
- spoj.com - ANARC05B
- spoj.com - RENT
- spoj.com - PIE
- spoj.com - MKUHAR
- spoj.com - SVADA
- spoj.com - SUBS
- Resources
Past Test:
Practice on the exact problems which had appeared in a past DSA Foundation level exam:
- Test 1 - https://www.codechef.com/FLPAST01
Mock Test:
- Test 1 - codechef.com/FLMOCK01
- Test 2 - codechef.com/FLMOCK02
- Test 3 - codechef.com/FLMOCK03
- Test 4 - codechef.com/FLMOCK04
This level is intended to test that the one has a very good grasp of data structures and algorithms, and can solve most problems that arise in practice. You can expect problems from the following topics to come in the DSA exam.
Syllabus:
Everything in the Foundation Level, along with:
- Heaps (priority queue)
- Disjoint Set Union
- Segment Trees
- Binary Index Tree (Fenwick tree)
- Trees (traversals, tree dynamic programming)
- Finding Lowest Common Ancestors (O(log N) solution where N is number of nodes).
- Graph Algorithms:
- Finding connected components and transitive closures.
- Shortest-path algorithms (Dijkstra, Bellman-Ford, Floyd-Warshall)
- Minimum spanning tree (Prim and Kruskal algorithms)
- Biconnectivity in undirected graphs (bridges, articulation points)
- Strongly connected components in directed graphs
- Topological Sorting
- Euler path, tour/cycle.
- Modular arithmetic including division, inverse
- Amortized Analysis
- Divide and Conquer
- Advanced Dynamic Programming problems (excluding the dp optimizations which are added in expert level)
- Sieve of Eratosthenes
Learning Resources:
- Heaps (priority queue)
- Resources
- Practice Problems
- codechef.com - IPCTRAIN, editorial
- codechef.com - ANUMLA, editorial
- codechef.com - KSUBSUM, editorial
- codechef.com - RRATING, editorial
- codechef.com - TSECJ05, editorial
- spoj.com - WEIRDFN
- codechef.com - CAPIMOVE, editorial
- spoj.com - RMID2
- spoj.com - LAZYPROG
- spoj.com - EXPEDI
- acm.timus.ru
- baylor.edu - Maze Checking and Visualization
- codechef.com - MOSTDIST, editorial
- Disjoint Set Union
- Resources
- Practice Problems
- codechef.com - GALACTIK, editorial
- codechef.com - DISHOWN, editorial
- codechef.com - JABO, editorial
- codechef.com - PARITREE, editorial
- codechef.com - FILLMTR, editorial
- B. Mike and Feet
- D. Quantity of Strings
- codechef.com - SETELE, editorial
- codechef.com - MAZE, editorial
- codechef.com - MAGICSTR, editorial
- codechef.com - MTRWY, editorial
- codechef.com - BIGOF01, editorial
- codechef.com - FIRESC, editorial
- Segment Trees
- Resources
- Practice Problems
- spoj.com - GSS1
- spoj.com - GSS2
- codeforces.com - Classic Segment Tree (Expert Level)
- spoj.com - IOPC1207
- spoj.com - ORDERSET
- spoj.com - HELPR2D2
- spoj.com - ANDROUND
- spoj.com - HEAPULM
- spoj.com - NICEDAY
- spoj.com - YODANESS
- spoj.com - DQUERY
- spoj.com - KQUERY
- spoj.com - FREQUENT
- spoj.com - GSS3
- spoj.com - GSS4
- spoj.com - GSS5
- spoj.com - KGSS
- spoj.com - HELPR2D2
- spoj.com - BRCKTS
- spoj.com - CTRICK
- spoj.com - MATSUM
- spoj.com - RATING
- spoj.com - RRSCHED
- spoj.com - SUPPER
- spoj.com - ORDERS
- codechef.com - LEBOBBLE
- codechef.com - QUERY
- spoj.com - TEMPLEQ
- spoj.com - DISUBSTR
- spoj.com - QTREE
- spoj.com - QTREE2
- spoj.com - QTREE3
- spoj.com - QTREE4
- spoj.com - QTREE5
- Problems on segment tree with lazy propagation
- spoj.com - HORRIBLE (must do basic lazy propagation problem)
- spoj.com - LITE (a nice lazy propagation problem)
- spoj.com - MULTQ3 (another nice lazy propagation problem)
- codechef.com - CHEFD
- codechef.com - FUNAGP (a difficult lazy propagation problem.)
- RPAR (a difficult and nice lazy propagation)
- codechef.com - ADDMUL
- spoj.com - SEGSQRSS (a difficult lazy propagation problem)
- spoj.com - KGSS
- codeforces.com - C. Circular RMQ
- codeforces.com - E. Lucky Queries (must do hard problem on lazy propagation)
- codeforces.com - E. A Simple Task
- codeforces.com - C. DZY Loves Fibonacci Numbers (important problem to do, introduces some nice properties over lazy propagation)
- codeforces.com - D. The Child and Sequence
- codeforces.com - E. Lucky Array
- Binary Index Tree (Fenwick tree)
- Resources
- Practice Problems:
Please solve the problems mentioned in the above segment tree practice problems section. Note that usually, it's difficult to do range updates in binary indexed trees. Mostly, it is used for for range query and point update. However, you can check the following article for checking how some simple specific kind of range updates can be performed on binary indexed tree (http://petr-mitrichev.blogspot.in/2013/05/fenwick-tree-range-updates.html). Note that range updates on BIT is not a part of the syllabus.
- Trees (traversals)
- Resources
- Practice Problems
- spoj.com - TREEORD
- Finding Lowest Common Ancestors (O(log N) solution where N is number of nodes)
- Resources
- Depth First Search, Breadth First Search (Finding connected components and transitive closures)
- Resources
- geeksforgeeks.org - Connected Components in an undirected graph
- geeksforgeeks.org - Transitive closure of a graph
- geeksforgeeks.org - Depth First Traversal or DFS for a Graph
- iarcs.org.in - Basic Graph Algorithms
- visualgo.net - Graph Traversal
- harvard.edu - Breadth-First Search
- Practice Problems
- codechef.com - FIRESC, editorial
- spoj.com - BUGLIFE
- spoj.com - CAM5
- spoj.com - GCPC11J
- spoj.com - KFSTB
- spoj.com - PT07Y
- spoj.com - PT07Z
- spoj.com - LABYR1
- spoj.com - PARADOX
- spoj.com - PPATH ;(must do bfs problem)
- spoj.com - ELEVTRBL (bfs)
- spoj.com - QUEEN (bfs)
- spoj.com - SSORT ;(cycles in a graph)
- spoj.com - ROBOTGRI ;(bfs)
- Resources
- Shortest-path algorithms (Dijkstra, Bellman-Ford, Floyd-Warshall)
- Resources
- geeksforgeeks.org - Dijkstra’s shortest path algorithm
- Iarcs.org.in - Shortest paths
- Visualgo.net - Single-Source Shortest Paths (SSSP)
- Practice Problems
- codechef.com - DIGJUMP, editorial
- codechef.com - AMR14B, editorial
- codechef.com - INSQ15_F, editorial
- codechef.com - SPSHORT, editorial (slightly difficult dijkstra's problem.)
- codechef.com - RIVPILE, editorial
- spoj.com - SHPATH
- spoj.com - TRAFFICN
- spoj.com - SAMER08A
- spoj.com - MICEMAZE
- spoj.com - TRVCOST
- codechef.com - PAIRCLST, editorial
- Resources
- Bellman Ford Algorithm
- Resources
- geeksforgeeks.org - Dynamic Programming - Bellman–Ford Algorithm
- compprog.wordpress.com - ;One Source Shortest Path - Bellman-Ford Algorithm
- Practice Problem
- community.topcoder.com - PeopleYouMayKnow
- codeforces.com - D. Robot Control
- spoj.com - ARBITRAG - Arbitrage ;(Floyd Warshall)
- community.topcoder.com - NetworkSecurity ;(Floyd Warshall)
- Resources
- Minimum spanning tree (Prim and Kruskal algorithms)
- Resources
- algs4.cs.princeton.edu - Minimum Spanning Trees
- iarcs.org.in - Spanning trees
- visualgo.net - Spanning Tree
- Practice Problem
- Resources
- Biconnectivity in undirected graphs (bridges, articulation points)
- Resources
- e-maxx-eng.appspot.com - Finding Bridges in a Graph
- iarcs.org.in - Articulation Points
- pisces.ck.tp.edu.tw - Articulation Points
- Practice Problem
- uva.onlinejudge.org - Network
- icpcarchive.ecs.baylor.edu - Building Bridges
- uva.onlinejudge.org - Tourist Guide
- tzcoder.cn - Network
- spoj.com - EC_P - Critical Edges
- spoj.com - SUBMERGE - Submerging Islands
- spoj.com - POLQUERY - Police Query
- codeforces.com - A. Cutting Figure
- Resources
- Strongly connected components in directed graphs
- Resources
- iarcs.org.in - Strongly connected components
- theory.stanford.edu - Strongly Connected Components
- Practice Problem
- Resources
- Topological Sorting
- Resources
- geeksforgeeks.org - Topological Sorting
- Practice Problem
- Resources
- Euler path, tour/cycle.
- Resources
- math.ku.edu - Euler Paths and Euler Circuits
- Practice Problem
- spoj.com - WORDS1
- codechef.com - CHEFPASS, editorial
- codechef.com - TOURISTS, editorial
- codeforces.com - D. New Year Santa Network
- B. Strongly Connected City
- codechef.com - PEOPLOVE
- codeforces.com - D. Tanya and Password
- codeforces.com - E. One-Way Reform
- spoj.com - GCPC11C
- spoj.com - MAKETREE
- Resources
- Modular arithmetic including division, inverse
- Resources
- codechef.com - Fast Modulo Multiplication (Exponential Squaring)
- codechef.com - Best known algos for calculating nCr % M ;(only for expert level)
- Resources
- Amortized Analysis
- Resources
- ocw.mit.edu - Amortized Analysis
- wikipedia.org - Amortized Analysis
- iiitdm.ac.in - Amortized Analysis
- Resources
- Divide and Conquer
- Advanced Dynamic Programming problems (excluding the dp optimizations which are added in expert level, Please go through the basic DP resources and problems mentioned in foundation level resource.)
- Resources
- apps.topcoder.com - Commonly used DP state domains
- apps.topcoder.com - Introducing Dynamic Programming
- apps.topcoder.com - Optimizing DP solution
- codeforces.com - DP over Subsets and Paths
- Problems for Advanced DP
- spoj.com - HIST2 ;(dp bitmask)
- spoj.com - LAZYCOWS ;(dp bitmask)
- spoj.com - TRSTAGE ;(dp bitmask)
- spoj.com - MARTIAN
- spoj.com - SQRBR
- spoj.com - ACMAKER
- spoj.com - AEROLITE
- spoj.com - BACKPACK
- spoj.com - COURIER
- spoj.com - DP
- spoj.com - EDIST
- spoj.com - KRECT
- spoj.com - GNY07H
- spoj.com - LISA
- spoj.com - MINUS
- spoj.com - NAJKRACI
- spoj.com - PHIDIAS
- spoj.com - PIGBANK
- spoj.com - PT07X
- spoj.com - VOCV
- spoj.com - TOURIST
- spoj.com - MKBUDGET
- spoj.com - MMAXPER
- spoj.com - ANARC07G
- spoj.com - MENU
- spoj.com - RENT ;(dp with segment tree/BIT)
- spoj.com - INCSEQ ;(dp with segment tree/BIT)
- spoj.com - INCDSEQ ;(dp with segment tree/BIT)
- You can solve some advanced problems from
- codeforces.com - Dynamic Programming Type
- Resources
- Sieve of Eratosthenes
- Resources:
- codechef.com - Sieve Methods
- Practice Problems
- spoj.com - TDKPRIME
- spoj.com - TDPRIMES
- spoj.com - ODDDIV ;(sieve + binary search)
- spoj.com - NDIVPHI ;O(N) prime testing algorithm)
- spoj.com - DIV ;(divisor sieve)
- codechef.com - LEVY, editorial
- codechef.com - PRETNUM, editorial
- codechef.com - KPRIME, editorial
- codechef.com - DIVMAC, editorial (segment tree with sieve)
- codechef.com - PPERM, editorial ;(a bit advanced sieve application)
- Resources:
- General
Past Test:
Practice on the exact problems which had appeared in a past Advanced level exam:
- Test 1 - https://www.codechef.com/ALPAST01
Mock Test:
- Test 1 - https://www.codechef.com/ADMOCK01
- Test 2 - https://www.codechef.com/ADMOCK02