DSA 101 Data Structures and Algorithms
COURSE NAVIGATION

SUBJECT CONTENT

⌂   Overview

PRELIMS

1. Introduction 2. Arrays 3. Searching 4. Sorting

MIDTERMS

1. Linked Lists 2. Stacks 3. Queues 4. Hash Tables

FINALS

1. Trees 2. Graphs 3. Advanced Topics ⚖   Grading System ▣   Resources

Welcome to

Data Structures and Algorithms

Master efficient data organization and problem-solving techniques to build better programs and solve real-world challenges. Start Learning   →
●
 ●  ●

Information about Subject

▣
Course NameData Structures
and Algorithms
</>
Course CodeCC 103
◷
Duration19 Weeks
♙
InstructorJDP

Course Description

This course covers fundamental data structures and algorithms and their applications in solving real-world problems efficiently. Students will learn how to design, analyze, and implement algorithms using appropriate data structures to optimize performance in terms of time and space complexity.

Course Outline

The course is divided into three major parts: Prelims, Midterms, and Finals.

🖉 PRELIMS

  1. Introduction to Data Structures and Algorithms
    • What is DSA?
    • What is a Data Structure?
    • What is an Algorithm?
    • Algorithm Complexity
    • Time Complexity
    • Space Complexity
  2. Arrays
    • Introduction to Arrays
    • Creating & Initializing Arrays
    • Access
    • Update
    • Traversal
    • Insertion
    • Deletion
    • Array Complexity
  3. Searching Algorithms
    • Linear Search
    • Binary Search
    • Jump Search
    • Searching Comparison
  4. Sorting Algorithms
    • Introduction to Sorting
    • Bubble Sort
    • Selection Sort
    • Insertion Sort
    • Merge Sort
    • Quick Sort
    • Sorting Comparison

🖉 MIDTERMS

  1. Linked Lists
    • Introduction to Linked Lists
    • Singly Linked List
    • Doubly Linked List
    • Circular Linked List
    • Linked List Operations
    • Linked List Comparison
  2. Stacks
    • Introduction to Stack
    • Push
    • Pop
    • Peek / Top
    • IsEmpty / IsFull
    • Stack Implementation
    • Applications of Stack
    • Stack Complexity
  3. Queues
    • Introduction to Queue
    • Enqueue
    • Dequeue
    • Front / Peek
    • IsEmpty
    • Queue Implementation
    • Circular Queue
    • Priority Queue
    • Queue Applications
  4. Hash Tables
    • Introduction to Hashing
    • Hash Functions
    • Insert
    • Search / Lookup
    • Delete
    • Update
    • Collision Handling
    • Applications

🖉 FINALS

  1. Trees
    • Introduction to Trees
    • Binary Trees
    • Tree Operations
    • Binary Search Tree
    • Tree Traversal
    • Tree Complexity
  2. Graphs
    • Introduction to Graphs
    • Graph Types
    • Graph Representation
    • Graph Operations
    • BFS
    • DFS
    • Shortest Path
  3. Advanced Algorithms
    • Recursion
    • Divide and Conquer
    • Dynamic Programming
    • Algorithm Comparison & Problem Solving
IT Learning Hub section icon

Topics in Prelims

Introduction, arrays, searching, and sorting.

1. Introduction

1.1 What is DSA?

Data Structures and Algorithms (DSA) is a way of organizing and processing data efficiently in a computer. In understanding DSA, it is essential to have a basic understanding of programming.


It is a fundamental area in Information Technology and Computer Science that focuses on:

  • How data is organized and stored
  • How data is accessed and manipulated
  • How problems can be solved systematically
  • How efficient solutions perform

In simplier terms, Data Structure determines how data is organized, while Algorithm determines how we process that data to solve a problem or perform a task.

Example:

When you search for a contact in your phone, the data is stored in some structure, such as a list or tree, and the search is done using an algorithm.

