Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

1.

Define data structures with examples:


- Data structures are a way of organizing and storing data in a computer. Examples include arrays,
linked lists, stacks, queues, trees, and graphs.
- Data structures can be used to improve the efficiency of algorithms, reduce memory usage, and
provide a more organized way of accessing and manipulating data.

2. Define abstract data structure:


- Abstract data structure refers to a high-level description of a data structure that focuses on its
properties and operations, rather than its implementation details.
- It defines the behavior of a data structure, without specifying how it is implemented.

3. Define linear and non-linear data structure with example:


- Linear data structure refers to a type of data structure where elements are arranged in a linear
sequence, such as an array or a linked list.
- Non-linear data structure refers to a type of data structure where elements are not arranged in a
linear sequence, such as trees or graphs.

4. Difference between linear and non-linear data structures using a table:

Linear Data Structures | Non-linear Data Structures


-----------------------|---------------------------
Data elements are arranged in a linear sequence | Data elements are not arranged in a linear
sequence
Examples: Arrays, Linked Lists, Stacks, Queues | Examples: Trees, Graphs
Access time is proportional to the position of the element | Access time depends on the structure of
the data
Elements are accessed sequentially | Elements are accessed through traversal
Operations include insertion, deletion, and searching | Operations include traversal, path finding, and
searching

5. Difference between primitive and non-primitive data structures:


- Primitive data structures are basic data types, such as integers, floats, and characters.
- Non-primitive data structures are more complex data types, such as arrays, linked lists, and trees.
- Primitive data structures are built-in to the programming language, whereas non-primitive data
structures must be implemented by the programmer.

6. Difference between array and linked list:


- Arrays are a data structure that stores elements in a contiguous block of memory, where each
element can be accessed by its index. Arrays have a fixed size and can be used to store homogeneous
data types.
- Linked lists are a data structure that consists of nodes, where each node contains an element and a
reference to the next node in the list. Linked lists can be used to store heterogeneous data types and
can be dynamically resized.

7. Applications of singly linked list:


- Implementing stacks and queues
- Representing polynomials in mathematics
- Implementing sparse matrices

8. Applications of doubly linked list:


- Implementing caches
- Implementing undo-redo functionality in text editors
- Implementing navigation systems in web browsers

9. Define stack abstract data type:


- A stack is an abstract data type that represents a collection of elements, where elements are added
and removed from only one end, known as the top. Stacks follow the Last-In-First-Out (LIFO) principle.
10. Applications of stack:
- Implementing function calls and recursion in programming
- Parsing and evaluating arithmetic expressions
- Implementing undo-redo functionality in applications

You might also like