0% found this document useful (0 votes)
6 views76 pages

Zero To Hero Data Structures Notes

This is made by me...its in very simple and easy language....
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views76 pages

Zero To Hero Data Structures Notes

This is made by me...its in very simple and easy language....
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Zero To Hero Notes By Abhishek HeHeHEHEHeHeHeHEHE :))

1️⃣ Algorithms, Flowcharts, Complexity & Basics of Data Structures

1. Define an algorithm. Explain characteristics of a good algorithm.


(Important)
Answer - 1. Definition

 An algorithm is a finite sequence of well-defined steps that solves a problem or


performs a task.

 It takes input, processes it, and produces output.

2. Key Characteristics

 Finiteness, definiteness, input/output, effectiveness.

3. Tiny Diagram

Input → [ Step 1 → Step 2 → ... → Step n ] → Output


2. Draw a flowchart for any simple problem (e.g., find largest
number / factorial).
Answer - Definition / Introduction

A flowchart is a graphical representation of the sequence of steps to solve a problem.


It uses different symbols to show the flow of control and decision-making in an
algorithm.

Detailed Explanation (bullet points)

 The problem is to find the largest of two numbers, say A and B.

 The flowchart begins with the Start symbol.

 Inputs A and B are read from the user.

 A decision box checks the condition A > B.

 Depending on the result, the appropriate output (“A is largest” or “B is largest”) is


displayed.

 The flowchart ends with the Stop symbol.

Neat ASCII Flowchart Diagram


Algorithm

Start the process.

Take two numbers as input: A and B.

Compare A with B.

If A is greater than B, then say “A is the largest.”

Otherwise, say “B is the largest.”

End the process.

Applications

 Used in basic decision-making problems.

 Helps beginners understand program logic visually.

 Useful for documenting software processes.

Conclusion

This flowchart clearly shows the logical steps and decision-making required to find the
largest of two numbers in a simple and visual manner.

3. Explain time and space complexity with examples.(Important)


Answer - Definitions

 Time Complexity: Measures how much time an algorithm takes as input size
increases.

 Focus: How the number of operations (steps) scales with N, not actual seconds.

 Example (Linear Search): Finding a number in an array of size N.

 Notation: Uses Big O (O), Omega (Ω ), Theta (Θ).

 Worst Case: The number is last or not present; you check all N elements. Time: O(N )
(linear time).

Space Complexity: Measures how much memory an algorithm uses during execution.

 Focus: Extra space for variables, inputs, outputs, auxiliary data structures (like
recursion stack).

 Notation: Also uses Big O.

 Example (Linear Search):

 Space: Just a few variables (loop counter, current element). Space: O(1)(constant
space).

Q- Random - Types of Algorithm Analysis


Answer – [Link] case

[Link] Case

[Link] case

Average case = all random case time / total no of case

Q- Random - Asymptotic Notations

Asnwer - Asymptotic Notations are mathematical tools used to analyze the performance

of algorithms by understanding how their efficiency changes as the input size

grows.

There are mainly three asymptotic notations:

Big-O Notation (O-notation)

Omega Notation (Ω-notation)

Theta Notation (Θ-notation)

4. Compare Big-O, Big-Ω, and Big-Θ notations with examples.


(Importanat)
Answer - omparison of Big-O, Big-Ω, and Big-Θ Notations

1. Definition / Introduction

Asymptotic notations are used to describe the performance of algorithms.


Big-O, Big-Ω, and Big-Θ measure the upper bound, lower bound, and tight bound of an
algorithm’s growth rate.

Detailed Explanation

Big-O Notation (Upper Bound)

 Represents the worst-case time or space complexity.

 Shows the maximum growth rate of an algorithm.

 If a function is O(f(n)) → it will not grow faster than f(n).


Big-Ω (Omega) Notation (Lower Bound)

 Represents the best-case complexity.

 Shows the minimum time required by an algorithm.

 If a function is Ω(f(n)) → it will grow at least as fast as f(n).

Big-Θ (Theta) Notation (Tight Bound)


 Represents the average or exact bound.

 When an algorithm is both O(f(n)) and Ω(f(n)), it is Θ(f(n)).

 Gives the most accurate growth rate representation.

5. Explain algorithmic complexity for common algorithms with


examples.
Answer - Algorithmic complexity measures how the running time or memory usage of
an algorithm grows with input size n.
It helps compare algorithms and choose the most efficient one for large inputs.

Detailed Explanation

Time Complexities of Common Algorithms

1. Linear Search → O(n)

 Scans each element one by one.

 Worst case: target is at the end or absent.

 Time increases linearly with input size.

2. Binary Search → O(log n)

 Works only on sorted data.


 Repeatedly divides the search interval into half.

 Very efficient for large datasets.

3. Bubble Sort → O(n²)

 Repeatedly compares adjacent elements.

 Nested loops cause quadratic complexity.

 Slow for large inputs.

4. Merge Sort → O(n log n)

 Uses divide-and-conquer strategy.

 Splits array, sorts parts, merges them.

 Much faster than O(n²) sorting.

5. Insertion Sort → O(n²)

 Inserts each element into its correct position.

 Efficient for small or nearly sorted arrays.

6. Hash Table Operations → O(1) average

 Searching, inserting, deleting take constant time.

 Based on hashing; collisions may worsen performance.

6. Write algorithms for: Linear Search, Binary Search, Selection Sort,


Bubble Sort, Quick Sort, Merge Sort (any two expected).(Important)
Answer - Here are the algorithms for the requested searching and sorting techniques:

1. Linear Search – Algorithm

1. Start from the first element of the list.

2. Compare the target with the current element.

3. If both match → element is found.

4. If not, move to the next element.

5. Continue until end of list.


6. If you reach the end and no match → element not found.

2. Binary Search – Algorithm (Array must be sorted)

1. Set two pointers: one at start and one at end.

2. Find the middle position.

3. If target equals the middle element → found.

4. If target is smaller → search only in the left half.

5. If target is larger → search only in the right half.

6. Repeat the steps until start pointer passes end pointer.

7. If pointers cross → element not found.

3. Selection Sort – Algorithm

1. Start from the first position.

2. Find the smallest element in the remaining unsorted part.

3. Swap the smallest element with the current position.

4. Move to the next position.

5. Repeat until the whole list becomes sorted.

4. Bubble Sort – Algorithm

1. Compare each pair of adjacent elements.

2. If a pair is in the wrong order, swap them.

3. After one full pass, the largest element goes to the end.

4. Repeat passes until no swaps are needed.

5. List becomes sorted.

5. Quick Sort – Algorithm


1. Select a pivot element (example: last element).

2. Divide list into two parts:

o Left side → elements smaller than pivot

o Right side → elements greater than pivot

3. Recursively apply quick sort on left part.

4. Recursively apply quick sort on right part.

5. Combine the results — final list is sorted.

6. Merge Sort – Algorithm

1. Divide the list into two equal halves.

2. Recursively sort the left half.

3. Recursively sort the right half.

4. Merge the two sorted halves:

o Compare elements from both halves

o Pick the smaller one and add to result

5. Continue until all elements are merged.

6. The final merged list is sorted.

7. Explain static and dynamic memory allocation.(Important)


Answer - 1. Definitions

 Static Memory Allocation: Memory is fixed at compile time and cannot change
during execution.

 Dynamic Memory Allocation: Memory is assigned at runtime using functions like


malloc()/new.

2. One Key Point

 Static → fast but inflexible; Dynamic → flexible but slightly slower.


8. Explain recursion. State conditions required for recursion with an
example.(Important)
Answer - Definition

 Recursion is a technique where a function calls itself to solve smaller subproblems


until reaching a simple base case.

Required Conditions

 Base Case: Stops further calls.

 Recursive Case: Function calls itself with reduced input.

Example (C++ – Factorial)


int fact(int n){
if(n==0) return 1; // base case
return n * fact(n-1); // recursive case
}

9. What is a Data Structure? Explain classification of data structures


with examples.
Answer - Definition / Introduction

A data structure is a systematic way of organizing, storing, and managing data so that
operations like access, insertion, deletion, and modification can be performed
efficiently.
It helps in designing efficient algorithms and improving program performance.

Detailed Explanation (bullet points)

Classification of Data Structures

A. Primitive Data Structures

 Basic data types provided by programming languages.

 Examples: int, float, char, boolean.

 Used to build non-primitive structures.

B. Non-Primitive Data Structures

 More complex and structured forms of data.


 Divided into two main categories:

Linear Data Structures

 Elements arranged sequentially, one after another.

 Easy to traverse using a single run.

 Examples:

o Array → fixed-size collection of same data type

o Linked List → nodes connected using pointers

o Stack → LIFO (Last In First Out)

o Queue → FIFO (First In First Out)

Non-Linear Data Structures

 Data is arranged hierarchically or with multiple relationships.

 Suitable for representing complex structures.

 Examples:

o Trees → hierarchical structure with root and children

o Binary Tree, BST, Heap

o Graphs → nodes connected by edges, used for networks

o Hash Tables → store data using key–value pairs

Neat ASCII Diagram – Classification


Examples (simple and clear)

 Array Example: A = [10, 20, 30, 40] → contiguous memory.

 Stack Example: Push(5), Push(10), Pop() → returns 10.

 Tree Example: Binary Tree where root = 50, left = 30, right = 70.

 Graph Example: Cities connected by roads.

Advantages / Applications

 Efficient data handling and processing.

 Required in databases, operating systems, compilers, networks, AI, and simulations.

 Helps in implementing algorithms like searching, sorting, graph traversal, etc.

Conclusion

Data structures classify data into organized formats—primitive, linear, and non-linear—
allowing efficient storage, access, and computation in software applications.

[Link] between static and dynamic data structures.


Answer - Definition

 Static Data Structure: Has a fixed size decided at compile time.


 Dynamic Data Structure: Can grow or shrink during program execution.

Key Point

 Static uses contiguous memory (e.g., array); Dynamic uses linked memory via
pointers (e.g., linked list).

[Link] is a function? Explain its role in modular programming and


algorithms.
Answer - Function in Programming

Definition / Introduction

A function is a self-contained block of code designed to perform a specific task.


It improves program structure by dividing a large problem into smaller manageable
parts.
Detailed Explanation

 A function groups related statements together so they can be reused whenever


needed.

 It accepts inputs (parameters), processes them, and may return a value.

 Functions reduce code repetition and enhance readability.

 In algorithms, functions represent logical modules like search(), sort(), insert(), etc.

 They allow abstraction—meaning the user focuses on what the function does, not
how it works internally.

ASCII Diagram (Concept of Modular Programming)

Algorithm / Steps (Generic Use of a Function)

Main Process

1. Start.

2. Take the input value from the user.


3. Send this input to the function to be processed.

4. Receive the result returned by the function.

5. Display the result.

6. End.

Function Process

1. Start the function.

2. Receive the value x.

3. Perform the required operations on x.

4. After processing, prepare the final value.

5. Return the processed value to the main process.

6. End the function.

Example

A function to compute the square of a number:

SQUARE(n):

return n * n

MAIN():

x=5

print SQUARE(x) // Output: 25

Role in Modular Programming

 Divides a large program into smaller modules.

 Each function handles a specific job → cleaner structure.

 Modules can be tested independently (unit testing).


 Makes maintenance and debugging easier.

 Supports teamwork—different members can work on different functions.

Role in Algorithms

 Complex algorithms like Merge Sort, Quick Sort, DFS, BFS rely heavily on
functions.

 Functions help represent repeated operations like merge(), partition(), visit() etc.

 Allows recursive solutions where a function calls itself.

 Enhances clarity and reduces algorithmic complexity.

Conclusion:

A function is a reusable, well-defined module of code that simplifies programming and


forms the backbone of modular program design and algorithm development.

2️⃣ Arrays, Pointers & Strings

[Link] an array. Explain 1D & 2D array memory representation.


(Important)
Answer – Array and Its Memory Representation

Definition / Introduction

An array is a collection of elements of the same data type stored in contiguous memory
locations.
Each element is accessed using its index, making retrieval fast and efficient.

Detailed Explanation

 Arrays allow storing multiple values under one variable name.

 Indexing starts from 0 in most programming languages.

 Memory is allocated sequentially, enabling constant-time access: O(1).

 Arrays can be 1-dimensional (linear) or 2-dimensional (matrix-like).


1D Array Memory Representation

 Elements are stored one after another in continuous memory.

 Address of element A[i] is calculated as:

LOC(A[i]) = Base_Address + (i * Size_of_each_element)

ASCII Diagram (1D Array in Memory)

2D Array Memory Representation

A 2D array is stored in memory using one of two methods:

 Row-major order (used in C, C++)

 Column-major order (used in Fortran, MATLAB)

Row-Major Order

 Entire row is stored before the next row.

 Formula:

LOC(A[i][j]) = BA + ((i * Total_Columns) + j) * Size

Column-Major Order

 Entire column is stored before the next column.

 Formula:

LOC(A[i][j]) = BA + ((j * Total_Rows) + i) * Size

ASCII Diagram (2D Array: 3 × 3 in Row-Major Order)


Algorithm / Steps (Accessing Array Elements)

Accessing 1D Element

READ index i

return A[i]

Accessing 2D Element

READ i, j

return A[i][j]

Example

1D Array: A = [3, 6, 9, 12]

 A[2] = 9

2D Array:

B= 1 2

3 4

 B[1][0] = 3

Advantages / Applications
 Fast element access due to direct indexing.

 Used in matrices, tables, dynamic programming, and scientific computations.

 Useful for implementing other data structures like heaps, hash tables, queues, etc.

Conclusion

Arrays store data in contiguous memory and support fast, indexed access.
Understanding 1D and 2D memory layouts (row-major and column-major) is essential
for efficient algorithm and system-level programming.

[Link] is an index of an array? How are elements accessed?


(Important)
Answer – Definition

 The index of an array is the position number of an element, starting from 0 in most
programming languages.

 It helps identify and locate each element inside the array.

Key Point: Accessing Elements

 Elements are accessed using the array name followed by the index, e.g., arr[i] in C++.

Tiny Diagram

[Link] is a sparse matrix? Represent a sparse matrix with an


example.(Important)
Answer - Definition / Introduction
A sparse matrix is a matrix in which most of the elements are zero.
To save memory, only the non-zero elements and their positions are stored instead of
the entire matrix.

Detailed Explanation

 Storing a sparse matrix in normal 2D array form wastes memory.

 Instead, sparse representation stores each non-zero element using a compact


structure.

 Common ways to represent sparse matrices:

o Triplet (3-tuple) form

o Linked list representation

o Compressed row/column storage

 Triplet form is the simplest and most commonly asked in examinations.

Advantages / Applications

 Saves memory when storing large matrices with many zeros.

 Used in scientific computing, machine learning, graph algorithms, and image


compression.

 Efficient in matrix operations like addition and multiplication.

Conclusion

A sparse matrix contains mostly zero elements, so only its non-zero values and their
positions are stored in compact forms like triplet representation, significantly reducing
memory usage and improving efficiency.

Algorithm (Triplet Conversion)

1. Start.

2. Read the number of rows and columns of the matrix.

3. Read all the elements of the matrix.


4. Count how many elements are non-zero.

5. Create a new sparse matrix with (non-zero count + 1) rows and 3 columns.

6. In the first row of the sparse matrix, store:

o total rows of original matrix

o total columns

o total number of non-zero elements

7. Scan the original matrix row by row:

o For every non-zero element, store its

 row index

 column index

 value
into the sparse matrix.

8. Continue until entire matrix is scanned.

9. Display the sparse matrix.

10. Stop.

[Link] between arrays and linked lists.(Important)


Answer - Difference Between Arrays and Linked Lists

Definition

Array:
A collection of elements stored in contiguous memory locations, accessed using an
index.

Linked List:
A collection of elements called nodes, where each node contains data and a
pointer/reference to the next node.
Nodes are stored in non-contiguous memory.

Structure
Array Structure:

 Continuous block of memory

 Example:

 [10][20][30][40]

Linked List Structure:

 Nodes connected via pointers

 [10 | *] → [20 | *] → [30 | *]

Memory Allocation

Array:

 Uses static or fixed memory allocation.

 Size must be known in advance.

Linked List:

 Uses dynamic memory allocation.

 Size can grow or shrink at runtime.

Access / Retrieval

Array:

 Direct/Random access using index.


Example: A[3] directly retrieves the 4th element.

Linked List:

 Sequential access only; traversal starts from the head node.

Insertion and Deletion

Array:

 Costly operations because shifting of elements is required.

Linked List:
 Efficient insert/delete by adjusting pointers.

 No shifting required.

Memory Usage

Array:

 Memory may be wasted if full size is not used.

 No extra memory for pointers.

Linked List:

 No memory wastage; grows as needed.

 Extra memory needed for pointers.

Implementation Complexity

Array:

 Simple to declare and use.

Linked List:

 More complex due to pointer handling.

Applications

Array:

 Good for index-based access, searching, and static data tables.

Linked List:

 Useful for dynamic memory scenarios, queues, stacks, and graph structures.

Conclusion

Arrays provide fast access but fixed size and costly insertions, while linked lists allow
dynamic growth with efficient insertions but slower access. Both structures are useful
depending on whether speed or flexibility is needed.
[Link] pointer, dangling pointer, and pointer arithmetic with
examples.(Important)
Answer - Pointer, Dangling Pointer, and Pointer Arithmetic

Definition / Introduction

A pointer is a variable that stores the memory address of another variable.


Pointers allow direct access and manipulation of memory locations, improving
efficiency in algorithms.

Detailed Explanation

Pointer

 Holds the address of a variable instead of storing data directly.

 Declared using * operator (e.g., int *p;).

 Useful for dynamic memory, arrays, functions, and linked lists.

Dangling Pointer

 A pointer that points to a memory location that has been freed or deleted.

 Occurs after freeing memory, returning address of a local variable, or invalid


deallocation.

 Using it leads to undefined behavior.

Pointer Arithmetic

 Allows performing arithmetic operations on pointers.

 Operations include:

o p + 1 → moves pointer to next element

o p - 1 → moves pointer to previous element

o p++, p-- → increment/decrement

 Arithmetic is scaled by the size of the data type.

Algorithm / Steps (Pointer Usage Example)


START

declare integer x

assign x ← 10

declare pointer p

assign p ← address of x

print value at p // *p

END

Advantages / Applications

 Enables dynamic memory allocation.

 Efficient for implementing linked lists, trees, graphs.

 Supports passing large structures efficiently using addresses.

 Crucial for low-level memory manipulation and system programming.

Conclusion

Pointers store memory addresses, dangling pointers arise from invalid memory
references, and pointer arithmetic allows controlled movement across memory—
making pointers powerful tools for efficient programming and data structure
implementation.

[Link] pointer to structure with a suitable example.


Answer - Definition

 A pointer to structure is a pointer variable that stores the address of a structure.

 It allows accessing structure members using the arrow operator (→).

Example (C++)

struct Student { int id; };

Student s = {10};
Student *p = &s;

cout << p->id; // accessing member

[Link] programs demonstrating basic pointer operations.


Answer - Pointer operations involve accessing, modifying, and navigating memory using
pointer variables.
They help in understanding memory addresses, dereferencing, pointer arithmetic, and
swapping using pointers.

Detailed Explanation

 A pointer stores the address of another variable.

 & operator → gives address of a variable.

 * operator → used to access the value stored at the address (dereferencing).

 Pointer arithmetic helps move through array elements.

 Pointers make functions more flexible (e.g., swapping values using addresses).

Advantages / Applications

 Useful for dynamic memory allocation.

 Efficient swapping, array manipulation, and passing large data to functions.

 Essential for data structures like linked lists, trees, and graphs.

Conclusion

Basic pointer operations—address access, dereferencing, arithmetic, and function usage


—allow programmers to work efficiently with memory and form the foundation for
advanced data structures.

[Link] strings. Explain how strings are stored in memory.


Answer - Definition

 A string is a sequence of characters ending with a null character (‘\0’).


 It is treated as a character array in memory.

How Strings Are Stored

 Each character occupies one byte and characters are stored contiguously, followed
by '\0' to mark the end.

[Link] briefly any five string library functions.(Important)


Answer - String library functions are predefined operations in <cstring> used to
process and manipulate C-style strings.

Five Functions (Briefly)

 strlen(s): Returns length of a string

 strcpy(d,s): Copies string s into d

 strcat(d,s): Appends s to d

 strcmp(a,b): Compares two strings

 strupr(s)/strlwr(s): Converts to upper/lowercase

3️⃣ Stacks & Queues

[Link] stack. Explain push and pop operations with algorithms.


(Important)
Answer - Definition

 A stack is a linear data structure that follows LIFO (Last In, First Out) order.

 Insertions and deletions occur only at the top of the stack.


Push Operation

Start.

Check if the stack is full.

If the stack is full → display “Stack Overflow” and stop.

If the stack is not full → increase the top pointer by 1.

Insert the new element at the position of the top.

End.

Pop Operation

Start.

Check if the stack is empty.

If the stack is empty → display “Stack Underflow” and stop.

If the stack is not empty → take the element from the top.

Decrease the top pointer by 1.

Return or display the removed element.

End.

[Link] the algorithm to create a stack using a linked list.(Important)


Answer - A stack using a linked list is a dynamic implementation of the LIFO (Last In
First Out) data structure where each node stores data and a pointer to the next node.
It allows push and pop operations without overflow as long as memory is available.

Detailed Explanation

 Uses a singly linked list where insertion and deletion occur at the head.

 The top pointer always refers to the first node.

 Push creates a new node and links it to the current top.

 Pop removes the node pointed to by top.

 Dynamic size—no fixed limit.

Algorithm: Create a Stack Using a Linked List


1. Start

1. Begin the process.

2. Initialize the Stack

2. Create an empty linked list.

3. Set the top pointer to NULL (means stack is empty).

3. Define a Node Structure

4. Each node should contain:

o A data field

o A pointer to the next node

4. Push Operation (Insert Element at Top)

5. Create a new node.

6. Store the given value in the data part of the node.

7. Set the new node’s next pointer to the current top node.

8. Update the top pointer to point to this new node.

9. Push completed.

5. Pop Operation (Remove Element from Top)

10. Check if the top is NULL.

11. If top is NULL, display “Stack Underflow” (stack empty).

12. Otherwise:

o Store the top node temporarily.

o Move the top pointer to the next node.

o Delete the temporarily stored node.


13. Pop completed.

6. End

14. Stop the process.

[Link] applications of stack (any three).


Answer - A stack is a LIFO structure used to manage data where the last inserted item
is removed first.

Applications

 Function call management (recursion stack)

 Expression evaluation (postfix/prefix)

 Undo/Redo in editors

 Backtracking (maze, DFS)

 Browser history navigation

[Link] multiple stacks and their implementation.


Answer - 1. Introduction

A stack is a linear data structure that follows the LIFO (Last In, First Out) principle.
When we store two or more stacks in a single array, it is called Multiple Stacks.

Multiple stacks are used to save memory, avoid wastage of unused space, and
efficiently utilize a single continuous block of memory instead of creating separate
arrays for each stack.

2. Need for Multiple Stacks

Multiple stacks are useful when:

 Memory is limited or fixed.

 We want to share unused memory between stacks.

 Applications like CPU memory management, expression evaluation, and multi-


threading require multiple stacks in limited space.
[Link] queue. Write algorithms for enqueue and dequeue in
circular queue.(Important)
Answer - ✅ Define Queue

A queue is a linear data structure that follows the FIFO (First In, First Out) principle.
In a queue, insertion is done at the rear end and deletion is done from the front end.

Operations

 Enqueue → Insert an element at the rear

 Dequeue → Remove an element from the front

✅ Circular Queue

A circular queue is an improved version of a simple queue where the last position is
connected back to the first position, forming a circle.
This avoids the problem of unused spaces in a simple queue.

Conditions

 Queue is empty when:

 front == -1

 Queue is full when:

 (rear + 1) % size == front

Algorithm for ENQUEUE in a Circular Queue

1. Start.

2. Check if the queue is full:

o If the front position is exactly one step ahead of the rear


(in circular manner), then the queue is full.

o If full, display “Queue Overflow” and stop.

3. If the queue is empty (front = -1):

o Set front = 0.

o Set rear = 0.

4. Otherwise (queue is not empty):


o Move rear to the next position in circular order using
modulo operation.

5. Insert the new item at the position pointed by rear.

6. End.

Algorithm for DEQUEUE in a Circular Queue

1. Start.

2. Check if the queue is empty (front = -1):

o If empty, display “Queue Underflow” and stop.

3. Take the element from the position pointed by front and store
it.

4. If there is only one element in the queue (front == rear):

o Set front = -1.

o Set rear = -1.

5. Otherwise (more than one element is present):

o Move front to the next position in circular order using


modulo operation.

6. Return the stored element.

7. End.

[Link] circular queue with advantages.


Answer - Definition / Introduction

A circular queue is a special type of queue where the last position of the array
connects back to the first, forming a loop.
It follows the FIFO rule (First In First Out) but uses memory more efficiently than a
normal linear queue.

Detailed Explanation

 In a circular queue, both front and rear move in a circle using modulo arithmetic.
 When the rear reaches the last index, it goes back to index 0 (wrap-around).

 It prevents the problem of unused spaces that occur in a simple linear queue.

 The queue is full when (rear + 1) % size == front.

 The queue is empty when front == -1.

 Insertion happens at the rear, deletion happens at the front.

