Ap Final Viva
Ap Final Viva
Ap Final Viva
Fixed-size stack:
Has a predetermined maximum capacity.
Once the stack is full, no more elements can be pushed onto it.
Simpler implementation but can lead to overflow errors if not managed carefully.
Dynamic-size stack:
Adjusts its size dynamically based on the number of elements.
Allows for flexibility in handling varying amounts of data.
May involve more complex memory management to resize and allocate space as needed.
Circular Queue:
Also follows the FIFO principle.
Implemented as a circular data structure to efficiently use space.
After reaching the end of the queue, new elements are inserted at the beginning if
space is available.
Uses modular arithmetic to navigate within the circular structure.
1. **Searching:**
Searching is the process of finding a specific item or element in a collection
of data. The collection could be an array, list, database, or any other data
structure. The goal of searching is to determine whether a particular element
exists in the dataset and, if it does, to locate its position or retrieve it.
2. **Sorting:**
Sorting is the process of arranging the elements in a dataset in a particular
order, usually in ascending or descending order. Sorting is crucial for various
applications, including data analysis, and efficient data retrieval.
Efficient searching and sorting algorithms are crucial for optimizing the
performance of computer programs and systems when dealing with large datasets. The
choice of algorithm depends on factors such as the size of the dataset, whether it
is already partially sorted, and the desired time and space complexities.
2. **Undirected Graph:**
- In an undirected graph, edges have no direction, indicating a two-way
relationship between nodes.
- The relationship is symmetric, meaning that if node A is connected to node B,
then node B is also connected to node A.
3. **Weighted Graph:**
- In a weighted graph, each edge has an associated numerical value or weight.
- The weight typically represents a cost, distance, or some other quantitative
measure of the relationship between nodes.
4. **Unweighted Graph:**
- In contrast to a weighted graph, an unweighted graph has edges with no
associated numerical values.
5. **Cyclic Graph:**
- A cyclic graph contains at least one cycle, which is a closed path that starts
and ends at the same node.
6. **Acyclic Graph:**
- An acyclic graph is one that does not contain any cycles. Directed Acyclic
Graphs (DAGs) are a specific type of acyclic graph.
7. **Connected Graph:**
- A connected graph is one in which there is a path between every pair of nodes.
- Disconnected graphs have two or more components that are not connected to each
other.
8. **Complete Graph:**
- In a complete graph, there is a unique edge between every pair of distinct
nodes.
- The complete graph with n nodes is denoted as Kn.
9. **Sparse Graph:**
- A graph is considered sparse if it has significantly fewer edges than the
maximum possible number of edges.
- Sparse graphs often have a relatively low edge density.
These are just a few examples of the many types of graphs, each with its own set of
properties and applications. Graph theory provides a rich framework for modeling
and analyzing various relationships and structures in different domains.
Types of Trees:
Binary Tree:
In a binary tree, each node has at most two children: a left child and a right
child.
Various types of binary trees include full binary trees, complete binary trees, and
perfect binary trees.
AVL Tree:
An AVL tree is a self-balancing binary search tree. The heights of the two child
subtrees of any node differ by at most one.
Q.) Explain dynamic programming? Give real life example of dynamic programming?
-->
**Dynamic Programming:** A technique used to solve problems by breaking them down
into smaller overlapping subproblems and solving each subproblem only once, storing
the solutions.
**Real-Life Example:**
- Wireless Communication
- Speech Recognition
Q) What is malloc.
--> Malloc is a function which is used to allocate memory dynamically during
program execution. It stands for "memory allocation".
Q) What is calloc.
--> “calloc” or “contiguous allocation” method is used to dynamically allocate the
specified number of blocks of memory of the specified type.
Q) What is realloc.
--> “realloc” or “re-allocation” method is used to dynamically change the memory
allocation of a previously allocated memory
Q) What is multithreading.
--> Multithreading is a process of executing multiple threads simultaneously.
A thread is a lightweight sub-process, the smallest unit of processing.
Multiprocessing and multithreading, both are used to achieve multitasking.
- **Head Recursion**: In head recursion, the recursive call is the first operation
in a function. The function performs some computation before making the recursive
call. As a result, the recursive calls accumulate on the call stack until the base
case is reached, and then they all start returning.
Each of these recursion types has its own characteristics and use cases in
programming.
Indirect recursion: Indirect recursion occurs when a function calls another
function that eventually calls the original function and it forms a cycle.
Q) What is overloading.
--> If we create two or more members having the same name but different in number
or type of parameter, it is known as overloading.
Types of overloading in C++ are:
Function overloading - Function Overloading is defined as the process of having two
or more function with the same name, but different in parameters is known as
function overloading
Operator overloading - Operator overloading is a compile-time polymorphism in which
the operator is overloaded to provide the special meaning to the user-defined data
type.
Extra-
Array are contiguous memory locations of homogenous data types stored in a fixed
location or size.
Lists are classic individual elements that are linked or connected to each other
with the help of pointers and do not have a fixed size.
While loop is also termed an entry-controlled loop
The do-while loop is termed an exit control loop
It simply means putting the operator before the operand
Block scope in C++ refers to the region of code enclosed within a pair of curly
braces `{}`. Variables declared inside a block are only visible and accessible
within that block, helping manage variable lifetimes and preventing unintended
conflicts with names outside the block.**
Command line arguments in C++ are values provided to a program when it is run from
the command line. They are passed as parameters to the `main` function and allow
external input to influence the behavior of the program.**
In C++, a reference function typically refers to a function that returns a
reference (alias) to a variable. This allows the function to modify the original
variable directly.**
Links-
https://www.edureka.co/blog/interview-questions/python-interview-questions/
https://www.interviewbit.com/cpp-interview-questions/