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

DS 2 Mark Answers

The document provides a comprehensive overview of data structures, including definitions and applications of data structures, abstract data types, queues, stacks, linked lists, searching and sorting algorithms, trees, and graphs. Key concepts such as time complexity, space complexity, and various operations on these structures are discussed. It also highlights the differences between data structures and their respective use cases in programming and algorithm design.

Uploaded by

sbalajibalaji512
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)
8 views6 pages

DS 2 Mark Answers

The document provides a comprehensive overview of data structures, including definitions and applications of data structures, abstract data types, queues, stacks, linked lists, searching and sorting algorithms, trees, and graphs. Key concepts such as time complexity, space complexity, and various operations on these structures are discussed. It also highlights the differences between data structures and their respective use cases in programming and algorithm design.

Uploaded by

sbalajibalaji512
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

DS 2 Mark Answers

Unit – 1: Basics of Data Structures

1. Define Data Structure


A data structure is a systematic way of organizing and managing data to enable efficient access
and modification.

2. Define Abstract Data Type (ADT)


An ADT is a model that defines a data type by its behavior from the point of view of a user, such
as operations possible and their meanings, without specifying implementation.

3. Define Time Complexity and Space Complexity

Time Complexity: Measures the amount of time an algorithm takes relative to input size.

Space Complexity: Measures the memory space required by an algorithm.

4. Describe the applications of the Queue


Queues are used in task scheduling, printer spooling, network packet management, and
asynchronous data transfer between processes.

5. Describe different types of Queues

Simple Queue (FIFO)

Circular Queue (wrap-around behavior)

Priority Queue (elements processed by priority)

Double-Ended Queue (Deque) (insert/delete at both ends)

6. List out the applications of Stack

Reversing data

Expression evaluation

Syntax parsing

Backtracking (e.g., maze solving)

Function calls in programming

7. Drawbacks of linear queue and solution using circular queue


Linear queues waste space after deletion. Circular queues reuse memory by wrapping the rear
pointer to the front when space is available.
---

Unit – 2: Linked Lists

1. Define Linked List


A linked list is a linear data structure where each element (node) contains data and a reference
(link) to the next node in the sequence.

2. Differentiate Arrays and Linked Lists

Arrays: Fixed size, direct access via index

Linked Lists: Dynamic size, sequential access via pointers

3. Describe the application of Linked Lists


Used in dynamic memory allocation, implementing stacks/queues, polynomial manipulation, and
navigation systems.

4. Explain inserting in a single linked list


Insertion involves creating a new node and adjusting pointers:

At beginning: new → head

At end: last node → new

In middle: previous node → new → next node

5. Differentiate Doubly Linked List and Circular Linked List

Doubly Linked List: Nodes have two pointers (next and previous)

Circular Linked List: Last node points back to the first node

6. Explain operations on Linked List

Insertion

Deletion

Traversal

Searching

Reversing

7. Time complexity of insertion/deletion in single linked list


Best/Average: O(1) at beginning

Worst: O(n) at end or specific position

8. Time complexity of search operation in double linked list

O(n) as traversal is required from head or tail to the node

---

Unit – 3: Searching and Sorting

1. Differentiate Linear Search and Binary Search

Linear Search: Sequential search, O(n)

Binary Search: Requires sorted array, divides array, O(log n)

2. Explain Fibonacci Search Algorithm


A divide-and-conquer technique similar to binary search but uses Fibonacci numbers to split
arrays, minimizing comparisons.

3. Use of pivot element in Quick Sort


The pivot partitions the array into elements smaller and greater than itself, enabling efficient
recursive sorting.

4. Define Hash Function


A function that converts input data into a fixed-size numerical value (hash code) used to index
data in hash tables.

5. What are collision resolution techniques?

Chaining: Linked lists at hash table index

Open Addressing: Finding next available slot (e.g., linear probing)

6. Worst and Best Case time of Quick Sort

Best Case: O(n log n) (balanced partition)

Worst Case: O(n²) (unbalanced partition)

7. Algorithm design technique used in Merge Sort


Divide and Conquer: Splits the array, sorts subarrays, and merges them.

8. Applications of Hash Tables


Database indexing

Caches

Symbol tables in compilers

Password verification

---

Unit – 4: Trees

1. Define Binary Tree and its types


A binary tree is a hierarchical structure where each node has at most two children. Types:

Full

Complete

Perfect

Skewed

Balanced

2. Define LR and RL Rotation in AVL Tree

LR Rotation: Left-Right rotation (left child has right-heavy subtree)

RL Rotation: Right-Left rotation (right child has left-heavy subtree)

3. Differentiate Binary Tree and Binary Search Tree

Binary Tree: No ordering rule

BST: Left child < parent < right child

4. Properties of Red-Black Trees

Each node is red or black

Root is black

No two reds in a row


Every path from node to leaf has same number of black nodes

Self-balancing tree

5. Define Height, Depth, and Level of a Binary Tree

Height: Max edges from node to leaf

Depth: Edges from root to node

Level: Distance from root (root at level 0)

6. When AVL tree is said to be balanced and how to find balance factor?
AVL tree is balanced if balance factor of every node is -1, 0, or +1.
Balance Factor = Height(left subtree) – Height(right subtree)

7. Time complexity of search in Red-Black Tree


Since height is O(log n), search takes O(log n) in worst case.

8. What is Splay Tree?


A self-adjusting binary search tree where recently accessed elements are moved to the root
using rotations.

---

Unit – 5: Graphs

1. Define Regular Graph


A graph is regular if each vertex has the same number of neighbors; i.e., all vertices have equal
degree.

2. Define Spanning Tree and Minimum Spanning Tree (MST)

Spanning Tree: A subgraph that connects all vertices without cycles

MST: A spanning tree with minimum total edge weight

3. Define Adjacency Matrix Representation


A 2D array where matrix[i][j] = 1 (or weight) if there is an edge between vertex i and j, otherwise
0.

4. Define Weighted Graph and Directed Graph

Weighted Graph: Each edge has a weight or cost

Directed Graph: Edges have a direction from one vertex to another


5. Define Shortest Path and its techniques
Shortest path is the minimum distance or cost between two vertices.
Techniques: Dijkstra’s, Bellman-Ford, Floyd-Warshall, A*

6. Graph Traversal Techniques

Depth-First Search (DFS)

Breadth-First Search (BFS)

7. Applications of Graphs

Social networks

Routing and navigation

Network flows

Dependency resolution

8. Operations on Graphs

Add/Delete vertex or edge

Search (DFS/BFS)

Path finding

Cycle detection

Topological sort

You might also like