Advantages / Applications

 Efficient memory use because no space is wasted.

 Fast operations (O(1) insertion and deletion).

 Useful in CPU scheduling, traffic management, buffering, and real-time systems.

 Works well in situations where continuous, cyclic data processing is needed.

Conclusion

A circular queue is an efficient FIFO structure that reuses array space in a loop, making
it ideal for memory-critical and real-time applications.

[Link] dequeue (double-ended queue) with operations.


Answer - Definition

 A deque (double-ended queue) is a linear data structure where insertion and


deletion can occur at both front and rear ends.

Operations

 InsertFront, InsertRear

 DeleteFront, DeleteRear

[Link] priority queue and its use cases.(Important)


Answer - Definition

 A priority queue is a special queue where each element has a priority, and the
element with the highest priority is removed first.

Use Cases
 Used in CPU scheduling,

 Dijkstra’s shortest path,

 event-driven simulations, and

 task management.

[Link] between stack and queue with examples.(Important)


Answer - Difference Between Stack and Queue

Stack (LIFO)

 Uses Last In, First Out order

 Insertion/deletion at top only

 Implemented using arrays or linked lists

 Used in function calls, undo operations

Queue (FIFO)

 Uses First In, First Out order

 Insertion at rear, deletion at front

 Implemented using arrays, linked lists, circular queues

 Used in CPU scheduling, printer queues

Example

 Stack → function call stack

 Queue → printer job queue

[Link] infix to postfix and explain evaluation using stack.


(Important)
Answer - 1. Infix, Prefix, Postfix Notations
 Infix: Operator is written between operands.
Example: A + B

 Postfix (Reverse Polish Notation): Operator is written after operands.


Example: AB+

 Prefix (Polish Notation): Operator is written before operands.


Example: +AB

2. Infix to Postfix Conversion (Using Stack)

Algorithm

1. Scan the infix expression from left to right.

2. If the symbol is an operand, add it to postfix output.

3. If the symbol is an operator:

o Pop operators from stack that have higher or equal precedence,


and append them to postfix.

o Then push the current operator.

4. If the symbol is ( → push to stack.

5. If the symbol is ) → pop from stack until '(' comes.

6. After entire expression is scanned, pop all remaining operators.

Precedence order

3. Example: Convert Infix → Postfix

Infix:

A+B*C

Postfix:
ABC*+

Explanation:

 B*C has higher precedence, so * comes first, then +.

4. Postfix Evaluation (Using Stack)

Algorithm

1. Scan postfix expression left to right.

2. If symbol is an operand, push to stack.

3. If symbol is an operator:

o Pop two operands from stack

o Apply the operator

o Push result back to stack

4. At the end, the value left in stack is the final answer.

Example: Evaluate Postfix

Postfix:

23*5+

Step-by-step:

 Push 2

 Push 3

 * → pop 3 and 2 → 2×3 = 6 → push 6

 Push 5

 + → pop 5 and 6 → 6+5 = 11 → push 11

Final Answer = 11
[Link] Polish and Reverse Polish Notation with examples.
(Important)
Answer - Definition

 Polish Notation (Prefix): Operator comes before operands.

 Reverse Polish Notation (Postfix): Operator comes after operands.

Examples

 Prefix: + A B

 Postfix: A B +

4️⃣ Linked Lists

[Link] linked list. Explain insertion and deletion in singly linked list.
(Important)
Answer - Definition / Introduction

A linked list is a simple data structure made of nodes, where each node stores data and
a pointer to the next node.
It is a dynamic structure, meaning memory grows or shrinks as needed.

Detailed Explanation

 A singly linked list has nodes connected in one direction.

 Each node contains: data and next pointer.

 The first node is called the head.

 Insertion means adding a new node at the beginning, end, or middle.

 Deletion means removing a node from the list.

 No need for continuous memory like arrays.

ASCII Diagram
Insertion in
Singly Linked List (Explanation Only)

 Insertion at Beginning:

o A new node is created.

o Its next pointer is made to point to the current head.

o Head is updated to this new node.

 Insertion at End:

o A new node is created.

o The list is traversed to reach the last node.

o The last node's next pointer is made to point to the new node.

 Insertion in Middle (After a Node):

o A new node is created.

o The position is located by traversing.

o The new node is linked between two nodes by adjusting next pointers.

Deletion in Singly Linked List (Explanation Only)

 Deletion at Beginning:

o Head moves to the next node.

o The first node is removed.

 Deletion at End:

o The list is traversed to reach the second-last node.

o Its next pointer is set to NULL.

o The last node is removed.

 Deletion in Middle (Specific Node):

o The previous node of the target node is located.


o Its next pointer is adjusted to skip the node to be deleted.

o The unwanted node is removed.

Advantages / Applications

 Easy insertion and deletion without shifting elements.

 Dynamic size; memory-efficient.

 Used in queues, stacks, hash chaining, graphs, and dynamic memory allocation.

Conclusion

A singly linked list stores nodes in a flexible, non-contiguous manner, making insertion
and deletion simple through pointer adjustments.

[Link] representation of linked lists in memory.


Answer -

[Link] is a doubly linked list? Explain its applications.(Important)


 Answer - A doubly linked list is a linked structure where each node has two
pointers: one to the next node and one to the previous node.

Applications

 Used in browser history navigation,

 music/video playlists,

 undo–redo operations, and


 memory management.

[Link] circular linked list with advantages.(Imptortant)


Answer - Definition

 A circular linked list is a list where the last node’s pointer points back to the first
node, forming a closed loop.

Advantages

 Efficient for repeated traversal,

 Useful in CPU round-robin scheduling,

 No NULL at end, so continuous movement is easy.

[Link] circular doubly linked list with structure and example.


(Important)
Answer - Definition / Introduction

A circular doubly linked list is a linked list where each node has two pointers
(previous and next), and the last node connects back to the first, forming a circle.
It allows movement in both directions and has no NULL pointers.

Detailed Explanation

 Each node contains: data, next pointer, and prev pointer.

 The next pointer of the last node points to the first node.

 The prev pointer of the first node points to the last node.

 You can traverse forward or backward because of two-way links.

 Useful for applications where continuous looping through data is needed.


Structure

struct Node {

int data;

Node* next; // points to next node

Node* prev; // points to previous node

};

Example

