CIT Question Bank 1
CIT Question Bank 1
Question Bank
1. Define space and time complexity.
5. Compare and contrast singly linked lists and doubly linked list.
11. State the advantages of circular lists over doubly linked list.
15Marks
1.Derive an ADT to perform insertion and deletion in circular single linked list.
2. Given a list 10,20,30,40 generalize the steps along with the routine and pictorial representation
for doubly linked list
3. (i)Write an ADT to implement stack of size N using an array. The elements in the stack are to
be integers. The operations to be supported are PUSH, POP. Take into account the exceptions of
stack overflow and stack Underflow.
(ii) Evaluate the expression A * (B + C) – D for A = 10, B = 20, C = 15, D = 5 using stack.
4. A queue has a size of 4 and has two elements 7,8.Let F be the pointer to Front end and R be
the pointer to Rear end. Then series of operations are performed
Assess the sequence of steps with necessary diagrams and also explain the routine with the
value of F & R.
Advantages:
∙ Modularity: ADTs can be combined with other ADTs to form more
complex data structures, which can increase flexibility and modularity in
programming.
∙ Abstraction: ADTs allow users to work with data structures without having to
know the implementation details, which can simplify programming and
reduce errors.
∙ Encapsulation: ADTs provide a way to encapsulate data and operations into a
single unit, making it easier to manage and modify the data structure.
5)Compare and contrast singly linked lists and doubly linked list.
Singly linked lists Doubly linked lists
singly linked lists Contain a pointer Contain pointers to both the next
to the next node in the list, but not and previous nodes in the list.
the previous node
Singly linked lists require less Doubly linked lists take up more
memory because they only store two space because they store data, the
members: data and the next node. next node, and the previous node.
Singly linked lists make it easy to Doubly linked lists make it easier to
deallocate or allocate memory iterate in both directions, delete
during execution, and insertion and nodes, and perform reverse
deletion don't require shifting all operations.
elements.
Pointers It has only one pointer It uses two pointers (in a simple queue)
the top. This pointer indicates for reading and writing data from both
the
the address of the topmost ends- the front and the rear. The rear one
element or the last inserted indicates the address of the last inserted
one of the stack. element, whereas the front pointer
indicates the address of the first inserted
element in a queue.
Circular linked lists (CLLs) and doubly linked lists (DLLs) have different
advantages:
Circular linked lists - any node can be a starting point, so you can traverse each
node from any point. This is useful for applications that repeatedly go around the
list, like implementing a queue. CLs also don't require a NULL assignment in the
code, and they never point to a NULL pointer unless fully deallocated.
Doubly linked lists -It can iterate in both directions, which is useful for
applications like music playlists, where songs can be changed by moving
backward and forward. DLLs can also shrink dynamically.
10)Some common applications of Queue data structure :
1. Task Scheduling: Queues can be used to schedule tasks based on priority or
the order in which they were received.
2. Resource Allocation: Queues can be used to manage and allocate
resources, such as printers or CPU processing time.
3. Batch Processing: Queues can be used to handle batch processing jobs, such
as data analysis or image rendering.
4. Message Buffering: Queues can be used to buffer messages in
communication systems, such as message queues in messaging systems or
buffers in computer networks.
5. Event Handling: Queues can be used to handle events in event-driven
systems, such as GUI applications or simulation systems.
6. Web servers: Web servers use queues to manage incoming requests from
clients. Requests are added to the queue as they are received, and they are
processed by the server in the order they were received.