Posts

BIG-O Notation in Programming

Image
 Hey there, Arin here  Happy Coding, In this Blog we'll Discuss about Big-O notations in Coding/Programming, Don't get intimidated it's really very easy to understand and implement, What is Big-O Notation? The Big O notation is used to express the upper bound of the runtime of an algorithm and thus measure the worst-case time complexity of an algorithm.  Now this is the standard definition given but shortly,  It analyses and calculates the time and amount of memory required for the execution of an algorithm for an input value. Basically it's like a system which checks the performance of any piece of code/program. There are different types of Big O notations Big O: “f(n) is O(g(n))” if for some constants c and N₀, f(N) ≤ cg(N) for all N > N₀ Omega: “f(n) is Ω(g(n))” if for some constants c and N₀, f(N) ≥ cg(N) for all N > N₀ Theta: “f(n) is Θ(g(n))” if f(n) is O(g(n)) and f(n) is Ω(g(n)) Little O: “f(n) is o(g(n))” if f(n) is O(g(n)) and f(n) is not Θ(g(n)...

Data Structures & Algorithms

Image
 Hey There, Arin here  Happy Coding,  Now, Before diving into things about data structures algos and etc etc..., lets understand... What are these Data Structures? It can be easily defined as different ways of Organizing Data om your Computer. Also remember, that efficiency of any program depends on the storage of the data, the data must be organised and stored in the most efficient way. Example: Movie Ticket - to buy a ticket you would have to stand in a queue , which is also a kind of data structure in Computer Science. There are a few Sub-divisions of Data Structure which we'll be discussing in later on blogs: What are Algorithms? Set of instructions to perform a task or solving a problem. There are many types of Algorithms : Recursive Algorithm Divide and Conquer Algorithm Dynamic Programming Algorithm Greedy Algorithm Brute Force Algorithm Backtracking Algorithm For now, this much Introduction is Sufficient we'll get to each of the topic with time.    

Code for Library Management using Java

 Hey there, Arin here, The below code is for a usual Library Management using Java Language  The Conditions used for the above Topic is, You have to implement a library using Java Class "Library" Methods: addBook, issueBook, returnBook, showAvailableBooks Properties: Array to store the available books, Array to store the issued books we have used Concepts of constructors, object & classes, and Methods under classes. The Logic can be further be extended based on the Requirements: package com.company ; class Library { String [] books ; int no_of_books ; Library (){ this . books = new String [ 100 ]; this . no_of_books = 0 ; } void addBook ( String book ){ this . books [ no_of_books ] = book ; no_of_books ++; System . out . println ( book + " has been added!" ); } void showAvailableBooks (){ System . out . println ( "Available Books are:" ); for ( String book ...

CODE for Guess the Number using OOP's Concepts

 Hey there,  Arin here, Below I'm posting a code for the Topic: Guess the Number (OOPs Edition) Create a class Game, which allows a user to play "Guess the Number" game once. Game should have the following methods: Constructor to generate the random number takeUserInput() to take a user input of number isCorrectNumber() to detect whether the number entered by the user is true getter and setter for noOfGuesses The for the above Game is : package com.company ; import java.util.Random ; import java.util.Scanner ; class game { int number ; int noOfGuesses ; int inputNumber ; public int getNoOfGuesses () { return noOfGuesses ; } public void setNoOfGuesses ( int noOfGuesses ) { this . noOfGuesses = noOfGuesses ; } game (){ Random rand = new Random (); this . number = rand . nextInt ( 100 ); } boolean isCorrectNumber (){ if ( inputNumber == number ){ return true ; } else if ( inp...

Code for Creating a ROCK-PAPER-SCISSOR Game Using Java

Hey there,  Happy Coding! Just Don't Give up Yet BUD! So the code goes something like this that I'm about to provide below, This is something that I Learnt While taking a Java Course from Youtube, I aim to be a Developer Some day!  The Program gives three chances to the user to play, Rock is set as 0, Paper as 1 and Scissor as 2. This is checked with the random variable 'a' which for the Random class is imported.    package com.company ; import java.util.Random ; import java.util.Scanner ; public class problemtwo { public static void main ( String [] args ) { Random r = new Random (); Scanner sc = new Scanner ( System . in ); int j = 3 ; int a = r . nextInt ( 3 ); for ( int i = 1 ; i <= j ; i ++) { System . out . println ( "Enter \n 0 for Rock \n 1 for Paper \n 2 for Scissor " ); int b = sc . nextInt (); if ( a == b ) { System . out . println ...