0% found this document useful (0 votes)
15 views31 pages

(FPT Software) DSA & Programming Study Guide For Entry Test

The DSA & Programming Study Guide provides comprehensive coverage of data structures and algorithms, including arrays, strings, stacks, queues, and linked lists, along with their key concepts, operations, and applications. It includes challenge questions and practice code links for each topic to aid in preparation for an entry test. The document serves as a resource for understanding fundamental programming concepts and enhancing problem-solving skills.

Uploaded by

taidoyasuovn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views31 pages

(FPT Software) DSA & Programming Study Guide For Entry Test

The DSA & Programming Study Guide provides comprehensive coverage of data structures and algorithms, including arrays, strings, stacks, queues, and linked lists, along with their key concepts, operations, and applications. It includes challenge questions and practice code links for each topic to aid in preparation for an entry test. The document serves as a resource for understanding fundamental programming concepts and enhancing problem-solving skills.

Uploaded by

taidoyasuovn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

DSA & Programming Study Guide

Ent ry T e st

Hanoi, 03/2025
Entry Test DSA & Programming Languages Issue/Revision: 1/1

RECORD OF CHANGES

No Effective Date Change Description Reason Reviewer Approver

Create DSA & Programming study


1 07/Apr/2025 Create a newly issue DieuNT1
guide for Entry Test

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 2/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

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

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 3/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

DSA & Programming Study Guide


1. Data Structures and Algorithms Study Guide
1.1. Array
Arrays are the most fundamental data structure, consisting of elements stored in contiguous memory locations. They
allow constant-time access to elements using indices but have fixed sizes in many programming languages.
Key Concepts

• Declaration and Initialization: How to create and initialize arrays


• Indexing: Accessing elements using zero-based indexing
• Memory Layout: Contiguous allocation of elements
• Time Complexity:
✓ Access: O(1)
✓ Search: O(n) for unsorted, O(log n) for sorted
✓ Insertion/Deletion: O(n) (worst case)
✓ Space Complexity: O(n)

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

• Storing homogeneous collections of data


• Implementation of other data structures like stacks, queues
• Matrix operations and multidimensional data
• Buffer pools and memory allocation

Reference Materials

• GeeksforGeeks Array Data Structure


• Leetcode Array Problems

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.

Practice Code Links


1. LeetCode: Two Sum
2. LeetCode: Maximum Subarray
25e-BM/HR/HDCV/FSOFT v1.1 Internal use 4/31
Entry Test DSA & Programming Languages Issue/Revision: 1/1

3. LeetCode: Move Zeroes


4. LeetCode: Rotate Array
5. LeetCode: Remove Duplicates from Sorted Array
6. LeetCode: Merge Sorted Array
7. LeetCode: Product of Array Except Self
8. LeetCode: Best Time to Buy and Sell Stock
9. LeetCode: Contains Duplicate
10. LeetCode: Majority Element

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

• Character Encoding: ASCII, Unicode (UTF-8, UTF-16)


• Immutability: In many languages like Java and Python, strings are immutable
• String Operations: Concatenation, substring, comparison
• Time Complexity (varies by language and implementation):
✓ Access: O(1)
✓ Search: O(n) for brute force, O(n+m) for algorithms like KMP
✓ Concatenation: O(n) to O(n²) depending on implementation

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

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 5/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

3. LeetCode: Valid Palindrome


4. LeetCode: String to Integer (atoi)
5. LeetCode: Implement strStr()
6. LeetCode: Longest Common Prefix
7. LeetCode: Group Anagrams
8. LeetCode: Palindromic Substrings
9. LeetCode: Reverse String
10. LeetCode: Longest Palindromic Substring

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.

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 6/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

9. Sort a stack without using any other data structure.


10. Implement a stack that supports push, pop, and findMiddle operations.
Practice Code Links
11. LeetCode: Valid Parentheses
12. LeetCode: Min Stack
13. LeetCode: Evaluate Reverse Polish Notation
14. LeetCode: Implement Stack using Queues
15. LeetCode: Backspace String Compare
16. LeetCode: Next Greater Element I
17. LeetCode: Daily Temperatures
18. LeetCode: Remove All Adjacent Duplicates In String
19. LeetCode: Decode String
20. LeetCode: Asteroid Collision

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