DATA▦
→
ALGORITHM⚙
→
OUTPUT✓
Why do we need DSA?

We need Data Structures and Algorithms (DSA) because they provide the core foundation for writing efficient code, solving complex computational problems, and building scalable software

The way data is organized and the algorithm used to process, significantly affects the applications performance.


For Example, a school system may need to manage:

  • 10,000 Students
  • 50,000 Grades
  • 100,000 Attendance Records

Simply storing the data is not enough. The program may need to:

  • Find a student
  • Add a new student
  • Delete record
  • Sort students
  • Search for grades
  • Calculate statistics
  • Connect related records

Determining the appropriate Data Structure and Algorithm to use is essential in the program's performance.


Another real-life example: Library System

The system contains:

  • Books
  • Students
  • Borrowing Records
  • Return Dates

The data can be organized using appropriate data strucutre.

Books

↓

Data Structure (Array / Linked List / Hash Table)

↓

Algorithm (Search for Book)

↓

Result

If a student searches for a book, the system needs an algorithm to locate it.

If thousands of books exist, choosing an appropriate data structure and algorithm becomes important.


Data vs Information
Data refers to raw facts and figures.
Information is processed and organized data that has meaning and can be used to make decisions.

Example:

Data: 25, 30, 28, 35, 32
 These are just numbers without context.

Information: "The temperatures for the past five days were 25°C, 30°C, 28°C, 35°C, and 32°C. The hottest day was 35°C."
 The data has been organized and given meaning, making it useful.

Another Example:

Data: Mars, Chris, Kyle, John, Rico
 These are just random names and we don't know who they are.

Information: "The starting lineup of Team Icon for the Basketball Championship are Kyle, John, Chris, Mars and Rico"
 In the information, the data was processed and given meaning.

1.2 Data Structures

A data structure is a way of organizing and storing data so that we can use it efficiently in a computer.


Why are there different Data Structures

Different problems require different ways of organizing data.

Consider the Following data:

    80, 76, 79, 83, 81

  • An array is suitable when we want to store elements in an indexed sequence.
  • But consider a browser's Back button.
  • The most recently visited page should be accessed first.
  • A Stack is appropriate for this situation.
  • Another example is a customer waiting in line.
  • The first customer who arrives should generally be served first.
  • A Queue is appropriate.

Therefore, different problems require different data structures


Classification of Data Structure

Data structures are commonly classified into two major categories: Primitive and Non-Primitive

Primitive Data Structures

These are the basic data types provided by a programming language.

  • Integer
  • Float/Double
  • Character
  • Boolean
  • String/Varchar
Non-Primitive Data Structures

These are more complex data organizations created by combining primitive data types (like integers, floats, and characters) to store, manage, and manipulate collections of data efficiently.

Unlike primitive types that store a single value directly in stack memory, non-primitive structures usually store references or memory addresses to objects allocated dynamically in the heap memory.


Non-Primitive Data Structures are divided into two categories, Linear and Non-Linear data structures.

A. Linear Data Structures
In a linear data structure, elements are arranged sequentially, one after another.
  • Array
  • Linked List
  • Stack
  • Queue
B. Non-Linear Data Structures
In a Non-Linear Data Structures, elements are not arranged sequentially. They can have hierarchical or network relationships.
  • Tree
  • Graph
Choosing a Data Structure

When choosing a data structure, consider:

  • What type of data is being stored?
  • How frequently will the data be accessed?
  • Will data be inserted frequently?
  • Will data be deleted frequently?
  • Is fast searching required?
  • How much memory is available?
  • What relationships exist between the data?

The goal is to choose a structure that makes the required operations efficient.

1.3 Algorithms

An algorithm is a step by step process, procedure or instruction to solve a problem or to perform or accomplish a specific task.

Algorithm tells the computer what steps to follow in order to get the desired result.

Example: Find and Display the Largest Number

Given: 25, 30, 28, 35, 32

