Advertisements
Advertisements
Question
State the principle by which the stack data structure works.
Advertisements
Solution
Last In First Out (LIFO)
APPEARS IN
RELATED QUESTIONS
Write an algorithm to find smallest element in an Array.
With suitable example explain how tree can be represented in Memory?
What is a linked list?
Explain with a flowchart the following control structure:
Sequence Logic
Explain with a flowchart the following control structure:
Iteration Logic
How linked list are represented in Memory?
Define the following term with reference to Tree:
Leaf
Define the following terms with reference to Tree : Sibling
Define the following term with reference to the Tree:
Depth
Data items are divided into sub-item is called as ________.
(i) Group Item
(ii) Elementary Item
(iii) Nodes
(iv) Arrays
What is Array?
Define Group Item
What is a binary tree?
What is Record?
What is Binary Tree ? Draw the Tree diagram for the expression.
B = (3R -5T)2 - (R + Q3)
Write two features of each of doto structures:
1) Record
2) Linear array
3) Linked list
Explain pointer Array with example.
A Queue is a linear data structure in which the operations are performed based on FIFO (First In First Out).
Define a class Queue with the following details:
| Class name | Queue |
| Data member/instance variable: | |
| dat[ ] | array to hold the integer elements |
| cap | stores the maximum capacity of the queue |
| front | to point the index of the front |
| rear | to point the index of the rear |
| Member functions/methods: | |
| Queue(int max) | constructor to initialize the data member cap = max, front = rear = 0 and create the integer array |
| void add_dat(int v) | to add integers from the rear index if possible else display the message(“Queue full”) |
| int pop_dat( ) | to remove and return elements from front, if any, else returns -999 |
| void display() | to display elements of the queue |
Specify the class Queue giving the details of void add_dat(int) and int pop_dat( ). Assume that the other functions have been defined.
The main( ) function and algorithm need NOT be written.
