0% found this document useful (0 votes)
4 views3 pages

22

Uploaded by

Numan Hidayat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

22

Uploaded by

Numan Hidayat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

In C++, a data structure is a way of organizing and storing data in a computer so that it can be accessed

and modified efficiently. There are several types of data structures in C++, including:

1. Array: A collection of elements stored in contiguous memory locations, accessed using an index.
Arrays have a fixed size.

2. Linked List: A data structure consisting of a sequence of elements, where each element points to the
next element in the sequence. Linked lists can be singly linked (each element points to the next) or
doubly linked (each element points to both the next and previous elements).

3. Stack: A last-in, first-out (LIFO) data structure where elements are inserted and removed from the
same end, called the top.

4. Queue: A first-in, first-out (FIFO) data structure where elements are inserted at the rear and removed
from the front.

5. Tree: A hierarchical data structure consisting of nodes connected by edges. Trees have a root node
and each node can have zero or more child nodes.

6. Binary Tree: A tree data structure where each node has at most two child nodes, referred to as the
left child and the right child.

7. Binary Search Tree (BST): A binary tree data structure where the left child of a node contains only
nodes with values less than the node's value, and the right child contains only nodes with values greater
than the node's value.

8. Graph: A collection of nodes (vertices) connected by edges. Graphs can be directed or undirected, and
edges may have weights.
These are some of the fundamental data structures in C++, each serving different purposes and suitable
for different kinds of operations and algorithms.

In programming, a data type defines the type of data that a variable can hold and the operations that
can be performed on that data. In C++, data types can be categorized into several types:

1. **Fundamental Data Types:**

- Integer types (e.g., int, short, long, long long)

- Floating-point types (e.g., float, double, long double)

- Character types (e.g., char, wchar_t, char16_t, char32_t)

- Boolean type (bool)

2. **Derived Data Types:**

- Array: A collection of elements of the same data type arranged in contiguous memory locations.

- Pointer: A variable that stores the memory address of another variable.

- Reference: An alias to another variable.

- Function: A data type that represents a function.

- Pointer to member: A pointer that points to a member of a class or struct.

3. **User-defined Data Types:**

- Structures: A collection of variables of different data types grouped together under a single name.

- Classes: Similar to structures but with additional features like inheritance and encapsulation.

- Enumerations (enums): A user-defined data type consisting of a set of named constants.

4. **Void Data Type:**

- Void: Represents the absence of a type. It is often used to indicate that a function does not return a
value or that a pointer does not point to any specific data type.
These are the main types of data types in C++, each serving different purposes and providing various
levels of abstraction and functionality.

You might also like