An Algorithm can be:

  1. Start
  2. Assume the first number is the largest number
  3. Compare it to the next number
  4. If the next number if larger, make it the new largest number
  5. Continue until all numbers have been checked
  6. Display the largest number
  7. End

Result: 35

Note: You have to first Understand the Problem or Task and come up with a Solution to solve it before writing it's algorithm.

Characteristics of an Algorithm
  • Input: one or more inputs may be provided.
  • Output: one or more outputs are produced.
  • Definiteness: each step must be clear and unambiguous.
  • Finiteness: the algorithm eventually terminates.
  • Effectiveness: each step is practical and executable.

Algorithm vs Pseudocode vs Program

Algorithm is the step by step solution or logic using natural language, Pseudocode expresses the algorithm using structured elements that resembles a programming code but may use a natural language, while Program is the actual implementation of the algorithm using a programming language that is executable.

Algorithm Example:

Algorithm: Find the Largest Number

Given: [25, 30, 28, 35, 32]

1. Start

2. Gather Data

3. Create variable named "Largest"

4. Create variable named "Current"

5. Set the first number as the initial value of Largest

6. Set the second number as the initial value of Current

7. Compare the value of Current to Largest

8. If the Current is larger, make it the new value of Largest

9. If not, the value of the Largest will retain

10. Set the next number to the Current as the new value of the Current

11. Repeat Steps 7 to 11, until the last number or until all numbers are checked

12. Display the largest number

13. End

Largest → stores the largest value found so far

Current → stores the value currently being examined

Pseudocode Example:

Pseudocode: Find the Largest Number

BEGIN

    Numbers ← [25, 30, 28, 35, 32]

    CREATE Largest

    CREATE Current

    Largest ← first number

    Current ← second number

 

    REPEAT for each remaining number

 

        IF Current > Largest THEN

            Largest ← Current

        END IF

 

        Current ← next number

 

    END REPEAT

 

    DISPLAY Largest

END

Program Example:

Pseudocode: Find the Largest Number

Programming Language: Java

public class LargestNumber {

    public static void main(String[] args) {

 

        int[] numbers = {25, 30, 28, 35, 32};

 

        int Largest;

        int Current;

 

        Largest = numbers[0];

        Current = numbers[1];

 

        for (int i = 1; i < numbers.length; i++) {

 

            Current = numbers[i];

 

            if (Current > Largest) {

                Largest = Current;

            }

 

        }

 

        System.out.println("Largest number: " + Largest);

 

    }

}

Output: Largest number: 35

Common Algorithms

Searching

  • Linear Search
  • Binary Search
  • Jump Search

Sorting

  • Bubble Sort
  • Selection Sort
  • Insertion Sort
  • Merge Sort
  • Quick Sort

Tree and Graph Algorithms

  • Tree Traversal
  • Breadth-first Search
  • Depth-first Search
  • Dijkstra's Algorithm

Advance Algorithms

  • Recursion
  • Divide and Conquer
  • Dynamic Programming

1.4 Algorithm Complexity

What is Algorithm Complexity?

Algorithm complexity describes how an algorithm's resource requirements change as the input size increases.

The Two Primary Resources are:

  • Time Complexity
  • Space Complexity

The purpose is not usually to determine the exact number of seconds or bytes on a particular computer.

Instead, we are going to understand How does the algorithm's resource usage grow when the input becomes larger?


Why is Algorithm Complexity Important?

Two algorithms can solve the same problem but may require different amounts of computational work.

For example, suppose two algorithms solve the same problem:

  • Algorithm A performs approximately 100 operations.
  • Algorithm B performs approximately 1,000,000 operations.

Both algorithms may produce the correct result, but Algorithm A may be significantly more efficient.

The difference becomes more important as the input size becomes larger. An algorithm that works well with a small amount of data may become slow when it needs to process thousands or millions of records.

Algorithm complexity helps programmers compare algorithms and choose solutions that can handle large amounts of data efficiently.


Input Size