Let the list contain: 10, 20, 30

Explanation of the example:

 [Link] → 20

 [Link] → 30

 [Link] → 10 (circular link)

 [Link] → 30

 [Link] → 10

 [Link] → 20

Advantages / Applications

 Easy forward and backward traversal.

 Circular nature allows continuous cycling through elements.

 Useful in music players, round-robin scheduling, and real-time applications.

Conclusion
A circular doubly linked list is a flexible structure where nodes link both ways and form
a closed loop, making traversal smooth and efficient.

[Link] is garbage collection? Explain how memory is reclaimed.


(Important)
Answer - Definition

 Garbage collection is the automatic process of identifying and freeing memory that
is no longer in use by a program.

How Memory Is Reclaimed

 The system scans for objects not referenced anymore and releases their memory
back to the heap.

 Techniques like mark-and-sweep are commonly used.

[Link] dynamic memory allocation for linked lists.


 Answer - Dynamic memory allocation allows linked list nodes to be created at
runtime using heap memory, usually with new in C++.

Explanation

 Each new node is allocated dynamically, linked using pointers, and freed with delete
when no longer needed.

5️⃣ Trees

[Link] a tree. Explain basic terminologies: root, degree, leaf, height,


level, etc.(Important)
Answer - Tree is non-linear data structure which organizes data in hierarchical
structure and this is a recursive definition.

Root: First/top node


Edge:

Parent:

Child:
Degree: Number of children of a node

Leaf: Node with no children

Siblings:
Internal Nodes:

Degree:

Level: Position of a node from the root


Height: Longest path from root to a leaf

Depth:
Path:

Sub-tree : In a tree data structure, each child from a node forms a sub tree recursively.
Every child node will form a sub tree on its parent node.

[Link] strictly binary tree and complete binary tree with examples.
Answer - A strictly binary tree is a binary tree in which every node has either 0 or 2
children.
A complete binary tree is a binary tree where all levels are completely filled, except
possibly the last, and nodes in the last level are filled from left to right.

Detailed Explanation

Strictly Binary Tree

 Also called a full binary tree.


 Each node must have exactly 0 or 2 children.

 No node is allowed to have only one child.

 Leaf nodes have no children; internal nodes have exactly two.

Complete Binary Tree

 All levels are completely filled, except maybe the last.

 Last level is filled left to right without gaps.

 Used in heaps due to compact structure.

 Ensures balanced height.

Advantages / Applications

Strictly Binary Tree

 Simple structure, useful for theoretical proofs.


 Basis for perfect and full trees.

Complete Binary Tree

 Used in heaps (priority queues).

 Ensures minimal height → efficient operations.

[Link] binary tree. Explain types of binary trees.


Answer - A binary tree is a tree in which each node can have at most two children,
called the left and right child.

Types of Binary Trees

1. Rooted Binary Tree

2. Full / Strictly Binary Tree

3. Complete / Perfect Binary Tree

4. Almost Complete Binary Tree


[Link] binary search tree (BST) operations with algorithms.
(Important)
Answer - A Binary Search Tree (BST) is a special binary tree where every node’s left
child contains smaller values, and the right child contains larger values.
It allows fast searching, insertion, and deletion because data is always stored in sorted
order.

Detailed Explanation

 BST follows the left < root < right property.

 All operations (search, insert, delete) use comparisons and move left or right.

 Searching becomes efficient because half of the tree is eliminated at each step.

 Deletion has three cases: leaf node, node with one child, node with two children.

 In-order traversal of BST produces sorted output.

Operations on BST

1. Algorithm for Searching in a Binary Search Tree (BST)

1. Start.

2. If the current node (root) is NULL, the key is not in the tree → return “Not Found.”

3. Compare the key with the data of the current node.

4. If both are equal, the key is found → return “Found.”

5. If the key is smaller than the current node’s data, move to the left child and continue
searching.

6. Otherwise, move to the right child and continue searching.

7. End.
2. Algorithm for Inserting a Node in a Binary Search Tree (BST)

1. Start.

2. If the tree is empty (root is NULL), create a new node with the given key and make it
the root.

3. Otherwise, compare the key with the root’s data.

4. If the key is smaller, insert it in the left subtree.

5. If the key is larger, insert it in the right subtree.

6. After inserting in the correct position, return the updated root.

7. End.

3. Algorithm for Deleting a Node from a Binary Search Tree (BST)

1. Start.

2. If the tree is empty (root is NULL), return NULL (nothing to delete).

3. Compare the key with the root’s data.

4. If the key is smaller, move to the left subtree to delete it.

5. If the key is larger, move to the right subtree to delete it.

6. If the key matches the root’s data (node found), then:

o Case 1: No child → remove the node and return NULL.

o Case 2: One child → return the child node to replace the deleted node.

o Case 3: Two children →

 Find the smallest value in the right subtree (inorder successor).

 Replace the node’s data with this smallest value.

 Delete the inorder successor from the right subtree.

7. Return the updated root.

8. End.
[Link] tree traversal: inorder, preorder, postorder with examples.
(Important)

Answer - Tree traversal means visiting all the nodes of a tree in a specific order.
The three basic depth-first traversal methods are inorder, preorder, and postorder.

Detailed Explanation

 Traversal allows us to process every node exactly once.

 In inorder, we visit: left → root → right.


 In preorder, we visit: root → left → right.
 In postorder, we visit: left → right → root.
 These methods are commonly used in expression trees, searching, and tree printing.

[Link] AVL tree with rotations (LL, RR, LR, RL).(Important)


Answer - 1. Introduction to AVL Tree

An AVL Tree is a self-balancing Binary Search Tree (BST) where the height
difference between the left and right subtrees of every node must be –1, 0, or +1.

This height difference is called the Balance Factor:

Balance Factor (BF) = height(left subtree) – height(right subtree)

If the BF becomes less than –1 or greater than +1, the tree becomes unbalanced, and
rotations are required to restore balance.
2. Types of Rotations in AVL Tree

AVL trees use four types of rotations to maintain balance:

1. LL Rotation (Left–Left)

2. RR Rotation (Right–Right)

3. LR Rotation (Left–Right)

4. RL Rotation (Right–Left)

Each is explained below.

3. LL Rotation (Left–Left Rotation)

Condition

Occurs when:

 A node becomes left-heavy, and

 The imbalance is caused by the left child’s left subtree.

Structure

Fix

Perform a Right Rotation on node A.

After rotation:

/\

C A

