ICT Cp&Ds Anskey
ICT Cp&Ds Anskey
PART-B (3X10=30)
A Doubly Linked List is a type of linked list where each node contains three parts:
(b) How to implement the stack ADT using two queues? Write the function for the push and
pop operations (13).
A stack is a linear data structure that follows the Last In, First Out (LIFO) principle. The two
primary operations for a stack are:
return 0;
}
(a) Write and explain the algorithms of enqueue and dequeue operations of
queue.
A Queue is a linear data structure that follows the First In, First Out (FIFO) principle. In a
queue, the first element added is the first one to be removed, like a line of people at a ticket
counter.
Enqueue: This operation adds an element to the back (rear) of the queue.
Dequeue: This operation removes an element from the front of the queue.
14 (a) Write short notes on circular linked list with few operations.(13) OR
Singly Circular Linked List (SCLL): Each node has a pointer to the next node, and the last
node points to the first node.
Doubly Circular Linked List (DCLL): Each node has two pointers: one pointing to the next
node and one pointing to the previous node. The last node points back to the first node, and
the first node points to the last node. Operations on Circular Linked List:
Insertion:
At the beginning: Insert a new node at the head, and make the last node's next point to the
new head.
At the end: Insert a new node at the end of the list and make the last node's next point to
the new node, and the new node's next point to the head.
After a specific node: Insert a node after a specified node and adjust the pointers
accordingly.
Deletion:
At the beginning: Remove the first node and make the second node the new head.
At the end: Remove the last node, and make the second-to-last node the last node.
After a specific node: Remove a node after a specified node and adjust the pointers
accordingly.
Traversal:
Traversing a circular linked list involves starting at the head node and following the next
pointers until you return to the head node.
Search:
Searching in a circular linked list is similar to a regular linked list, except we loop back to the
head node if we haven’t found the target.
Display:
Display the list by starting from the head node and continuing until we reach the head node
again.
(b) With appropriate diagram explain any one application of queue.(13)
15 (a) Explain about File Handling in c with a suitable example .(13) OR
File handling in C is a crucial aspect of programming that allows a program to store and
retrieve data from external storage devices like hard drives, SSDs, or networked storage.
This is essential for managing data persistently between program executions.
#include <stdio.h>
int main() {
FILE *file;
char ch;
// Open a file for reading
file = fopen("example.txt", "r");
if (file == NULL) {
printf("File not found!\n");
return 1;
}
// Read and display file content
printf("File content:\n");
while ((ch = fgetc(file)) != EOF) {
putchar(ch); // Print characters to console
}
// Close the file
fclose(file);
// Open a file for writing
file = fopen("output.txt", "w");
if (file == NULL) {
printf("Error opening file for writing!\n");
return 1;
}
// Write content to file
fprintf(file, "This is a test.\nFile Handling in C.\n");
// Close the file
fclose(file);
printf("\nContent written to 'output.txt'.\n");
return 0;
}
(b) Explain about Decision Making and Conditional Statements.(13)
Conditional statements allow the program to make decisions and execute different
actions depending on whether a condition is true or false.
(c) The main conditional statements used in C are:
(d) if statement
(e) if-else statement
(f) else-if ladder
(g) switch statement
(h) Ternary (conditional) operator
PART-C (1X10=10)
16 (a)Explain about Expressions using operators with a suitable example .(13) OR L1,L2 1
organizing code and defining how data is stored and manipulated. A function in C is a block
of code that performs a specific task. Functions help to modularize code, making it reusable