Download as odt, pdf, or txt
Download as odt, pdf, or txt
You are on page 1of 5

data - this is raw facts and figures

A data structure is a data organization, management, and storage format that enables efficient
access and modification

Data Type

Data type is a way to classify various types of data such as integer, string, etc. which determines
the values that can be used with the corresponding type of data, the type of operations that can
be performed on the corresponding type of data. There are two data types −

1 Built-in Data Type

2 Derived Data Type

Built-in Data Type

Those data types for which a language has built-in support are known as Built-in Data types. For
example, most of the languages provide the following built-in data types.

Integers

Boolean (true, false)

Floating (Decimal numbers)

Character and Strings

Derived Data Type

Those data types which are implementation independent as they can be implemented in one or
the other way are known as derived data types. These data types are normally built by the
combination of primary or built-in data types and associated operations on them. For example −

List

Array

Stack

Queue

Lists -A list is a collection of items (called nodes) orderer in linear sequence. It is a tool that can
be used to store multiple pieces of information at once. It can also be defined as a variable
containing multiple other variables.

It is therefore an abstract data type that contains a countable number of ordered values where
the same value may occur more than once.The name list is also used for several concrete data
structures that can be used to implement abstract lists, especially linked lists

Arrays

An array is an ordered collection of items,where each item inside the array has an index

difrence between a list and an arrays

Array is collection of homogeneous elements

list is collection of hetrogeneous elements

for array memory allocated is static and continuous

for list memory allocated is dynamic and random

Array: users need not to keep in track of next memory allocation

list: user has to keep in track of next location where memory is allocated

List in C++ Standard Template Library

(STL)

Functions used with List :

front() – Returns the value of the first element in the list

back() – Returns the value of the last element in the list

Push front(g) – Adds a new element ‘g’ at the beginning of the list

Push_back(g) – Adds a new element ‘g’ at the end of the list


Pop_front() – Removes the first element of the list, and reduces

size of the list by 1

Pop_back() – Removes the last element of the list, and reduces

size of the list by 1

begin() – Returns an iterator pointing to the first element of the

end() – Returns an iterator pointing to the theoretical last element

empty() – Returns whether the list is empty(1) or not(0)

insert() – Inserts new elements in the list at a specified position

erase() – Removes a single element or a range of elements from

the list

assign() – Assigns new elements to list by replacing current

elements and resizes the list

remove() – Removes all the elements from the list, which are

equal to given element

reverse() – Reverses the list

size() – Returns the number of elements in the list

sort() – Sorts the list in increasing order

search()- searches an element using the given key

A linked list (also just called list) is a linear collection of data elements of any type, called nodes,
where each node has itself a value, and points to the next node in the linked list. (A linked list is a
linear data structure, in which the elements are not stored at contiguous memory locations. The
elements in a linked list are linked using pointers)

The principal advantage of a linked list over an array, is that values can always be efficiently
inserted and removed without relocating the rest of the list. Certain other operations, such as
random access to a certain element, are however slower on lists than on arrays
Each element (node) of a list is comprising of two items - the data and a reference to the next
node.

The last node has a reference to null.

The entry point into a linked list is called the head of the list.

It should be noted that head is not a separate node, but the reference to the first node.

If the list is empty then the head is a null reference.

A linked list is a dynamic data structure. The number of nodes in a list is not fixed and can grow
and shrink on demand. Any application which has to deal with an unknown number of objects
will need to use a linked list.

One disadvantage of a linked list against an array is that it does not allow direct access to the
individual elements. If you want to access a particular item then you have to start at the head
and follow the references until you get to that item.

Another disadvantage is that a linked list uses more memory as compared with an array – we
need extra 4 bytes (on 32-bit CPU) to store a reference to the next node.

Doubly linked list:

A doubly linked list is a list that has two references, one to the next node and another to
previous node.

Circular Linked List:

Another important type of a linked list is called a circular linked list where the last node of the
list points back to the first node (or the head) of the list.

Circular doubly linked list:

A circular doubly linked list has the same arrangement as the doubly linked list but in a circular
format.

ref https://www.geeksforgeeks.org/data-structures/linked-list/
https://www.tutorialspoint.com/data_structures_algorithms/linked_list_algorithms

https://en.wikipedia.org/wiki/Linked_data_structure

You might also like