• Enqueue: queue.enqueue(element) or queue.add(element)


• Dequeue: queue.dequeue() or queue.remove()
• Front/Peek: queue.front() or queue.peek()
• isEmpty: queue.isEmpty()
• Size: queue.size()

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

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 7/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

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

• Insert: Add a node at the beginning, end, or middle


• Delete: Remove a node by value or position
• Search: Find a node with specific value
• Traverse: Visit each node in sequence

Applications
• Implementation of other data structures (stacks, queues, graphs)
• Dynamic memory allocation

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 8/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

• Implementing hash tables with chaining


• Representing polynomials
• Implementing sparse matrices
• Undo functionality in applications
Reference Materials
• Linked List Data Structure
• Programiz Linked List Tutorial
Challenge Questions
1. Implement a singly linked list with operations: insert, delete, search.
2. Implement a doubly linked list with operations: insert, delete, search.
3. Detect a cycle in a linked list.
4. Find the middle element of a linked list in one pass.
5. Reverse a linked list iteratively and recursively.
6. Merge two sorted linked lists into one sorted list.
7. Remove duplicates from a sorted linked list.
8. Check if a linked list is a palindrome.
9. Implement an algorithm to find the nth node from the end of a linked list.
10. Implement an algorithm to detect the starting point of a cycle in a linked list.
Practice Code Links
21. LeetCode: Reverse Linked List
22. LeetCode: Middle of the Linked List
23. LeetCode: Linked List Cycle
24. LeetCode: Merge Two Sorted Lists
25. LeetCode: Remove Nth Node From End of List
26. LeetCode: Palindrome Linked List
27. LeetCode: Intersection of Two Linked Lists
28. LeetCode: Remove Duplicates from Sorted List
29. LeetCode: Add Two Numbers
30. LeetCode: Flatten a Multilevel Doubly Linked List

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)

• Search: O(log n) average, O(n) worst

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 9/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

• Insert: O(log n) average, O(n) worst


• Delete: O(log n) average, O(n) worst

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

• Uniqueness: No duplicate elements allowed


• No Order: Elements are not stored in any specific order
• Hash Function: Maps elements to indices in the underlying array
• Load Factor: Ratio of elements to bucket count
• Collision Resolution: Methods like chaining or open addressing
• Time Complexity:
✓ Add: O(1) average

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 10/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

✓ Remove: O(1) average


✓ Contains: O(1) average
✓ Worst case: O(n) for all operations (bad hash function)

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

1. Implement a HashSet from scratch using an array and hash function.

2. Find the intersection of two arrays using a HashSet.

3. Implement an algorithm to find the first recurring character in a string.

4. Check if an array contains duplicates using a HashSet.

5. Find the union of two arrays using a HashSet.

6. Implement a function to check if a string contains all unique characters.

7. Design a data structure that can add, remove, and check if an element is present in O(1) time.

8. Find the longest consecutive sequence in an unsorted array.

9. Implement a function to find all pairs in an array with a given sum.

10. Design a system to detect if a user has already visited a webpage.

Practice Code Links

1. LeetCode: Contains Duplicate

2. LeetCode: Intersection of Two Arrays

3. LeetCode: Happy Number

4. LeetCode: Longest Consecutive Sequence

5. LeetCode: Jewels and Stones

6. LeetCode: Single Number

7. LeetCode: Valid Sudoku

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 11/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

8. LeetCode: Find the Difference

9. LeetCode: First Unique Character in a String

10. LeetCode: Unique Email Addresses

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

• Put/Insert: hashTable.put(key, value)


• Get: hashTable.get(key)
• Remove: hashTable.remove(key)
• ContainsKey: hashTable.containsKey(key)
• Size: hashTable.size()

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

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 12/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

1. Two Sum

2. Happy Number

3. Isomorphic Strings

4. Group Anagrams

5. Word Pattern

6. Longest Consecutive Sequence

7. Contains Duplicate

8. Valid Sudoku

9. Jewels and Stones

10. Design a HashMap

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

• Add Vertex: graph.addVertex(vertex)


• Add Edge: graph.addEdge(vertex1, vertex2, weight)
• Remove Vertex: graph.removeVertex(vertex)
• Remove Edge: graph.removeEdge(vertex1, vertex2)

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

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 13/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

