0% found this document useful (0 votes)
5 views6 pages

Mukund DS Short Answers

The document provides an overview of various data structures including nodes, linked lists, stacks, queues, hash tables, and trees. It explains their definitions, implementations, operations, and applications, with specific focus on singly and doubly linked lists, stack operations, queue management, and binary search trees. Additionally, it discusses hashing functions and their applications in areas like database indexing and password verification.

Uploaded by

perupoguajay9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

Mukund DS Short Answers

The document provides an overview of various data structures including nodes, linked lists, stacks, queues, hash tables, and trees. It explains their definitions, implementations, operations, and applications, with specific focus on singly and doubly linked lists, stack operations, queue management, and binary search trees. Additionally, it discusses hashing functions and their applications in areas like database indexing and password verification.

Uploaded by

perupoguajay9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1. Define Node and explain about Linked List.

A node is a basic unit of a data structure like a linked list. It typically contains two parts:

- Data: the actual value/information.

- Pointer: address of the next node.

A linked list is a linear data structure where each node is linked to the next one using pointers. Unlike arrays,

linked lists don't store elements in contiguous memory. They are dynamic, meaning they can grow/shrink

during runtime.

2. Explain about Single Linked List and its Implementations.

A singly linked list is a type of linked list where each node points to the next node only.

Structure:

struct Node {

int data;

struct Node* next;

};

Operations:

- Insertion (at beginning, end, or position)

- Deletion (by value or position)

- Traversal (to print or search elements)

Implementation Tip: Use dynamic memory (malloc) in C for node creation.

3. Define Stack and implementation of Stack using arrays.

A stack is a linear data structure that follows LIFO (Last In, First Out).

Operations:

- push(): add element on top

- pop(): remove top element


- peek(): see top element

Array implementation:

#define MAX 100

int stack[MAX], top = -1;

void push(int val) {

if(top == MAX-1) return;

stack[++top] = val;

void pop() {

if(top == -1) return;

top--;

4. Write about Hashing Tables.

A hash table is a data structure that stores key-value pairs using a hash function to compute an index into an

array.

Advantages:

- Fast access: O(1) average time

- Good for lookups, insertions, deletions

Collisions are handled using:

- Chaining (linked list at each index)

- Open addressing (linear probing, etc.)

5. Explain the implementation of Queue.

A queue is a linear data structure that follows FIFO (First In, First Out).
Operations:

- enqueue(): add to rear

- dequeue(): remove from front

Array implementation:

int queue[MAX], front = -1, rear = -1;

void enqueue(int val) {

if(rear == MAX-1) return;

if(front == -1) front = 0;

queue[++rear] = val;

void dequeue() {

if(front == -1 || front > rear) return;

front++;

6. Explain about Double Linked List and its Implementations.

A doubly linked list allows traversal in both directions. Each node has:

- Data

- Pointer to the next node

- Pointer to the previous node

Structure:

struct Node {

int data;
struct Node* prev;

struct Node* next;

};

Operations:

- Insert at front/back/middle

- Delete any node

- Traverse forward and backward

7. Write about the Hashing Functions.

A hash function converts keys into array indices. A good hash function:

- Minimizes collisions

- Distributes keys uniformly

Common types:

- h(key) = key % table_size (modulo method)

- Multiplication method

- Folding method

8. Explain about Application of Stacks.

Stacks are used in:

- Expression evaluation (Postfix, Prefix)

- Undo/Redo operations

- Syntax parsing in compilers

- Recursion management (function call stack)

- Balancing symbols (e.g., brackets in code)

9. Write about Operations and Application of Hashing.

Operations in hashing:
- Insert(key)

- Search(key)

- Delete(key)

Applications:

- Database indexing

- Symbol tables in compilers

- Caching (e.g., LRU cache)

- Password verification (hashing passwords)

- Routing and IP address lookup

10. Define Tree and implementation Binary Search Tree.

A tree is a non-linear hierarchical data structure with nodes connected by edges.

Each node has:

- Data

- Left child

- Right child

A Binary Search Tree (BST) is a tree where:

- Left child < Node

- Right child > Node

BST Node in C:

struct Node {

int data;

struct Node* left;

struct Node* right;


};

Operations:

- Insert

- Search

- Delete

- In-order/Pre-order/Post-order traversal

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy