Professional Documents
Culture Documents
IMP Question DSA Usig c
IMP Question DSA Usig c
computer's memory so that it may be used effectively later. Data can be organised in a
data is organised.
1. 1. Linear data structures : The organisation of linear data structures is similar to that
of computer memory. In a linear approach, linear data structures store elements one
after the other. At any one time, just one element of the data can be explored. Consider
a stack of books on a shelf. A book will be put between two other books, but not three;
at any given time, a book will only have a relationship with two other books. In a
similar fashion, linear data elements are stored. Arrays, Queues, Linked Lists, and
2. 2. Non linear data structures :Data structures that are not linear are stored in a
sequential order. In non linear data structures, data elements may have relationships
with one or more elements at the same time. It is more harder to manipulate non linear
data structures than linear data structures. Tree and graph are common examples of
in any data handling circumstance. Here are a few scenarios in which data structures are
frequently used:
contiguous. It is the most basic data structure in which the index number of each data
connects each node in a Linked List to its neighbouring node. In a node, there are two fields
7. What is a queue in C?
A queue is a collection of data organised according to the FIFO principle (First in, First Out).
It's some kind of linear data structure. Only the elements at the front of a queue are removed,
8. What is Stack in C?
A linear data structure is referred to as a stack. Stacks follows the strategy of "last in, first
out." A new item is added to the top of a stack. Both insert and delete actions are performed
There are two different uses for stacks. Use the push method to add components to the
stack, and the pop function to remove parts from the stack.
node in the sequence and the other to the previous node in the series. This allows traversal
Examples:
accessed. The phrase "storage structure" refers to the structure that houses the computer
system's main memory. When interacting with auxiliary structures, we refer to them as file
structures.
1. Queues are commonly used to build queues for a single shared resource, such as a
2. Queues are used for asynchronous data transfer in pipes, file IO, and sockets (when
3. Queues are used as buffers by most programmes, such as MP3 players and CD players.
4. In media players, queues are used to maintain track of the playlist and add and remove
tracks.
in a binary tree called a Binary Search Tree. The value at the root node is smaller than all of
the elements on the left. All elements to the right have a value larger than the value of the
root node.
sorting neighbouring data to create larger sorted lists, which are then merged recursively to
top of the selection sort. This operation is repeated as you get closer to the end of the list or
sorted subarray.
objects in close proximity and swaps their values if they are out of order.
difference in the heights of the subtrees from the root is used to calculate the balance.
entries of varying priority. Components with a higher priority are processed first, followed by
those with a lower priority. A minimum of two queues are necessary in this circumstance,
set of vertices and E(G) represents the set of edges connecting these vertices. , rather than