• Cycle Detection: Using DFS, Union-Find


Applications
• Social networks
• Web page links
• Maps and navigation
• Network routing
• Scheduling problems
• Computer networks
• Recommendation systems
Reference Materials
• Graph Data Structure
• Programiz Graph Tutorial
Challenge Questions
1. Implement a graph using adjacency list and adjacency matrix representations.
2. Implement depth-first search (DFS) and breadth-first search (BFS) for a graph.
3. Find the shortest path between two vertices in an unweighted graph.
4. Implement Dijkstra's algorithm for finding the shortest path in a weighted graph.
5. Detect cycles in directed and undirected graphs.
6. Implement topological sorting for a directed acyclic graph (DAG).
7. Find strongly connected components in a directed graph.
8. Implement Prim's and Kruskal's algorithms for finding minimum spanning trees.
9. Solve the graph coloring problem.
10. Find the longest path in a directed acyclic graph.
Practice Code Links
1. LeetCode: Clone Graph
2. LeetCode: Course Schedule
3. LeetCode: Number of Islands
4. LeetCode: Word Ladder
5. LeetCode: Graph Valid Tree
6. LeetCode: Network Delay Time
7. LeetCode: Cheapest Flights Within K Stops
8. LeetCode: Redundant Connection
9. LeetCode: Is Graph Bipartite?
10. LeetCode: Pacific Atlantic Water Flow

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)

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 14/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

o Deletion (Extract Max/Min): O(log n)


Common Operations
• Insert: heap.insert(element) - O(log n)
• Extract Max/Min: heap.extractMax() or heap.extractMin() - O(log n)
• Peek: heap.peek() - O(1)
• Heapify: Build a heap from an array - O(n)
Array Implementation
• For a node at index i:
o Parent index: Math.floor((i-1)/2)
o Left child index: 2*i + 1
o Right child index: 2*i + 2
Applications
• Priority queues
• Heap sort algorithm
• Graph algorithms (Dijkstra's shortest path, Prim's minimum spanning tree)
• K largest/smallest elements
• Median finding algorithms
• Event-driven simulation
• Job scheduling
Reference Materials
• Heap Data Structure
• Programiz Heap Tutorial
Challenge Questions
1. Implement a min heap and max heap from scratch.
2. Implement heap sort using a max heap.
3. Find the kth smallest element in an array using a heap.
4. Merge k sorted arrays using a heap.
5. Design a data structure for efficiently finding the median of a stream of numbers.
6. Implement a priority queue using a heap.
7. Convert a binary search tree to a max heap.
8. Implement a function to check if a binary tree is a heap.
9. Find the k closest points to the origin in a 2D plane.
10. Implement a continuous median finder that supports insert and findMedian operations.
Practice Code Links
1. LeetCode: Kth Largest Element in an Array
2. LeetCode: Find Median from Data Stream
3. LeetCode: Top K Frequent Elements
4. LeetCode: Merge K Sorted Lists
5. LeetCode: K Closest Points to Origin
6. LeetCode: Last Stone Weight
7. LeetCode: Sliding Window Median
8. LeetCode: Ugly Number II
9. LeetCode: Super Ugly Number
10. LeetCode: The Skyline Problem

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 15/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

1.11. Sort Algorithms


Sorting algorithms arrange elements in a specific order (usually ascending or descending). Different algorithms have
different efficiency, stability, and memory usage characteristics.

Key Concepts

• Stability: A stable sort preserves the relative order of equal elements

• In-Place: An in-place sort uses only a constant amount of extra memory

• Adaptive: An adaptive sort performs better on partially sorted arrays

• Comparison vs. Non-comparison sorts

Common Sorting Algorithms

1.1.1. Bubble Sort

• 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

1.1.2. Selection Sort

• 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

1.1.3. Insertion Sort

• 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

1.1.4. Merge Sort

• 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)

1.1.5. Quick Sort

• 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)

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 16/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

• In-Place: Yes

1.1.6. Heap Sort

• 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

1.1.7. Counting Sort

• 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

1.1.8. Radix Sort

• 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

1.1.9. Bucket Sort

• 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

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 17/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

3. LeetCode: Merge Intervals


