
This course includes our updated coding exercises so you can practice your skills as you learn.
See a demo
Launch into data structures and algorithms essentials in C++, with hands-on implementations and real problem solving. Build a solid programming foundation and a shopping cart backend through practical projects.
Maximize your learning by actively using all Udemy tools, doing coding exercises, practicing common patterns like 2D and 1D prefix sums, and engaging with TAs and the community.
Learn how arrays store elements of the same type in contiguous memory, indexed from zero, with examples in integers, characters, and 2D arrays, including input, output, and update operations.
Learn to implement a simple c++ array for input and output with cin and cout, including reading marks for n students, updating values, and initialization considerations to avoid garbage.
Explore pass by reference for arrays in C++, showing how functions receive the array address, not a copy, and how to use n to track elements.
Implement linear search to locate a key in an array, returning its index or -1 if absent. Recognize it as a brute force technique with O(n) time.
Learn how binary search finds elements in sorted arrays by halving the search range with a middle index, comparing to the target, and returning the index or -1.
Implement binary search by maintaining start, end, and mid to locate a key in a sorted array, returning its index or -1 when not found, with O(log n) time.
learn to reverse an array in place by swapping symmetric elements from the ends toward the middle, achieving order of n time and order of one space.
Print all unique pairs from an array using two nested loops with i and j starting from i+1. Explore index-based and for each loop approaches to form and print pairs.
Print subarrays by i, j, and k loops to output elements from i to j. Subarrays are consecutive, about n^2, with O(n^3) time; homework: print sums and largest sum.
The lecture uses a brute force approach to find the largest subarray sum by checking all subarrays with three loops, updating the current and largest sums, and revealing O(n^3) time.
Use prefix sums to optimize the largest subarray sum problem, building a prefix sum array and computing subarray sums in constant time to reduce time from O(n^3) to O(n^2).
Learn Kadane's algorithm to solve the maximum subarray sum problem by maintaining a running current sum and a maximum sum, discarding negative sums.
Explore vectors as dynamic, continuous memory 1D/2D arrays from the standard template library that grow automatically by doubling, with copies on reallocation, and learn passing by value or by reference.
Explore vectors in C++, creating vector<int> and inspecting size and capacity while using push_back. Print elements with a loop, learn to pop_back, insert, erase, and fill constructors for 2-d vectors.
Explore the solution for finding the largest element in a vector and compare it to arrays, highlighting vectors as a practical learning point in C++.
Apply kadane's algorithm to compute the maximum subarray sum, handling the all-negative case by choosing the largest element. Maintain a current sum, reset to zero when negative, and track maximum.
Implement a modified binary search to compute the lower bound in a sorted array, updating the answer when mid is less than or equal to the value and narrowing search.
Using a sorted array, move two pointers from the ends to find the pair whose sum is closest to x, updating the best pair as you go.
Explore solving k rotate clockwise by using k mod n, then build a new vector with the last k elements followed by the first n−k elements, noting a second approach.
Rotate an array in place by three reversals: reverse the first n-k elements, reverse the last k elements, and reverse the entire array, achieving in-place k-rotation without extra space.
Explore how sorting algorithms organize everyday items, from fruits to books, and begin with bubble, selection, and insertion sort, while previewing counting, merge, quick, and heap sort.
bubble sort moves the largest element to the end by repeatedly swapping adjacent elements in an unsorted array, using two nested loops that compare a[j] and a[j+1].
Implement bubble sort in C++ with two loops, repeat n minus one times, swap a[j] and a[j+1] when needed, and print the sorted array with cout.
Explore insertion sort, a simple sorting algorithm inspired by card games, and learn how to insert each element into its proper position by shifting larger items.
Implement insertion sort in C++, inserting the current element into its correct position in the array by shifting larger elements, iterating from index one to n minus one.
Identify the minimum in the unsorted part, swap it into the current position, and progressively sort the array from left to right using a simple selection sort.
Explain and implement selection sort in C++ by repeatedly finding the minimum in the unsorted portion and swapping it into place, using an outer loop to n-2.
Explore C++'s inbuilt sort algorithm from the algorithm header, its N log N performance, and how to use comparators or built-in options like reverse and greater to control order.
Learn counting sort, a linear-time sorting technique using a frequency count array to sort data within a known range, illustrated with exam marks 0 to 100 and frequency-based placement.
Learn counting sort by locating the largest element to define the range, building a frequency vector, and copying results back with linear time complexity O(n + range).
Explore character arrays in C++, declare and initialize them with a null character, and learn cout, strlen, sizeof, and cin input nuances.
Explore how cin.get reads input character by character, including spaces and newlines, fills a character array, and uses a stop condition such as a hash or newline to determine length.
Count alphabets, digits, and spaces in an input sentence with C++ by reading one character at a time using cin.get until newline and updating counters.
Discover how cin.getline reads an entire line into a sentence array, replaces the newline with a terminator, and compares with cin.get for large inputs or paragraphs.
Parse a directional string on a 2-D grid to compute the final displacement in x and y, then convert it to the shortest route using north, south, east, and west.
Explore c style strings in c++, learn to measure length with strlen (null terminated), copy with the string copy function, compare with the string compare function, and concatenate with strcat.
The lecture shows how to find the largest string by scanning N inputs with two variables: the current string and the largest so far, comparing by length and updating accordingly.
Explore how strings work in C++ by using the string class instead of character arrays, with getline input, vector<string> storage, and iterating over characters.
Implement run length encoding to compress a string by counting consecutive characters and emitting character plus count; select the shorter between encoded and original, in linear time using C++ strings.
Explore how multidimensional arrays extend 1-D arrays to 2-D, 3-D and beyond, with real-life examples like student marks, image pixels, and video data used in machine learning.
Create and input a 2-D array in c++, with n rows and m columns, and print it row by row while exploring zero-based indexing and row major memory layout.
Learn how to define and initialize a 2-D character array in C++, store each row as a string, and print specific rows or iterate through all rows using cout.
Print a 2D array in spiral order from the top-left corner by traversing the boundary. Manage start and end row and column indices to complete inner boundaries and avoid duplicates.
Implement staircase search to locate a key in a matrix, returning a pair of row and column indices or -1,-1 when not found, starting from the top-right.
Compare brute force and optimized 2D prefix sum approaches to partition an n x n grid into quadrants with a horizontal and a vertical cut, maximizing Rahul’s minimum mango trees.
Analyze a 2d matrix sorted by rows and columns to search for a target element. Follow staircase search that achieves linear time by moving left or down from a corner.
Discover how the address of operator yields a variable's memory address, and how dereference and reference variables relate to pointers in c++, with hexadecimal printing via cout.
Learn how a pointer stores the address of another variable and how to use the address-of operator to assign it. Explore int pointers, pointer to a pointer, and dereference concepts.
Master the dereference operator, shown as a star, to access the value pointed to by a pointer and understand the risk of null pointers causing segmentation faults.
Explore how reference variables in C++ create aliases for the same object, enabling pass-by-reference and showing that x and y share memory and must be initialized.
Explore pass by reference with reference variables in C++, using an income tax example to show how the original income updates due to shared memory, unlike pass by value.
Learn how to implement pass by reference in c++ using pointers and the dereference and address-of operators to increment a video’s view count in place, with a void return.
Master dynamic memory allocation in C++. Distinguish stack and heap memory, allocate at runtime with new, and free with delete while preventing memory leaks.
Demonstrate creating a dynamic array with new, initializing and printing its elements, then deleting it to free heap memory while noting potential pointer and data issues after deletion.
Explore creating a 2d dynamic array in C++ by allocating each row as a 1d array, using an int**, and returning the 2d array to main for access.
Explore vectors as dynamic sequence containers in C++, contrast with fixed-size arrays, and learn both using the standard template library and building your own vector header to understand implementation.
Vectors grow by doubling capacity when full, copying elements to a new memory block and freeing the old one; pushback has amortized constant time with occasional linear reallocations.
Master vector creation and core operations in c++ by exploring size versus capacity, push_back and pop_back, insert and erase, fill constructors, and 2d vectors through practical initializations.
The lecture shows how a 2d vector, a vector of vectors, replaces a 2d array. It uses index-based and for-each loops to print elements and update a specific element.
Implement a vector class in c++ with pushback, popback, and front/back access, backed by a dynamic array that doubles capacity when full, plus size, capacity, and operator[].
Explore how vector push back adapts. Full vectors reallocate with doubled capacity, copy elements, and delete old array; non-full inserts at the next index and updates current size.
Explore a c++ vector class extension with front, back, at, size and capacity queries, push back, and pop back, and operator overloading with const correctness.
Convert your data structure into a reusable header file, import it in multiple programs, and keep the code generic by using templates to support any data type.
Use the inbuilt find function from the algorithm header to search arrays or vectors, returning an iterator; derive index by subtracting begin and compare to end to detect not found.
Sort a complex student data structure—name paired with a vector of marks—using a custom comparator to rank by total marks with the C++ sort function.
Explore bitwise operators in C++ to manipulate data at the binary level, including and, or, xor, not, and left/right shifts. Understand how two's complement enables negation and representation.
Explore binary left shift and right shift in C++. Left shift multiplies by two to the power, while right shift divides by two to the power, with simple examples.
Learn to determine odd or even in C++ using the bitwise and with 1, recognizing that odd numbers have last bit one and contrasting with modulus two.
learn how to get the ith bit of a number using bitwise operations in c++, by creating a mask with 1 left shifted by i and AND-ing with the number.
Learn to set the ith bit using a mask (1 left shift i) and update n with a bitwise or, as 5 becomes 7 when the first bit is set.
Shows clearing ith bit with a mask that has zero at that position and ones elsewhere, then and-ing the number to preserve bits, as 13 becomes 9 when clearing bit.
Update the ith bit of a number by clearing it, building a mask for the desired value, and applying bitwise operations to set it to 0 or 1.
Learn to clear the last i bits of a number in C++ by creating a mask with minus one left-shifted by i and bitwise AND-ing it with the number.
Learn to clear bits in a range i to j by constructing a mask with ones outside the range and zeros inside, then apply it to the number.
Learn to replace bits in a 32-bit number by clearing the bit range from J to I, creating a mask from M, and OR-ing the shifted M into N.
Determine whether a number is a power of two by using a bitwise and of n and n minus one, which yields zero when n is a power of two.
Count the set bits in a number by inspecting the least significant bit, incrementing the count when it is one, and right-shifting until zero.
Demonstrates a hack to count set bits by using n and n minus one, removing the last set bit each iteration, so total iterations equal the number of set bits.
Master fast exponentiation by using binary representation and bit masking to compute a^n in logarithmic time, multiplying by the current power when bits are set and squaring each step.
Convert a decimal number to binary using bitwise operators by extracting the last bit, updating the answer with powers of ten, and right-shifting the input.
Explore recursion basics by breaking complex problems into smaller subproblems, solve them via base and recursive cases, and combine results using factorial and call stack examples.
Compute factorials with recursion using a base case of zero returning one. Apply the recursive step n multiplied by factorial(n-1) and explore the call stack and linear time and space.
Explore recursion through the fibonacci series by implementing a two-call recursive function for F(n-1) and F(n-2), examining base cases, call stack, and exponential time with linear space.
Explore a recursive solution to check if an array is sorted in c++, comparing adjacent elements and validating the remaining subarray, with a single element base case.
Explore recursion by printing numbers from 1 to n in decreasing and increasing order. Learn how base cases and pre- or post-recursive calls shape the output.
Implement a recursive function to find the first occurrence of a key in an array using a linear search, returning the correct index or minus one if not found.
Learn to find the first occurrence of a key with a recursive approach that reduces the problem size, checks the zeroth index, and returns the index or minus one.
Learn to find the last occurrence of a key in an array using a recursive approach that checks the subproblem first and returns the index or -1.
Demonstrate a recursive last occurrence solution in an array, with a base case returning -1 when absent, and a subindex that computes the final index, comparing to the first occurrence.
Explore how to compute a raise to the power n using a recursive approach with base case n equals zero returning one, and note its linear time and space complexity.
Explore exponentiation by squaring to optimize the power function, reducing time and space complexity to logarithmic by solving a recurrence that halves n and handles odd and even powers.
Explore converting bubble sort from iterative loops to recursive implementations in C++. Learn outer- and inner-loop recursion with base cases and practical notes.
present a recursive method that prints the word for each digit of a number, using n mod 10 and n/10 with a base case when the number reaches zero.
Explore solving a board filling problem with 4-unit tiles by deriving a recurrence, comparing vertical and horizontal placements, identifying base cases, and recognizing overlapping subproblems for dynamic programming.
determine the number of binary strings of length n with no consecutive ones using f(n)=f(n-1)+f(n-2), with recursion, dp, and matrix exponentiation techniques.
Explore the friends pairing problem with recursion, deriving f(n)=f(n-1)+(n-1)f(n-2) and base cases, then apply memoization to reach linear time via dynamic programming.
Are you a beginner looking to enter the world of Data Structures or intermediate programmer wondering what happens behind a Hash-table?
Welcome to Data Structures & Algorithms, Essentials Course - the only course you need to understand the core concepts behind Data Structures & build a solid programming foundations using C++ . The course is taught by an expert instructor Prateek Narang from Google, who is not just a software engineer but also has mentored thousands of students in becoming great programmers & developers and is top rated on Udemy for his amazing teaching skills.
Every software application revolves around data, performing different operations like Insert, Delete, Update & Search. To be a great software developer, understanding of Data Structures & Algorithms is must and this course provides you a deep understanding of the topic by covering both the theory and hands-on-implementation of each data structure from scratch.
The Course contains 20+ hours of interactive video content & dozens of coding exercises, teaching you all essential concepts starting from ground zero. Each section covers data structure in great detail, with Coding Exercises & real life examples. Here is what you will learn -
Programming Concepts
Bit masking
Object Oriented Programming Basics
Pointers & Dynamic Memory (C++)
Recursion
Data Structures Foundation
Array, 2D Array, Strings, Vectors
Linked Lists, Stacks, Queues
Trees, BST, Tries
Heaps/Priority Queues
Hash-tables, Collision Handling
Graphs
Algorithms Foundation
Brute Force, Backtracking
Sorting & Searching
Divide & Conquer
Dynamic Programming
The course is designed for beginner & intermediate programmers. We try to make not so easy topics look easy with intuitive explanations & interactive video lectures with dozens of memes ;) The course finishes with a final mini project - a command line app for an online shopping cart combining principles from Object Oriented Programming & Data Structures.
Unlike most instructors, we are not a salesperson or a marketer. My job is to help you build strong fundamentals in programming & be a successful developer. Through Udemy & Coding Minutes, I am providing this course to you at a fraction of cost of its original cost, so that anyone who is interested to learn can take their skills to the next level. So I hope you sign up today, and I will see you in the course.