EXERCISE NO : 16(a)
Description:
Here, we will implement a classical data structure known as a stack. Stack is a linear data structure which follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out).
Build any one classical data structure.
Mainly the following three basic operations are performed in the stack:
Push: Adds an item in the stack. If the stack is full, then it is said to be an Overflow condition.
Pop: Removes an item from the stack. The items are popped in the reversed order in which they are pushed. If the stack is empty, then it is said to be an Underflow condition.
Peek or Top: Returns top element of stack.
Applications of stack:
Balancing of symbols.
Infix to Postfix /Prefix conversion.
Redo-undo features at many places like editors, photoshop.
Forward and backward feature in web browsers.
Used in many algorithms like Tower of Hanoi, tree
traversals, stock span
problem, histogram problem.
Other applications can be Backtracking, Knight tour problem, rat in a maze, N queen
problem and sudoku solver.
EXERCISE - 16(b)
Description:
Here, we will implement a classical data structure known as a stack. Stack is a linear data structure which follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out).
Build any one classical data structure.
Mainly the following three basic operations are performed in the stack:
Push: Adds an item in the stack. If the stack is full, then it is said to be an Overflow condition.
Pop: Removes an item from the stack. The items are popped in the reversed order in which they are pushed. If the stack is empty, then it is said to be an Underflow condition.
Peek or Top: Returns top element of stack.
Applications of stack:
Balancing of symbols.
Infix to Postfix /Prefix conversion.
Redo-undo features at many places like editors, photoshop.
Forward and backward feature in web browsers.
Used in many algorithms like Tower of Hanoi, tree
traversals, stock span
problem, histogram problem.
Other applications can be Backtracking, Knight tour problem, rat in a maze, N queen
problem and sudoku solver.
EXERCISE - 16(b)
Description:
The knapsack problem or rucksack problem is a problem in combinatorial optimization.
Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible. It derives its name from the problem faced by someone who is constrained by a fixed-size knapsack and must fill it with the most valuable items.
Applications of 0/1 Knapsack problem
Knapsack problems appear in real-world decision-making processes in a wide variety of fields, such as finding the least wasteful way to cut raw materials,selection ofinvestmentsandportfolios,selection of assets forasset-backed securitization,and generating keys for the Merkle–Hellman and other knapsack cryptosystems.
No comments