0% found this document useful (0 votes)
14 views

Data Structure PLC

Uploaded by

jayshah2337
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Data Structure PLC

Uploaded by

jayshah2337
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Vishwakarma Government Engineering College,

Chandkheda, Ahmedabad
Department of Information Technology

DATA STRUCTURE

PLACEMENT GUIDE

Mentor: Nikunj Gamit Compiled by:Janvi Gupta


Guide By:Abhi Shah Ayushi Mandavia
Darmit Shah Aayushi Prajapati
Mihir Someshwara Sakshi Bagaria
Table of Content
SR.NO TITLE PAGE NO
1. Introduction 1

2. Applications 1

3. Types of Data Structure 6

4. Linear Data Structures 6

5. Non-Linear Data Structures 9

6. Tower of Hanoi 12

7. Recursive function 13

8. Hashing 13

9. Hash Map 13
Data Structure
● A data structure is a mechanical or logical way that data is organized within a
program.
● The organization of data is what determines how a program performs. There
are many types of data structures, each with its own uses.
● When designing code, we need to pay particular attention to the way data is
structured.
● If data isn't stored efficiently or correctly structured, then the overall
performance of the code will be reduced.

❖ Applications:
● Decision Making
● Genetics
● Image Processing
● Blockchain
● Numerical and Statistical Analysis
● Compiler Design
● Database Design and many more

❖ Types of data structure:

● Linear Data Structure: A data structure that includes data elements


arranged sequentially or linearly, where each element is connected to
its previous and next nearest elements, is referred to as a linear data
structure. Arrays and linked lists are two examples of linear data
structures.
● Non-Linear Data Structure: Non-linear data structures are data
structures in which data elements are not arranged linearly or
sequentially. We cannot walk through all elements in one pass in a

1
non-linear data structure, as in a linear data structure. Trees and graphs
are two examples of non-linear data structures

❖ Linear Data Structures:

1) Array:

● An array is a linear data structure that collects elements of the same


data type and stores them in contiguous and adjacent memory
locations.
● Arrays work on an index system starting from 0 to (n-1), where n is the
size of the array.

➢ Applications of Array:
● Array data structures are commonly used in databases and other
computer systems to store large amounts of data efficiently. They are
also useful for storing information that is frequently accessed, such as
large amounts of text or images.

➢ Types of array:

i. One-dimensional array:

● 1d array is a row, where elements are stored one after another.

ii. Multi-dimensional array:

2
● A table where each cell contains elements.

iii. Three-dimensional array:

● A three-dimensional array is a grid that has rows, columns, and depth


as a third dimension. It comprises a cube with rows, columns, and
depth as a third dimension.
● The three-dimensional array has three subscripts for a position in a
particular row, column, and depth. Depth (dimension or layer) is the first
index, row index is the second index, and column index is the third
index.

2) Stack:
● A stack is a data structure that is used to represent the state of an
application at a particular point in time.
● The stack consists of a series of items that are added to the top of the
stack and then removed from the top. It is a linear data structure that
follows a particular order in which operations are performed. LIFO
(Last In First Out) or FILO (First In Last Out) are two possible orders.
● A stack consists of a sequence of items.

3
● Example: A stack of clothes on top of each other. When we remove the
cloth that was previously on top, we can say that the cloth that was
added last comes out first.

➢ Applications of stack:
● It acts as temporary storage during recursive operations
● Redo and Undo operations in doc editors
● Reversing a string
● Parenthesis matching
● Postfix to Infix Expressions
● Function calls order

➢ Operations in stack:
● push: This adds an item to the top of the stack. The overflow condition
occurs if the stack is full.
● pop: This removes the top item of the stack. Underflow condition
occurs if the stack is empty
● top: This returns the top item from the stack.
● isEmpty: This returns true if the stack is empty else false.
● size: This returns the size of the stack.

3) Queue:
● A queue is a linear data structure that allows users to store items in a
list in a systematic manner.
● The items are added to the queue at the rear end until they are full, at
which point they are removed from the queue from the front.
● Queues are commonly used in situations where the users want to hold
items for a long period of time.
● Example: A queue at ticket counter

4
➢ Applications of Queue:
● Breadth-first search algorithm in graphs
● Operating system: job scheduling operations, Disk scheduling, CPU
scheduling etc.
● Call management in call centres

➢ Operations in Queue:
● enqueue: This adds an element to the rear end of the queue. Overflow
conditions occur if the queue is full.
● dequeue: This removes an element from the front end of the queue.
Underflow conditions occur if the queue is empty.
● isEmpty: This returns true if the queue is empty or else false.
● rear: This returns the rear end element without removing it.
● front: This returns the front-end element without removing it.
● size: This returns the size of the queue

➢ Stack vs Queue:

5
4) Deque:
● A deque can be thought of as an array of items, but with one important
difference: Instead of pushing and popping items off the end to make
room, deques are designed to allow items to be inserted at either end.
● This property makes deques well-suited for performing tasks such as
keeping track of inventory, scheduling tasks, or handling large amounts
of data.

➢ Types of deque:
● Input Restricted Deque: Insertion operations are performed at only one
end while deletion is performed at both ends in the input restricted
queue.

● Output Restricted Deque: Deletion operations are performed at only


one end while insertion is performed at both ends in the output
restricted queue

➢ Applications of deque:
● It can be used as both stack and queue, as it supports all the
operations for both data structures.
● Web browser’s history can be stored in a deque.
● Operating systems job scheduling algorithm

5) Priority queue:
● Priority Queue is an abstract data type that is similar to a queue in that
each element is assigned a priority value.

6
● The order in which elements in a priority queue are served is
determined by their priority (i.e., the order in which they are removed).
● If the elements have the same priority, they are served in the order they
appear in the queue.

➢ Applications of Priority Queue:


● Used in graph algorithms like Dijkstra, Prim’s Minimum spanning tree
etc.
● Huffman code for data compression
● Finding Kth Largest/Smallest element

6) Linked list:
● A linked list can be thought of as a series of linked nodes (or items)
that are connected by links (or paths).
● Each link represents an entry into the linked list, and each entry points
to the next node in the sequence.
● The order in which nodes are added to the list is determined by the
order in which they are created.

➢ Applications of linked list:


● Stack, Queue, binary trees, and graphs are implemented using linked
lists.
● Dynamic management for Operating System memory.
● Round robin scheduling for operating system tasks.

7
● Forward and backward operation in the browser.

➢ Types of linked list:


i. Singly linked list: A singly linked list is a data structure that is used to
store multiple items. The items are linked together using the key. The
key is used to identify the item and is usually a unique identifier. In a
singly linked list, each item is stored in a separate node. The node can
be a single object or it can be a collection of objects. When an item is
added to the list, the node is updated and the new item is added to the
end of the list. When an item is removed from the list, the node that
contains the removed item is deleted and its place is taken by another
node.

ii. Doubly linked list: A doubly linked list is a data structure that allows for
two-way data access such that each node in the list points to the next
node in the list and also points back to its previous node. In a doubly
linked list, each node can be accessed by its address, and the contents
of the node can be accessed by its index.

iii. Circular linked list: A circular linked list is a unidirectional linked list
where each node points to its next node and the last node points back
to the first node, which makes it circular.

iv. Doubly circular linked list: A doubly circular linked list is a linked list
where each node points to its next node and its previous node and the
last node points back to the first node and first node’s previous points
to the last node.

8
v. Header List: A list that contains the header node at the beginning of the
list, is called the header-linked list. This is helpful in calculating some
repetitive operations like the number of elements in the list etc.

❖ Non-linear Data Structure:

1) Graphs:
● A Graph is a non-linear data structure consisting of vertices and edges.
● The vertices are sometimes also referred to as nodes and the edges
are lines or arcs that connect any two nodes in the graph.
● More formally a Graph is composed of a set of vertices( V ) and a set
of edges( E ).
● The graph is denoted by G(E, V).

➢ Application of Graph:
● Graphs are used to define the flow of computation.

● Graphs are used to represent networks of communication.

● Graphs are used to represent data organization.

● Graph theory is used to find shortest path in road or a network.

