Skip to main content

Posts

Showing posts from February, 2024

Queue | Unit-2 | DSA

 https://www.programiz.com/dsa/queue Array Implementaion of queue: #include <stdio.h> #define MAX_SIZE 100 // Maximum size of the queue int queue[MAX_SIZE]; // Array to store the queue elements int front = -1;      // Front of the queue int rear = -1;       // Rear of the queue // Function to check if the queue is empty int is_empty() {     return (front == -1 && rear == -1); } // Function to check if the queue is full int is_full() {     return (rear == MAX_SIZE - 1); } // Function to insert an element into the queue void enqueue(int value) {     if (is_full()) {         printf("Queue Overflow\n");         return;     }     if (is_empty()) {         front = rear = 0; // If the queue is empty, initialize front and rear to 0     } else {         rear++; // Move rear to the next position   ...

Data Structure Unit 4 | serching | AKTU Free Notes Online.

  Concept of Searching: Searching is the process of finding a particular item or element within a collection of items. It involves examining each element in the collection until the desired item is found. Sequential Search: Also known as linear search. Involves checking each element in a list or array one by one from the beginning until the target element is found or the end of the list is reached. Simplest form of searching. Works well for small lists or unsorted data. Time complexity is O(n) where n is the number of elements in the list. Index Sequential Search: Enhances the efficiency of sequential search by using an index. The index is a data structure containing pointers or references to the elements in the main data structure (e.g., array). The index allows for quicker access to elements, reducing the number of comparisons needed. The search first checks the index to locate the block where the target element might be, then performs a sequential search within that block. Suita...

linkedlist

  Linked Lists: An Overview Definition: A linked list is a linear data structure consisting of a sequence of elements called nodes. Each node contains data and a reference (or pointer) to the next node in the sequence. Properties: Dynamic Size : Linked lists can grow or shrink in size dynamically as elements are added or removed. Flexibility : They allow for efficient insertion and deletion operations at any position in the list. Non-Contiguous Memory Allocation : Unlike arrays, linked list nodes can be scattered in memory, connected only by pointers. Types of Linked Lists: Singly Linked List: In a singly linked list, each node contains data and a pointer to the next node in the sequence. Doubly Linked List: In a doubly linked list, each node contains data and pointers to both the next and previous nodes, allowing bidirectional traversal. Circular Linked List: In a circular linked list, the last node points back to the first node, forming a circular structure. Advantages of Linked ...