0% found this document useful (0 votes)
12 views10 pages

Ds 2 Marks

The document outlines various data structures and algorithms, including implementations of List ADT, properties of heaps, and the advantages of doubly linked lists. It discusses concepts such as circular linked lists, binary trees, and sorting algorithms, along with their applications and limitations. Additionally, it covers hash functions, critical paths, and the differences between cyclic and acyclic graphs.

Uploaded by

maheshla21
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)
12 views10 pages

Ds 2 Marks

The document outlines various data structures and algorithms, including implementations of List ADT, properties of heaps, and the advantages of doubly linked lists. It discusses concepts such as circular linked lists, binary trees, and sorting algorithms, along with their applications and limitations. Additionally, it covers hash functions, critical paths, and the differences between cyclic and acyclic graphs.

Uploaded by

maheshla21
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/ 10

1.

Mention the ways in which list ADT can be implemented


The List ADT can be implemented in two main ways:
1. Array-based: Using a fixed-size array to store elements in a
contiguous block of memory.
2. Linked List-based: Using nodes, where each node stores data
and a reference to the next node, allowing dynamic size.
2.Outline a circular linked list with a diagram.

A circular linked list is a type of linked list in which the last node
points back to the first node, forming a circle.
Diagram:
o .

3.Outline a linear and a non linear data structure with an


example.

1. Linear Data Structure:


A linear data structure is a type of data structure where elements are
stored in a sequential order, and each element is connected to its
previous and next element.
Example:
• Array: A collection of elements stored in contiguous memory
locations, where each element can be accessed by an index.
Example:
Array = [10, 20, 30, 40]
Here, each element has a specific position (index), and elements are
accessed sequentially.
2. Non-Linear Data Structure:
A non-linear data structure is a type of data structure where
elements are not stored sequentially. Elements can be connected in a
hierarchical or graph-like manner.
Example:
• Tree: A hierarchical structure where each element (node) has a
parent and potentially many children.
Example:

10
/ \
20 30
/ \ \
40 50 60
In this tree, 10 is the root, with two children 20 and 30. Each of those
children can have their own sub-branches.
4.Write the underflow and overflow conditions in stack?

Overflow Condition in Stack:


Occurs when you try to push an element onto a stack that is already
full.
• Cause: The stack has reached its maximum capacity.
• Result: No more elements can be added.
Underflow Condition in Stack:
Occurs when you try to pop an element from a stack that is empty.
• Cause: The stack has no elements to remove.
• Result: No elements can be removed.
5.List the advantages of doubly linked list.
Advantages of Doubly Linked List:
1. Bidirectional Traversal: Can be traversed in both directions
(forward and backward).
2. Efficient Deletion: Deletion of nodes is easier since both the
previous and next nodes are accessible.
6.What is a heap? Outline the properties of a heap.
Heap:
A heap is a binary tree-based data structure that satisfies the heap
property.
Properties:
1. Complete Binary Tree: All levels are fully filled except
possibly the last, which is filled from left to right.
2. Heap Property:
o Max-Heap: Parent is greater than or equal to its children.
o Min-Heap: Parent is less than or equal to its children.
o

7.Write an algorithm for inserting a new element into the stack.

Algorithm for Inserting a New Element into the Stack:


1. Start
2. Check if Stack is Full:
o If stack is full, print "Overflow" and stop.
3. Increment the Top pointer.
4. Insert the New Element at the position pointed by the Top.
5. End
8. Convert the infix expression (a +b) * (c — d) to prefix
expression.

prefix expression:
*+ab-cd

9. Identify the advantages and disadvantages of a circular linked


list.

Advantages of Circular Linked List:


1. Continuous Traversal: Can loop through the list without
needing to reset.
2. Efficient for Circular Applications: Useful in applications like
round-robin scheduling.
Disadvantages of Circular Linked List:
1. Complex Traversal: No NULL pointer to mark the end, which
can be confusing.
2. Difficult to Manage: Handling the last node’s pointer properly
is tricky.

10. Give the limitations of linear queue.

Limitations of Linear Queue:


1. Fixed Size: Once full, no more elements can be added.
2. Wasted Space: Space at the front can't be reused after
dequeueing elements.

11. Mention the types of rotations performed on AVL tree.

Types of Rotations in AVL Tree:


1. Left Rotation (LL): For imbalance on the left side.
2. Right Rotation (RR): For imbalance on the right side.
3. Left-Right Rotation (LR): Combination of left and right
rotations.
4. Right-Left Rotation (RL): Combination of right and left
rotations.
12. If the depth of the binary tree is k, the maximum number of
nodes in the binary tree is 2k-1 – Justify.

The statement 2k - 1 is incorrect.


Correct Formula:
• The maximum number of nodes in a binary tree with depth k
is 2^(k+1) - 1.
Justification:
• At each level of the tree, the number of nodes doubles.
• The total number of nodes is the sum:
1+2+4+⋯+2k=2k+1−11 + 2 + 4 + \dots + 2^k = 2^{k+1} - 1.