The input size refers to the amount of data given to an algorithm. Input size is commonly represented by the variable n.

For example, consider the following array:

[25, 30, 28, 35, 32]

The array contains five elements, therefore:

n = 5

If an array contains 1,000 elements, then n = 1000. Complexity analysis examines how the algorithm behaves as n increases.


Growth Rate

The growth rate describes how the amount of work performed by an algorithm increases as the input size increases.

Common complexity classes include:

  • O(1) – Constant
  • O(log n) – Logarithmic
  • O(n) – Linear
  • O(n log n) – Linearithmic
  • O(n²) – Quadratic
  • O(n³) – Cubic
  • O(2ⁿ) – Exponential
  • O(n!) – Factorial

Asymptotic Analysis

Asymptotic analysis is the study of how an algorithm behaves as the input size becomes very large. It is a technique used to analyze the efficiency and performance of an algorithm as the input size becomes larger.

Instead of asking exactly how many seconds an algorithm takes on one particular computer, we focus on how the amount of work grows as the input size increases.

This allows us to analyze algorithms without depending entirely on the speed of a particular computer.


Big O Notation

Big O notation is commonly used to describe the asymptotic upper bound of an algorithm's growth.

It allows programmers to describe and compare how algorithms behave as the input size becomes larger.

Common Big O notations include:

  • O(1) – Constant
  • O(log n) – Logarithmic
  • O(n) – Linear
  • O(n log n) – Linearithmic
  • O(n²) – Quadratic
  • O(n³) – Cubic
  • O(2ⁿ) – Exponential
  • O(n!) – Factorial

O(1) – Constant Time

O(1) means that the amount of work remains approximately constant regardless of the input size.

Example:

int value = numbers[0];

The program accesses one specific array element directly. Whether the array contains 10 elements or 1,000,000 elements, accessing a particular element by index is typically a constant-time operation.

Time Complexity: O(1)


O(log n) – Logarithmic Time

O(log n) means that the problem size is repeatedly reduced by a constant factor.

A common example is Binary Search.

Consider the sorted array:

[10, 20, 30, 40, 50, 60, 70, 80]

Binary Search repeatedly reduces the search space.

  • 8 possible elements
  • Approximately 4 possible elements
  • Approximately 2 possible elements
  • Approximately 1 possible element

Time Complexity: O(log n)

Important: Standard Binary Search requires the data to be sorted.


O(n) – Linear Time

O(n) means that the amount of work grows proportionally to the input size.

Example:

for (int i = 0; i < numbers.length; i++) {
                        System.out.println(numbers[i]);
                    }

If there are 5 elements, the loop executes approximately 5 times. If there are 1,000 elements, it executes approximately 1,000 times.

Time Complexity: O(n)


O(n log n) – Linearithmic Time

O(n log n) is called linearithmic complexity. This complexity commonly appears in efficient sorting algorithms.

  • Merge Sort
  • Average-case Quick Sort

Typical Complexity: O(n log n)


O(n²) – Quadratic Time

O(n²) means that the amount of work grows approximately as the square of the input size.

Example:

for (int i = 0; i < n; i++) {
                        for (int j = 0; j < n; j++) {
                            System.out.println(i + " " + j);
                        }
                    }

The outer loop executes n times. For every iteration of the outer loop, the inner loop also executes n times.

n × n = n²

Time Complexity: O(n²)

Common examples include:

  • Bubble Sort
  • Selection Sort
  • Insertion Sort in its average and worst cases

O(n³) – Cubic Time

O(n³) commonly occurs when an algorithm contains three nested loops.

for (int i = 0; i < n; i++) {
                        for (int j = 0; j < n; j++) {
                            for (int k = 0; k < n; k++) {
                                // operation
                            }
                        }
                    }

n × n × n = n³

Time Complexity: O(n³)


O(2ⁿ) – Exponential Time

O(2ⁿ) is called exponential complexity. Exponential algorithms can grow extremely quickly as the input size increases.