4. LeetCode: Largest Number
5. LeetCode: Kth Largest Element in an Array
6. LeetCode: Wiggle Sort II
7. LeetCode: Meeting Rooms II
8. LeetCode: H-Index
9. LeetCode: Insert Interval
10. LeetCode: Sort List

1.12. Search Algorithms


Searching algorithms are designed to retrieve elements from collections like arrays, linked lists, or trees. They vary in
efficiency and applicability depending on the data structure and whether the data is sorted.

Key Concepts

• Search Space: The set of elements being searched


• Search Key: The value being searched for
• Efficiency: Time and space complexity of the algorithm
• Prerequisites: Some algorithms require sorted data

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

while left <= right:


mid = Math.floor((left + right) / 2)

if arr[mid] equals key:


return mid
else if arr[mid] < key:
left = mid + 1

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 18/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

else:
right = mid - 1

return -1 // Key not found

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

Practice Code Links

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

1.13. Recursion Algorithm


Recursion is a programming technique where a function calls itself to solve subproblems of the original problem. It's a
powerful method for solving problems that can be broken down into smaller, similar subproblems.

Key Concepts

• Base Case: The condition that stops the recursion


• Recursive Case: The part where the function calls itself
• Call Stack: Memory used to keep track of function calls
• Stack Overflow: Error that occurs when recursion depth is too great
• Direct vs. Indirect Recursion: Direct is when a function calls itself, indirect is when it calls another function that
eventually calls the original function

Structure of a Recursive Function

function recursiveFunction(parameters):
if base_case_condition:
return base_case_value
else:
// Recursive case
return recursiveFunction(modified_parameters)

Types of Recursion

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 19/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

• 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 vs. Iteration

• 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

Common Recursive 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. Implement a recursive function to calculate factorial.


2. Implement a recursive function to calculate the nth Fibonacci number.
3. Solve the Tower of Hanoi problem using recursion.
4. Implement binary search recursively.
5. Write a recursive function to find the sum of elements in an array.
6. Implement a recursive function to calculate the power of a number.
7. Write a recursive function for tree traversals (preorder, inorder, postorder).
8. Solve the N-Queens problem using backtracking.
9. Implement a recursive function to generate all permutations of a string.
10. Write a recursive function to solve the subset sum problem.

Practice Code Links

1. LeetCode: Fibonacci Number


2. LeetCode: Pow(x, n)
3. LeetCode: Generate Parentheses

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 20/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

4. LeetCode: Merge Two Sorted Lists


5. LeetCode: N-Queens
6. LeetCode: Permutations
7. LeetCode: Combinations
8. LeetCode: Subsets
9. LeetCode: Letter Combinations of a Phone Number
10. LeetCode: Palindrome Partitioning

2. Programming Languages Review Guide


Table of Contents

1. Introduction
2. Control Flow Statements
3. Variables and Data Types
4. Classes and Objects
5. Methods and Functions

3.1. Control Flow Statements


Control flow statements determine the order in which code executes. They allow programs to make decisions, repeat
actions, and execute different code blocks based on conditions.

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

• Java Control Flow Tutorial (Oracle)


• C++ Control Flow (cppreference.com)
• Python Control Flow (Python.org)
• C# Control Flow (Microsoft Docs)

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.

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 21/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

10. Write a program that uses if-else statements to grade scores (A: 90-100, B: 80-89, etc.).

Practice Code Links

1. Java FizzBuzz on LeetCode


2. C++ Prime Number Check on CodeSignal
3. Python Loop Challenge on HackerRank
4. C# Control Flow on Exercism
5. Java Pattern Printing on GeeksforGeeks
6. C++ Switch Statement on Codewars
7. Python if-else on HackerRank
8. C# Loop Problems on Exercism
9. Java While Loop on CodeSignal
10. C++ For Loop on LeetCode

3.2. Variables and Data Types


Variables are containers for storing data values. Data types define the kind of data a variable can hold, affecting how
that data is stored in memory and what operations can be performed on it.

Key Concepts

Primitive Data Types