13. Define critical path.


Critical Path:
The critical path is the longest sequence of tasks in a project,
determining the shortest time to complete the project.
• Key Point: Any delay in the critical path will delay the entire
project.
14. List some applications of queues

Applications of Queues:
1. Scheduling: Used in operating systems for scheduling tasks or
processes (e.g., CPU scheduling).
2. Buffering: Used in data streaming or network buffering, where
data is stored temporarily before being processed.

15. Identify the principle behind the external sorting algorithms.

Principle of External Sorting:


External sorting works by dividing large data into smaller chunks,
sorting them in memory, and then merging the sorted chunks.
• Divide and Merge: Split data, sort chunks in memory, and
merge them.
• Use of External Storage: Data is stored on disk due to memory
limitations.
16. For railway reservations, the queue data structure is preferred
–Justify.

Justification for Using Queue in Railway Reservations:


1. FIFO Order: Passengers are served in the order they arrive,
ensuring fairness.
2. Efficient Processing: The queue efficiently handles reservations
as each request is processed one at a time.

17. Construct a binary tree for the expression (a + b)*(c- d).

Binary Tree for the Expression:


(a+b)∗(c−d)(a + b) * (c - d)
*
/\
+ -
/\/\
a bc d
Explanation:
• Root: * (multiplication)
• Left subtree: + (addition) with children a and b
• Right subtree: - (subtraction) with children c and d

18. State the uses of topological sort.

Uses of Topological Sort:


1. Task Scheduling: To schedule tasks that have dependencies.
2. Dependency Resolution: To determine the order of tasks or
processes based on dependencies (e.g., in compilation).

19. State the properties of binary search tree.


Properties of Binary Search Tree (BST):
1. Left Subtree: Contains values smaller than the root.
2. Right Subtree: Contains values greater than the root.
3. Unique Values: Each node has a unique value.
4. Subtree Rule: Both left and right subtrees are also BSTs.
20. Differentiate between cyclic graph and acyclic graph.

Cyclic Graph:
• Has at least one cycle (a loop where you can return to the
starting node).
Acyclic Graph:
• No cycles (no loop, can't return to the starting node).

21. Distinguish External & Internal Sorting.

External Sorting:
• Used when data is too large to fit in memory.
• Data is stored on external storage like a disk.
Internal Sorting:
• Data fits entirely in memory (RAM).

• Faster sorting using in-memory algorithms.

22. Does the minimum spanning tree of a graph give the shortest
distance between any twospecified nodes? Justify the answer.
No, the Minimum Spanning Tree (MST) does not give the shortest
distance between two specific nodes.
Reason:
• The MST connects all nodes with the minimum total weight,
but it doesn't always provide the shortest path between two
nodes.

23. State the uses of Abstract Data Type (ADT).


Uses of Abstract Data Type (ADT):
1. Organizes Data: Helps in arranging and managing data
efficiently.
2. Hides Details: Only shows the necessary actions (like adding or
removing data), without exposing how it's done.

24. Give the time complexities of linear search and binary search.
Time Complexities:
1. Linear Search:
o Time Complexity: O(n)
o Explanation: It checks each element one by one, so the
time increases with the number of elements.
2. Binary Search:
o Time Complexity: O(log n)
o Explanation: It divides the list in half with each step, so
it’s much faster for large lists (works only on sorted lists).

25. Define B+ Tree with an Example

B+ Tree:
A B+ Tree is a type of tree used to store data in an organized way. In
this tree, data is stored only in the leaf nodes, while the internal
nodes store keys to help find the data quickly.

Example:
[20]
/ \
[10] [30]
/ \ / \
[5] [15] [25] [35]

26. Define a fully binary tree.

Fully Binary Tree:


A fully binary tree is a tree where every non-leaf node has exactly
two children.
Example:
1
/\
2 3
/\/\
4 56 7
Here, all nodes (except the leaves) have two children.

27. Outline a directed graph with an example.

Directed Graph:
A directed graph is a graph where edges go in a specific direction.
Example:
A→B→C
↑ ↓
D←E
• The arrows show the direction from one node to another.

28. Define a hash function.

A hash function is a mathematical function that takes an input (like a


string or number) and turns it into a fixed-size value, usually a unique
code called a hash. This process helps in quickly searching, sorting, or
verifying data in systems like databases or security applications.

29. Outline perfect minimal hashing function

A perfect minimal hashing function is a function that:


1. Minimizes Collisions: It makes sure different inputs (like words
or numbers) don't give the same hash value.
2. Fixed Output: It always gives a fixed-size result, no matter how
big or small the input is.
In short, it tries to avoid mistakes and keeps the result the same size.

30. What is a hash function?

A hash function is a mathematical function that takes an input (like a


string or number) and turns it into a fixed-size value, usually a unique
code called a hash. This process helps in quickly searching, sorting, or
verifying data in systems like databases or security application.

You might also like