0% found this document useful (0 votes)
9 views

DS MID-1 (2 marks)

The document provides an overview of linked lists, including definitions and types such as singly, doubly, and circular linked lists, along with their operations like insertion, deletion, traversal, search, and update. It also discusses memory representation, space complexity, abstract data types, and compares arrays with linked lists. Additionally, it covers data structure terminologies, advantages, searching, and sorting algorithms.

Uploaded by

onlypes802
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)
9 views

DS MID-1 (2 marks)

The document provides an overview of linked lists, including definitions and types such as singly, doubly, and circular linked lists, along with their operations like insertion, deletion, traversal, search, and update. It also discusses memory representation, space complexity, abstract data types, and compares arrays with linked lists. Additionally, it covers data structure terminologies, advantages, searching, and sorting algorithms.

Uploaded by

onlypes802
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/ 4

1. What is a Linked List?

A linked list is a linear data structure where elements (called nodes) are connected using pointers.
Each node contains two parts:
o Data (stores the actual value)
o A pointer (stores the address of the next node)

Unlike arrays, linked lists allow dynamic memory allocation and efficient insertion/deletion.

2. What is a Singly Linked List?


A singly linked list is a type of linked list where each node points to the next node in the sequence
but does not have a reference to the previous node. It consists of:
o A head (points to the first node)
o Nodes with a data field and a next pointer
o The last node’s next pointer is NULL, indicating the end of the list
3. What is a Doubly Linked List?
A doubly linked list is a type of linked list where each node has two pointers:
o prev (points to the previous node)
o next (points to the next node)

This allows traversal in both directions and makes insertion and deletion operations more
efficient than a singly linked list.

4. What is a Circular Linked List?


A circular linked list is a variation of a linked list where:
o In a singly circular linked list, the last node's next pointer points back to the head
instead of NULL.
o In a doubly circular linked list, both the prev of the first node and next of the last
node form a circular connection.

This ensures that the list never terminates and allows continuous traversal.

5. What are the operations of a Linked List?


o Insertion: Add a node at the beginning, middle, or end.
o Deletion: Remove a node from any position.
o Traversal: Go through the list to access elements.
o Search: Find a node with a specific value.
o Update: Modify the data of a node.
6. Describe the memory representation of a Linked List.
o In a singly linked list, each node occupies memory dynamically, containing a data part
and a pointer to the next node.
o In a doubly linked list, each node contains two pointers (prev and next), requiring
more memory but improving operations.
o Unlike arrays, linked lists are scattered in memory, with nodes linked via pointers rather
than contiguous memory blocks.
a. What is Space Complexity?

Space complexity refers to the total memory required by an algorithm, including:

1. Fixed Part – Constants, variables, and program size.


2. Variable Part – Memory for input data, dynamic allocations, and recursive calls.
o It is often expressed using Big-O notation (e.g., O(n), O(1)).

b. Define Abstract Data Type (ADT).

An Abstract Data Type (ADT) is a mathematical model for data structures, defining what
operations can be performed but not how they are implemented.

• Example: Stack ADT supports operations like push(), pop(), and isEmpty() without
specifying implementation details.

c. What are the operations of a Linked List?

1. Insertion – Add a node (beginning, middle, or end).


2. Deletion – Remove a node.
3. Traversal – Access each node sequentially.
4. Search – Find a node with a specific value.
5. Update – Modify the value of a node.

d. Describe the memory representation of a singly linked list.

• Each node consists of data and a pointer to the next node.


• Nodes are stored non-contiguously in memory, and each node links to the next using a
pointer.
• The last node has a NULL pointer indicating the end.

Example Structure:

[Data | Next] → [Data | Next] → [Data | NULL]

e. Define Little Omega (ω).

Little Omega (ω) notation describes a lower bound that is not asymptotically tight.

• It represents functions that grow faster than a given function but without an exact
bound.
• Example: f(n) = ω(g(n)) means f(n) grows strictly faster than g(n), but not
necessarily at the same rate.
f. Compare Arrays and Linked Lists.

Feature Array Linked List


Memory Allocation Contiguous Dynamic
Access Time O(1) (Direct) O(n) (Sequential)
Insertion/Deletion Costly (O(n)) Efficient (O(1) or O(n))
Extra Memory No Yes (for pointers)

g. What is a Circular Linked List

A Circular Linked List (CLL) is a linked list where the last node connects back to the first
node.

• Singly Circular Linked List – The last node points to the first node.
• Doubly Circular Linked List – Both first and last nodes are interconnected.

h. How many types of data structures?

1. Linear Data Structures (Sequential)


o Arrays, Linked Lists, Stacks, Queues
2. Non-Linear Data Structures
o Trees, Graphs
3. Hashing-Based Structures
o Hash Tables

i. How to access elements of an array?

Elements of an array can be accessed using indexing, where indices start from 0.

• Example (C/Python): arr[2] accesses the 3rd element.

j. What is Row Major Storage of an Array?

• Row-major order stores a 2D array row by row in continuous memory locations.


• Example:
• int arr[2][2] = {{1, 2}, {3, 4}};

Stored as: 1, 2, 3, 4

k. What is Column Major Storage of an Array?

• Column-major order stores a 2D array column by column.


• Example:
• 1 3
• 2 4

Stored as: 1, 3, 2, 4

l. What are the Terminologies of Data Structures?

1. Nodes – Elements in linked lists, trees, graphs.


2. Edges – Connections between nodes (in graphs).
3. Pointers – Memory addresses linking nodes.
4. Front & Rear – Used in queues.
5. Top & Bottom – Used in stacks.

m. What are the Advantages of Data Structures?

1. Efficient Data Management – Faster access and modifications.


2. Optimized Memory Usage – Helps reduce wastage.
3. Easy Searching & Sorting – Algorithms like binary search are efficient with structured
data.
4. Data Relationships – Graphs and trees store hierarchical and network-based
relationships.

n. What is Searching?

Searching is the process of finding an element in a data structure.


Types:

1. Linear Search (O(n)) – Checks each element.


2. Binary Search (O(log n)) – Works on sorted data, divides the array into halves.

o. Define Sorting.

Sorting is the process of arranging elements in a specific order (ascending/descending).


Common algorithms:

• Bubble Sort (O(n²))


• Merge Sort (O(n log n))
• Quick Sort (O(n log n))
• Insertion Sort (O(n²))

You might also like