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

1. What Are Data Structures in C and How Does It Work?

In computer jargon, a data structure is a method of storing and organising data in a

computer's memory so that it may be used effectively later. Data can be organised in a

number of different ways. A data structure is a logical or mathematical representation of how

data is organised.

2. What Are The Different Types Of Data Structures in C?


Data structures can be divided into two categories:

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

Stacks are some common examples of linear data structures.

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

non linear data structures.

3. List the areas where Data Structure can be used in C.


Data structures are important in almost every field you can think of. Algorithms are required

in any data handling circumstance. Here are a few scenarios in which data structures are

frequently used:

Artificial Intelligence / DBMS/ Operating System / Numerical Analysis/Graphics /Compiler

Design /Simulation etc.

4. What is an array in C programming language?


Arrays are groups of data elements of similar types stored in memory regions that are

contiguous. It is the most basic data structure in which the index number of each data

element can be used to get it at random.

5. In C, what is a linked list?


A Linked List is a collection of nodes, or data objects that are randomly stored. A pointer

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,

and only the elements at the back are added.

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

from one end of the stack.

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.

9. What is the definition of a doubly-linked list? Give some


specific examples.
It's a type of linked list (double-ended LL) in which each node has two links, one to the next

node in the sequence and the other to the previous node in the series. This allows traversal

of the data elements in both directions.

Examples:

1. A music playlist with next and previous track navigation options.

10. Distinguish between a file and a storage structure.


The fundamental difference between the two data structures is the memory space that is

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.

11. List a few uses for the queue data structure.


Some examples of queue applications are as follows:

1. Queues are commonly used to build queues for a single shared resource, such as a

printer, disc, or CPU.

2. Queues are used for asynchronous data transfer in pipes, file IO, and sockets (when

data is not transferred at the same pace between two processes).

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.

12. What is a Binary Search Tree, and how does it work?


The scanned input travels to the left or right of the root node, also known as the parent node,

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.

13. What exactly is a merge sort? What is the mechanism


behind it?
Merge sort is a data sorting algorithm that divides and conquers. It works by merging and

sorting neighbouring data to create larger sorted lists, which are then merged recursively to

create even larger sorted lists until only one remains.

17. What is selection sort and how does it work?


The smallest number from the list is repeatedly selected in ascending order and placed at the

top of the selection sort. This operation is repeated as you get closer to the end of the list or

sorted subarray.

18. What is bubble sort?


A bubble sort is a data structure sorting algorithm that may be used with arrays. It compares

objects in close proximity and swaps their values if they are out of order.

19. What exactly is an AVL tree?


An AVL tree is a binary search tree that is always in a partially balanced state. The

difference in the heights of the subtrees from the root is used to calculate the balance.

20. What is a priority queue, and how does it work?


A priority queue is an abstract data type that resembles a standard queue but contains

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,

one for data and the other for storing priority.

24. What is graph data structure in c?


A graph G can be used to represent an ordered collection G(V, E), where V(G) represents the

set of vertices and E(G) represents the set of edges connecting these vertices. , rather than

having parent-child relationships.

29. Write the C code for traversing a binary tree in order.


void in-order(struct treenode *tree)
{
if(tree != NULL)
{
in-order(tree→ left);
printf("%d",tree→ root);
in-order(tree→ right);
}
}

You might also like