Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Data Structures And Their Algorithms, Summaries of Data Structures and Algorithms

What is data structures, algorithms of data structures,binary tree,binary Search Tree

Typology: Summaries

2021/2022

Available from 02/06/2024

sivanika
sivanika 🇮🇳

1 document

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Data Structures
Introduction:
Data structures are essential elements of computer science that effectively arrange
and store data. An overview of various popular data structures is provided below:
1. Arrays: Groups of related data types that are stored in adjacent memory regions.
2. Linked Lists: Nodes containing elements are kept in order, with each node
linking to the subsequent element in the list.
3. Stacks: Adds and removes components from the same end, in accordance with
the Last In, First Out (LIFO) concept.
4. Queues: Components are added at one end and withdrawn from the other
according to the First In, First Out (FIFO) principle.
5. Trees: Nodes with parent-child relationships make up these hierarchical data
structures.
6. Binary Trees: The left and right children of each node are limited to two.
7. Binary Search Trees: A binary tree where the left child is smaller and the right
child is greater than the parent.
8. Heaps: Specialized trees where the parent node is always greater (max heap) or
smaller (min heap) than its children.
9. Hash Tables: Data structure that maps keys to values for efficient retrieval.
Array:
One of the most basic and basic types of data structures is an array. They are made
up of a single, continuous block of memory cells, each of which holds a single
piece of data. Here are a few important array-related points:
pf3
pf4
pf5
pf8

Partial preview of the text

Download Data Structures And Their Algorithms and more Summaries Data Structures and Algorithms in PDF only on Docsity!

Data Structures Introduction: Data structures are essential elements of computer science that effectively arrange and store data. An overview of various popular data structures is provided below:

  1. Arrays: Groups of related data types that are stored in adjacent memory regions.
  2. Linked Lists: Nodes containing elements are kept in order, with each node linking to the subsequent element in the list.
  3. Stacks: Adds and removes components from the same end, in accordance with the Last In, First Out (LIFO) concept.
  4. Queues: Components are added at one end and withdrawn from the other according to the First In, First Out (FIFO) principle.
  5. Trees: Nodes with parent-child relationships make up these hierarchical data structures.
  6. Binary Trees: The left and right children of each node are limited to two.
  7. Binary Search Trees: A binary tree where the left child is smaller and the right child is greater than the parent.
  8. Heaps: Specialized trees where the parent node is always greater (max heap) or smaller (min heap) than its children.
  9. Hash Tables: Data structure that maps keys to values for efficient retrieval. Array: One of the most basic and basic types of data structures is an array. They are made up of a single, continuous block of memory cells, each of which holds a single piece of data. Here are a few important array-related points:
  1. Random Access: An array’s elements can be directly accessed by utilizing their indices. This makes it possible to access any element in constant time, ( O(1) ).
  2. Fixed Size: An array’s size is fixed, decided upon at the declaration stage. An array cannot have its size dynamically altered once it has been constructed.
  3. Homogeneous Elements: An array can only have one type of data per element. An array of strings, for instance, can only hold strings, and an array of integers can only contain integers.
  4. Continuous Memory Assigning: Components within An array’s sequential storage in memory enables effective memory access.
  5. Efficient for Iteration: Due to their contiguous memory arrangement, arrays are effective for iterating over all elements sequentially.
  6. Insertion and Deletion: Because they can need to rearrange items to account for the size change, insertion and deletion operations in arrays can be inefficient, particularly in the center.
  7. Static vs. Dynamic Arrays: Static arrays, like those in Python or Java, have a fixed size that is set at build time, but dynamic arrays can resize themselves dynamically as needed. Because they are easy to use and efficient at retrieving elements, arrays are frequently utilized in a variety of algorithms and data structures. But in some cases, their limited size and ineffective insertion/deletion procedures can be drawbacks. Linked List:
  1. Efficient Insertion and Deletion: Since linked lists just need to update pointers rather than shifting members like arrays do, they are excellent at insertion and deletion operations, particularly when done at the beginning or end of the list. Stack: A stack is a linear data structure that uses the Last In, First Out (LIFO) principle, which states that the last thing added to the stack is the first to be removed. Here are some important points concerning stacks:
  2. Operations: Stacks usually support two main operations:
  • Push: Places an element at the top of the stack.
  • Pop: removes and returns the element at the top of the stack.
  1. Peek: Shows you the element at the top of the stack without deleting it.
  2. Dynamic Size: Stacks can expand or contract dynamically as elements are pushed or popped.
  3. Implementation: Stacks can be implemented as arrays or linked lists. Arrays give constant-time access, whereas linked lists allocate memory dynamically.
  1. Application:- Function Calls: A programming language feature that manages function calls and local variables. Expression Evaluation: Used by compilers to evaluate arithmetic expressions. Backtracking is used in algorithms such as depth-first search (DFS).
  2. LIFO Principle states that the last element added to the stack is the first to be deleted. This behavior is akin to a stack of plates, where you can only add or remove the top one.
  3. Empty Stack: An empty stack is one that does not contain any components. Attempting to pop an element from an empty stack causes an underflow problem.
  4. Full Stack: Depending on the implementation (e.g., array-based stack), a stack may become full if the underlying data structure is fixed in size. Attempting to push an element to a full Stacks are adaptable data structures with extensive applications in computer science, and their simplicity and efficiency make them useful in a variety of algorithms and programming tasks. Queue: A queue is a linear data structure that adheres to the FIFO (First In, First Out) principle, with components added at the back and removed at the front. It’s similar

operations, which normally have a temporal complexity of O(log n) in balanced trees. Heap: A heap is a specific tree-based data structure that exhibits the heap property. It is commonly implemented as a binary tree. In a max heap, each node’s value is larger than or equal to the values of its offspring, with the root node holding the maximum value. In a min heap, it is the inverse. Heaps are often used in algorithms such as heap sort, priority queues, and efficient search for the kth largest/smallest element. Hash Tables: Hash tables are data structures for storing key-value pairs. They employ a hashing method to generate an index into an array of buckets or slots, from which the needed value can be extracted. This allows for exceptionally efficient data retrieval, with an average complexity of constant time. Hash tables are commonly utilized in a variety of applications, including associative arrays, database indexing, and caching. However, collisions can occur when two different keys hash to the same index, necessitating handling mechanisms such as chaining or open addressing to resolve.