Algorithm Lab Experiments: Sorting, Searching, Greedy, DP and String Matching

Experiment 1: Insertion Sort

Aim: To implement Insertion Sort.

Theory: Insertion sort builds the sorted array one element at a time, like arranging playing cards in your hand. Each element (key) is inserted into its correct place in the already sorted left part by shifting larger elements right. It is stable, in-place and works best on small or nearly sorted data.

Algorithm:

  1. Start.
  2. Read n and the array A.
  3. For i = 2 to n, set key = A[i] and j = i - 1.
  4. While j ≥ 1 and A[j] > key, shift A[j] to A[j+1]
Read More

Binary Trees Explained: Structure, Traversals, Hashing and Sorting

1. Explain Binary Tree

A Binary Tree is a non-linear, hierarchical data structure in which each node can have a maximum of two children, traditionally referred to as the left child and the right child.

Core Structural Components

  • Root Node: The topmost node of the tree with no parent.
  • Leaf Node: A node with no children (degree 0).
  • Internal Node: A node containing at least one child.
  • Subtree: A tree structure formed by a child node and its descendants.

Key Types of Binary Trees

  • Full Binary Tree: Every node
Read More

SQL Tutorial for DBMS Unit III: Commands, DDL, DML, Joins and Subqueries

DBMS Unit III


1. SQL

Full Form

SQL = Structured Query Language

SQL is used to communicate with a relational database.

It is used to:

  • Create tables
  • Insert data
  • Retrieve data
  • Update data
  • Delete data
  • Create views
  • Define constraints
  • Control access to data

The uploaded notes also describe SQL as supporting data definition, data manipulation, view definition, transaction control and authorization.


2. Features of SQL ⭐⭐⭐⭐

1. Simple

SQL commands are relatively easy to learn.

2. Data Definition

SQL can create and modify

Read More

Algorithms Q&A: MST, Knapsack, and Backtracking

Q1. State Minimum Cost Spanning Trees Problem. Discuss Prim’s Algorithm to Solve This Problem and State Its Running Time.

Minimum Cost Spanning Tree (MCST/MST): Given a connected, weighted, undirected graph G = (V, E), a spanning tree connects all vertices using exactly |V| − 1 edges and contains no cycle. An MST is a spanning tree having minimum total edge weight: Cost(T) = Σ w(e), e ∈ T.

Prim’s Algorithm: A greedy algorithm that starts from any vertex and repeatedly adds the minimum-weight

Read More

Advanced Statistical Modeling and Real-Time Stream Analytics

Regression Modeling: Linear and Multiple Regression

1. Definition

Regression modeling is a statistical technique used to study the relationship between a dependent variable and one or more independent variables. It is mainly used for prediction and estimating relationships between variables.

2. Simple Linear Regression

It uses one independent variable.

$$Y = \beta_0 + \beta_1X + \epsilon$$

where:

  • $Y$ = dependent variable
  • $X$ = independent variable
  • $\beta_0$ = intercept
  • $\beta_1$ = regression coefficient
  • $\
Read More

Comprehensive Machine Learning Algorithms Tutorial

Linear Regression and Working Principle

Linear Regression is a supervised learning algorithm used to predict a continuous dependent variable from one or more independent variables.

For Simple Linear Regression, the relationship between x and y is represented by:

where:

  • y = predicted value
  • x = input feature
  • b0 = intercept
  • b1 = slope

Calculation of Slope

Intercept

Therefore, the regression equation becomes:

Working

  1. Collect training data.
  2. Assume a linear relationship between input and output.
  3. Calculate the regression
Read More