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

+2ComputerAnsvyv

Chapter 3 discusses data structures, focusing on queues, stacks, and linked lists, explaining their definitions, operations, and algorithms for insertion and deletion. It differentiates between static and dynamic data structures, highlighting their memory allocation methods, and outlines the advantages of circular queues. The chapter also covers the classification of data structures into simple and compound types, as well as linear and non-linear structures.

Uploaded by

abidmuhammed2024
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

+2ComputerAnsvyv

Chapter 3 discusses data structures, focusing on queues, stacks, and linked lists, explaining their definitions, operations, and algorithms for insertion and deletion. It differentiates between static and dynamic data structures, highlighting their memory allocation methods, and outlines the advantages of circular queues. The chapter also covers the classification of data structures into simple and compound types, as well as linear and non-linear structures.

Uploaded by

abidmuhammed2024
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Chapter 3

Data Structures and Operations


1. What is “queue" in data structure?
Ans.
A Queue is a linear data structure used to store and retrieve data in a method is called FIFO. FIFO
means First In First Out. In a Queue the insertion takes place at the Rear end and deletion takes place at
Front end.
2. List the different operations on data structures
Ans. Different operations on data structures are:
 Traversing
 Insertion
 Deletion
 Searching
 Sorting
 Merging
3.Write an algorithm to insert new item into a queue
Ans. step 1: if (Rear= =N-1)
step 2: Print “Overflow”
step 3: Else
step 4: Rear++;
step 5: Queue [Rear] = item
4. Write an algorithm to add a new element in a stack .
Ans:
1. start
2. if (top=N-1)
3. print “Overflow”
4. else
5. top++
6. stack[top]=item
7. stop
5.Write a procedure to implement transversal operation in a linked list
Ans.
Step 1: Get the address from the first node start and store it in temp.
Step 2: Using the address in temp, get the data of first /next node and store it in val.
Step 3: Get the content of the link part of this node and store it in temp.
Step 4: If the content of this temp is not NULL, otherwise go to step2.
6. What is the advantage of circular queue over linear queue ?
Ans.
Easier for insertion-deletion. Efficient utilization of memory/No wastage of memory.
7. What is data structures? How are they classified?
Ans. A data structure is a particular way of organizing similar data items, which can be processed
in a single unit.
Classification of data structure
Data structures can be classified into two types, Simple Data Structure and Compound Data
Structure.
 Simple data structures
Simple data structures are normally built from primitive data types like integer, character
etc. They are of two types Array and Structure.
 Compound data structure
Simple data structures can be combined in various ways to form more complex
structures called compound data structures. Compound data structures are classified into two, linear data
structures and Non-Linear data structures.
 Linear data structure
A data structure is said to be linear if its elements are form in sequence. A linear data structure is
again classified in to three. They are Stack, Queue and Linked List.
 Non-Linear data structure
A data structure is said to be non-linear if its elements do not form in sequence. Non-linear data
structure is again classified in to Tree and Graph.
8. Linked lists usually do not have the problem of overflow. Discuss.
Ans.
Linked lists is dynamic data structure where there is no limit in the number of items. The
memory allocation takes place when a new item is about to insert in to the list. As any number of data
can be inserted into linked list, it does not have the problem of overflow.
9. Illustrate linked list with suitable diagram
Ans.
A linked list is a collection of data item(nodes). Each node consists of data part and a
link(pointer) part. The data part which stores the data and link part stores the address of the next node.
10. Explain about operations performed on stack data structure
Ans.
push – The process of adding a new element at the TOP of the stack is called PUSH operation.
pop - The process of deleting an element at the TOP of the stack is called POP operation.
11. Write an algorithm to perform insertion operation in a queue
Ans. Start
If (REAR < N-1) Then
REAR = REAR + 1
Q[REAR] = VAL
Else
Print "Queue Overflow "
End of If
Stop
12. Match the following :

Ans.
1.Stack --- Push – Inserting a new item
2. Queue ---- Front ---- Removing an item
3. Array ---- Subscript ---- Elements are accessed by specifying its position
4. Linked list -------- Start ----- Contains the address of the first
13.Differentiate static and dynamic data structure. Give an example for each.
Ans.
In static data structures, memory is allocated before the execution of the program. Here, the
memory space will be fixed throughout the execution. Eg:- Arrays, Structures etc.
In dynamic data structures, the memory is allocated during the execution of program. Data
structures implemented using linked lists are dynamic in nature.
14. Write an algorithm to perform pop operation in a stack.
Start
If (TOP > - 1) Then
VAL = STACK [TOS]
TOP = TOP - 1
Else
Print “Stack Underflow”
End of If
Stop

You might also like