A classic example is a straightforward recursive implementation of the Fibonacci sequence that repeatedly solves the same subproblems.

Typical Complexity: O(2ⁿ)


O(n!) – Factorial Time

O(n!) is called factorial complexity. Factorial growth is extremely rapid and commonly appears in problems that require generating or examining all possible permutations.

  • 3! = 6
  • 4! = 24
  • 5! = 120
  • 6! = 720
  • 10! = 3,628,800

Typical Complexity: O(n!)


Complexity Ranking

The following is a useful general ordering from slower growth to faster growth:

  • O(1) – Constant
  • O(log n) – Logarithmic
  • O(n) – Linear
  • O(n log n) – Linearithmic
  • O(n²) – Quadratic
  • O(n³) – Cubic
  • O(2ⁿ) – Exponential
  • O(n!) – Factorial

Best Case

The best case represents the most favorable situation for an algorithm.

For example, in Linear Search, if the target is the first element, only one comparison may be required.

Best Case: O(1)


Worst Case

The worst case represents the least favorable situation for an algorithm.

If the target is the last element, or if the target does not exist, the algorithm may need to examine every element.

Worst Case: O(n)


Average Case

The average case describes the expected performance of an algorithm over typical inputs under an assumed input distribution.

Average Case: O(n)


Big O, Big Omega, and Big Theta

There are three important asymptotic notations commonly discussed in algorithm analysis.

  • Big O – O: Describes an asymptotic upper bound.
  • Big Omega – Ω: Describes an asymptotic lower bound.
  • Big Theta – Θ: Describes a tight asymptotic bound.

For beginners, Big O is usually the most important notation to understand first.


Big O Does Not Represent Exact Execution Time

Big O does not mean the exact number of seconds an algorithm takes to execute.

For example, O(n) does not mean that an algorithm takes exactly n seconds.

Instead, Big O describes how the computational work grows as the input size increases.

1.5 Time & Space Complexity

Time complexity measures how the computational work of an algorithm grows as the input size increases, while space complexity measures how the memory requirements of an algorithm grow as the input size increases.

In simple terms:

  • Time: How much computational work does the algorithm perform?
  • Space: How much memory does the algorithm require?

What is Time Complexity?

Time complexity describes how the amount of computational work performed by an algorithm grows as the input size increases.

Time complexity is commonly expressed using Big O notation.

It does not normally refer to the exact number of seconds required by a program because actual execution time depends on hardware, programming language, implementation, compiler, and system environment.

Instead, we focus on the growth of the work performed by the algorithm.


Example 1: Constant Time – O(1)
int value = numbers[0];

The program accesses one specific element directly. It does not need to inspect every element in the array.

Time Complexity: O(1)


Example 2: Linear Time – O(n)
for (int i = 0; i < n; i++) {
                        System.out.println(i);
                    }

The loop executes approximately n times.

Time Complexity: O(n)


Example 3: Quadratic Time – O(n²)
for (int i = 0; i < n; i++) {
                        for (int j = 0; j < n; j++) {
                            System.out.println(i + j);
                        }
                    }

The outer loop runs n times. For every iteration of the outer loop, the inner loop also runs n times.

n × n = n²

Time Complexity: O(n²)


Example 4: Cubic Time – O(n³)
for (int i = 0; i < n; i++) {
                        for (int j = 0; j < n; j++) {
                            for (int k = 0; k < n; k++) {
                                // operation
                            }
                        }
                    }

There are three nested loops, each performing approximately n iterations.

n × n × n = n³

Time Complexity: O(n³)


Sequential Loops

When loops are executed one after another rather than nested inside each other, their work is generally added.

for (int i = 0; i < n; i++) {
                        // operation
                    }
                    for (int j = 0; j < n; j++) {
                        // operation
                    }

The total work is approximately:

n + n = 2n

Ignoring the constant factor:

Time Complexity: O(n)

Important: Sequential operations are generally added, while nested loops are generally multiplied.


