Data Structure
Data Structure
A data structure is a storage that is used to store and organize data. It is a way of arranging data on a computer so that it can be accessed and updated efficiently.
Type of Data Structure?
Primitive data Structures are also called Primitive Data Types. byte, short,? int, float, char, boolean, long, and double are primitive Data types.
Non-primitive data Structures – Non-primitive Data Structures are of two types:-
Common Type of Data Structure?
Classification of Data Structures
Array
An array is a dynamically-created object. It serves as a container that holds the constant number of values of the same type. It has a contiguous memory location. Once an array is created, we cannot change its size. We can create an array by using the following statement:
Array Advantages
Array Disadvantages
Java ArrayList
In Java, ArrayList is a class of Collections framework. It implements List<E>, Collection<E>, Iterable<E>, Cloneable, Serializable, and RandomAccess interfaces. It extends AbstractList<E> class.
ArrayList is internally backed by the array in Java. The resize operation in ArrayList slows down the performance as it involves new arrays and copying content from an old array to a new array. It calls the native implemented method System.arraycopy(sec, srcPos, dest, destPos, length) .
We cannot store primitive types in ArrayList. So, it stores only objects. It automatically converts primitive types to objects. For example, we have create an ArrayList object,
The JVM converts it into an Integer object through auto-boxing.
Similarities
Linked list
A linked list is a linear data structure that includes a series of connected nodes. Here, each node stores the data and the address of the next node.
Type of Linked List?
Singly Linked List?
Singly linked lists contain two “buckets” in one node; one bucket holds the data and the other bucket holds the address of the next node of the list. Traversals can be done in one direction only as there is only a single link between two nodes of the same list.
Doubly Linked List
Doubly Linked Lists contain three “buckets” in one node; one bucket holds the data and the other buckets hold the addresses of the previous and next nodes in the list. The list is traversed twice as the nodes in the list are connected to each other from both sides.
Circular Linked List
Circular linked lists can exist in both singly linked list and doubly linked list.
Since the last node and the first node of the circular linked list are connected, the traversal in this linked list will go on forever until it is broken.
Linked List Advantages
领英推荐
Linked List Disadvantages
Stack
A stack is a representation of nodes. There are two components to each node: data and next (storing address of next node). Each node’s data portion contains the assigned value, and its next pointer directs the user to the node that has the stack’s subsequent item. The highest node in the stack is referred to as the top. Follows LIFO: Last In First Out.
Stack Operations
Queue
The queue is called an abstract data structure. Data is always added to one end (enqueued), and removed from the other (dequeue). Queue uses the First-In-First-Out approach and data item that was stored initially will be accessed first in a queue.
Queue Operations
A queue is an object (an abstract data structure - ADT) that allows the following operations:
Binary Tree
In a binary tree, the branches of the tree are made up of up to two child nodes for each node. The left and right nodes are the common names for the two youngsters. Child nodes make references to their parents, whereas parent nodes are nodes with children.
Features of Binary Tree
Binary Tree Advantages
Binary Tree Disadvantages
Binary Tree Applications
Heap
In this tutorial, you will learn what heap data structure is. Also, you will find working examples of heap operations in C, C++, Java and Python.
Heap data structure is a complete binary tree that satisfies the heap property, where any given node is
Heap Operations
Some of the important operations performed on a heap are described below along with their algorithms.
Heapify
Heapify is the process of creating a heap data structure from a binary tree. It is used to create a Min-Heap or a Max-Heap.
Hashing
Hashing is a technique or process of mapping keys, and values into the hash table by using a hash function. It is done for faster access to elements. The efficiency of mapping depends on the efficiency of the hash function used.
Let a hash function H(x) maps the value x at the index x%10 in an Array. For example if the list of values is [11,12,13,14,15] it will be stored at positions {1,2,3,4,5} in the array or Hash table respectively.
Graph
In this tutorial, you will learn what a Graph Data Structure is. Also, you will find representations of a graph.
A graph data structure is a collection of nodes that have data and are connected to other nodes.
Let's try to understand this through an example. On facebook, everything is a node. That includes User, Photo, Album, Event, Group, Page, Comment, Story, Video, Link, Note...anything that has data is a node.
Every relationship is an edge from one node to another. Whether you post a photo, join a group, like a page, etc., a new edge is created for that relationship.
Human Resources Assistant at Magenta Investments LLC
1 年Hi Mr. Kawsar, I am from HR of Magenta Investments may I know your contact number? We need to contact you. Thanks
Software Engineer at BRAC IT Services Limited
1 年Thanks for sharing