Operations on Queue in Data Structures

Arnab Chakraborty
Updated on 27-Aug-2019 07:51:59

698 Views

Queue is First In First Out data structure. The queue is used in different area for graph traversal algorithms Breadth First Search etc. The queue has some primitive operations. Here we will see those operations of queue, and see one example using the queue ADT.The ADT (abstract datatype) is special kind of datatype, whose behavior is defined by a set of values and set of operations. The keyword “Abstract” is used as we can use these datatypes, we can perform different operations. But how those operations are working that is totally hidden from the user. The ADT is made of ... Read More

Tail Recursion in Data Structures

Arnab Chakraborty
Updated on 27-Aug-2019 07:45:44

4K+ Views

Here we will see what is tail recursion. The tail recursion is basically using the recursive function as the last statement of the function. So when nothing is left to do after coming back from the recursive call, that is called tail recursion. We will see one example of tail recursion.Example Live Demo#include using namespace std; void printN(int n){    if(n < 0){       return;    }    cout

Stack Primitive Operations

Arnab Chakraborty
Updated on 27-Aug-2019 07:38:16

8K+ Views

Stack is Last In First Out data structure. The stack is used in different area for evaluating expressions, call and recursion strategy etc. The stack has some primitive operations. Here we will see those operations of stack, and see one example using the stack ADT.The ADT (abstract datatype) is special kind of datatype, whose behavior is defined by a set of values and set of operations. The keyword “Abstract” is used as we can use these datatypes, we can perform different operations. But how those operations are working that is totally hidden from the user. The ADT is made of ... Read More

Applications of Stack in Data Structure

Arnab Chakraborty
Updated on 27-Aug-2019 07:15:14

3K+ Views

The Stack is Last In First Out (LIFO) data structure. This data structure has some important applications in different aspect. These are like below −Expression Handling −Infix to Postfix or Infix to Prefix Conversion −The stack can be used to convert some infix expression into its postfix equivalent, or prefix equivalent. These postfix or prefix notations are used in computers to express some expressions. These expressions are not so much familiar to the infix expression, but they have some great advantages also. We do not need to maintain operator ordering, and parenthesis.Postfix or Prefix Evaluation −After converting into prefix or ... Read More

Regular Functions vs Arrow Functions in JavaScript

vineeth.mariserla
Updated on 26-Aug-2019 15:49:36

586 Views

Regular functions vs Arrow functionsAn arrow function is used to write the code concisely. Both functions regular and arrow work in a similar manner but there are some differences between them. Let's discuss those differences in a nutshell.syntax of an arrow functionlet x = (params) => { // code };syntax of a regular functionlet x = function functionname(params){ // code };Usage of "this" keywordIt is unable to use "this" keyword in arrow functions whereas in regular functions it can be used without any disturbance.ExampleIn the following example, both regular(rectangle) and arrow(square) functions were used inside the object "num", which consists of len(length) ... Read More

Principles of Recursion in Data Structures

Arnab Chakraborty
Updated on 26-Aug-2019 11:24:06

4K+ Views

The recursion is a process by which a function calls itself. We use recursion to solve bigger problem into smaller sub-problems. One thing we have to keep in mind, that if each sub-problem is following same kind of patterns, then only we can use the recursive approach.A recursive function has two different parts. The base case and the recursive case. The base case is used to terminate the task of recurring. If base case is not defined, then the function will recur infinite number of times (Theoretically).In computer program, when we call one function, the value of the program counter ... Read More

Access JavaScript Object Using Its Own Prototype

vineeth.mariserla
Updated on 26-Aug-2019 08:52:59

403 Views

We can able to access the existing object by creating its own prototype using a javascript method called "Object.create()". Using this method we can inherit the properties from the existing properties to the newly created prototype. Let's discuss it in a nutshell.syntaxObject.create(existing obj);This method takes the existing object and creates its own prototype so that the properties will be inherited from the existing object to the newly created prototype.ExampleIn the following example, Initially, an object named "person" is created and the using "Object.create" its own prototype is created and assigned to a variable "newper". Later on, using the prototype the ... Read More

MySQL Query to Display Empty and Null Values Together

AmitDiwan
Updated on 26-Aug-2019 08:52:04

299 Views

To check for NULL, use the IS NULL. For empty values, you need to check with an empty string. We will now see an example.Let us first create a table −mysql> create table DemoTable691(    PlayerId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    PlayerName varchar(100),    PlayerScore int ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable691(PlayerName, PlayerScore) values('Robert', 56); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable691(PlayerName, PlayerScore) values('David', 89); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable691(PlayerName, PlayerScore) values('', 98); Query ... Read More

Create Table in MySQL Using Reserved Words

AmitDiwan
Updated on 26-Aug-2019 08:45:55

168 Views

Let us first see a case wherein we use “create table table” while creating a table. An error will arise −mysql> create table table(    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    FirstName varchar(100) );This will produce the following output i.e. error −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 'table(    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    FirstName varchar(100) )' at line 1As you can see above, the word “table” is a reserved keyword, and we ... Read More

Select Records That Begin With a Specific Value in MySQL

AmitDiwan
Updated on 26-Aug-2019 08:41:11

1K+ Views

To select records that begin with a specific value, you need to use LIKE operator. Let us first create a table −mysql> create table DemoTable690(    UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    UserValue varchar(100) ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable690(UserValue) values('567890'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable690(UserValue) values('789032'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable690(UserValue) values('567342'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable690(UserValue) values('890678'); Query OK, 1 row affected (0.16 sec)Display ... Read More

Advertisements