● In computer network, the relationships among interconnected


computers within the network, follow the principles of graph theory.

9
2) Trees:
● A Tree is a non-linear data structure and a hierarchy consisting of a
collection of nodes such that each node of the tree stores a value and a
list of references to other nodes (the “children”).

➢ Applications of tree:
● Storing naturally hierarchical data: Trees are used to store the data in
the hierarchical structure. For example, the file system. The file system
stored on the disc drive, the file and folder are in the form of the
naturally hierarchical data and stored in the form of trees.
● Organize data: It is used to organize data for efficient insertion, deletion
and searching. For example, a binary tree has a logN time for searching
an element.
● Trie: It is a special kind of tree that is used to store the dictionary. It is a
fast and efficient way for dynamic spell checking.
● Heap: It is also a tree data structure implemented using arrays. It is
used to implement priority queues.
● B-Tree and B+Tree: B-Tree and B+Tree are the tree data structures used
to implement indexing in databases.
● Routing table: The tree data structure is also used to store the data in
routing tables in the routers.

➢ Operations of tree:
● Create – create a tree in data structure.
● Insert − Inserts data in a tree.
● Search − Searches specific data in a tree to check it is present or not.
● Preorder Traversal – perform Traveling a tree in a pre-order manner in
data structure .
● In order Traversal – perform Traveling a tree in an in-order manner.
● Post order Traversal –perform Traveling a tree in a post-order manner.

10
➢ Types of tree:
i. General tree: A node can have either 0 or maximum n number of nodes.
There is no restriction imposed on the degree of the node. The topmost
node in a general tree is known as a root node. The children of the
parent node are known as subtrees.

ii. Binary tree: Binary name itself suggests two numbers, i.e., 0 and 1. In a
binary tree, each node in a tree can have utmost two child nodes. Here,
utmost means whether the node has 0 nodes, 1 node or 2 nodes.

iii. Binary Search tree: A binary search tree is a special type of binary tree
that has a specific order of elements in it. It has three basic qualities:

11
● All elements in the left subtree of a node should have a value
less than or equal to the parent node's value.
● All elements in the right subtree of a node should have a value
greater than or equal to the parent node's value.
● Both the left and right subtrees must be binary search trees too.

iv. AVL tree: It is a self-balancing binary search tree that was invented
by Adelson Velsky Lindas. Here, self-balancing means that balancing
the heights of left subtree and right subtree.

➢ Tree traversal:
● Tree traversal is the process of visiting all the nodes of a tree. Since the
root (head) is the first node and all nodes are connected via edges (or
links) we always start with that node.
● There are three ways which we use to traverse a tree:
i. Inorder: left subtree-root-right subtree
ii. Preorder: root-left subtree- right subtree
iii. Postorder: left subtree-right subtree-root

❖ Tower of Hanoi:

12
● Tower of Hanoi is a mathematical puzzle where we have three rods
(A, B, and C) and N disks.
● Initially, all the disks are stacked in decreasing value of diameter i.e.,
the smallest disk is placed on the top and they are on rod A.
● The objective of the puzzle is to move the entire stack to another rod
(here considered C), obeying the following simple rules:
i. Only one disk can be moved at a time.
ii. Each move consists of taking the upper disk from one of the
stacks and placing it on top of another stack i.e. a disk can only be
moved if it is the uppermost disk on a stack.
iii. No disk may be placed on top of a smaller disk.

❖ Recursive function:
● Recursion is a process in which the function calls itself indirectly or
directly in order to solve the problem.
● The function that performs the process of recursion is called a
recursive function. There are certain problems that can be solved pretty
easily with the help of a recursive algorithm.

❖ Hashing:
● It is a technique of mapping a large chunk of data into small tables
using a hashing function.
● It is also known as the message digest function. It is a technique that
uniquely identifies a specific item from a collection of similar items.

❖ Hash map:
● Hash maps are a common data structure used to store key-value pairs
for efficient retrieval.
● A value stored in a hash map is retrieved using the key under which it
was stored. # `states` is a Hash Map with state abbreviation keys and
state name values.

13

You might also like