-
Introduction To DS
- What Is Data Structure
- Need Of Data Structure
-
Advantages Of Data Structure
- Efficiency
- Reusability
- Abstraction
- Efficiency of a program depends upon the choice of data structures.
- Data structures are reusable.
- Data structure is specified by the ADT which provides a level of abstraction.
-
Types Of Data Structure
- Primitive Data Structure
-
Non-Primitive Data Structure
-
Linear
- Static
- Array
- Dynamic
- Linked List
- Stack
- Queue
-
Non-Linear
- Tree
- Graph
-
Data Structure Operations
- 1.Traversing
- 2.Insertion
- 3.Deletion
- 4.Searching
- 5.Sorting
- 6.Merging
- - group of data elements which provides an efficient way of storing and organising data.
- Some examples of Data Structures are arrays, Linked List, Stack, Queue, etc.
-
Stack & Queue
-
Stack
- What is Stack ?
-
Operations of Stack
- Push()
- pop()
- peek()/top()
- isEmpty()
- isFull()
- Insert operation is called push operation.
- Delete operation is called pop operation.
-
Ways To Implement Stack
- Static
- Dynamic
-
Queue
- What is Queue ?
-
Operation of Queue
- enqueue()
- dequeue()
- Insert operation is called enqueue operation.
- delete operation is called enqueue operation.
-
Linked List
- What is Linked List ?
- Why use a linked list over an array?
-
Types of Linked List
-
Singly Linked List
-
Operation on SLL
- Insertion
- Insertion at beginning
- Insertion at end of list
- insertion after specified node
- Deletion
- Deletion at beginning
- Deletion at the end of list
- Deletion after specified node
- Traversing
- Searching
-
Doubly Linked List
-
Operation On DLL
- Insertion
- Insertion at beginning
- Insertion at end of list
- insertion after specified node
- Deletion
- Deletion at beginning
- Deletion at the end of list
- Deletion after specified node
- Traversing
- Searching
- Circular Linked List
- Doubly Circular Linked List
-
Trees
-
Basic Terminologies Of Tree DS
- Parent Node
- Child Node
- Root Node
- Leaf Node or External Node
- Ancestor of a Node
- Descendant
- Sibling
- Level of a node
- Internal Node
- Neighbour of a Node
- Subtree
-
Basic Properties Of Tree DS
- Number Of Edges
- Depth of a node
- Height of a node
- Height of the Tree
- Degree of a Node
- An edge can be defined as the connection between two nodes.
- The depth of a node is defined as the length of the path from the root to that node. Each edge adds 1 unit of length to the path.
- The height of a node can be defined as the length of the longest path from the node to a leaf node of the tree.
- The height of a tree is the length of the longest path from the root of the tree to a leaf node of the tree.
- The total count of subtrees attached to that node is called the degree of the node. The degree of a leaf node must be 0.
-
Basic Operation Of Tree DS
- Create
- Insert
- Search
- Pre-Order Traversal
- In-Order Traversal
- Post-Order Traversal
- create a tree in data structure.
- Inserts data in a tree.
- Searches specific data in a tree to check it is present or not.
- perform Traveling a tree in a pre-order manner in data structure .
- perform Traveling a tree in an in-order manner.
- perform Traveling a tree in a post-order manner.
-
Types Of Trees
- General Tree
- Binary Tree
- Balanced Tree
- Binary Search Tree
-
Application Of Tree DS
- Spanning Trees
-
Binary Search Tree
- Full Binary tree
- Complete Binary tree
- Skewed Binary tree
- Strictly Binary tree
- Extended Binary tree
- Storing hierarchical data
- Syntax Tree
- Trie
- Heap
-
Sorting & Hashing
-
Sorting Algorithms
-
Selection Sort
- How Selection Sort Works
-
Maintains Two Sub Arrays
- The subarray which already sorted.
- The remaining subarray was unsorted.
-
Stability
- Stability: The default implementation is not stable. However, it can be made stable. Please see stable selection sort for details.
-
Advantages
- Simple and easy to understand.
- Preserves the relative order of items with equal keys which means it is stable.
- Works well with small datasets.
- It is adaptable to various types of data types.
- Selection sort is an in-place sorting algorithm, which means it does not require any additional memory to sort the list.
-
Bubble Sort
- How it Works
-
Solving Method
- Run a nested for loop to traverse the input array using two variables i and j, such that 0 ≤ i < n-1 and 0 ≤ j < n-i-1
- If arr[j] is greater than arr[j+1] then swap these adjacent elements, else move on
- Print the sorted array
-
Stability
- Yes, the bubble sort algorithm is stable.
-
Advantages
- Bubble sort is easy to understand and implement.
- It does not require any additional memory space.
- It’s adaptability to different types of data.
-
Insertion Sort
- How It Works
-
Stability
- Yes, insertion sort is a stable sorting algorithm.
-
Merge Sort
- How it works
-
Stability
- Yes, merge sort is stable.
-
Advantages
- Merge sort has a time complexity of O(n log n), which means it is relatively efficient for sorting large datasets.
- Merge sort is a stable sort, which means that the order of elements with equal values is preserved during the sort.
- It is easy to implement thus making it a good choice for many applications.
-
Quick Sort
- How It Works
-
Stability
- The default implementation is not stable. However any sorting algorithm can be made stable by considering indexes as comparison parameter.
-
Advantages
- It is a divide-and-conquer algorithm that makes it easier to solve problems.
- It is efficient on large data sets.
- It is a stable sort, meaning that if two elements have the same key, their relative order will be preserved in the sorted output.
- It has a low overhead, as it only requires a small amount of memory to function.
- Graph