Report Project (Anjali)
Report Project (Anjali)
Report Project (Anjali)
On
C++ AND DATA STRUCTURE
In partial fulfillment of the requirements for the award of the Degree of Bachelor of
Technology
In
Submitted By Submitted to
Anjali kumari [B.TECH(CSE)] Mr. Sanjeev Sharma
Roll NO.- UU2201010074 Assitant Professor
CSE Department
UIT, University
ACKNOWLEDGMENT
I express my satisfaction on the completion of this summer training programme and project
report summation as a part of the curriculum for the degree of Bachelor of Engineering
Computer Science. I express my deepest gratitude to my supervisor and mentor Mr Akshay for
his kind guidance during the entire period of training his consistent support and advises has
helped me to complete this research project successfully also I thank all the members of Slog
I would also like to extend my gratitude to the Head of the Department of Computer Science
Dr. Sumit Chaudhary for providing me with all the facilities that was required.
Anjali kumari
B.tech[CSE]
Date:
CERTIFICATE OF TRAINING
TABLE OF CONTENTS -
ACKNOWLEDGMENT
1 . INTRODUCTION
2. FUNCTIONS IN C++
6 . DATA STRUCTURE
8. LINKED LIST
9 . STACK
10 . QUEUE
10.3 Applications
11. TREE
11.3 Applications
12. GRAPH
12.3 Applications
13. CONCLUSION
1. INTRODUCTION
A function is a set of statements that take inputs , do some specific computation and produces
output. The idea is to put some commonly or repeatedly done tasks together to make a
function so that instead of writing the same code again and again for different inputs, we can
call this function.
2.1 SYNTAX:
EXAMPLE:
C++
OUTPUT : m is 20
LIBRARY FUNCTION
Library functions are also called “built-in Functions“. These functions are part
of a compiler package that is already defined and consists of a special function
with special and different meanings.
3. POINTERS AND REFERENCE VARIABLE IN C++
POINTERS:
Pointers are symbolic representation of addresses. They enable programs to stimulate call-
by-reference as well as to create and manipulate dynamic data structure . Iterating over
elements in arrays or other data structure is one of the main use of pointers.
SYNTAX:
datatype *var_name;
int *ptr; // ptr can point to an address which holds int data
ACCESS SPECIFIER:
Private- members cannot be accessed (or viewed) from outside the class .
There are some basic concepts that act as the building blocks of OOPs i.e.
i. Class
ii. Objects
iii. Encapsulation
iv. Abstraction
v. Polymorphism
vi. Inheritance
5.1 ENCAPSULATION
In normal terms, Encapsulation is defined as wrapping up data and information under a
single unit. In Object-Oriented Programming, Encapsulation is defined as binding together
the data and the functions that manipulate them. Consider a real-life example of
encapsulation, in a company, there are different sections like the accounts section, finance
section, sales section, etc
5.2 ABSTRACTION
Data abstraction is one of the most essential and important features of object-
oriented programming in C++. Abstraction means displaying only essential
information and hiding the details. Data abstraction refers to providing only
essential information about the data to the outside world, hiding the
background details or implementation. Consider a real-life example of a man
driving a car.
5.3 POLYMORPHISM
The word polymorphism means having many forms. In simple words, we can
define polymorphism as the ability of a message to be displayed in more than
one form. A person at the same time can have different characteristics. A man
at the same time is a father, a husband, and an employee. So the same person
possesses different behavior in different situations. This is called
polymorphism.
5.4 INHERITANCE
The capability of a class to derive properties and characteristics from another
class is called Inheritance. Inheritance is one of the most important features of
Object-Oriented Programming.
• Sub Class: The class that inherits properties from another class is
called Sub class or Derived Class.
• Super Class: The class whose properties are inherited by a sub-class
is called Base Class or Superclass.
• Reusability: Inheritance supports the concept of “reusability”, i.e.
when we want to create a new class and there is already a class that
includes some of the code that we want, we can derive our new class
from the existing class. By doing this, we are reusing the fields and
methods of the existing class.
6. DATA STRUCTURE-
A data structure is a way to store and organize data in order to facilitate access and
modifications . More precisely, a data structure is a collection of data values, the relationships
among them, and the functions or operations that can be applied to the data. No single data
structure works well for all purposes, and so it is important to know the strengths and
limitations of several of them.
USAGE-
Different kinds of data structures are suited to different kinds of applications, and some are
highly specialized to specific tasks. For example, relational databases commonly use B-
tree indexes for data retrieval while compiler implementations usually use hash tables to look
up identifiers. Data structures provide a means to manage large amounts of data efficiently
for uses such as large databases and internet indexing services. Usually, efficient data
structures are key to designing efficient algorithms. Some formal design methods
and programming languages emphasize data structures ,rather than algorithms, as the key
organizing factor in software design. Data structures can be used to organize the storage and
retrieval of information stored in both main memory and secondary memory.
6.1 CLASSIFICATION OF DATA STRUCTURE
Data structure has many different uses in our daily life. There are many different data
structures that are used to solve different mathematical and logical problems. By using data
structure, one can organize and process a very large amount of data in a relatively short
period. Let’s look at different data structures that are used in different situations.
6.2 LINEAR DATA STRUCTTURE: Data structure in which data elements are
arranged sequentially or linearly, where each element is attached to its previous and next
adjacent elements, is called a linear data structure.
Examples of linear data structures are array, stack, queue, linked list, etc.
• Static data structure: Static data structure has a fixed memory size. It is easier
to access the elements in a static data structure.
An example of this data structure is an array.
• Dynamic data structure: In the dynamic data structure, the size is not fixed. It
can be randomly updated during the runtime which may be considered efficient
concerning the memory (space) complexity of the code.
Examples of this data structure are queue, stack, etc.
6.3 NON-LINEAR DATA STRUCTTURE: Data structures where data elements
are not placed sequentially or linearly are called non-linear data structures. In a non-
linear data structure, we can’t traverse all the elements in a single run only.
NEED OF DATA STRUCTURE:
The structure of the data and the synthesis of the algorithm are relative to each other. Data
presentation must be easy to understand so the developer, as well as the user, can make an
efficient implementation of the operation.
Data structures provide an easy way of organizing, retrieving, managing, and storing data.
Here is a list of the needs for data.
1. Data structure modification is easy.
2. It requires less time.
3. Save storage memory space.
4. Data representation is easy.
5. Easy access to the large database.
IMPLEMENTATION-
Data structures are generally based on the ability of a computer to fetch and store data at any
place in its memory, specified by a pointer — a bit string, representing a memory address,
that can be itself stored in memory and manipulated by the program. Thus, the array and
record data structures are based on computing the addresses of data items with arithmetic
operations, while the linked data structures are based on storing addresses of data items
within the structure itself. Many data structures use both principles, sometimes combined in
non-trivial ways.
Figure 6:
• Dequeue: The front element can be removed from the queue by performing a
dequeue operation, effectively removing the first element that was added to the
queue.
• Peek: The front element can be inspected without removing it from the queue
using a peek operation.
A graph is a non-linear data structure consisting of nodes and edges. Here are some
common operations performed on graphs:
• Add Vertex: New vertices can be added to the graph to represent a new node.
• Add Edge: Edges can be added between vertices to represent a relationship
between nodes.
• Remove Vertex: Vertices can be removed from the graph by updating the
references of adjacent vertices to remove the reference to the current vertex.
• Remove Edge: Edges can be removed by updating the references of the adjacent
vertices to remove the reference to the current edge.
• Depth-First Search (DFS): A graph can be traversed using a depth-first search
by visiting the vertices in a depth-first manner.
• Breadth-First Search (BFS): A graph can be traversed using a breadth-first
search by visiting the vertices in a breadth-first manner.
• Shortest Path: The shortest path between two vertices can be determined using
algorithms such as Dijkstra’s algorithm or A* algorithm.
• Connected Components: The connected components of a graph can be
determined by finding sets of vertices that are connected to each other but not to
any other vertices in the graph.
• Cycle Detection: Cycles in a graph can be detected by checking for back edges
during a depth-first search.
CONCLUSION
My internship experience at Slog Solution Company was invaluable. Through it, I gained
valuable skills, as well as a better understanding of the different aspects of a C++ and Data
Structure . The knowledge I have acquired will benefit me in my future endeavours. During
my internship, I developed my technical skills . I have also made some lasting connections
that will be of great value in my professional life. Overall, I have learned so much from this