0% found this document useful (0 votes)
43 views5 pages

DSA Questions

DSA question
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
43 views5 pages

DSA Questions

DSA question
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 5

DSA Questions

1. What do you understand by Data Structure?


A data structure is a way of organizing and storing data so that it can be
accessed and modified efficiently.

2. What is an Algorithm?
An algorithm is a step-by-step procedure or formula for solving a problem

3. Give some examples of data structure.


 Array
 Linked List
 Stack
 Queue
 Tree
 Graph
 Hash table, etc.
4. What is difference between Array and Linked Lists?
 Arrays have a fixed size, while linked lists are dynamic in size.
 Arrays allow random access, whereas linked lists require sequential
access.
 Insertion and deletion are more expensive in arrays compared to linked
lists.

5. Name different operation which we perform on arrays.


 Searching
 Sorting
 Incertion
 Deletion
6. What is Linear Search?
Linear search, also known as sequential search, is a simple searching
algorithm used to find a specific element in a list or array. The algorithm
works by checking each element of the list sequentially until the desired
element is found or the end of the list is reached.

7. What is Binary Search?


Binary search is an efficient algorithm for finding an element in a sorted
array. It works by repeatedly dividing the search interval in half and
comparing the target value to the middle element of the array

8. Tell me Different types of linked lists.


 Singly linked list
 Doubly linked list
 Circular linked list
9. What is difference between singly linked list and doubly
linked list?
1. Structure

Singly Linked List:

 Each node contains data and a single reference to the next node.

Doubly Linked List:

 Each node contains data, a reference to the next node, and a reference to the previous node.

2. Memory Usage

Singly Linked List:

 Requires less memory as each node only stores one reference (to the next node).

Doubly Linked List:

 Requires more memory because each node stores two references (one to the next node and one to the
previous node).
3. Traversal

Singly Linked List:

 Can only be traversed in one direction (from the head to the tail).

Doubly Linked List:

 Can be traversed in both directions (from the head to the tail and from the tail to the head).

4. Insertion and Deletion

Singly Linked List:

 Insertion: Adding a new node requires updating the next reference of the previous node to point to
the new node.
 Deletion: Removing a node requires updating the next reference of the previous node to skip the
deleted node. No direct reference to the previous node, so often requires traversal from the head to
find the previous node.

Doubly Linked List:

 Insertion: Adding a new node requires updating both the next reference of the previous node and the
previous reference of the next node.
 Deletion: Removing a node is easier because each node has a direct reference to both its previous
and next nodes, making it straightforward to update references.

5. Complexity

Singly Linked List:

 Simpler to implement and manage due to fewer references per node.

Doubly Linked List:

 More complex to implement and manage due to additional references per node.

6. Use Cases

Singly Linked List:

 Useful when memory usage is a concern and bidirectional traversal is not required.
 Suitable for simple applications like implementing stacks or queues.

Doubly Linked List:

 Useful when bidirectional traversal is needed or when frequent insertion and deletion of nodes from
both ends are required.
 Suitable for more complex applications like implementing deques (double-ended queues), LRU
(Least Recently Used) cache, etc
10. What do you understand by Stacks?
A stack is a linear data structure that follows the Last In, First Out (LIFO)
principle, meaning the last element added to the stack is the first one
to be removed. Stacks are commonly used in various applications, such
as expression evaluation, backtracking, and memory management.

11. What are difference between Stacks and queues?


 A stack is a linear data structure that follows the Last In, First Out
(LIFO) principle.

 A queue is a linear data structure that follows the First In, First Out
(FIFO) principle.

12. What is a sorting algorithm? Name a few common


sorting algorithms.
A sorting algorithm is a method or process used to arrange elements of a
list or array in a specific order, typically in numerical or lexicographical
order
 Bubble sort
 Merge sort
 Selection sort
 Insertion sort
 Quick sort
13. What do you understand by time complexity & space
complexity?
Time Complexity
Definition: Time complexity measures the amount of time an algorithm takes to
complete as a function of the size of the input. It provides an upper
bound on the running time, giving a way to express how the runtime
grows with larger inputs.

Space Complexity
Definition: Space complexity measures the amount of memory an algorithm uses
as a function of the size of the input. It provides an upper bound on the
space needed, including both the space required for input storage and
additional space used by the algorithm.

14. What is Big O notation?


Big O notation is a mathematical notation used to describe the upper
bound of an algorithm's running time or space requirements in terms of
the input size.

15. What is recursion?


Recursion is a process where a function calls itself directly or indirectly
to solve a problem.

You might also like