CASE STUDY
Algorithms:
1. Space Complexity: Space complexity of an algorithm refers to the amount of memory space
required by the algorithm to execute as a function of the input size. It indicates how much
memory is needed by the algorithm in the worst-case scenario. Space complexity is usually
expressed in terms of Big O notation.
2. Worst Case, Average Case, and Best Case:
Worst Case: This refers to the scenario where the algorithm takes the maximum amount
of time or resources to execute for a given input size. It represents the slowest possible
execution time.
Average Case: This refers to the expected performance of the algorithm over all possible
inputs. It takes into account the likelihood of various inputs occurring and their
corresponding execution times.
Best Case: This refers to the scenario where the algorithm takes the minimum amount of
time or resources to execute for a given input size. It represents the fastest possible
execution time.
3. Algorithm FindMaximum(num1, num2, num3)
if num1 >= num2 and num1 >= num3 then
return num1
else if num2 >= num1 and num2 >= num3 then
return num2
else
return num3
FLOWCHART
Procedural Programming:
1. C Program for Student Examination:
#include <stdio.h>
int main() {
int subjects, marks[20], coefficient[20], total_marks = 0;
float average;
printf("Enter the number of subjects written: ");
scanf("%d", &subjects);
printf("Enter marks for each subject and its coefficient:\n");
for (int i = 0; i < subjects; i++) {
printf("Subject %d marks: ", i + 1);
scanf("%d", &marks[i]);
printf("Subject %d coefficient: ", i + 1);
scanf("%d", &coefficient[i]);
total_marks += marks[i] * coefficient[i];
average = (float)total_marks / subjects;
printf("Total Marks: %d\n", total_marks);
printf("Average: %.2f\n", average);
if (average >= 0 && average <= 6)
printf("Remark: Very Poor\n");
else if (average > 6 && average <= 9)
printf("Remark: Poor\n");
else if (average > 9 && average < 10)
printf("Remark: Below Average\n");
else if (average == 10)
printf("Remark: Average\n");
else if (average > 10)
printf("Remark: Good\n");
return 0;
2. Function to Find Location of Target in Array:
#include <stdio.h>
int location_of_target(int array[], int size, int target) {
int max_subscript = -1;
for (int i = 0; i < size; i++) {
if (array[i] == target) {
max_subscript = i;
return max_subscript;
int main() {
int array[] = {58, 26, 91, 34, 70, 34, 88};
int size = sizeof(array) / sizeof(array[0]);
int target = 34;
int result = location_of_target(array, size, target);
if (result == -1)
printf("Target value not found in the array.\n");
else
printf("The largest subscript containing the target value is: %d\n", result);
return 0;
Object Oriented Programming:
1. Definitions:
i. Object: An object is an instance of a class. It represents a real-world entity that has state and
behavior. Objects are created using classes and can interact with each other to perform tasks.
ii. Classes: A class is a blueprint or template for creating objects. It defines the properties (data
members) and behaviors (methods) that objects of the class will have.
iii. Methods: also known as member functions, are the behaviors or actions that objects of a
class can perform. They define the operations that can be applied to objects of the class.
2. Four Major Principles of Object-Oriented Programming (OOP):
i. Encapsulation: Bundling of data and methods that operate on the data into a single unit
(class). It helps in hiding the internal implementation details of an object from the outside world.
ii. Inheritance: Mechanism where a class (subclass or derived class) inherits properties and
behaviors from another class (superclass or base class). It promotes code reusability and allows
the creation of a hierarchy of classes.
iii. Polymorphism: Ability of an object to take on different forms or behaviors based on the
context. It allows methods to be overridden in subclasses and provides flexibility in method
invocation.
iv. Abstraction: Process of hiding the complex implementation details and showing only the
necessary features of an object. It focuses on what an object does rather than how it does it.
3. Differences between Private and Public Class Members:
Private Class Members: Private members are accessible only within the same class.
They cannot be accessed from outside the class. They are used to hide the internal
implementation details of a class and provide data security.
Public Class Members: Public members are accessible from outside the class. They can
be accessed by any part of the program. They define the interface through which external
code can interact with the class.
4. Differences between Data Hiding and Encapsulation:
Data Hiding: Data hiding is a concept where the implementation details of a class are
hidden from the outside world. It prevents direct access to the class's data members, thus
providing security and preventing unintended modifications.
Encapsulation: Encapsulation is a broader concept that encompasses data hiding. It
involves bundling the data (attributes) and methods (behaviors) that operate on the data
into a single unit (class). It ensures that the data is accessed and modified only through
well-defined methods, thus promoting data security and abstraction.
5. Designing Class Cube and Cube Test in C++:
#include <iostream>
#include <cmath>
class Cube {
private:
double side;
public:
// Constructor with one argument
Cube(double s) {
side = s;
// Getter method for side of the cube
double getSide() {
return side;
// Setter method for side of the cube
void setSide(double s) {
side = s;
// Method to calculate volume of the cube
double calculateVolume() {
return pow(side, 3);
};
int main() {
// Test class Cube
Cube cube1(3.0); // Create a cube object with side length 3.0
cout << "Cube side length: " << cube1.getSide() << endl;
cout << "Cube volume: " << cube1.calculateVolume() <<endl;
// Modify side length of the cube
cube1.setSide(5.0);
cout << "Modified cube side length: " << cube1.getSide() <<endl;
cout << "Modified cube volume: " << cube1.calculateVolume() <<endl;
return 0;
SECTION B: DATABASE DEVELOPMENT AND ADMINISTRATION
1. Entity: An entity represents a real-world object or concept that can be uniquely identified. In
database design, an entity typically corresponds to a table.
2. List of Possible Entities:
Teacher
Student
Course
Enrollment
3. Attribute: An attribute is a characteristic or property of an entity. It represents a piece of
information associated with the entity. In database terms, attributes correspond to columns in a
table.
4. Attributes for Each Entity:
Teacher:
TeacherID (primary key)
Name
Matricule
Telephone
Gender
Grade
Student:
StudentID (primary key)
Name
Matricule
Telephone
Gender
Address
Age
Course:
CourseID (primary key)
Title
Code
Credit
Enrollment:
StudentID (foreign key referencing Student table)
CourseID (foreign key referencing Course table)
Mark
5. E-R Diagram (Entity-Relationship Diagram): An E-R diagram is a graphical representation of
the entities, their attributes, and the relationships between them in a database.
Components of an E-R diagram:
Entities
Attributes
Relationships (with cardinality and participation constraints)
Primary keys
6. Equivalent E-R Diagram:
7. Relational Model:
Teacher(TeacherID, Name, Matricule, Telephone, Gender, Grade)
Student(StudentID, Name, Matricule, Telephone, Gender, Address, Age)
Course(CourseID, Title, Code, Credit)
Enrollment(StudentID, CourseID, Mark)
8.
CREATE TABLE Teacher (
TeacherID INT PRIMARY KEY,
Name VARCHAR(50),
Matricule VARCHAR(20),
Telephone VARCHAR(15),
Gender CHAR(1),
Grade VARCHAR(10)
);
CREATE TABLE Student (
StudentID INT PRIMARY KEY,
Name VARCHAR(50),
Matricule VARCHAR(20),
Telephone VARCHAR(15),
Gender CHAR(1),
Address VARCHAR(100),
Age INT
);
CREATE TABLE Course (
CourseID INT PRIMARY KEY,
Title VARCHAR(100),
Code VARCHAR(20),
Credit INT
);
CREATE TABLE Enrollment (
StudentID INT,
CourseID INT,
Mark DECIMAL(5, 2),
PRIMARY KEY (StudentID, CourseID),
FOREIGN KEY (StudentID) REFERENCES Student(StudentID),
FOREIGN KEY (CourseID) REFERENCES Course(CourseID)
);
ii. Create the database of the university called "UNIV"
CREATE DATABASE UNIV;
iii. Insert a student into your database
INSERT INTO Student (StudentID, Name, Matricule, Telephone, Gender, Address, Age)
VALUES (1, 'John Doe', '2021001', '1234567890', 'M', '123 Main St', 20);
iv. Retrieve the marks of all students in a particular subject
SELECT s.Name AS StudentName, e.Mark
FROM Student s
INNER JOIN Enrollment e ON s.StudentID = e.StudentID
INNER JOIN Course c ON e.CourseID = c.CourseID
WHERE c.Title = 'Mathematics';
SECTION D: NETWORKING
1. Lower Four Layers of the OSI Model:
Physical Layer:
i. Functions: The physical layer is responsible for transmitting raw data bits over a
communication channel. It deals with the physical transmission medium and establishes,
maintains, and terminates connections between devices.
ii. Protocol: Ethernet
iii. Equipment/Systems: Network Interface Cards (NICs), Ethernet cables, Hubs
Data Link Layer:
i. Functions: The data link layer provides error detection and correction mechanisms to
ensure reliable data transmission over the physical layer. It also handles framing, flow control,
and media access control.
ii. Protocol: Point-to-Point Protocol (PPP)
iii. Equipment/Systems: Switches, Bridges, Network Interface Cards (NICs)
Network Layer:
i. Functions: The network layer is responsible for routing packets between different
networks. It determines the optimal path for data transmission, performs logical addressing, and
handles congestion control.
ii. Protocol: Internet Protocol (IP)
iii. Equipment/Systems: Routers, IP addresses, Gateways
Transport Layer:
i. Functions: The transport layer ensures reliable end-to-end data delivery and error
recovery. It establishes, maintains, and terminates logical connections between sender and
receiver. It also handles segmentation and reassembly of data.
ii. Protocol: Transmission Control Protocol (TCP)
iii. Equipment/Systems: Hosts (computers, servers), TCP/IP stacks, Firewalls
2. Network Topology: A network topology refers to the physical or logical layout of a computer
network. It defines how devices are interconnected and how data flows between them. Common
network topologies include bus, star, ring, mesh, and hybrid topologies.
3. Advantages and Disadvantages of Network Topologies:
i. Star Topology:
Advantages:
Easy to install and manage.
Fault tolerance as failure of one device does not affect others.
Disadvantages:
Dependency on central hub; failure of hub can disrupt the entire network.
Costlier than bus or ring topologies due to the requirement of a central hub.
ii. Ring Topology:
Advantages:
Equal access to resources as each device has the same opportunity to transmit data.
Simple and inexpensive to install.
Disadvantages:
Network performance can be affected if one node fails, as it can disrupt the entire ring.
Expansion or modification of the network is difficult as it requires the entire ring to be
disrupted.