Viva Preparation
Viva Preparation
My last Night:
I spent the evening reviewing my notes to complete my preparation, had
dinner, and made sure to get enough sleep to stay fresh for the viva.
What I Learned from the OOP Course
Book Name: Object Oriented Programming in C++
Author: Robert Lafore
Four key principles of OOP:
1. Encapsulation: Encapsulation is the bundling of data and methods into a class while
restricting direct access to some components.
2. Inheritance: Inheritance allows one class to acquire the properties and methods of
another class.
3. Polymorphism: Polymorphism enables methods or objects to behave differently based
on context.
4. Abstraction: Abstraction hides implementation details and shows only essential features
to the user
Constructor: A special method used to initialize an object when it is created. It sets initial
values for the attributes of the object.
Destructor: A method that is called when an object is destroyed or goes out of scope. It is
used to clean up resources, like closing files or releasing memory.
Others:
1. Class: A class is a blueprint for creating objects with attributes and methods.
2. Object: An object is an instance of a class that holds data and can perform actions.
3. Function overloading: Function overloading allows multiple functions with the same
name but different parameters to coexist in a program.
4. Function overriding: Function overriding is a concept in object-oriented programming
where a subclass provides a specific implementation of a method already defined in its
superclass, using the same method name, parameters, and return type.
5. Operator overloading: Operator overloading is a feature in object-oriented programming
that allows custom implementation of operators (e.g., +, -, *) for user-defined types,
enabling them to behave differently based on the operands.
6. Virtual Functions: A virtual function is a function in a base class that can be overridden
in a derived class to achieve runtime polymorphism.
Electronics Devices and Circuits
Book Name: Electronic Devices and Circuit Theory
FET (Field Effect Transistor)
Data Structures
1. Complexity: Time complexity refers to the amount of time an algorithm takes to run as a
function of the size of the input, while space complexity refers to the amount of memory
or storage an algorithm uses relative to the input size.
2. Time-Space Tradeoff: The time-space tradeoff refers to the concept where improving the
time complexity of an algorithm (e.g., faster execution) often requires using more
memory, and vice versa, where reducing memory usage may increase execution time.
3. Array: An array is a data structure that stores a fixed-size sequence of elements of the
same type, accessible by index, and stored in contiguous memory locations.
4. Linked List: A linked list is a linear data structure where elements (nodes) are connected
by pointers.
5. Stack: A stack is a Last-In-First-Out (LIFO) data structure that allows adding and removing
elements from one end (top).
6. A queue is a First-In-First-Out (FIFO) data structure that processes elements in the order
they were added.
7. A tree is a hierarchical structure consisting of nodes with a root and child nodes, often
used for efficient searching and sorting.
8. A graph is a collection of nodes (vertices) connected by edges, used to represent
relationships or connections between entities.
Linked list:
#include <iostream>
using namespace std;
class node {
public:
char data;
node* link;
node(char data) {
this->data = data;
link = NULL;
}
};
int main() {
node* head = new node('a');
head->link = new node('b');
head->link->link = new node('c');
cout << head->data << " -> " << head->link->data << " -> " << head->link->link->data << endl;
return 0;
}
Output: a -> b -> c
Tree:
#include <iostream>
using namespace std;
class node {
public:
int data;
node* left;
node* right;
node(int data) {
this->data = data;
left = right = NULL;
}
};
int main() {
node* root = new node(1);
root->left = new node(2);
root->right = new node(3);
Output:
Pre-order: 1 2 3
In-order: 2 1 3
Post-order: 2 3
Binary search algorithm:
#include <iostream>
using namespace std;
int main() {
int n;
cout << "Enter the number of elements in the array: ";
cin >> n;
int arr[n];
cout << "Enter sorted array elements: ";
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
int target;
cout << "Enter target amount: ";
cin >> target;
if (result == -1) {
cout << "Item not found.";
} else {
cout << "Item found at: " << result + 1;
}
return 0;
}