⭐ 4. RR Rotation (Right–Right Rotation)

Condition
Occurs when:

 A node becomes right-heavy, and

 The imbalance is caused by the right child’s right subtree.

Structure

Fix

Perform a Left Rotation on node A.

After rotation:

/\

A C

5. LR Rotation (Left–Right Rotation)

Condition

Occurs when:

 A node is left-heavy, but

 The left child is right-heavy.

Structure

\
C

Fix

Two rotations:

1. Left Rotation on B

2. Right Rotation on A

Final Balanced Tree

/\

B A

6. RL Rotation (Right–Left Rotation)

Condition

Occurs when:

 A node is right-heavy, but

 The right child is left-heavy.

Structure

Fix

Two rotations:

1. Right Rotation on B

2. Left Rotation on A

Final Balanced Tree

C
/\

A B

[Link] notes on B-Tree.(Important)


Answer - Definition

 A B-Tree is a balanced multi-way search tree where each node can store multiple
keys and have multiple children.

 It keeps data sorted and maintains balance for fast search, insert, and delete.

Key Point

 Widely used in databases and file systems because it minimizes disk accesses.

[Link] notes on B+ Tree.(Important)


Answer - Definition

 A B+ Tree is an extended form of B-Tree where all actual data is stored only in leaf
nodes, and internal nodes store keys for indexing.

Key Point

 Leaves are linked, making range queries and sequential access very efficient
(commonly used in databases).
[Link] threaded binary tree with diagram.
Answer - Definition

 A threaded binary tree replaces NULL pointers with special links called threads
that point to the inorder predecessor or successor, enabling faster traversal
without recursion or stack.

Key Point

 Threads help in inorder traversal by providing direct links to next nodes.

6️⃣ Graphs, Searching & Sorting

[Link] basic graph terminology: vertex, edge, degree, paths, types


of graphs.
Answer - A graph is a non-linear data structure consisting of vertices (nodes) and
edges that connect pairs of vertices.
A graph is represented as G = (V, E) where:
 V = set of vertices

 E = set of edges

Graphs are widely used to represent networks, social media connections, maps, etc.

Types:
[Link] a graph using adjacency matrix and adjacency list.
(Important)
Answer - Adjacency Matrix

 A 2D array where 1 shows an edge and 0 shows no edge.

ABC

A [0 1 0]

B [1 0 1]

C [0 1 0]
Adjacency List

 Each vertex stores a list of its adjacent vertices.

A→B

B→A→C

C→B

[Link] BFS and DFS with examples.(Important)


Answer - BFS (Breadth-First Search) and DFS (Depth-First Search) are two
fundamental graph/tree traversal algorithms.

 BFS explores level by level (horizontal movement).

 DFS explores as deep as possible before backtracking (vertical movement).

Both are used in graphs and trees for searching, pathfinding, cycle detection, etc.

Detailed Explanation

Breadth-First Search (BFS)

 Uses a queue.

 Visits nodes level by level.

 Suitable for finding shortest path in an unweighted graph.

 Good for exploring neighbors first.

Depth-First Search (DFS)

 Uses stack (explicit or via recursion).

 Goes deep into one path until no more nodes, then backtracks.

 Good for topological sorting, cycle detection, etc.

Algorithm for Breadth-First Search (BFS)


1. Start.
2. Create an empty queue.
3. Mark the starting node as visited.
4. Insert (enqueue) the starting node into the queue.
5. Repeat the following steps while the queue is not empty:
o Remove (dequeue) a node from the front of the queue.
o Visit all its neighbouring nodes one by one.
o For each neighbour that is not visited:
 Mark it as visited.
 Insert (enqueue) it into the queue.
6. Continue until all reachable nodes are visited.
7. End.

Example Graph

/ \

B C

/\ \

D E F

BFS Traversal

Order: A → B → C → D → E → F

Level 0: A

/ \

Level 1: B C

/\ \

Level 2: D E F

Algorithm for DFS (Recursive Method)

1. Start.

2. Select a starting node.

3. Mark the starting node as visited.

4. For each neighbour of this node:

o If the neighbour is not visited,


→ call DFS again on that neighbour.

5. Continue this process until all connected nodes are visited.

6. End.

Algorithm for DFS (Iterative Using Stack)

1. Start.
2. Create an empty stack.

3. Push the starting node onto the stack.

4. Repeat while the stack is not empty:

o Pop a node from the stack.

o If the node is not visited:

 Mark the node as visited.

 Push all its neighbouring nodes onto the stack.

5. Continue until all reachable nodes are visited.

6. End.

We use the same graph as earlier:

/\

B C

/\ \

D E F

DFS Traversal Example

Possible DFS Order:


A→B→D→E→C→F

Advantages / Applications

BFS

 Finds shortest path.

 Used in network broadcasting, AI level-order processing.

 Good for problems involving distance.

DFS
 Ideal for maze solving, cycle detection, topological sort.

 Used in backtracking (N-Queens, Sudoku).

[Link] Dijkstra’s Algorithm for the shortest path.(Important)


Answer - Definition / Introduction

Dijkstra’s Algorithm is a shortest-path algorithm used to find the minimum distance


from a source node to all other nodes in a graph with non-negative weights.
It is widely used in routing, navigation, and network optimization.

Detailed Explanation

 Works on weighted graphs (edges have costs).

 Finds the shortest path from the source to every other node.

 Uses a priority queue or minimum-distance selection.

 Always expands the nearest unvisited node first.

 Stores distances in a table (distance array).

 Updates distances continuously (called relaxation).

 Stops when all nodes are visited.

ASCII Diagram (Simple Graph)


(2)
A ------ B
| |
(4)| |(1)
| |
C ------ D
(3)
Weights:
A–B = 2, A–C = 4, B–D = 1, C–D = 3

Algorithm for Dijkstra’s Shortest Path

1. Start.

2. Set the distance of every node to infinity.

3. Set the distance of the source node to 0.


4. Mark all nodes as unvisited.

5. Repeat the following steps until all nodes are visited:

o Select the unvisited node that has the smallest distance value. Call this node
U.

o Mark node U as visited.

o Check every neighbouring node V of U:

 If the distance from the source to U, plus the edge weight between U
and V, is smaller than the current distance of V,
then update the distance of V with this new smaller value.

6. When all nodes have been visited, stop.

7. The final distance values represent the shortest path from the source to all other
nodes.

[Link] in-degree and out-degree with examples.(Important)


Answer - Definition

 In-degree: Number of edges coming into a vertex.

 Out-degree: Number of edges going out from a vertex.

