Java Implementation of BST with parent node reference algorithm | Binary Search Tree

BST with parent node:

Implement the BST with parent node. Modify the insert and delete functions. Add the following functions too.

  • private TreeNode<E getNode(E element)
  • private boolean<E isLeaf(E element)
  • public ArrayList<E getPath(E element)

Get Now!


Buy now

Java Program to implement Radix Sort Algorithm and displaying the step by step sorting

Write a program for Radix Sort. The output of the program, apart from displaying the final result of the sorting algorithm, you also need to display the result of every round after one digit is sorted. Get the solution now!

Output Screenshot


Get Now


Buy now

Concurrent and non-concurrent threads in Java | Two different project in NetBeans

Concurrent Thread Execution:

Write a Java program that has a method named atomic(). Demonstrate in the program how two threads can, sometimes, invoke atomic() concurrently.

Non-Concurrent Thread Execution:

Create a second version of the program in which the two threads cannot invoke atomic concurrently.

Output Screenshots:

Get Now

Buy now

Tic Tac Toe Game (Console Based) in Java full project free download

Game Features


  • As the program starts executing, player X starts
  • The player types in a column and a row number. For example for column A and row 3, it should be ‘A3’.
  • The program should verify that the box is not already populated, if it is already set then the program asks the player to re-enter a new column and a row. If it is not already populated then set that particular box to X.
  • Program checks to verify if there is any winner
  • The program prints out the Tictactoe board.
  • Program asked player O to type in a column and a row number.
  • The program should verify that the box is not already populated, if it is already set then the program asks the player to re-enter a new column and a row. If it is not already populated then set that particular box to O.
  • Program checks to verify if there is any winner
  • The program prints out the Tictactoe board.
  • The steps should be repeated until all boxes are populated or a winner is found.
  • The program should end.

Source Code

