All Question paper with solution mean Bachelorexam.com

Data Structures AKTU’s Unit-2: Important Questions on Stacks and Queues

This is Btech, MCA, and BCA’s common subject, “data structures.” Providing Unit -2 STACKS AND QUEUES important questions, Last year’s question paper with solutions, and many more study materials that will help students or bachelor’s exam

Dudes 🤔.. You want more useful details regarding this subject. Please keep in mind this as well.

Important Questions For Data Structures : 
*Unit-01     *Unit-02    
*Unit-03    *Unit-04 
*Unit-05    *Short-Q/Ans
*Question-Paper with solution 21-22 

Q1. Write a C function for array implementation of a stack. Write all primitive operations.

Ans. 

Data structure program

Q2. What is stack? Implement stack with singly linked list.

Ans. Stack:

  • 1 A stack is one of the most commonly used data structure.
  • 2.A stack, also called Last In First Out (LIFO) system, is a linear list in which insertion and deletion can take place only at one end, called top.
  • 3. This structure operates in much the same way as stack of trays.
  • 4. If we want to remove a tray from stack of trays it can only be removed from the top only.
  • 5. The insertion and deletion operation in stack terminology are known as PUSH and POP operations.

Implementation using singly linked list:

data structure program in c language
data structure program in c language

Q3. Write a function in C language to reverse a string using stack.

Ans. 

reverse a string in c language
reverse a string in c language

Q4. Consider the following infix expression and convert into reverse polish notation using stack. A + (B * C- (D/E A F)* H)

Ans. 

polish notation in data structures

Q5. Write the procedures for insertion, deletion and traversal of a queue.

Ans. 1. Insertion:

Insert in Q (Queue, Max, Front, Rear, Element)

Let Queue is an array, Max is the maximum index of array, Front and Rear to hold the index of first and last element of Queue respectively and Element is value to be inserted.

Step1:If Front = 1 and Rear = Max or if Front = Rear + 1

           Display “Overflow” and Return

Step2: If Front = NULL [Queue is empty]

            Set Front = 1 and Rear = 1

            else if Rear = N, then

            Set Rear = 1|

            else

            Set Rear = Rear +1

            [End of if Structure]

Step 3: Set Queue [Rear) = Element [This is new element

Step4: End

2. Deletion:

Delete from Q (Queue, Max, Front, Rear, Item)

Step1:If Front = NULL [Queue is empty]

           display Underflow” and Return

Step 2: Set Item = Queue [Front]

Step 3: If Front = Rear [Only one element}

             Set Front = Rear and Rear = NULL

             Else if

             Front = N, then

            Set Front =1

            Else

            Set Front = Front+ 11

            [End if structure]

Step 4: End

3. Traversal of a queue: Here queue has Front End FE and Rear End RE. This algorithm traverses queue applying an operation PROCESS to each element of the queue:

Step 1: [Initialize counter] Set K=FE

Step 2: Repeat step 3 and 4 while K≤RE

Step3: [Visit element] Apply PROCESS to queue [K]

Step 4: [Increase counter] Set K= K+1

             [End of step 2 loop]

             Step5: Exit

Q6. What is a circular queue? Write a C code to insert an element in a circular queue. Write all the condition for overflow.

Ans. 1. A circular queue is one in which the insertion of a new element is done at the very first location of the queue if the last location at the queue is full.

2. In circular queue, the elements Q[0], Q[1], Q[2]…Q[n-1] is represented in a circular fashion.

For example: Suppose Q is a queue array of six elements.

3. PUSH and POP operation can be performed on circular queue. Fig. will illustrate the same.

circular queue in c (data structures)

C code to insert an element in circular queue:

           void insert ()

{

             int item;

             if(front ==0 && rear == Max – 1)||((front = = rear + 1))

             {

             printf(“Queue is overflow \n”);

             Return;

             }

             if(front == -1) /*If queue is empty*/

             }

             front = 0;

             rear = 0;

             }

             else

             if(rear== Max – 1) /*rear is at last position of queue*/

             rear = 0;

             else

             rear = rear + 1;

             printf(“Input the element for insertion:”);

             scanf (“%d”, &item);

            cqueue [rear] = item;

            }

Conditions for overflow: There are two conditions:

1. (front = 0) and (rear = Max – 1)

2. front = rear + 1

If any of these two conditions is satisfied, it means that overflow occurs.

Important Questions | Short Questions Series | Quantum-data structures | last year's question paper -B.Tech AKTU

Cracking AKTU B.Tech: Quantum Data Structures – Last Year’s Short Questions Paper

Important QuestionQuestion Links
Data Structure – Unit-1UNIT-1
Data Structure – Unit-2UNIT-2
Data Structure – Unit-3UNIT-3
Data Structure – Unit-4UNIT-4
Data Structure – Unit-5Unit-5
Important Short Questions- Data StructureShort Question List
Last Year’s Question PaperExam 2021-22
Quantum -Data structureQuantum

AKTU Important Links | Btech Syllabus

Link NameLinks
Btech AKTU CircularsLinks
Btech AKTU SyllabusLinks
Btech AKTU Student DashboardStudent Dashboard
AKTU RESULT (One VIew)Student Result

Important Links-Btech (AKTU)| Data Structures Syllabus

LabelLinks
Btech InformationInfo Link
Btech CSECSE-LINK
Quantum-PageLink
Data Structure SyllabusSyllabus-DS

4 thoughts on “Data Structures AKTU’s Unit-2: Important Questions on Stacks and Queues”

Leave a Comment