• Numeric: Integers (int, long, etc.) and floating-point numbers (float, double)
• Character: Individual symbols (char)
• Boolean: True/false values (boolean)
Reference Data Types
• String: Text sequences
• Arrays: Collections of elements
• Objects: Instances of classes
Variable Declaration and Initialization
• Declaring variables with appropriate data types
• Initializing variables with values
• Type casting and conversion
Scope and Lifetime
• Local vs. global variables
• Block scope
• Variable lifetime

Reference Resources

• Java Data Types (Oracle)


• C++ Data Types (cppreference.com)
• Python Data Types (Python.org)
• C# Types (Microsoft Docs)

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).

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 22/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

6. Create a program that demonstrates variable scoping rules.


7. Write a function that shows the difference between pass-by-value and pass-by-reference.
8. Implement a program that shows precision loss when working with floating-point numbers.
9. Create a program that demonstrates automatic type conversion (implicit casting).
10. Write code that shows the differences between mutable and immutable types.

Practice Code Links

1. Java Variable Declaration Practice on HackerRank


2. C++ Type Casting on Codewars
3. Python Data Types on LeetCode
4. C# Type Conversions on Exercism
5. Java String Comparison on HackerRank
6. C++ Array Declaration on LeetCode
7. Python Number Types on Codewars
8. C# Basic Types on Microsoft Learn
9. Java Primitives on Project Euler
10. C++ Data Type Limits on CodeSignal

3.3. Classes and Objects


Classes provide a blueprint for creating objects, defining object properties (attributes) and behaviors (methods).
Objects are instances of classes that encapsulate state and functionality.

Key Concepts

Object-Oriented Programming Principles


• Encapsulation: Bundling data and methods that operate on that data
• Inheritance: Creating new classes from existing ones
• Polymorphism: Treating objects of different types in a similar way
• Abstraction: Hiding implementation details and showing only necessary features
Class Components
• Fields/Attributes: Variables that belong to a class
• Methods: Functions that define class behavior
• Constructors: Special methods to initialize objects
• Destructors: Methods to clean up objects (in some languages)
• Access modifiers: public, private, protected
Object Creation and Usage
• Instantiating objects
• Accessing fields and methods
• Object lifecycle

Reference Resources

• Java Classes (Oracle)


• C++ Classes (cppreference.com)
• Python Classes (Python.org)
• C# Classes (Microsoft Docs)

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.

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 23/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

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.

Practice Code Links

1. Java OOP on HackerRank


2. C++ Classes on LeetCode
3. Python Classes on Exercism
4. C# Classes on Microsoft Learn
5. Java Bank Account on Codewars
6. C++ Rectangle Class on LeetCode
7. Python Point Class on Codewars
8. C# Book Class on Exercism
9. Java Employee Class on HackerRank
10. C++ Product System on CodeSignal

3.4. Methods and Functions


Methods and functions are blocks of code designed to perform specific tasks. They help organize code, promote
reusability, and implement abstraction. Methods are functions associated with objects, while functions exist
independently.

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

• Java Methods (Oracle)


• C++ Functions (cppreference.com)
• Python Functions (Python.org)
• C# Methods (Microsoft Docs)

Practice Challenges

1. Create a method that calculates the factorial of a number recursively.


2. Write a function to check if a string is a palindrome.

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 24/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

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.

Practice Code Links

1. Java Methods on HackerRank


2. C++ Functions on LeetCode
3. Python Functions on Exercism
4. C# Methods on Microsoft Learn
5. Java Recursion on Codewars
6. C++ Overloaded Functions on LeetCode
7. Python Lambda Functions on HackerRank
8. C# Delegates and Lambda on Exercism
9. Java Method Parameters on CodeSignal
10. C++ Parameter Passing on Codewars

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

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 25/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

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.2. Matrix Operations


