New Microsoft Word Document
New Microsoft Word Document
• Insertion of element
• Deletion of element
5. List out the areas in which data structures are applied extensively.
Following are the areas in which data structures are applied extensively.
• Operating system- the data structures like priority queues are
used for scheduling the jobs in the operating system.
• Compiler design- the tree data structure is used in parsing the
source program. Stack data structure is used in handling
recursive calls.
• Database management system- The file data structure is used in
database management systems. Sorting and searching
techniques can be applied on these data in the file.
• Numerical analysis package- the array is used to perform the
numerical analysis on the given set of data.
• Graphics- the array and the linked list are useful in graphics
applications.
• Artificial intelligence- the graph and trees are used for the
applications like building expression trees, game playing.
6. What is recursion in data structure?
Programmers use the recursion technique to solve problems by breaking them
down into smaller, related subproblems. Recursion in the context of data
structures refers to the use of a recursive function to iteratively traverse or
modify a data structure. When dealing with recursive data structures or issues
that have a recursive nature, recursive algorithms are frequently used.
Deque stands for Double ended queue. It is a linear list in which insertions and
deletion are made from either end of the queue structure.
17. Define Circular Queue.
Definition of Stack:
A stack is a linear data structure that follows the Last In, First Out (LIFO)
principle, meaning that the last element added to the stack is the first one to
be removed. It is analogous to a stack of plates, where you can only add or
remove a plate from the top.
Significance of TOP in Stack:
The TOP in a stack is a pointer or an index that keeps track of the position of
the most recently added element. It plays a crucial role in the stack
operations:
1. Push Operation: When an element is inserted into the stack, the TOP is
incremented to point to the newly added element.
2. Pop Operation: When an element is removed, the TOP is decremented to
point to the previous element.
3. Stack Overflow: If the TOP reaches the maximum size of the stack, no
more elements can be added.
4. Stack Underflow: If the TOP is at -1 (indicating an empty stack), no
elements can be removed.
26. Develop an algorithm for inserting a new element into the stack.
2. Queue
A queue is a linear data structure that follows the FIFO (First In, First
Out) principle, meaning the first element added is the first one removed.
Operations on Queue:
1. Enqueue(x): Inserts element x at the rear (end).
2. Dequeue(): Removes and returns the front element.
3. Front(): Returns the front element without removing it.
4. isEmpty(): Checks if the queue is empty.
5. isFull(): Checks if the queue is full (in case of an array implementation).
✅ Example:
Enqueue(10) → Enqueue(20) → Enqueue(30) → Queue: [10, 20, 30]
Dequeue() → Removes 10 → Queue: [20, 30]
Features of Stacks
1. Follows LIFO (Last In, First Out) Principle:
o The last element inserted is the first one to be removed.
o Example: If elements A, B, C are pushed, C will be popped first.
2. Operations are Performed on One End (TOP):
o Push (Insert) and Pop (Delete) occur only at the top of the stack.
o This makes stacks efficient for managing data.
3. Fixed or Dynamic Size:
o Array-based stack: Fixed size, limited by memory.
o Linked-list-based stack: Dynamic size, grows as needed.
4. Supports Basic Operations:
o Push() – Insert an element.
o Pop() – Remove the top element.
o Peek()/Top() – View the top element.
o isEmpty() – Check if the stack is empty.
5. Efficient Time Complexity:
o Push and pop operations take O(1) time (constant time).
6. Used for Backtracking & Recursion:
o Stacks help in function calls, undo operations, and maze solving.
7. Overflow & Underflow Conditions:
o Overflow: Occurs when trying to push into a full stack.
o Underflow: Occurs when trying to pop from an empty stack.
Stacks are simple yet powerful data structures widely used in computing! 🚀
1. Infix Notation
Definition: The operator is placed between operands.
Example: A + B
Evaluation Order: Requires operator precedence and parentheses to
define the order.
Example with Precedence: A + B * C (Multiplication * is done before
Addition +).
Challenge: Needs extra processing for evaluation (operator precedence
and associativity).
39. Given the prefix for an expression. Write its postfix: -*-+abc/ef-g/hi
40. Mention the advantages of representing stacks using linked lists than arrays
49. Write down the function to insert an element into a queue, in which the
queue is implemented as an array.
50. Analyze and write a routine to check whether the queue is full or empty.
51. For railway reservation the queue data structure is preferred –Justify.