/
DSA QUIZ
Save to my account
Sign up
DSA QUIZ
Upload a PDF by clicking the button below π
View
Untitled Deck
Study
1
Question
What is a linked list?
Answer
A linked list is a linear data structure that includes a series of connected nodes. Each node stores the data and the address of the next node.
2
Question
How are pointers used in a linked list?
Answer
Pointers are used to store addresses of a variable in a linked list. They allow operations such as defining a pointer variable, assigning the address of a variable to a pointer, and locating the value at the address available in the pointer variable.
3
Question
What special name is given to the address of the first node in a linked list?
Answer
The address of the first node in a linked list is given a special name called HEAD.
4
Question
How can the last node in a linked list be identified?
Answer
The last node in the linked list can be identified because its 'next' portion points to NULL.
5
Question
What are some limitations of arrays in storing linear data of similar types?
Answer
The limitations of arrays include fixed size, the need to know the upper limit on the number of elements in advance, expensive insertion and deletion operations, and the inability to allow dynamic size changes.
6
Question
Why is insertion of a new element and deletion of an existing element expensive in arrays?
Answer
Insertion and deletion in arrays are expensive because new elements require room to be created, existing elements have to be shifted, and maintaining a sorted order involves moving elements. Dynamic Array Ease of Insertion/Deletion.
7
Question
What are the advantages of a linked list over arrays in terms of insertion and deletion operations?
Answer
In a linked list, insertion and deletion operations are more efficient than in arrays because if the head node is known, any node can be traversed to and a new node can be inserted at the required position without moving existing elements.
8
Question
What are the advantages of arrays over linked lists?
Answer
Arrays allow random access, whereas linked lists require sequential access. Arrays also have a more straightforward memory allocation structure and can be used for dynamic array implementation.
9
Question
Dynamic Array
Answer
- Ease of Insertion/Deletion - Random access is allowed - Not cache friendly - Contiguous memory locations for elements
10
Question
Linked List
Answer
- Ease of Insertion/Deletion - Random access is not allowed - Extra memory space for a pointer is required with each element - Not cache friendly - Sequential access of elements - Represented by a pointer to the head node
11
Question
Stack
Answer
- Abstract data type - Fundamental operations: Push, Pop - Follows Last In First Out (LIFO) principle - All insertions and deletions happen from one side (Top)
12
Question
Stack
Answer
A data structure that follows the Last In First Out (LIFO) principle.
13
Question
Stack Operations
Answer
1. Push: Adding an element to the top of a stack 2. Pop: Removing an element from the top of a stack 3. IsEmpty: Checking if the stack is empty 4. IsFull: Checking if the stack is full 5. Peek: Getting the value of the top element without removing it
14
Question
Stack Implementation
Answer
1. Using arrays 2. Using linked list
15
Question
Stack Pointer (TOP)
Answer
A pointer used to keep track of the top element in the stack.
16
Question
Initializing Stack
Answer
Setting the value of the stack pointer to 1 for checking if the stack is empty.
17
Question
Push Operation
Answer
Increases the value of the stack pointer and places the new element pointed to by TOP.
18
Question
Pop Operation
Answer
Returns the element pointed to by TOP and reduces its value.
19
Question
Check if Stack is Full
Answer
Before pushing, check if the stack is already full.
20
Question
Check if Stack is Empty
Answer
Before popping, check if the stack is already empty.
21
Question
Queue
Answer
A data structure that follows the First In First Out (FIFO) principle.
22
Question
Queue Operations
Answer
1. Enqueue: Putting items in the queue 2. Dequeue: Removing items from the queue
23
Question
Queue Implementation
Answer
Can be implemented using arrays or linked list.
24
Question
FIFO Rule
Answer
First In First Out - the item that goes in first is the item that comes out first.
25
Question
Ticket Queue Analogy
Answer
Similar to a ticket queue outside a cinema hall where the first person entering the queue is the first person who gets the ticket.
26
Question
What is a Queue in data structures?
Answer
A Queue is an abstract data structure (ADT) that follows the FIFO (First In First Out) rule, allowing the operations: Enqueue, Dequeue, IsEmpty, IsFull, and Peek.
27
Question
What is Enqueue operation in a Queue?
Answer
Enqueue operation adds an element to the end of the queue.
28
Question
What is Dequeue operation in a Queue?
Answer
Dequeue operation removes an element from the front of the queue.
29
Question
How is a Queue implemented using an array?
Answer
A queue can be represented in an array using variables Queue (array storing queue elements), Front (index of the first element), and Rear (index of the last element).
30
Question
What are the pointers used in Queue operations?
Answer
The pointers used in Queue operations are FRONT (tracks the first element) and REAR (tracks the last element).