Matrices are fundamental data structures in computer science and mathematics. They are widely used in graphics,
machine learning, scientific computing, and many algorithms. Understanding matrix operations is crucial for solving
complex problems efficiently.
Key Concepts
• Matrix Representation: 2D arrays, sparse matrices
• Basic Operations: Addition, subtraction, multiplication
• Special Matrices: Identity, diagonal, triangular, symmetric
• Matrix Properties: Determinant, trace, rank, eigenvalues
• Matrix Transformations: Rotation, reflection, scaling
• Matrix Algorithms: Gaussian elimination, LU decomposition
Reference Materials
• Khan Academy - Matrices
• MIT OpenCourseWare - Linear Algebra
• 3Blue1Brown - Essence of Linear Algebra
Challenge Questions
1. Implement matrix multiplication for two matrices of compatible dimensions.
2. Calculate the determinant of a 3x3 matrix.
3. Implement an algorithm to rotate a square matrix by 90 degrees clockwise.
4. Find the transpose of a given matrix.
5. Solve a system of linear equations using Gaussian elimination.
6. Check if a given matrix is symmetric.
7. Calculate the trace of a square matrix.
8. Find the inverse of a 2x2 matrix.
25e-BM/HR/HDCV/FSOFT v1.1 Internal use 26/31
Entry Test DSA & Programming Languages Issue/Revision: 1/1

9. Implement an algorithm to search in a sorted 2D matrix.


10. Calculate the eigenvalues of a 2x2 matrix.
Practice Coding Exercises
1. LeetCode - Rotate Image
2. LeetCode - Spiral Matrix
3. LeetCode - Search a 2D Matrix
4. HackerRank - Matrix Layer Rotation
5. LeetCode - Valid Sudoku
6. LeetCode - Game of Life
7. LeetCode - Set Matrix Zeroes
8. HackerRank - Matrix Script
9. LeetCode - Toeplitz Matrix
10. LeetCode - Diagonal Traverse

3.3. Regular Expressions (Regex)


Regular Expressions provide a powerful and flexible way to search, match, and manipulate text patterns. They are
essential tools for string processing, validation, data extraction, and parsing in software development.
Key Concepts
• Basic Patterns: Literal characters, wildcards
• Character Classes: Sets of characters, negated sets
• Quantifiers: Matching repetitions (*, +, ?, {n}, {n,}, {n,m})
• Anchors: Start (^) and end ($) of line/string
• Grouping and Capturing: Using parentheses ()
• Alternation: Using pipe symbol |
• Escape Characters: Special character handling
• Lookaheads and Lookbehinds: Positive and negative assertions
• Greedy vs. Lazy Matching: Controlling quantifier behavior
Reference Materials
• RegExr - Learn, Build, & Test RegEx
• MDN Web Docs - Regular Expressions
• Regular-Expressions.info
Challenge Questions
1. Write a regex pattern to validate an email address.
2. Create a pattern to extract all URLs from a text.
3. Write a regex to validate a phone number in international format.
4. Create a pattern to validate a strong password (with specific requirements).
5. Write a regex to extract all dates in the format MM/DD/YYYY from a text.
6. Create a pattern to match HTML tags.
7. Write a regex to validate an IPv4 address.
8. Create a pattern to extract all words that start with a vowel.
9. Write a regex to match quoted text within a string.
10. Create a pattern to validate a credit card number (supporting major formats).
Practice Coding Exercises
1. HackerRank - Matching Specific String
2. LeetCode - Regular Expression Matching
3. HackerRank - Detect HTML Tags
4. LeetCode - Valid Phone Numbers

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 27/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

5. HackerRank - Detect HTML Attributes


6. RegexOne - Interactive Tutorial
7. HackerRank - Find A Sub-Word
8. LeetCode - Validate IP Address
9. HackerRank - Alien Username
10. LeetCode - Camelcase Matching

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

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 28/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

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

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 29/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

• 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

3.7. Linear Algebra


Linear algebra is a branch of mathematics that deals with vector spaces, linear transformations, and systems of linear
equations. It's extensively used in computer graphics, machine learning, data analysis, and many computational
algorithms.
Key Concepts
• Vectors: Direction and magnitude, vector operations
• Matrices: Matrix operations, types of matrices
• Linear Transformations: Mapping between vector spaces
• Systems of Linear Equations: Solutions and methods
• Vector Spaces: Subspaces, basis, dimension
• Eigenvalues and Eigenvectors: Properties and applications
• Orthogonality: Perpendicular vectors, orthogonal projections
• Singular Value Decomposition (SVD): Matrix factorization technique
• Linear Independence: Sets of vectors with no linear combinations

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 30/31


Entry Test DSA & Programming Languages Issue/Revision: 1/1

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

25e-BM/HR/HDCV/FSOFT v1.1 Internal use 31/31

You might also like