Different Input Sizes

Sometimes an algorithm processes two different inputs.

for (int i = 0; i < n; i++) {
                        // operation
                    }
                    for (int j = 0; j < m; j++) {
                        // operation
                    }

The first loop performs approximately n operations, while the second performs approximately m operations.

Time Complexity: O(n + m)

If the loops are nested:

for (int i = 0; i < n; i++) {
                        for (int j = 0; j < m; j++) {
                            // operation
                        }
                    }

Time Complexity: O(n × m)


Ignoring Constants

When analyzing Big O, constant factors are normally ignored.

3n becomes O(n).

5n + 10 also becomes O(n).

Big O focuses on the growth rate as the input size becomes large.


Ignoring Lower-Order Terms

When an expression contains multiple terms, we normally keep the dominant term.

n² + n + 10

The dominant term is n², therefore:

Time Complexity: O(n²)

n³ + n² + n + 100

The dominant term is n³, therefore:

Time Complexity: O(n³)


What is Space Complexity?

Space complexity describes how the memory requirements of an algorithm grow as the input size increases.

Memory may be required for:

  • Variables
  • Arrays
  • Objects
  • Data structures
  • Recursive function calls
  • Temporary data

Auxiliary Space

Auxiliary space refers to the additional memory used by an algorithm while it is executing, excluding the input itself when the input is treated as already provided.


Example 1: Constant Space – O(1)
int largest;
                    int current;
                    int index;

Only a fixed number of variables are created. The number of variables does not increase when the input size increases.

Auxiliary Space Complexity: O(1)


Example 2: Linear Space – O(n)
int[] copy = new int[n];

The new array contains n elements. As n increases, the amount of memory required also increases.

Space Complexity: O(n)


Example 3: Quadratic Space – O(n²)
int[][] matrix = new int[n][n];

The two-dimensional array contains approximately n × n = n² elements.

Space Complexity: O(n²)


Time and Space Example

Consider the following program:

int[] copy = new int[n];

                    for (int i = 0; i < n; i++) {
                        copy[i] = numbers[i];
                    }

The loop executes n times.

Time Complexity: O(n)

The program also creates a new array containing n elements.

Space Complexity: O(n)


Finding the Largest Number

Consider the following data:

[25, 30, 28, 35, 32]

The algorithm examines the numbers one by one.

  • Largest = 25
  • Compare 30 → Largest becomes 30
  • Compare 28 → Largest remains 30
  • Compare 35 → Largest becomes 35
  • Compare 32 → Largest remains 35

Every element must be examined to guarantee that the largest number has been found.

Time Complexity: O(n)

The algorithm uses only a fixed number of additional variables, such as Largest and Current.

Auxiliary Space Complexity: O(1)


Linear Search Example

Consider the array:

[25, 30, 28, 35, 32]

Suppose we want to search for 35.

The algorithm checks the elements one by one:

  • 25 → Not found
  • 30 → Not found
  • 28 → Not found
  • 35 → Found

The number of comparisons depends on where the target is located.


Linear Search – Best Case

If the target is the first element, only one comparison may be required.

Best Case: O(1)


Linear Search – Worst Case

If the target is the last element, or if the target does not exist, the algorithm may need to examine every element.

Worst Case: O(n)


Linear Search – Average Case

For typical inputs, the number of comparisons grows proportionally with the number of elements.

Average Case: O(n)


Binary Search Example

Binary Search works on sorted data.

[10, 20, 30, 40, 50, 60, 70, 80]

Instead of checking every element, Binary Search repeatedly reduces the search space.

  • Start with 8 possible elements.
  • Reduce the possible search area to approximately 4 elements.
  • Reduce it to approximately 2 elements.
  • Reduce it to approximately 1 element.

Time Complexity: O(log n)


Sorting Example

Sorting algorithms arrange data into a particular order, such as ascending or descending order.

[5, 3, 4, 1, 2]