TicTacToe.java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class TicTacToe {
 
    private char[][] board = new char[3][3];
    private String player1;
    private String player2;
    private int currentPlayer;
    private char marker1;
    private char marker2;
    private int plays;
    private BufferedReader reader =
            new BufferedReader(new InputStreamReader(System.in));
 
    protected void init() {
        int counter = 0;
        for (int i = 0; i < 3; i++) {
            for (int i1 = 0; i1 < 3; i1++) {
                board[i][i1] = Character.forDigit(++counter, 10);
            }
        }
        currentPlayer = 1;
        plays = 0;
    }
 
    protected void switchPlayers() {
        if (getCurrentPlayer() == 1) {
            setCurrentPlayer(2);
        } else {
            setCurrentPlayer(1);
        }
        setPlays(getPlays() + 1);
    }
 
    protected boolean placeMarker(int play) {
        for (int i = 0; i < 3; i++) {
            for (int i1 = 0; i1 < 3; i1++) {
                if (board[i][i1] == Character.forDigit(play, 10)) {
                    board[i][i1] = (getCurrentPlayer() == 1) ? getMarker1() : getMarker2();
                    return true;
                }
            }
        }
        return false;
    }
 
    protected boolean winner() {
        //Checking rows
        char current = ' ';
        for (int i = 0; i < 3; i++) {
            int i1 = 0;
            for (i1 = 0; i1 < 3; i1++) {
                if (!Character.isLetter(board[i][i1])) {
                    break;
                }
                if (i1 == 0) {
                    current = board[i][i1];
                } else if (current != board[i][i1]) {
                    break;
                }
                if (i1 == 2) {
                    //Found winner
                    return true;
                }
            }
        }
        //Checking columns
        for (int i = 0; i < 3; i++) {
            current = ' ';
            int i1 = 0;
            for (i1 = 0; i1 < 3; i1++) {
                if (!Character.isLetter(board[i1][i])) {
                    break;
                }
                if (i1 == 0) {
                    current = board[i1][i];
                } else if (current != board[i1][i]) {
                    break;
                }
                if (i1 == 2) {
                    //Found winner
                    return true;
                }
            }
        }
        //Checking diagonals
        current = board[0][0];
        if (Character.isLetter(current) && board[1][1] == current && board[2][2] == current) {
            return true;
        }
        current = board[2][0];
        if (Character.isLetter(current) && board[1][1] == current && board[0][2] == current) {
            return true;
        }
        return false;
    }
 
    protected String getRules() {
        StringBuilder builder = new StringBuilder();
        builder.append("Players take turns marking a square. Only squares \n");
        builder.append("not already marked can be picked. Once a player has \n");
        builder.append("marked three squares in a row, the player wins! If all squares \n");
        builder.append("are marked and no three squares are the same, a tie game is declared.\n");
        builder.append("Have Fun! \n\n");
        return builder.toString();
    }
 
    protected String getPrompt() {
        String prompt = "";
        try {
            prompt = reader.readLine();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        return prompt;
    }
 
    protected String drawBoard() {
        StringBuilder builder = new StringBuilder("Game board: \n");
        for (int i = 0; i < 3; i++) {
            for (int i1 = 0; i1 < 3; i1++) {
                builder.append("[" + board[i][i1] + "]");
            }
            builder.append("\n");
        }
        return builder.toString();
    }
 
    public int getCurrentPlayer() {
        return currentPlayer;
    }
 
    public void setCurrentPlayer(int currentPlayer) {
        this.currentPlayer = currentPlayer;
    }
 
    public char getMarker1() {
        return marker1;
    }
 
    public void setMarker1(char marker1) {
        this.marker1 = marker1;
    }
 
    public char getMarker2() {
        return marker2;
    }
 
    public void setMarker2(char marker2) {
        this.marker2 = marker2;
    }
 
    public int getPlays() {
        return plays;
    }
 
    public void setPlays(int plays) {
        this.plays = plays;
    }
 
    public String getPlayer1() {
        return player1;
    }
 
    public void setPlayer1(String player1) {
        this.player1 = player1;
    }
 
    public String getPlayer2() {
        return player2;
    }
 
    public void setPlayer2(String player2) {
        this.player2 = player2;
    }
}

Output



 download

Restaurant Management System in Java - Full Project Free Download

System specification

Application

The Pay Per View system allows users to download and view titles. The system starts with a pre-defined set of titles on offer, and two users. A user enters their name, selects a title and downloads it. The user can then view the title once; the download is deleted after viewing. A user starts with $100 and is charged at a rate of $1 per minute. The users are "Marge" and "Homer". The system uses the same titles as Assignment 1. Neither the users nor the titles on offer change, for simplicity.

Graphical interface

The system starts by showing with two windows:
Clicking on a View window list entry "views" that title; it disappears from the list of user titles, and the number of unseen titles in the customer window decreases by one.

Output



Free Download

 download

Basic Linked List and Sorted Linked List in Java with Unit Testing

Code Distribution

The project's code distribution is available by checking out the project named LinkedListsProject. The code distribution provides you with the following:

  • listClasses package → Where classes implementing linked lists will appear.
  • tests package → Where you should place your student tests.


Specifications


  • You are expected to implement two classes: BasicLinkedList and SortedLinkedList.The javadoc describing what you need to implement can be found at Project Javadoc.
  • The linked list in our project has a head and tail reference. The next link of the last node points to null.
  • Methods addToEnd(), getLast(), retrieveLastElement() rely (and must use) the tail reference.
  • The head and tail must be set correctly when list operations update the list.
  • You can use recursion for the implementation of methods.
  • Two methods must be implemented using recursion: getReverseArrayList() and getReverseList(). You are allowed to add an auxiliary function (only one) during the implementation of a recursive method. You MAY NOT add any instance variables nor static variables to support the implementation of a recursive method. If you do you will lose significant credit.
  • Your code must be efficient. For example, you will lose credit if you perform an unnecessary list traversal(s) during the implementation of a method.
  • If you see in the submit server the error "missing_component", the problem is that you are missing a required class. You can also get this error if you are not defining a generic class correctly. For example, your SortedLinkedList class is not being defined as expected. It is recommended that you try submiting your project immediately (if you have not done so yet) so you can identify this problem (your code may work in Eclipse but not in the submit server).


Requirements


  • Your student tests must include at least a test for each method of each class. Write tests as you develop your code and not at the end; this is the correct approach to develop student tests. Also, think how you can test your code so it will work with any data set. Hint: For a list, you can try inserting and deleting all the permutations for a set of numbers. This kind of hint is what you need to discover for future projects (and for your future job) by yourself.
  • If you have a problem with your code and need assistance during office hours, you need to have a student test(s) that illustrates the problem you are experiencing. See Student Tests for information regarding the implementation of student tests.
  • You may not shared your student tests with other students.
  • The iterator you define may NOT be used to implement other list operations (e.g., add). The iterator is for users that want to iterate over the list.
  • You need to implement a singly-linked list that relies on a head and tail reference.
  • See Style Guidelines for information regarding style.


Honor's Section Requirement

The following requirement is for students enrolled in the honor's section.

  • Implement the iterator's remove method for the BasicLinkedList class.
  • Add a clone method to the BasicLinkedList class.

Get Now


Buy now

Arithmetic Expressions Background | Postfix Notation Calculation | Java

Background

The arithmetic expressions considered in this project consist of non-negative integers, operators "+", "-", and "*", and parentheses "(" and ")". Arithmetic expressions are usually written using the infix notation, in which operators appear between the two operands on which they act (e.g., "2 + 2"). The evaluation of expressions in infix notation is done according to the standard order of operations: multiplications must be done first, from left to right, then all additions and subtractions, again from left to right. Parentheses can be used to change the order in which operations must be performed, e.g., the expression inside the innermost parentheses must be evaluated first, etc.

Since each of the considered operators takes exactly two operands, such an arithmetic expression can be represented as a proper binary tree whose internal nodes are associated with the expression's operators and whose leaves are associated with non-negative integers. This project requires you to write a program that reads a fully parenthesized arithmetic expression written in infix notation, constructs the corresponding binary tree, and then uses the tree to evaluate it and print the expression in postfix notation. A fully parenthesized infix expression is one where all operands are surrounded by either one parenthesis and one operator, or two parentheses. Recall that the postfix notation is an unambiguous way of writing an expression in which the operands precede the operator, and parentheses are not required. For example, the infix expression "( 3 * ( 4 + 7 ) )" would be written in postfix notation as "3 4 7 + *"

Implementation requirements 

You must implement and use your own binary tree class, and must implement at least one of the methods operating on the expression tree recursively. If needed, generic implementations provided by the Java collections framework can be used for other data structures (e.g., stacks).

Program Input

Your program should read from the standard input one line containing a fully parenthesized infix expression, with tokens (integers, operators, and parentheses) separated by spaces. You may assume that the expression is well-formed.

Program Output

The program should print two lines (both terminated with newline characters). The first line should contain the expression in postfix notation, with the tokens separated by single spaces, and no leading or trailing spaces. The second line should contain a single integer, corresponding to the value to which the expression evaluates

Sample Output


Custom Projects

For custom projects and Code please contact me at WhatsApp +92 324 7042178 or send me email at projecthelper247@gmail.com

Get Now


Buy now