0% found this document useful (0 votes)
29 views3 pages

Stack, Queue, and Linked List Operations

The document consists of questions and tasks related to stack, queue, and linked list data structures, divided into three modules. It covers definitions, operations, algorithms for evaluating postfix expressions, converting infix to postfix, and implementing various queue types with C functions. Additionally, it addresses linked list operations, self-referential structures, and polynomial representation in linked lists.

Uploaded by

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

Stack, Queue, and Linked List Operations

The document consists of questions and tasks related to stack, queue, and linked list data structures, divided into three modules. It covers definitions, operations, algorithms for evaluating postfix expressions, converting infix to postfix, and implementing various queue types with C functions. Additionally, it addresses linked list operations, self-referential structures, and polynomial representation in linked lists.

Uploaded by

bneelagund
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

MODULE-1

Questions on Stack Data structure


1. Define stack? Explain different operations that can be performed on
stack with suitable C Functions and Examples? [8 Marks]
2. Write an algorithm to evaluate the postfix expression and also trace
the algorithm for the following expression showing the content of stack
i. 6 5 1 – 4 * 2 3 ^ / + [ 8 Marks]
ii. 5 4 6 + * 4 9 3 / + *
iii. 6 2 3 + - 3 8 2 / + * 2 $ 3 +
3. Convert the following infix expression into postfix expression using
stack
i. A+(B* C-(D/E^F)*G)*H [7 Marks]
ii. (( A/(B-C+D))*(E-A)*C)
4. Mention the applications of stacks [ 4 Marks]

MODULE-2

QUEUE and LINKED LIST

Answer the following:

1. Write the difference between Arrays and Queue [ 4 Marks]


2. Write a note on Dequeue and Priority Queue [ 5 Marks]
3. Define Queue? Develop C Functions to implement Insert(), Delete() and
Display() on Ordinary Queue? [8 Marks]
4. Define Queue? Develop C Functions to implement Insert(), Delete() and
Display() on Circular Queue? [8 Marks]
5. A Circular queue the size of which is 5 has 3 elements 10,40,25, where
F = 2 and R = 4. After inserting 50,60, what is the value of F and R?
Trying to insert an element 30 at this stage what will happen? Delete 2
elements from the queue and insert 100. Show the sequence of steps
with necessary diagrams with the value of F and R
6. Show the content of circular Queue after performing each of the
following operations (Circular Queue of size 5)
a. Empty Queue
b. Insert 10
c. Insert 20 and 30
d. Insert 40 and 50
e. Insert 60
f. Delete two items
g. Insert 60 and 70
h. Insert 80 [ 8 Marks]
7. Define Queue? What are the different types of Queue? State the
limitations of an ordinary Queue. Explain how do you overcome the
limitation by specifying the required C-statements and diagrammatic
representation using example[10 Marks]
8. What is linked list? Explain different types of linked list with diagrams
and examples[8 Marks]
9. Write C Functions for the following operations on Singly linked list
i. Inserting node at the beginning
ii. Inserting node at the rear end of linked list
iii. Delete node at the beginning
iv. Delete node at the rear end of linked list
v. Display the content of the linked list [ 10 Marks]
10. What is self referential structure? Explain with Example the self-
referential structure? [5 Marks]
11. Explain C-statements to create a node, add a node, delete a node on a
Singly Linked List with proper message where each node is containing
the details of employees in the form of EmpId,EmpName,Empaddr and
EmpSalary as Data fields[ 10Marks]
12. Write C Functions for the following operations on Circular Singly linked
list
i. Inserting node at the beginning
ii. Inserting node at the rear end of linked list
iii. Delete node at the beginning
iv. Delete node at the rear end of linked list
v. Display the content of the linked list [ 10 Marks]
13. Write a node structure for linked list representation of polynomial and
C-function to add the polynomial term at the rear_end of the linked
list[8 Marks]
MODULE-3

LINKED LIST and TREES

Common questions

Powered by AI

An ordinary queue faces the challenge of unused space at the beginning after several elements are dequeued, which leads to inefficient memory usage. A circular queue addresses this by treating the queue as circular, allowing enqueued elements to wrap around to the front when there is available space, optimizing space utilization and maintaining efficient enqueue and dequeue operations .

Adjusting and visualizing the content of a circular queue involves performing operations like insertions, deletions, and displaying elements, considering the wrapping nature of the queue. For instance, inserting elements until full and then deleting some to allow more insertions demonstrates its circular behavior. Visualizations typically show index changes in the array format, reflecting how F (front) and R (rear) move .

To convert an infix expression (e.g., A+(B*C-(D/E^F)*G)*H) to postfix using a stack, operators are pushed onto the stack, and operands are appended to the output. Operators are popped from the stack based on precedence and associativity when a lower precedence operator or a parenthesis is encountered. This transformation is useful for facilitating expression evaluation without operator precedence rules and parentheses, which postfix inherently manages, thus simplifying parsing in computer algorithms .

Implementing a circular singly linked list in C requires managing a head pointer that points to the first node, which also points back to connect the last node to itself, ensuring a complete circular connection. Functions for insertion and deletion must correctly handle the circular nature, especially when altering the first or last node, using logic like `void insertAtBeginning(Node** head, int data)` and `void deleteLast(Node** head)` to maintain integrity .

A singly linked list comprises nodes where each node contains data and a pointer to the next node. Core operations like insertion (at the beginning or end), deletion (from the beginning or end), and traversal require specific C functions. Example operations include `void insertAtBeginning(Node** head, int data)`, `void insertAtEnd(Node** head, int data)`, and `void deleteFromBeginning(Node** head)`. These functions manipulate pointers to adjust nodes in the list .

A dequeue (double-ended queue) allows insertion and deletion at both the front and rear ends, providing flexibility for applications like palindrome checking. In contrast, a priority queue elements are removed based on priority rather than insertion order, making it ideal for scheduling tasks or managing process priorities in operating systems. Both are variations of the FIFO concept but adapted for specific needs .

Arrays are fixed-size data structures where elements are stored consecutively in memory, allowing easy access with index-based access patterns. Queues follow a First In, First Out (FIFO) principle where elements are added at the rear and removed from the front. This makes queues more suitable for scenarios requiring sequential processing of data, whereas arrays are used for static storage when element order is less dynamic .

A self-referential structure is a data structure in which a structure type includes at least one pointer that refers directly or indirectly to an instance of the same structure type, enabling linked structures like linked lists. For instance, `struct Node { int data; struct Node *next; };` is a basic illustration where each node points to the next, forming a linked list .

A circular queue is preferred over a regular queue when efficient use of storage is important, since it allows reuse of the space from dequeued elements by connecting the end of the queue to the front in a circular manner. Operations include Insert(), Delete(), and Display(), with additional logic to handle wrapping around the array to utilize all available space, demonstrated through managing the front (F) and rear (R) indices appropriately .

A stack data structure operates on the principle of Last In, First Out (LIFO), meaning the last element added is the first to be removed. The primary operations include push (to add an element), pop (to remove the top element), and peek (to view the top element without removing it). In C, these operations can be implemented using functions such as `void push(int stack[], int *top, int element)`, `int pop(int stack[], int *top)`, and `int peek(int stack[], int top)`. These functions manipulate an array used as the stack and maintain a pointer or index for tracking the top element .

You might also like