0% found this document useful (0 votes)
23 views

Data Structure

This document discusses different data structures including stacks, queues, and linked lists. It defines each data structure, describes their operations and implementations. Specifically, it covers the three types of linked lists (singly, doubly, circularly), their applications, and implementations of stacks and queues using linked lists. Operations for each data structure are provided such as push, pop, insert, delete, etc. Applications like polynomial representation, sorting, and file systems are discussed for linked lists.

Uploaded by

Nai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Data Structure

This document discusses different data structures including stacks, queues, and linked lists. It defines each data structure, describes their operations and implementations. Specifically, it covers the three types of linked lists (singly, doubly, circularly), their applications, and implementations of stacks and queues using linked lists. Operations for each data structure are provided such as push, pop, insert, delete, etc. Applications like polynomial representation, sorting, and file systems are discussed for linked lists.

Uploaded by

Nai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

TEST 1 DATA STRUCTURE

1. What is a data structure?


i. Why do we need data structures?
ii. List some common data structures
iii. How data structures are classified?

2. Differentiate between
i. Linear data structure
ii. Non-linear data structure

3. What are the types of linked lists?


i. How can each type of linked list be implemented?
ii. List down application of Linked List
iii. What are the advantages of Linked List
iv. Mention Demerits of linked list
v. What are the operations performed in list?

4. Define Stack.
i. What are the operations of the stack?
ii. How the operations performed on linked list implementation
of stack?
iii. What are the applications of stack?
iv. What are the methods to implement stack in C?

5. Define Queue.
i. What are the operations of the Queue?
ii. Write the routine to insert an element onto a queue.
iii. What are the types of queue and define them?
iv. How the queue is implemented by linked list?
v. What are the applications of queue?
MARKINGS CHEME TEST 1 DATA STRUCTURE
1. What is a data structure?
A data structure is a method for organizing and storing data which would
allow efficient data retrieval and usage.
A data structure is a way of organizing data that considers not only the items
stored, but also their relationships to each other.

i. Why do we need data structures?


Data structures allow us to achieve an important goal: component reuse.
Once data structure has been implemented, it can be used again and again in
Various applications.

ii. List some common Data Structures


● Stacks
● Queues
● Lists
● Trees
● Graphs
● Tables
iii. How data structures are classified?
Data structures are classified into two categories based on how the
data items are operated:
i. Primitive data structure
ii. Non-Primitive data structure

2. Differentiate between
a. Linear data structure
b. Non-linear data structure
Linear data structure Non-linear data structure

Data are arranged in linear or Data are not arranged in linear


sequential manner manner
Every items is related to its previous Every item is attached with many other
and next item items
Data items can be traversed in a Data items cannot be traversed in a
Single run. Single run.
Implementation is easy Implementation is difficult.
Example: array, stack, queue, linked Example: tree, graph
list
3. What are the types of linked lists?
There are three types
i. Singly linked list
ii. Doubly linked list
iii.Circularly linked list

i. Implementation
Type of Implementation Marks
Liked List
Singly
linked list

Each node has two elements


i. Data
ii. Next

Doubly
linked list

Doubly linked list is a collection of nodes


where nodes are connected by forwarded
and backward link.
Each node has three fields:
1. Address of previous node
2. Data
3. Address of next node
Circularly i. In a singly linked list, all the nodes
linked list are connected with forward links
to the next nodes in the list. The
last node has a next field, NULL.
In order to implement the
circularly linked lists from singly
linked lists, the last node’s next
field is connected to the first node.
i. In a doubly linked list, all nodes
are connected with forward and
backward links to the next and
previous nodes respectively. In
order to implement circular linked
lists from doubly linked lists, the
first node’s previous field is
connected to the last node and the
last node’s next field is connected
to the first node

ii. List down application of Linked List


a. Representation of polynomial ADT
b. Used in radix and bubble sorting
c. In a FAT file system, the metadata of a large file is organized
as a linked list of FAT entries.
d. Simple memory allocators use a free list of unused memory
Regions, basically a linked list with the list pointer inside the
free memory itself.

iii. What are the advantages of Linked List


a. Save memory space and easy to maintain
b. It is possible to retrieve the element at a particular index
c. It is possible to traverse the list in the order of increasing
index
d. It is possible to change the element at a particular index to a
different value, without affecting any other elements

iv. Mention Demerits of linked list


i. It is not possible to go backwards through the list
ii. Unable to jump to the beginning of list from the end.
v. What are the operations performed in list?
i. Insertion
a. Insert at beginning
b. Insert at end
c. Insert after specific node
d. Insert before specific node
ii. Deletion
a. Delete at beginning
b. Delete at end
c. Delete after specific node
d. Delete before specific node
iii. Merging
iv. Traversal

4. Define Stack.
Stack is an ordered list in which all insertions and deletions are made at one
end, called the top. It is an abstract data type and based on the principle of
LIFO (Last in First Out).

i. What are the operations of the stack?


a. CreateStack/ InitStack(Stack) – creates an empty stack
b. Push(Item) – pushes an item on the top of the stack
c. Pop(Item) – removes the top most element from the stack
d. Top(Stack) – returns the first element from the stack
e. IsEmpty(Stack) – returns true if the stack is empty

ii. How the operations performed on linked list implementation of stack?


a. Push and pop operations at the head of the list.
b. New nodes should be inserted at the front of the list, so that they
become the top of the stack.
c. Nodes are removed from the front (top) of the stack.

iii. What are the applications of stack?


• Evaluating arithmetic expressions
• Balancing the parenthesis
• Towers of Hanoi
• Function calls
• Tree traversal
iv. What are the methods to implement stack in C?
 Array based
 Linked list based

5. Define Queue.
It is a linear data structure that maintains a list of elements such that
insertion happens at rear end and deletion happens at front end. FIFO – First
In First Out principle

i. What are the operations of the Queue?


● isEmpty()
● isFull()
● insert()
● delete()
● display()

ii. Write the routine to insert an element onto a queue.


void insert(int element)
{
if(front==-1 )
{
front = rear = front +1;
queue[front] = element;
return;
}
if(rear==99)
{
printf(“Queue is full”);
getch();
return;
}
rear = rear +1;
queue[rear]=element;
}
iii. What are the types of queue and define them?
● Double ended queue
It is a special type of queue that allows insertion and
deletion of elements at both ends. It is also termed as DEQUE.

● Circular queue
A Circular queue is a queue whose start and end
locations are logically connected with each other. That means
the start location comes after the end location.

● Priority queue

iv. How the queue is implemented by linked list?


• It is based on the dynamic memory management techniques
which allow allocation and. De-allocation of memory space at
runtime.
Insert operation
It involves the following subtasks:
1. Reserving memory space of the size of a queue
element in memory
2. Storing the added value at the new location
3. Linking the new element with existing queue
4. Updating the rear pointer
Delete operation
It involves the following subtasks:
1. Checking whether queue is empty
2. Retrieving the front most element of the queue
3. Updating the front pointer
4. Returning the retrieved value

v. What are the applications of queue?


a. Simulation
b. Batch processing in an operating systems
c. Multiprogramming platform systems
d. Queuing theory
e. Printer server routines
f. Scheduling algorithms like disk scheduling, CPU
scheduling
g. I/O buffer requests

You might also like