## Stack: Evaluate a postfix expression

Question: Evaluate a postfix expression

## Stack: Basic stack implementation using an array

Question: Write a class ‘Stack’ that has:1. private data fields to store the stack, the top element, and the total capacity of the stack. 2.

## Stack Programming Problems

Basic Stack Implementation (push, pop, length, peek) using array Infix expression to postfix expression Infix expression to prefix expression Evaluate Prefix Expression Evaluate Postfix Expression

Question: Given a singly linked list and a number K, you are required to complete the function modularNode() which returns the modular node of the linked list. A modular node

Question: You have to try to implement push and pop functionality of a stack using a linked list

## Linked List: Sum of last N nodes

Question: Write a function that returns the sun of the last N nodes of a linked list. For example. for the linked list 4->6->10->8->9->10->18->20, and

Question: Write a function isCircular() which checks whether a linked list is circular or not.

## Linked List: Delete Alternating Nodes

Question: Given a linked list, delete alternating nodes. For example is the linked list is 4->6->10->8->9->10->18->20, then the output should be 4->10->9->18.

Question: You are given a linked list where every node represents a linked list. All linked lists are sorted. You have to flatten the lists

## Linked List: Insert node at the ith position

Question: Write a function that inserts a node at the ith position of a linked list. Consider the position of the head as the 0th

Question: Find the middle of a linked list. For example, if the given linked list is 1->2->3->4->5 then the output should be 3. If there are

Question: Write a function that returns the length of the linked list. Throw an exception if the list is empty.

## Linked List: Delete a specific node

Question: Write a function that deletes the node passed as a parameter

Question: Write a function print() function to print the entire linked list. Throw an exception if the linked list of empty

Question: Write a function add(Listnode node) function to add a new node at the end of the linked list

## Linked List: ListNode Class to create a node of a linked list

Question: Create a class Listnode which has two private data fields: data (int type) and next (Listnode type). The class should have a constructor which

ListNode Class to create a node of a linked list In the Linked List Class: add(Listnode node) function to add a new node at the

## Classes and Objects: Algebra: 2×2 linear equations

Question: Design a class named LinearEquation for a 2×2 system of linear equations: ax+by=e cx+dy=f x=(ed−bf)/(ad−bc) y=(af−ec)/(ad−bc)The class contains:o Private data fields a, b, c,

## Classes and Objects: Algebra- quadratic equations

Question: Design a class named QuadraticEquation for a quadratic equation ax2+bx+c=0 . The classcontains:o Private data fields a, b, and c represents three coefficients.o A

## Classes and Objects: Geometry: n-sided regular polygon

