C Program for Radix Sort

sudhir sharma
Updated on 24-Dec-2019 06:33:31

14K+ Views

A sorting algorithm is an algorithm that puts components of a listing in a certain order. The most-used orders are numerical order and lexicographic order.The Radix sort is a non-comparative sorting algorithm. The Radix sort algorithm is the most preferred algorithm for the unsorted list.It sorts the elements by initially grouping the individual digits of the same place value. The idea of Radix Sort is to do digit by digit sort starting from least significant digit(LSD) to the most significant digit(MSD), according to their increasing/decreasing order. Radix sort is a small method that is used several times when alphabetizing an ... Read More

Increase Precision with Division in MySQL

AmitDiwan
Updated on 24-Dec-2019 06:32:19

765 Views

To increase precision with division, use MySQL CAST(). Let us first create a table −mysql> create table DemoTable1823      (      Value int      ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1823 values(1); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1823 values(2); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1823 values(3); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1823;This will produce the following output −+-------+ | Value ... Read More

Update Record on a Specific Date in MySQL

AmitDiwan
Updated on 24-Dec-2019 06:30:57

751 Views

Let us first create a table −mysql> create table DemoTable1822      (      Amount int,      DueDate date      ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1822 values(1000, '2019-10-11'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1822 values(500, '2019-11-30'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1822 values(700, '2018-11-30'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1822;This will produce the following output −+--------+------------+ | Amount | ... Read More

MySQL VARCHAR Size Impact on Table Creation

AmitDiwan
Updated on 24-Dec-2019 06:29:40

139 Views

No, the query won’t work. Let’s create the same scenario and check the error −mysql> create table DemoTable1821      (      Id int,      FirstName varchar,      LastName varchar      ); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ', LastName varchar )' at line 4To remove the above error, you need to give the size of varchar(10). Let us first create a table −mysql> create table DemoTable1821      (      Id int, ... Read More

MySQL Query to Subtract Date Records and Display Weekday

AmitDiwan
Updated on 24-Dec-2019 06:28:24

246 Views

For this, you can use DATE_FORMAT(). Let us first create a table −mysql> create table DemoTable1820      (      AdmissionDate varchar(20)      ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1820 values('20/10/2019'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1820 values('19/12/2018'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1820 values('16/04/2017'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1820;This will produce the following output −+---------------+ | AdmissionDate | +---------------+ ... Read More

C Program for Rabin Karp Algorithm for Pattern Searching

sudhir sharma
Updated on 24-Dec-2019 06:26:19

3K+ Views

Pattern matching in C − We have to find if a string is present in another string, as an example, the string "algorithm” is present within the string "naive algorithm". If it is found, then its location (i.e. position it is present at) is displayed. We tend to create a function that receives 2character arrays and returns the position if matching happens otherwise returns -1.Input: txt = "HERE IS A NICE CAP"    pattern = "NICE" Output: Pattern found at index 10 Input: txt = "XYZXACAADXYZXYZX"    pattern = "XYZX" Output: Pattern found at index 0    Pattern found at index ... Read More

Count Same Value of Each Row in a MySQL Column

AmitDiwan
Updated on 24-Dec-2019 06:25:07

402 Views

To count the same value of each row, use COUNT(*) along with GROUP BY clause. Let us first create a table −mysql> create table DemoTable1818      (      Id int,      Name varchar(20)      ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1818 values(10, 'Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1818 values(11, 'Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1818 values(11, 'Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1818 values(12, 'Chris'); Query ... Read More

Passing Multiple IDs to Single Parameter in MySQL

AmitDiwan
Updated on 24-Dec-2019 06:23:54

1K+ Views

To pass multiple ids to single parameter, use FIND_IN_SET(). Let us first create a table −mysql> create table  DemoTable1817      (      EmployeeName varchar(20),      CountryName varchar(20)      ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1817 values('Chris', 'AUS'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1817 values('David', 'UK'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1817 values('Bob', 'US'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1817;This ... Read More

Randomly Select 2 Values from Column in MySQL

AmitDiwan
Updated on 24-Dec-2019 06:21:23

403 Views

To randomly select, use ORDER BY RAND(). To select only 2 values, use LIMIT 2 in MySQL. Let us first create a table −mysql> create table DemoTable1815      (      Question text      ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1815 values('What is your name?'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1815 values('What is your college name?'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1815 values('What is your nick name?'); Query OK, 1 row affected (0.00 sec) mysql> ... Read More

Implement and Set Double Length in MySQL

AmitDiwan
Updated on 24-Dec-2019 06:20:19

517 Views

To implement DOUBLE in MySQL, the syntax is as follows −create table yourTableName      (      yourColumnName double(5, 2) unsigned );Let us first create a table −mysql> create table DemoTable1814      (      Amount double(5, 2) unsigned      ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1814 values(1.98); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1814 values(100.24); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1814 values(198.50); Query OK, 1 row affected (0.00 sec)Display all records from the table ... Read More

Advertisements