can be sorted into:

[1, 2, 3, 4, 5]

Different sorting algorithms have different complexity characteristics.

  • Bubble Sort: typically O(n²)
  • Selection Sort: O(n²)
  • Insertion Sort: O(n²) average and worst case
  • Merge Sort: O(n log n)
  • Quick Sort: O(n log n) average and O(n²) worst case

Time-Space Trade-Off

A time-space trade-off occurs when an algorithm uses additional memory to potentially improve execution time.

For example, a hash table uses additional memory to store its data but can provide very fast average-case lookup.

More memory → potentially faster operations

However, using more memory is not always desirable. Programmers must consider the requirements and limitations of the application.


Common Data Structure Operation Complexities
  • Array Access by Index: O(1)
  • Array Search: O(n)
  • Array Traversal: O(n)
  • Linked List Access by Position: O(n)
  • Linked List Search: O(n)
  • Stack Push: O(1)
  • Stack Pop: O(1)
  • Stack Peek: O(1)
  • Queue Enqueue: O(1)
  • Queue Dequeue: O(1)
  • Hash Table Search: O(1) average
  • Hash Table Insert: O(1) average
  • Hash Table Delete: O(1) average

Quick Reference
  • O(1) – Constant
  • O(log n) – Logarithmic
  • O(n) – Linear
  • O(n log n) – Linearithmic
  • O(n²) – Quadratic
  • O(n³) – Cubic
  • O(2ⁿ) – Exponential
  • O(n!) – Factorial

Key Difference Between Time and Space Complexity

Time Complexity focuses on how the amount of computational work grows as the input size increases.

Space Complexity focuses on how the amount of memory required by the algorithm grows as the input size increases.

Time = How much work?

Space = How much memory?


Final Example

Consider an algorithm that finds the largest number in an array.

[25, 30, 28, 35, 32]

The algorithm must examine each element to guarantee that it finds the largest value.

Time Complexity: O(n)

The algorithm only needs a fixed number of additional variables, such as Largest and Current.

Auxiliary Space Complexity: O(1)

Time = O(n)

Auxiliary Space = O(1)

2. Arrays

2.1 What is an Array?

An array stores multiple values in an ordered collection. Each element can be accessed using its index.

let numbers = [10, 20, 30, 40]; console.log(numbers[0]); // 10

2.2 Array Operations

Common array operations include traversal, searching, insertion, and deletion.

3. Searching

3.1 Linear Search

Linear search checks elements one at a time until the requested value is found or the list ends.

3.2 Binary Search

Binary search works on sorted data and repeatedly divides the search interval in half.

4. Sorting

4.1 Common Sorting Algorithms

Sorting arranges data into a particular order. Common algorithms include Bubble Sort, Selection Sort, Insertion Sort, Merge Sort, and Quick Sort.

// Simple Bubble Sort
                    for (let i = 0; i < numbers.length; i++) {
                        for (let j = 0; j < numbers.length - i - 1; j++) {
                            if (numbers[j] > numbers[j + 1]) {
                                let temp = numbers[j];
                                numbers[j] = numbers[j + 1];
                                numbers[j + 1] = temp;
                            }
                        }
                    }
IT Learning Hub section icon

Topics in Midterms

Linked lists, stacks, queues, and hash tables.

Loading...
IT Learning Hub section icon

Topics in Finals

Trees, graphs, recursion, and advanced algorithms.

Loading...

Grading System

The following is the sample grading distribution presented in the course syllabus.

PRELIM

Attendance / Values 10%

Activity / Quiz / Laboratory 20%

Assignment 15%

Project 15%

Prelim Exam 40%

MIDTERM

Attendance / Values 10%

Activity / Quiz / Laboratory 20%

Assignment 15%

Project 15%

Midterm Exam 40%

FINAL

Attendance / Values 10%

Activity / Quiz / Laboratory 20%

Assignment 15%

Project 15%

Final Exam 40%

Resources