Question: In an n-sided regular polygon, all sides have the same length and all angles have the same degree (i.e., thepolygon is both equilateral and

## Classes and Objects: Fan Class

Question: Design a class named Fan to represent a fan. The class contains:o Three constants named SLOW , MEDIUM , and FAST with the values

## Classes and Objects: Create a bank account

Question: Design a class named Account that contains:o A private int data field named id for the account (default 0 ).o A private double data

## Classes and Objects: Build a watch Stopwatch

Question: Design a class named StopWatch . The class contains:o Private data fields startTime and endTime with getter methods.o A no-arg constructor that initializes startTime

## Classes and objects: Use the GregorianCalendar class

Question: Java API has the GregorianCalendar class in the java.util package, which you can use toobtain the year, month, and day of a date. The

## Classes and objects: Use the Random class

Question: Write a program that creates a Random objectwith seed 1000 and displays the first 50 random integers between 0 and 100using the nextInt(100) method.

## Classes and objects: Use the Date class

Question: Write a program that creates a Date object, sets itselapsed time to 10000 , 100000 , 1000000 , 10000000 , 100000000 ,1000000000 , 10000000000

## Classes and Objects: Stock Class

Question: Design a class named Stock that contains:o A string data field named symbol for the stock’s symbol.o A string data field named name for

## Classes and Objects: Rectangle Class

Question: Design a class named Rectangle to represent a rectangle. The class contains:1. Two double data fields named width and height specify thewidth and height

## Classes and Objects: Track the number of objects

Question: Create a class which keeps track of the number of its objects

## Arrays: Identical arrays

Question: The arrays list1 and list2 are identical if they have the same contents.Write a method that returns true if list1 and list2 are identical,

## Arrays: Strictly identical arrays

Question: The arrays list1 and list2 are strictly identical if their corresponding elements are equal.Write a method that returns true if list1 and list2 are

## Classes and Objects: Random Class

Question: Write a program that generates two sequences of random int values which are identical. Use the java.util.Random class. OutputSeries 1:87 92 74 24 6

## Classes and Objects: Point2D Class

Question: Create two Point2D object for a point with the specified x- and y- coordinates, use the distance method to compute the distance between the

## Classes and Objects: TV Class

Question: Create a class TV which defines for its objecs: states (channelNumber, volume, and power on or off)and behaviors (change channels (channelUp(), channelDown(), setChannel()), adjust

## Classes and Objects: Circle Class

Question: Create a class Circle that has a data field radius. If no radius is passed during instantiation then set the radius to 1. Write

## Classes and Objects Programming Problems

Circle Class TV Class Point2D Class (Built-in Java Class) Date Class (Built-in Java Class) Random Class (Built-in Java Class) Track the number of objects Rectangle

## Array: Math: Combinations

Question: Write a program that prompts the user to enter 10 integers and displays all combinations of picking two numbers from the 10 numbers. Sample

## Array: Algebra: solve quadratic equation

Question: Write a method for solving a quadratic equation using the following header:public static int solveQuadratic(double[] eqn, double[] roots)The coefficients of a quadratic equation ax2+bx+c=0

## Array: Unique suit picker

Question: Coupon collector is a classic statistics problem with many practical applications. The problem is to repeatedly pick objects from a set of objects and

## Array: Locker Puzzle

Question: A school has 100 lockers and 100 students. All lockers are closed on the first day of school. As the studentsenter, the first student,

## Array: Find the number of upper case letters in a String which is entered from the command line

Question: Write a program that passes a string to the command line and displays the number of uppercase letters in the string. Input from Command

## Array: Sum Integer from command line array input

Question: Write a program that passes an unspecified number of integers from the command line and displays their total. Sample input/output: args: [“1”, “2”, “3”,

## Array: Revise Selection Sort

Question: The selection-sort method repeatedly finds the smallest number in the current array and swaps it with the first.Rewrite this program by finding the largest

## Array: Sorted?

Question: Write the following method that returns true if the list is already sorted in non-decreasing order:public static boolean isSorted(int[] list)Write a test program that

## Array: Bubble Sort

Question: Write a sort method that uses the bubble-sort algorithm.The bubble-sort algorithm makes several passes through the array. On each pass, successive neighboring pairs are

## Array: Sort Students

Question: Write a program that prompts the user to enter the number of students, the student’s names, and theirscores and prints student names in decreasing

## Array: Execution Time

Question: Write a program that randomly generates an array of 100,000 integers and a key.Estimate the execution time of invoking the linearSearch method.Sort the array

## Array: Eliminate duplicates

Question: Write a method that returns a new array by eliminating the duplicate valuesin the array using the following method header:public static int[] eliminateDuplicates(int[] list)Write

## Array: Computing GCD

Question: Write a method that returns the gcd of an unspecified number of integers. The method header is specified as follows:public static int gcd(int… numbers)Write

## Array: Random number chooser

Question: Write a method that returns a random number between 1 and 54, excluding the numbers passed in the argument.The method header is specified as

## Array: Reverse array without creating a new array

Question: Write a program to reverse the elements in an integer array without copying it into a new array.Write a test program that prompts the

## Array: Statistics- Compute deviation

Question: Write a program that takes 10 elements as input for a double array and calculates the mean andstandard deviation of the elements.Mean= (n1+n2+n3+…+nl)/lStandard deviation=

## Array: Find the index of the smallest element

Question: Write a method that returns the index of the smallest element in an array of integers. If the number of such elements is greater

## Array: Find the smallest element

Question: Write a method that finds the smallest element in an array of double values using the following header:public static double min(double[] array)Write a test

## Array: Average an array

Question: Write two overloaded methods that return the average of an array with the following headers:public static int average(int[] array)public static double average(double[] array)Write a

## Array: Count Single Digits

Question: Write a program that generates 10 random integers between 0 and 9 and displays the count for each number. Example:3 4 4 5 0

## Array: Prime Numbers less than 50

Question: Write a program that gives the first 50 prime numbers using the following approach: Check whether any of the prime numbers less than or

## Array: Print Distinct Numbers

Question: Write a program that reads in 10 numbers and displays the number of distinct numbers and the distinct numbers in their input order and

## Array: Analyze scores

Question: Write a program that reads an unspecified number of scores and determines how many scores are above or equal to the average, and how

## Array: Count occurrence of numbers

Question: Write a program that generates random integers between 1 and 100 and counts the occurrences of each.

## Array: Reverse the numbers entered

Question: Write a program that reads 10 integers then displays them in the reverse of the order in which they were read. Example: Enter array

Question: Write a program that reads student scores, gets the best score, and then assigns grades based on the following scheme: The grade is A

## Arrays: Calculator

Question: Write a program that takes three arguments (num1 operation num2) from the command line and displays the result of the expression

## Array: Selection Sort

package Array; /** * Created by aarushi on 1/5/21. */ public class ArraySortSelction { /* Selection sort selects the smallest number in the array and

## Array: Binary Search

package Array; /** * Created by aarushi on 1/5/21. */ public class ArraySearchBinary { /*Step 1: The array must be sorted Step 2: Assign the

## Array: Linear Search

package Array; /** * Created by aarushi on 1/5/21. */ public class ArrayLinearSearch { public static boolean linearSerach (int [] array, int key){ //In Linear

## Array: Random Characters generator + counter

Question: Generate 10 random characters and store them in an array. Count and display the occurrence of each letter in the character array Example: Output

## Array: Reverse an array

Question: Write a program to reverse an array Example: original array: {1,2,3,4,5} Output:5,4,3,2,1

## Array: Use arraycopy method

Question: Use arraycopy method to contents of one array to another

## Array: Deck of cards

Question: Write a program that will pick four random cards from a deck of cards Examples: Output 1: 9 of Hearts6 of Spade4 of Diamond2

## Array: Number of elements greater than average

Question: Write a program that finds the average of contents in an array and counts the number of elements greater than the average

## Array: Randomly shuffle the elements of an array

Q) Randomly shuffle the elements of an array Example Original Array: 2,5,1,7,8,2 Output 1:5 2 8 1 2 7 Output 2:5 1 8 2 2

## Array: Obtain the English name of a given month by its number

Q) Obtain the English name of a given month by its number Example: Input:Enter month number: 4 Output:April

## Array: Shift elements of an array to the right

Q) Shift elements of an array to the right Example: Array:1,2,3,4,5 Output:5 1 2 3 4

## Array: Shifting elements of an array to the left

Q) Shifting elements of an array to the left Example: Array: 1,2,3,4,5 Output:2 3 4 5 1

## Array: Find the lowest index of the largest element in an array

Q) Find the lowest index of the largest element in an array Example: Array: 1,5,2,3,5,5 Output: Lowest Index of max element= 2

## Array: Find the largest element in an array

Q) Find the largest element in an array Example: Array: 33 93 29 40 36 81 46 14 60 24 Output:Max Element= 93

## Array: Find the sum of all elements in an array

Q) Find the sum of all elements in an array Example: Array: 27 26 11 41 53 18 90 82 79 46 Output: Sum= 473

## Array: Display the contents of an array

Q) Display the contents of an array

## Array: Initialize an array with random values between 1 and 100

Q) Initialize an array with random values between 1 and 100 Example: First time running the program: 94 74 73 76 50 70 88 55