(FPT Software) DSA & Programming Study Guide For Entry Test
(FPT Software) DSA & Programming Study Guide For Entry Test
Ent ry T e st
Hanoi, 03/2025
Entry Test DSA & Programming Languages Issue/Revision: 1/1
RECORD OF CHANGES
Contents
DSA & Programming Study Guide ............................................................................................................................... 4
1. Data Structures and Algorithms Study Guide .................................................................................................... 4
1.1. Array ............................................................................................................................................................ 4
1.2. String ........................................................................................................................................................... 5
1.3. Stack ............................................................................................................................................................ 6
1.4. Queue .......................................................................................................................................................... 7
1.5. LinkesList ..................................................................................................................................................... 8
1.6. Tree ............................................................................................................................................................. 9
1.7. HashSet ..................................................................................................................................................... 10
1.8. HashTable .................................................................................................................................................. 12
1.9. Graph ......................................................................................................................................................... 13
1.10. Heap ..................................................................................................................................................... 14
1.11. Sort Algorithms ..................................................................................................................................... 16
1.12. Search Algorithms ................................................................................................................................ 18
1.13. Recursion Algorithm ............................................................................................................................. 19
2. Programming Languages Review Guide .......................................................................................................... 21
Table of Contents .................................................................................................................................................. 21
3.1. Control Flow Statements ........................................................................................................................... 21
3.2. Variables and Data Types .......................................................................................................................... 22
3.3. Classes and Objects ................................................................................................................................... 23
3.4. Methods and Functions............................................................................................................................. 24
3. Related Knowledge ......................................................................................................................................... 25
3.1. Mathematics ............................................................................................................................................. 25
3.2. Matrix Operations ..................................................................................................................................... 26
3.3. Regular Expressions (Regex) ...................................................................................................................... 27
3.4. Geometry .................................................................................................................................................. 28
3.5. Combinatorics ........................................................................................................................................... 29
3.6. Sequences ................................................................................................................................................. 29
3.7. Linear Algebra ........................................................................................................................................... 30
Common Operations
• Access: array[index]
• Insertion: Shift elements and insert (O(n))
• Deletion: Remove and shift elements (O(n))
• Traversal: Visit each element in sequence
Applications
Reference Materials
Challenge Questions:
1. Find the largest and second largest element in an array in a single traversal.
2. Rotate an array by k positions to the right.
3. Find the missing number in an array containing 1 to n with one missing value.
4. Merge two sorted arrays into one sorted array.
5. Find if there exists a pair in array with given sum.
6. Find the maximum subarray sum (Kadane's algorithm).
7. Find the equilibrium index of an array (where sum of elements on left equals sum on right).
8. Rearrange an array such that arr[i] becomes arr[arr[i]].
9. Find the smallest positive number missing from an unsorted array.
10. Implement array manipulation to solve the Dutch National Flag problem.
1.2. String
Strings are sequences of characters used to represent text. They can be viewed as arrays of characters with special
operations designed for text processing.
Key Concepts
Common Operations
• Length: string.length()
• Access: string[index] or string.charAt(index)
• Substring: string.substring(start, end)
• Concatenation: string1 + string2
String Algorithms
• Pattern Matching: Naive approach, Knuth-Morris-Pratt (KMP), Boyer-Moore
• String Manipulation: Tokenization, reversal, rotation
• String Comparison: Lexicographical comparison, edit distance
Reference Materials
• GeeksforGeeks - String
• Leetcode String Problems
Challenge Questions
1. Implement an algorithm to determine if a string has all unique characters.
2. Write a function to check if one string is a permutation of another.
3. Implement a method to perform basic string compression (e.g., "aabcccccaaa" to "a2b1c5a3").
4. Check if a string is a palindrome (reads the same forward and backward).
5. Find the longest palindromic substring in a given string.
6. Implement an algorithm to find the first non-repeated character in a string.
7. Write a function to reverse words in a string (e.g., "Hello World" to "World Hello").
8. Check if two strings are anagrams of each other.
9. Implement a function to validate if a string has balanced parentheses.
10. Find all permutations of a given string.
Practice Code Links
1. LeetCode: Valid Anagram
2. LeetCode: Longest Substring Without Repeating Characters
1.3. Stack
A stack is a linear data structure that follows the Last-In-First-Out (LIFO) principle. Elements can only be added or
removed from the top of the stack.
Key Concepts
• LIFO Principle: Last element added is the first one to be removed
• Operations: Push (add to top), Pop (remove from top), Peek (view top without removing)
• Implementation: Using arrays or linked lists
• Time Complexity:
✓ Push: O(1)
✓ Pop: O(1)
✓ Peek: O(1)
✓ Search: O(n)
Common Operations
• Push: stack.push(element)
• Pop: stack.pop()
• Peek/Top: stack.peek() or stack.top()
• isEmpty: stack.isEmpty()
• Size: stack.size()
Applications
• Function call management (call stack)
• Expression evaluation and conversion
• Backtracking algorithms
• Undo mechanisms in applications
• Browser history
• Syntax parsing
Reference Materials
• Stack Data Structure
• Programiz Stack Tutorial
Challenge Questions
1. Implement a stack using an array.
2. Implement a stack using a linked list.
3. Design a stack that supports getMin() operation in O(1) time.
4. Evaluate a postfix expression using a stack.
5. Convert infix expression to postfix expression.
6. Check if parentheses in an expression are balanced.
7. Implement a function to reverse a string using a stack.
8. Implement the "undo" functionality using a stack.
1.4. Queue
A queue is a linear data structure that follows the First-In-First-Out (FIFO) principle. Elements are added at the rear
and removed from the front.
Key Concepts
• FIFO Principle: First element added is the first one to be removed
• Operations: Enqueue (add to rear), Dequeue (remove from front), Front/Peek (view front)
• Implementation: Using arrays, linked lists, or circular arrays
• Time Complexity:
o Enqueue: O(1)
o Dequeue: O(1)
o Front/Peek: O(1)
o Search: O(n)
Common Operations
Variants
• Circular Queue: Uses a circular array for efficient implementation
• Double-ended Queue (Deque): Allows insertion and deletion at both ends
• Priority Queue: Elements have priorities and are dequeued in order of priority
Applications
• CPU/Disk scheduling
• Breadth-First Search algorithm
• Task scheduling
• Message buffers
• IO Buffers
• Print job scheduling
Reference Materials
• Queue Data Structure
• Programiz Queue Tutorial
Challenge Questions
1. Implement a queue using an array.
2. Implement a queue using a linked list.
3. Implement a circular queue.
4. Implement a queue using two stacks.
5. Design a queue that supports getMin() operation in O(1) time.
6. Implement a sliding window algorithm using a queue.
7. Generate binary numbers from 1 to n using a queue.
8. Implement a queue data structure which supports peek(), poll(), add(), and retrieving the minimum element
in constant time.
9. Implement a Josephus problem solution using a queue.
10. Design a data structure for implementing an LRU (Least Recently Used) cache.
Practice Code Links
1. LeetCode: Implement Queue using Stacks
2. LeetCode: Design Circular Queue
3. LeetCode: Number of Recent Calls
4. LeetCode: Design Circular Deque
5. LeetCode: Moving Average from Data Stream
6. LeetCode: Perfect Squares (BFS using queue)
7. LeetCode: Rotting Oranges
8. LeetCode: Walls and Gates
9. LeetCode: Open the Lock
10. LeetCode: Sliding Window Maximum
1.5. LinkesList
A linked list is a linear data structure consisting of nodes, where each node contains data and a reference (link) to the
next node in the sequence.
Key Concepts
• Node Structure: Data + Next pointer (and Previous pointer in doubly linked lists)
• Types:
o Singly Linked List: Each node points to the next node
o Doubly Linked List: Each node points to both next and previous nodes
o Circular Linked List: Last node points back to the first node
• Time Complexity:
o Access: O(n)
o Search: O(n)
o Insertion/Deletion at beginning: O(1)
o Insertion/Deletion at end: O(n) for singly, O(1) for doubly with tail pointer
o Insertion/Deletion at middle: O(n) to find position, O(1) to insert/delete
Common Operations
Applications
• Implementation of other data structures (stacks, queues, graphs)
• Dynamic memory allocation
1.6. Tree
A tree is a hierarchical data structure consisting of nodes connected by edges. Each tree has a root node, and every
node can have child nodes.
Key Concepts
• Tree Terminology: Root, Parent, Child, Leaf, Internal Node, Height, Depth
• Types:
✓ Binary Tree: Each node has at most two children
✓ Binary Search Tree (BST): Left child < Parent < Right child
✓ AVL Tree: Self-balancing BST
✓ Red-Black Tree: Self-balancing BST with color properties
✓ B-Tree: Self-balancing search tree (not binary)
✓ Trie (Prefix Tree): Specialized tree for string operations
• Tree Traversal:
✓ Depth-First: Preorder (Root-Left-Right), Inorder (Left-Root-Right), Postorder (Left-Right-Root)
✓ Breadth-First: Level Order Traversal
Common Operations (for BST)
Applications
• Hierarchical data representation (file systems, organization charts)
• Expression evaluation
• Searching and sorting
• Network routing algorithms
• Decision trees in machine learning
• Syntax trees in compilers
Reference Materials
• Tree Data Structure
• Binary Tree and BST
Challenge Questions
1. Implement a binary search tree with operations: insert, delete, search.
2. Implement different tree traversal methods (preorder, inorder, postorder, level order).
3. Check if a binary tree is a binary search tree.
4. Find the lowest common ancestor of two nodes in a binary tree.
5. Calculate the height and diameter of a binary tree.
6. Implement a function to check if a binary tree is balanced.
7. Serialize and deserialize a binary tree.
8. Convert a binary search tree to a sorted doubly linked list.
9. Implement an algorithm to find the kth smallest element in a BST.
10. Construct a binary tree from given inorder and preorder traversal.
Practice Code Links
1. LeetCode: Maximum Depth of Binary Tree
2. LeetCode: Validate Binary Search Tree
3. LeetCode: Binary Tree Level Order Traversal
4. LeetCode: Symmetric Tree
5. LeetCode: Path Sum
6. LeetCode: Lowest Common Ancestor of a Binary Tree
7. LeetCode: Binary Tree Zigzag Level Order Traversal
8. LeetCode: Construct Binary Tree from Preorder and Inorder Traversal
9. LeetCode: Convert Sorted Array to Binary Search Tree
10. LeetCode: Kth Smallest Element in a BST
1.7. HashSet
A HashSet is a data structure that implements a set abstract data type, storing unique elements with no particular order.
It uses a hash function to map elements to indices in an underlying array.
Key Concepts
Common Operations
• Add: hashSet.add(element)
• Remove: hashSet.remove(element)
• Contains: hashSet.contains(element)
• Size: hashSet.size()
• Clear: hashSet.clear()
Applications
• Removing duplicates
• Membership testing
• Mathematical set operations (union, intersection, difference)
• Counting distinct elements
• Caching data
Reference Materials
• HashSet in Java
• Set Implementation
Challenge Questions
7. Design a data structure that can add, remove, and check if an element is present in O(1) time.
1.8. HashTable
A HashTable (also called HashMap or Dictionary) is a data structure that maps keys to values using a hash function. It
enables efficient lookup, insertion, and deletion operations.
Key Concepts
• Key-Value Pairs: Data is stored as key-value pairs
• Hash Function: Converts keys into array indices
• Collision Handling: Methods like chaining (linked lists) or open addressing
• Load Factor: Ratio of number of entries to table size
• Rehashing: Resizing the hash table when load factor exceeds a threshold
• Time Complexity:
o Insert: O(1) average
o Delete: O(1) average
o Search: O(1) average
o Worst case: O(n) for all operations (due to collisions)
Common Operations
Applications
• Database indexing
• Caches
• Symbol tables in compilers
• Associative arrays
• Counting frequency of items
• Implementing sets
Reference Materials
• Hash Table Data Structure
• Programiz Hash Table Tutorial
Challenge Questions
1. Implement a HashTable from scratch with operations: put, get, remove.
2. Handle collisions in a HashTable using chaining with linked lists.
3. Implement an LRU cache using a HashTable and a doubly linked list.
4. Design a data structure to find the most frequent element in a stream.
5. Check if two strings are anagrams using a HashTable.
6. Implement a function to find all pairs in an array that sum to a target value.
7. Design a data structure that supports insert, delete, and getRandom in O(1) time.
8. Implement a method to find the first non-repeating character in a string.
9. Design a HashTable that uses linear probing for collision resolution.
10. Implement a spell checker using a HashTable.
Practice Code Links
1. Two Sum
2. Happy Number
3. Isomorphic Strings
4. Group Anagrams
5. Word Pattern
7. Contains Duplicate
8. Valid Sudoku
1.9. Graph
A graph is a non-linear data structure consisting of vertices (nodes) and edges that connect pairs of vertices. Graphs
can represent many real-world relationships and networks.
Key Concepts
• Components: Vertices (nodes) and Edges (connections)
• Types:
o Directed vs. Undirected
o Weighted vs. Unweighted
o Cyclic vs. Acyclic
o Connected vs. Disconnected
o Simple vs. Multi-graph
• Representations:
o Adjacency Matrix: 2D array where matrix[i][j] indicates an edge from i to j
o Adjacency List: Array of lists where each list contains the neighbors of a vertex
o Edge List: List of all edges in the graph
• Time Complexity (depends on representation):
o Adjacency Matrix: Space O(V²), Edge lookup O(1), All neighbors O(V)
o Adjacency List: Space O(V+E), Edge lookup O(degree), All neighbors O(degree)
Common Operations
Graph Traversal
• Depth-First Search (DFS): Explores as far as possible along each branch
• Breadth-First Search (BFS): Explores all neighbors at the current depth before moving to vertices at the next
depth
Graph Algorithms
• Shortest Path: Dijkstra's, Bellman-Ford, Floyd-Warshall
• Minimum Spanning Tree: Prim's, Kruskal's
• Topological Sort: For directed acyclic graphs
• Strongly Connected Components: Kosaraju's, Tarjan's
1.10. Heap
A heap is a specialized tree-based data structure that satisfies the heap property. In a max heap, for any given node, the
node's value is greater than or equal to the values of its children. In a min heap, the node's value is less than or equal
to its children's values.
Key Concepts
• Heap Property:
o Max Heap: Parent nodes have values greater than or equal to their children
o Min Heap: Parent nodes have values less than or equal to their children
• Complete Binary Tree: All levels filled except possibly the last level, which is filled from left to right
• Implementation: Usually implemented using arrays
• Time Complexity:
o Insertion: O(log n)
Key Concepts
• Description: Repeatedly steps through the list, compares adjacent elements, and swaps them if they are in
the wrong order.
• Time Complexity: O(n²) average and worst case, O(n) best case (already sorted)
• Space Complexity: O(1)
• Stable: Yes
• In-Place: Yes
• Description: Finds the minimum element from the unsorted part and puts it at the beginning.
• Time Complexity: O(n²) for all cases
• Space Complexity: O(1)
• Stable: No
• In-Place: Yes
• Description: Builds a sorted array one element at a time by inserting each element in its proper position.
• Time Complexity: O(n²) average and worst case, O(n) best case
• Space Complexity: O(1)
• Stable: Yes
• In-Place: Yes
• Adaptive: Yes
• Description: Divides the array into two halves, sorts them, and then merges them.
• Time Complexity: O(n log n) for all cases
• Space Complexity: O(n)
• Stable: Yes
• In-Place: No (typical implementation)
• Description: Picks a pivot element and partitions the array around the pivot.
• Time Complexity: O(n log n) average case, O(n²) worst case
• Space Complexity: O(log n) average case (recursion stack)
• Stable: No (typical implementation)
• In-Place: Yes
• Description: Builds a max heap and repeatedly extracts the maximum element.
• Time Complexity: O(n log n) for all cases
• Space Complexity: O(1)
• Stable: No
• In-Place: Yes
• Description: Counts occurrences of each element and places them in correct order.
• Time Complexity: O(n + k) where k is the range of key values
• Space Complexity: O(n + k)
• Stable: Yes (with careful implementation)
• In-Place: No
• Description: Sorts by processing individual digits from least significant to most significant.
• Time Complexity: O(d * (n + k)) where d is the number of digits and k is the range of values
• Space Complexity: O(n + k)
• Stable: Yes
• In-Place: No
• Description: Distributes elements into buckets and sorts each bucket individually.
• Time Complexity: O(n + k) average case, O(n²) worst case
• Space Complexity: O(n * k)
• Stable: Depends on the sorting algorithm used for each bucket
• In-Place: No
Reference Materials
• Sorting Algorithms
• Programiz Sorting Algorithms
• Visualization of Sorting Algorithms
Challenge Questions
1. Implement bubble sort, selection sort, and insertion sort from scratch.
2. Implement merge sort and quick sort from scratch.
3. Implement heap sort using a max heap.
4. Analyze the best, average, and worst-case time complexities of different sorting algorithms.
5. Implement a hybrid sorting algorithm that uses insertion sort for small subarrays and merge sort for larger
arrays.
6. Sort a nearly sorted array efficiently.
7. Sort an array with only a few unique elements (many duplicates).
8. Implement external sorting for sorting data that doesn't fit in memory.
9. Implement radix sort for sorting large integers.
10. Design an algorithm to find the kth largest element in an array without fully sorting it.
Practice Code Links
1. LeetCode: Sort an Array
2. LeetCode: Sort Colors
Key Concepts
Linear Search
• Description: Sequentially checks each element until it finds a match or reaches the end.
• Time Complexity: O(n)
• Space Complexity: O(1)
• Advantages: Works on unsorted data, simple to implement
• Disadvantages: Inefficient for large datasets
function linearSearch(arr, key):
for i from 0 to arr.length - 1:
if arr[i] equals key:
return i
return -1 // Key not found
Binary Search
• Description: Repeatedly divides the search space in half by comparing the middle element with the key.
• Time Complexity: O(log n)
• Space Complexity: O(1) for iterative, O(log n) for recursive
• Prerequisites: Data must be sorted
• Advantages: Very efficient for large sorted datasets
function binarySearch(arr, key):
left = 0
right = arr.length - 1
else:
right = mid - 1
Jump Search
• Description: Jumps ahead by fixed steps and then uses linear search in the smaller range.
• Time Complexity: O(√n)
• Space Complexity: O(1)
• Prerequisites: Data must be sorted
• Advantages: Better than linear search, doesn't require as many comparisons as binary search
Reference Materials
• Searching Algorithms
• Binary Search Tutorial
1. Binary Search
2. Find Numbers with Even Number of Digits
3. Check if Array Is Sorted and Rotated
4. Search Insert Position
4. First Bad Version
5. Sqrt(x)
6. Find Smallest Letter Greater Than Target
7. Two Sum II - Input Array Is Sorted
8. Count Negative Numbers in a Sorted Matrix
9. Arranging Coins
Key Concepts
function recursiveFunction(parameters):
if base_case_condition:
return base_case_value
else:
// Recursive case
return recursiveFunction(modified_parameters)
Types of Recursion
• Linear Recursion: Each function call makes at most one recursive call
• Binary Recursion: Each function call makes at most two recursive calls (like in merge sort, quicksort)
• Multiple Recursion: Each function call makes multiple recursive calls
• Tail Recursion: Recursive call is the last statement in the function (can be optimized by compilers)
• Head Recursion: Recursive call is the first statement in the function
• Recursion:
✓ More elegant and easier to understand for certain problems
✓ Uses more memory due to call stack
✓ Can lead to stack overflow for deep recursions
✓ Useful for problems with recursive structure (trees, graphs)
• Iteration:
✓ Generally more efficient in terms of memory and speed
✓ Can be more complex to implement for certain problems
✓ No risk of stack overflow
✓ Better for linear algorithms
• Factorial: n! = n * (n-1)!
• Fibonacci: F(n) = F(n-1) + F(n-2)
• Binary Search: Divide and conquer approach
• Tree Traversals: DFS, inorder, preorder, postorder
• Graph Traversals: DFS
• Divide and Conquer: Merge sort, quicksort
• Backtracking: N-Queens, Sudoku solver
• Dynamic Programming: Some DP problems use recursion with memoization
Reference Materials
• Recursion in Programming
• Programiz Recursion Tutorial
Challenge Questions
1. Introduction
2. Control Flow Statements
3. Variables and Data Types
4. Classes and Objects
5. Methods and Functions
Key Concepts
Conditional Statements
• if/else: Executes code based on whether a condition is true or false
• switch/case: Selects among multiple code blocks to execute based on a value
Loop Statements
• for loop: Repeats code a specific number of times
• while loop: Repeats code while a condition is true
• do-while loop: Executes code at least once, then repeats while a condition is true
• foreach/for-in/for-of: Iterates through elements in collections
Reference Resources
Practice Challenges
1. Write a program that prints numbers from 1 to 100, but for multiples of 3 print "Fizz" and for multiples of 5
print "Buzz". For multiples of both, print "FizzBuzz".
2. Create a function that checks if a year is a leap year.
3. Implement a switch statement that returns the name of a month when given its number (1-12).
4. Write a loop that calculates the factorial of a number.
5. Create a nested loop structure to print a pattern of stars forming a right triangle.
6. Write a program that uses control flow to determine if a number is prime.
7. Use a do-while loop to create a simple menu system that continues until the user chooses to exit.
8. Implement a for loop that iterates through an array backwards.
9. Create a loop that finds the sum of all even numbers between 1 and 100.
10. Write a program that uses if-else statements to grade scores (A: 90-100, B: 80-89, etc.).
Key Concepts
Reference Resources
Practice Challenges
1. Create variables of each primitive data type and perform basic operations with them.
2. Write a program that demonstrates type conversion between different numeric types.
3. Create a function that determines what happens when you divide integers vs floating-point numbers.
4. Implement a program that demonstrates different ways to declare and initialize arrays.
5. Write code to show the difference between == and .equals() in Java (or equivalent in other languages).
Key Concepts
Reference Resources
Practice Challenges
1. Create a Rectangle class with width and height attributes, and methods to calculate area and perimeter.
2. Design a BankAccount class with deposit and withdraw methods that maintain a balance.
3. Implement a Student class to store name, ID, and a list of course grades with methods to calculate GPA.
4. Create a Car class with attributes for make, model, year, and methods for accelerating and braking.
5. Design a Book class with attributes like title, author, and ISBN, and methods for checking availability.
6. Implement a Product class for an e-commerce system with price, discount, and tax calculation methods.
7. Create a Point class for 2D coordinates with methods for calculating distance to another point.
8. Design a Clock class that keeps track of hours, minutes, and seconds, with methods to advance time.
9. Implement a Person class with name, address, and phone attributes, plus appropriate getter/setter methods.
10. Create an Employee class with salary calculation methods based on hours worked and hourly rate.
Key Concepts
Method/Function Components
• Parameters/Arguments: Input values passed to methods
• Return Types: The kind of data returned by methods
• Method Signature: A method's name and parameter list
• Method Overloading: Multiple methods with the same name but different parameters
• Lambda Functions/Anonymous Functions: Functions without declarations
Types of Methods
• Instance Methods: Operate on object instances
• Static/Class Methods: Belong to the class rather than instances
• Constructor Methods: Initialize objects
• Accessor/Mutator Methods: Get/set object properties
Reference Resources
Practice Challenges
3. Implement a method that finds the maximum value in an array without using built-in functions.
4. Create overloaded methods to calculate the area of different shapes (circle, rectangle, triangle).
5. Write a method that uses variable arguments to find the average of any number of values.
6. Implement a recursive function to calculate Fibonacci numbers.
7. Create a static utility method that converts between different temperature units (Celsius, Fahrenheit).
8. Write a method that demonstrates parameter passing by value vs. by reference.
9. Implement a function that uses lambda expressions to filter a list based on a condition.
10. Create a method with default parameters that generates customizable greetings.
3. Related Knowledge
Table of Contents
1. Mathematics
2. Matrix Operations
3. Regular Expressions (Regex)
4. Geometry
5. Combinatorics
6. Sequences
7. Linear Algebra
3.1. Mathematics
Mathematics forms the foundation of computer science and is essential for problem-solving in many areas of software
development. This section covers key mathematical concepts that commonly appear in programming interviews and
tests.
Key Concepts
• Number Theory: Prime numbers, divisibility, GCD, LCM
• Modular Arithmetic: Operations under modulo, modular exponentiation
• Probability: Basic probability principles, conditional probability
• Discrete Mathematics: Sets, relations, functions
• Mathematical Induction: Proof technique essential for algorithm validation
• Logarithms: Properties and applications in algorithm complexity analysis
Reference Materials
• Khan Academy - Mathematics
• Brilliant.org - Math Concepts
• MIT OpenCourseWare - Mathematics for Computer Science
Challenge Questions
1. Find the sum of all proper divisors of 220.
2. Prove that for any positive integer n, the value 5^n - 4n - 1 is divisible by 16.
3. A bag contains 5 red balls and 3 blue balls. If 2 balls are drawn randomly without replacement, what is the
probability of drawing exactly 1 red ball?
4. Find the last digit of 7^100.
5. Solve the recurrence relation: T(n) = 2T(n-1) + 3 with T(1) = 5.
6. Calculate the number of trailing zeros in 100!
7. Find the value of x in the equation: log₂(x) + log₄(x) + log₈(x) = 7
8. Prove that √2 is irrational using proof by contradiction.
9. Find the number of different ways to make change for $1.00 using standard US coins.
10. If a set has n elements, how many different subsets does it have?
Practice Coding Exercises
1. LeetCode - Count Primes
2. HackerRank - Number Theory: Find the number of divisors
3. CodeForces - Modular Exponentiation
4. LeetCode - GCD of Strings
5. HackerRank - Sherlock and GCD
6. ProjectEuler - Problem 3: Largest prime factor
7. LeetCode - Perfect Number
8. CodeSignal - Different Squares
9. HackerRank - Minimum Height Triangle
10. LeetCode - Power of Three
3.4. Geometry
Computational geometry deals with algorithms that solve geometric problems. It's essential in computer graphics,
robotics, geographic information systems, and many other applications. Understanding geometric algorithms helps
solve spatial problems efficiently.
Key Concepts
• Coordinate Systems: Cartesian coordinates, polar coordinates
• Basic Shapes: Points, lines, circles, triangles, polygons
• Distance Formulas: Euclidean distance, Manhattan distance
• Line Intersection: Determining if and where lines intersect
• Polygon Properties: Area, perimeter, convexity
• Convex Hull: Finding the smallest convex polygon containing a set of points
• Point in Polygon: Determining if a point lies inside a polygon
• Geometric Transformations: Translation, rotation, scaling
• Spatial Data Structures: Quadtrees, R-trees
Reference Materials
• GeeksforGeeks - Computational Geometry
• Brilliant.org - Geometry Concepts
• Computational Geometry: Algorithms and Applications
Challenge Questions
1. Calculate the distance between two points in 2D space.
2. Determine if two line segments intersect.
3. Calculate the area of a polygon given its vertices.
4. Find the convex hull of a set of points.
5. Check if a point lies inside a polygon.
6. Calculate the circumcenter of a triangle.
7. Find the closest pair of points from a set of points.
8. Determine if a polygon is convex.
9. Calculate the angle between two vectors.
10. Find the minimum enclosing circle for a set of points.
Practice Coding Exercises
1. LeetCode - Valid Square
2. HackerRank - Points on a Line
3. LeetCode - K Closest Points to Origin
4. GeeksforGeeks - Convex Hull
5. LeetCode - Rectangle Area
6. HackerRank - Rectangular Game
7. LeetCode - Erect the Fence
8. LeetCode - Rectangle Overlap
9. GeeksforGeeks - Check if point lies inside polygon
10. LeetCode - Max Points on a Line
3.5. Combinatorics
Combinatorics is the branch of mathematics dealing with counting, arrangement, and combination of objects. It plays
a crucial role in algorithm analysis, probability theory, and solving complex counting problems efficiently.
Key Concepts
• Permutations: Arrangements of objects where order matters
• Combinations: Selection of objects where order doesn't matter
• Binomial Coefficients: Numbers representing combinations (n choose k)
• Pigeonhole Principle: If n items are put into m containers with n > m, at least one container has more than
one item
• Inclusion-Exclusion Principle: Counting elements in the union of multiple sets
• Recurrence Relations: Expressing sequences in terms of previous terms
• Generating Functions: Formal power series encoding sequences
• Catalan Numbers: Sequence appearing in many counting problems
Reference Materials
• Brilliant.org - Combinatorics
• Art of Problem Solving - Combinatorics
• MIT OpenCourseWare - Mathematics for Computer Science (Counting)
Challenge Questions
1. How many different ways can you arrange the letters in the word "MISSISSIPPI"?
2. Calculate the number of ways to select 3 items from 10 distinct items.
3. In how many ways can 8 people be seated at a round table?
4. How many different ways can you make change for $1 using pennies, nickels, dimes, and quarters?
5. Calculate the number of different paths from the top-left corner to the bottom-right corner of an n×m grid,
moving only right or down.
6. How many different non-negative integer solutions are there to x + y + z = 20?
7. Calculate the nth Catalan number efficiently.
8. How many different binary strings of length n contain no consecutive 1's?
9. Find the number of derangements (permutations with no fixed points) of n elements.
10. Calculate the number of ways to partition n distinct objects into k non-empty subsets.
Practice Coding Exercises
1. LeetCode - Combinations
2. LeetCode - Permutations
3. HackerRank - nCr Table
4. LeetCode - Unique Paths
5. LeetCode - Subsets
6. CodeForces - Binomial Coefficients
7. LeetCode - Generate Parentheses
8. HackerRank - Picking Numbers
9. LeetCode - Count Numbers with Unique Digits
10. LeetCode - Permutation Sequence
3.6. Sequences
Sequences are ordered collections of objects that follow specific patterns. Understanding different types of sequences
and their properties is important for solving mathematical problems and developing efficient algorithms.
Key Concepts
• Arithmetic Sequences: Sequences with constant difference between consecutive terms
• Geometric Sequences: Sequences with constant ratio between consecutive terms
• Fibonacci Sequence: Each number is the sum of the two preceding ones
• Recurrence Relations: Defining sequences in terms of previous terms
• Sequence Convergence/Divergence: Behavior as the number of terms increases
• Series: Sum of sequence terms
• Special Sequences: Prime numbers, perfect squares, triangular numbers
• Sequence Operations: Finding terms, sums, limits
Reference Materials
• Khan Academy - Sequences
• Brilliant.org - Sequences and Patterns
• OEIS - The On-Line Encyclopedia of Integer Sequences
Challenge Questions
1. Find the 50th term of an arithmetic sequence with first term 5 and common difference 3.
2. Calculate the sum of the first 20 terms of a geometric sequence with first term 2 and common ratio 3.
3. Find the 15th Fibonacci number efficiently.
4. For the sequence defined by a(n) = 2*a(n-1) - a(n-2) with a(1) = 3 and a(2) = 7, find a(10).
5. Find the sum of the infinite geometric series: 1 + 1/3 + 1/9 + 1/27 + ...
6. Find the general term of the sequence: 2, 6, 12, 20, 30, ...
7. Calculate the sum of the first 100 positive integers.
8. Find the period of the repeating decimal expansion of 1/7.
9. Determine if 13255323 is part of the Fibonacci sequence.
10. Find the next term in the sequence: 1, 11, 21, 1211, 111221, ...
Practice Coding Exercises
1. LeetCode - Fibonacci Number
2. HackerRank - Fibonacci Modified
3. LeetCode - Count and Say
4. HackerRank - Making Anagrams
5. LeetCode - Climbing Stairs
6. HackerRank - The Full Counting Sort
7. LeetCode - Pascal's Triangle
8. HackerRank - Sequence Equation
9. LeetCode - N-th Tribonacci Number
10. HackerRank - Recursive Digit Sum
Reference Materials
• Khan Academy - Linear Algebra
• MIT OpenCourseWare - Linear Algebra
• 3Blue1Brown - Essence of Linear Algebra
Challenge Questions
1. Find the dot product of two vectors.
2. Calculate the cross product of two 3D vectors.
3. Solve a system of linear equations using matrices.
4. Find the eigenvalues and eigenvectors of a 2×2 matrix.
5. Determine if a set of vectors is linearly independent.
6. Calculate the rank of a matrix.
7. Find the orthogonal projection of a vector onto a subspace.
8. Perform singular value decomposition of a matrix.
9. Find the inverse of a matrix using elementary row operations.
10. Determine if a given transformation is linear.
Practice Coding Exercises
1. LeetCode - Matrix Multiplication
2. HackerRank - Linear Algebra Foundations #1
3. LeetCode - Transpose Matrix
4. HackerRank - Determinant of Matrix
5. LeetCode - Valid Sudoku
6. HackerRank - Linear Algebra Foundations #3 - Matrix Multiplication
7. LeetCode - Image Smoother
8. HackerRank - Eigenvalue of Matrix
9. LeetCode - Projection Area of 3D Shapes
10. HackerRank - Linear Algebra Foundations #4 - Matrix Inverse