[Link] shortest path in unweighted graphs using BFS.


Answer - Definition / Introduction

The shortest path in an unweighted graph means finding the minimum number of
edges needed to go from a source node to any other node.
Since all edges have equal weight (1), the best method is Breadth-First Search (BFS)
because it explores the graph level by level.

Detailed Explanation

 In an unweighted graph, every edge has the same cost (1).

 BFS is ideal because it visits all nodes at distance 1, then distance 2, and so on.
 When BFS first reaches a node, that visit is guaranteed to be the shortest path.

 BFS uses a queue to process nodes level-wise.

 A distance array stores the shortest distance of each node from the source.

 A parent array is often used to reconstruct the actual shortest path.

Algorithm:

1. Start.

2. Mark every vertex as not visited.

3. Set the distance of the source to 0.

4. Put the source into a queue.

5. While the queue has elements:

o Take out one vertex u from the queue.

o Look at every neighbour v of u.

o If v is not visited:

 Mark v as visited.

 Set distance of v = distance of u + 1.

 Set parent of v = u.

 Put v into the queue.

6. When the queue becomes empty, all shortest distances are ready.

7. End.

[Link] various searching techniques (overview).


Answer - Definition

 Searching techniques are methods used to find an element in a data structure like
an array or list.

Key Techniques

 Linear Search: Checks each element one by one (works on any list).
 Binary Search: Repeatedly divides a sorted list into halves to locate the element.

[Link] sorting algorithms overview and comparison table (time &


space).
Answer - Overview

 Sorting algorithms arrange data in ascending or descending order.

 Common methods include Bubble, Selection, Insertion, Merge, and Quick Sort.

Comparison Table (Very Short)

Algorithm Time (Avg) Space Stable

Bubble O(n²) O(1) Yes

Insertion O(n²) O(1) Yes

Merge O(n log n) O(n) Yes

Quick O(n log n) O(log n) No

7️⃣ Hashing

[Link] hashing and hash table.(Important)


Answer - Hashing is a technique used in data structures that

efficiently stores and retrieves data in a way that

allows for quick access.

Definition

 Hashing is a technique that converts a key into a fixed index using a hash function.

 A hash table is a data structure that stores values at these computed indices for fast
access.

Example / Key Point

 Used for O(1) average-time search, insert, delete.


[Link] types of hash functions: division, folding, mid-square, etc.
Answer – Types:

Division Method.

Mid Square Method

Folding Method.

Multiplication Method

[Link] collisions and collision resolution techniques (chaining,


linear probing).(Important)
Answer - Definition / Introduction

A collision happens in a hash table when two different keys get the same hash index.
Because only one value can be stored at one index, we need special methods to handle
these collisions safely.

Detailed Explanation

What Causes Collisions?

 Limited table size.

 Many keys mapping to the same index.

 Poor hash function.

Collision Resolution Techniques

Two common methods:

1. Chaining (Open Hashing)

 Each index stores a linked list of values.

 If multiple keys map to the same index, they are added to that index’s list.

 Table never becomes full (except memory limit).

 Searching involves scanning the linked list.

2. Linear Probing (Open Addressing)

 If an index is full, move to the next empty index (index + 1).


 Continue checking sequentially (wrapping around using modulo).

 No linked lists; everything stored inside the table.

 May cause primary clustering (long chain of filled slots).

Chaining
Hash Table (Index → Linked List)

0 → 15 → 35 → 75
1 → 21
2 → 42 → 62
3 → (empty)
4 → 19

Linear Probing

Suppose keys: 10, 20, 30


Table size = 10
Hash: key % 10

Insert 10 → index 0

Insert 20 → index 0 (collision) → index 1

Insert 30 → index 0 (collision) → 1 (full) → index 2

Final table:

Index: 0 1 2

Data : 10 20 30

Algorithm / Steps (Chaining & Linear Probing)

Chaining – Insert

index = hash(key)

insert key into linked list at table[index]

Linear Probing – Insert

index = hash(key)

while table[index] is full:

index = (index + 1) % size

store key at table[index]

Advantages / Applications
Chaining

 Easy to implement.

 No clustering.

 Table can handle many elements.

Linear Probing

 Simple and memory-efficient.

 Better cache performance (array-based).

[Link] is a perfect hash function? Explain with example.(Important)


Answer - Definition

 A perfect hash function maps each key to a unique index with no collisions.

 Works only when the set of keys is fixed and known in advance.

Example

Keys: {10, 22, 37}


A perfect hash may map: 10→0, 22→1, 37→2 (no two keys share an index).

10 → 0

22 → 1

37 → 2

(no collisions)

[Link] principles for designing a good hash function.(Important)


Answer - Definition

 A good hash function distributes keys uniformly across the table and minimizes
collisions while being fast to compute.

Principles

 Avoid patterns; ensure uniform distribution

 Use all parts of the key in computation


 Should be fast, simple, and produce different indices for similar keys

 Table size often chosen as a prime number to reduce clustering

8️⃣ Miscellaneous Short Notes

[Link] and basics of heap sort.(Important)


Answer - Definition

 A heap is a special complete binary tree where each parent follows a rule:
Max-Heap: parent is bigger than children
Min-Heap: parent is smaller than children

Basics of Heap Sort

 First convert the array into a max-heap.

 Then repeatedly remove the largest element (root) and place it at the end of the
array.

 Finally, the array becomes sorted.

[Link] Polish Notation (RPN).(Important)


Answer - Definition

 Reverse Polish Notation (RPN) or Postfix notation is a form of writing


expressions where the operator comes after the operands.

 It removes the need for brackets.

Example

 Infix: A + B

 RPN/Postfix: A B +

[Link] pointer.(Important)
Answer - Definition
 A dangling pointer is a pointer that still points to a memory location after it has
been freed or deleted.

 Using it can cause errors or crashes.

Example

int *p = new int(5);

delete p; // memory freed

p; // now p is a dangling pointer

[Link] of searching techniques.(Important)


Answer - Definition

 Searching techniques are methods used to find a specific element in a list, array, or
any data structure.

Overview

 Linear Search: Checks each element one by one; works on unsorted data.

 Binary Search: Repeatedly divides the list into halves; works only on sorted data
and is much faster

[Link] of sorting types with comparison chart.(Important)


Answer - Sorting arranges elements in ascending or descending order.

Common types: Bubble, Selection, Insertion, Merge, Quick Sort.

You might also like