Posts

Data structures implementation in C

              C is a classical Programming Language which deals with Structured programming. Data structures are the foundation concepts in Programming. When the classical Programming meets the foundations of data, here is the road map to follow to learn about the concepts. The concepts are classified into 5 types of data structures. ·        Array and Strings ·        Stacks and Queues ·        Linked List ·        Graphs ·        Trees Let us implement this one by one consequently. Array Traversal :               Array is a collection of Similar elements grouped under a common name. Eg:   ‘int a[5];’ Here ‘a’ is array which is of integer type. It has 5 elements. Let us create a array and traverse it using C ...

MYSQL statements for display database information’s:

 In this blog post, we list out some mysql functions for processing the database informations like databases linked in the mysql, its name and describe the table and its properties. Some other functions like display time,day. First, the list of databases used in the mysql can be expressed using the code ‘ SHOW DATABASES ’. mysql> SHOW DATABASES; +--------------------+ | Database            | +--------------------+ | information_schema | | my_database         | | mysql               | | performance_schema | | sakila              | | sys                 | | world               | +--------------------+ 7 ro...

MySql queries for update and delete operations

               Update is a SQL operation which updates a column or one or more column. Let us create the query.The syntax is given below. Syntax: ‘ UPDATE tablename set value1,valu2,…,valuen where condition;’ Query: single field update mysql > UPDATE Students SET age=15 WHERE name = 'Edward'; Query OK, 1 row affected (0.054 sec) Rows matched: 1   Changed: 1   Warnings: 0 Display the table contents by SELECT Query: mysql> SELECT * FROM students; +----+--------+------+ | id | name    | age   | +----+--------+------+ |   1 | ajay    |    12 | |   2 | bob     |    15 | |   3 | Edward |    15 | |   4 | Jey     |    13 | +----+--------+------+ 4 rows in set (0.009 sec) Update query : Multiple field update mysql> UPDATE Students SET name='John',age=12 WHERE id =3; Query OK, 1 ro...

Learn SQL using MySQL

       SQL – Structured Query Language . It has various commands to execute. Let us the mysql to run the SQL commands . Steps to follow: ·        MySql is open source,you can run the SQL command in this environment. ·        First, download the MySql from official website. ·        Install it in your system. ·        Login into mysql in command prompt by entering the passwords. Enter password: *********** ·        The environment is look like as follows. Welcome to the MySQL monitor.   Commands end with ; or \g. Your MySQL connection id is 21 Server version: 9.6.0 MySQL Community Server - GPL ·        First, create   a database as my_database. mysql> create database my_database; Query OK, 1 row affected (0.995 sec) ·      ...

Stock Price Predictor in java

               It is mathematical model which describes the relationship between variables. One is dependent variable and another one is independent variable . For eg: stock price predictor. Here, dependent variable is stock price. Independent variables are time, trade data and volume . The formula for predicted stock price is given by, Y= beta1+beta2*X+ error term Where, Y = predicted stock price X = predictor value ‘beta1’ = intercept ‘beta2’ = slope Error term The java implementation is given below… public class StockPricePredictor {     private double slope1;     private double intercept1;     // Train simple regression model     public void fit(double[] x, double[] y) {         if (x.length != y.length) {             throw new IllegalArgumentException ("Two...

Maze Solver in java

               It is logical thinking game. Let us implement this program in java. Maze solver can be done in many ways as follows.. This maze solver uses DFS (Depth First Search) This algorithm starts from a root node and traverses through its child node until depth. It marks the visited node as visited and continues to next node. Complete all nodes using recursion . Code: import java.util .*; public class MazeSolver {     // let us create the Maze.here, 0 = path, 1 = wall     private static int[][] maze = {         {0, 1, 0, 0, 0},         {0, 1, 0, 1, 0},         {0, 0, 0, 1, 0},         {1, 1, 0, 1, 0},         {0, 0, 0, 0, 0}     };     private static boolean[][] m_visited; ...

Implementation of TicTacToe in java

               TicTacToe program is a classic one. Here, we implement this with AI . When a player plays,AI plays opposite side. The program is given below. // importing built-in package. import java.util. Scanner ; //public class definition public class TTTAI {     static char[][] board1 = {         {' ', ' ', ' '},         {' ', ' ', ' '},         {' ', ' ', ' '}     }; // main() function includes the play_Move(), ai_Move(), isGameOver().     public static void main(String[] args) {         Scanner s1 = new Scanner( System.in );         while (true) {             printIt();             play...