Professional Documents
Culture Documents
DS - and - Algo - Assigment 2
DS - and - Algo - Assigment 2
DS - and - Algo - Assigment 2
SHEET
NAME: DIVEK S
COURSE: DATA STRUCTURES
WITH ALGORITHMS
ASSIGNMENT 2
Undertaking:
I affirm that I have not given or received any unauthorized help on this assignment, and that this
work is my own. I understand that any violation of this will result in disciplinary action from the JAIN
Online program.
Answers
import java.util.*;
import java.util.Scanner;
class LinearSearch {
static ArrayList<Integer> linearSearch(int a[], int val) {
ArrayList<Integer> indexes = new ArrayList<Integer>();
ii. 1 * 2 * 3 * 4
1. postfix result is 1 2 * 3 * 4 *
3. Overflow and underflow
a. overflow: This happens when a queue is full and there is no more space to put
element inside the queue, to avoid this, we need to check if rear is equal to size of
the queue, condition to be used is if (front == size – 1)// counting from 0
b. underflow: This happens when and queue is empty and we are trying to pop out
from queue, to avoid this we can check if front is equal to rear, condition if (front ==
rear)