Week 1
Week 1
C Programming
Solution - OUTPUT - 0
Solution - As ‘’ single quotes are used for char and strcat takes str as the second
argument we must use “!”.
C++ Programming
What is the output and explain the same?
Solution – The output is: "Say I am in SomeFunc." The output indicates that the
program encountered a double-free error and was aborted due to memory corruption.
The default copy constructor performs a shallow copy, causing multiple objects (s1 and
the temporary object) to share the same pointer. This leads to the double freeing of the
same memory. Additionally, <<endl is missing in void PrintVal().
Solution - Every non-static member function has an implicit parameter called the “this”
pointer, which refers to the calling object. It allows the member function to access the
object's data members and other functions.
Technical Questions
Data structures
A data structure is a way of organizing, managing, and storing data to enable efficient access
and modification. It provides a framework for handling data logically and helps in implementing
algorithms effectively. Common types include arrays, linked lists, stacks, queues, trees, and
graphs, each suited for specific types of operations and use cases, such as searching, sorting,
and data manipulation. Data structures are fundamental to computer science and
programming for solving complex problems efficiently.
Unix
In Unix, devices are represented as special files in the /dev directory. These include character
devices (e.g., /dev/tty) for stream-based data and block devices (e.g., /dev/sda) for block-
based data. Each device file has a major number (identifying the driver) and a minor number
(identifying the device).
An inode (index node) is a data structure in Unix-like file systems that stores metadata about
a file or directory, excluding its name or data. It contains information such as the file's size,
permissions, owner, timestamps (creation, modification), and pointers to the data blocks on
disk where the file's content is stored. Each file is associated with a unique inode, allowing
efficient file management and access.
DBMS
1. Primary Key: A unique identifier for each record in a table. No two records can have
the same primary key value, and it cannot be null.
2. Foreign Key: A key used to establish a link between two tables. It is a column (or set
of columns) in one table that refers to the primary key in another table, ensuring
referential integrity.
3. Candidate Key: A set of attributes that could uniquely identify a record in a table. The
primary key is chosen from the candidate keys.
4. Unique Key: Similar to the primary key, but it allows for a null value in some cases. It
ensures that all values in the column are unique.
5. Composite Key: A key that consists of two or more attributes used together to
uniquely identify a record. It is often used when no single attribute can uniquely identify
a record.
6. Alternate Key: A candidate key that was not selected as the primary key.
7. Superkey: A set of one or more attributes that can uniquely identify a record in a table,
which may include extra attributes beyond those needed for uniqueness.
Operating system
In operating systems, reentrancy refers to the ability of a function to be safely interrupted and
called again before its previous execution completes, without causing errors or corrupting
data. A reentrant function does not rely on or modify shared resources and uses only local
variables, ensuring that each execution is independent. This allows the function to be safely
invoked in multi-threaded or interrupt-driven environments.
Belady's Anomaly refers to a situation in operating systems where increasing the number of
page frames can unexpectedly lead to more page faults. This counterintuitive behavior is most
often observed with certain page replacement algorithms, such as FIFO (First-In-First-Out),
where adding more memory does not always improve performance. Instead, under certain
memory access patterns, it can cause more frequent page faults, highlighting inefficiencies in
the algorithm's ability to manage memory.
SQL
The subset of SQL commands used to manipulate Oracle Database structures, including
tables, is called Data Definition Language (DDL). Common DDL commands include
CREATE (to create tables), ALTER (to modify tables), DROP (to delete tables), TRUNCATE
(to remove all rows from a table), and RENAME (to rename tables). These commands define
and modify database structures.
The LIKE operator in SQL performs pattern matching. It uses wildcards like % (any
sequence of characters) and _ (a single character) to search for patterns in a column.
Computer Networks
The two main types of transmission technology available in computer networks are:
1. Guided (Wired) Transmission: This involves physical media such as copper cables
(e.g., Ethernet cables), fibre optics, and coaxial cables, which guide the data signals
along a specific path.
2. Unguided (Wireless) Transmission: This involves the transmission of data through
the air using radio waves, microwaves, or infrared signals, with technologies like Wi-
Fi, Bluetooth, and cellular networks.