Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OOPS Assignment – Java Algorithms & Networking Demos

Overview

This repository contains small, self-contained Java programs demonstrating basic data structures/algorithms and simple TCP networking (single-connection and multithreaded variants).

Prerequisites

  • Java JDK 8+ installed and available on PATH (java -version, javac -version).
  • All files are plain Java classes with main() and can be compiled/run individually.

Quick Start

  • Compile: javac <file>.java
  • Run: java <class_name>
    • Note: Class names match file names (e.g., binary_search for binary_search.java).

Contents

  • binary_search.java

    • Demonstrates binary search on a fixed sorted int array.
    • Input: number to search.
    • Output: index if found, otherwise not-found message.
    • Run:
      javac binary_search.java
      java binary_search
  • linear_search.java

    • Linear search over a fixed String[] of numbers.
    • Input: number as string (e.g., "56").
    • Output: index or not-found.
    • Run:
      javac linear_search.java
      java linear_search
  • bubble_sort.java

    • Classic bubble sort for int[] read from user.
    • Input: n and then n integers.
    • Output: original and ascending-sorted arrays.
    • Run:
      javac bubble_sort.java
      java bubble_sort
  • selection_sort_ui.java

    • Selection by shortest length over 5 input names.
    • Input: 5 names (lines).
    • Output: names sorted by length (shortest to longest).
    • Run:
      javac selection_sort_ui.java
      java selection_sort_ui
  • linked_list.java

    • Manually builds a singly linked list with 5 nodes, prints it, then sorts by swapping node data.
    • Output: original list and sorted list.
    • Run:
      javac linked_list.java
      java linked_list
  • Hamming Code demos

    • Purpose: Illustrate parity-bit coverage and computation for Hamming codes using example arrays.
    • Files:
      • hamming_algo.java – array-based coverage and parity computation with ODD/EVEN support.
      • hamming_algo1.java – simplified single-parity calculation demo.
      • hamming_algo_al.javaArrayList variant of the algorithm in hamming_algo.java.
      • hamming_algo_sir.java – loop structure showing coverage blocks (array).
      • hamming_algo_sir_al.java – same as above using ArrayList.
    • Run (example):
      javac hamming_algo.java
      java hamming_algo
  • TCP (line-oriented) demo

    • Files:
      • server.java – waits on port 9090, accepts one client, echos a simple response.
      • client.java – connects to localhost:9090, sends a single line, prints server response.
    • Usage:
      1. In one terminal:
        javac server.java
        java server
      2. In another terminal:
        javac client.java
        java client
  • TCP (DataInputStream/DataOutputStream) chat demo

    • Files:
      • server_tcp.java – single client chat on port 6789 using DataInputStream/DataOutputStream.
      • client_tcp.java – connects to localhost:6789 and chats until either side types stop.
    • Usage:
      1. In one terminal:
        javac server_tcp.java
        java server_tcp
      2. In another terminal:
        javac client_tcp.java
        java client_tcp
  • Multithreaded TCP servers

    • Files:
      • multi_thread_v1.java – handles one client at a time; waits (join) for client thread to finish before accepting next.
      • multi_thread_v2.java – truly concurrent; accepts clients and starts a new handler thread without blocking new accepts. Tracks active client count.
    • Client: Use client_tcp.java against port 6789 to open one or more client sessions.
    • Usage (server v1):
      javac multi_thread_v1.java
      java multi_thread_v1
    • Usage (server v2):
      javac multi_thread_v2.java
      java multi_thread_v2
    • Then, in other terminals (one per client):
      javac client_tcp.java
      java client_tcp

Notes

  • On Windows PowerShell, replace the shell block with equivalent commands (same syntax for javac/java).
  • Ensure no other process is using ports 9090 or 6789 when running the server programs.
  • Use Ctrl+C in the server terminal to stop a server after testing.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages