Print Alternate Nodes of Linked List Using Iterative Method in C

Sunidhi Bansal
Updated on 22-Aug-2019 08:50:52

1K+ Views

In this problem, program must print the alternates from the given linked list that is leaving one printing other and so on using iterative method.Iterative method is the one which generally uses loops that are executed till the condition holds value 1 or true.Let’s say, list contains the nodes 29, 34, 43, 56 and 88 and than the output will be the alternate nodes such as 29, 43 and 88.ExampleInput: 29->34->43->56->88 Output: 29 43 88The approach is to traverse the entire list till the last node. While, traversing a counter variable can be taken which is incremented to 1 and ... Read More

MySQL Binary Data Insertion: Choosing the Right Data Type

AmitDiwan
Updated on 22-Aug-2019 08:48:59

645 Views

For this, use BIT data type. Let us first create a table −mysql> create table DemoTable(binaryValue BIT(5)); Query OK, 0 rows affected (0.83 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(15); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output. Now you can see the records aren’t visible −+-------------+ | binaryValue | +-------------+ |             | |           ... Read More

Print Reverse of a Linked List Without Actually Reversing in C

Sunidhi Bansal
Updated on 22-Aug-2019 08:48:12

350 Views

The task is to print the reverse of a given linked list by using recursive function. The program must print the reverse but not reverse the list that means the order of the nodes remains the sameHere, the program will move head pointer containing the address of a first node to next node until the NULL is examined which is stored in last node of a list and printing the data of a head node.ExampleInput: 29 34 43 56 Output: 56 43 34 29Firstly, the nodes are inserted into the list and a pointer will start pointing to the nodes ... Read More

Print Pair with Maximum Value in an Array in C

Sunidhi Bansal
Updated on 22-Aug-2019 08:45:50

254 Views

According to the problem we are given an array of n positive integers, we have to find a pair with maximum AND value from the array.ExampleInput: arr[] = { 4, 8, 12, 16 } Output: pair = 8 12 The maximum and value= 8 Input:arr[] = { 4, 8, 16, 2 } Output: pair = No possible AND The maximum and value = 0For finding Maximum AND value is similar to find out Maximum AND value in an array. Program must find out the pair of elements resulting in obtained AND value. For finding the elements, simply traverse the ... Read More

Print Right View of a Binary Tree in C Language

Sunidhi Bansal
Updated on 22-Aug-2019 08:45:40

413 Views

The task is to print the right nodes of a given binary tree. Firstly user will insert data for creating a binary tree and than print right view of the tree so formed.The above diagram showcase the binary tree created with the nodes 10, 42, 93, 14, 35, 96, 57 and 88 amongst these nodes the one that lies in the right side of a tree are chosen and displayed over the screen. For example, 10, 93, 57 and 88 are the rightmost nodes of a binary tree.ExampleInput : 10 42 93 14 35 96 57 88 Output : 10 ... Read More

Print Middle Level of Perfect Binary Tree in C Language

Sunidhi Bansal
Updated on 22-Aug-2019 08:43:00

246 Views

The program should print the middle level of a binary tree e.g. if there are 4 levels in a binary tree than the program must print the level 2 nodes but the demand here is to calculate the level without finding the height.Perfect binary tree is a tree in which interior nodes must have two children and all leave nodes should be at the same level or depth.Here, Interior nodes 21 and 32 both are having childrenLeaf nodes are 41, 59, 33 and 70 all lies at the same level.Since it is satisfying both the properties it’s a perfect binary ... Read More

Fix MySQL Float Data Field Not Accepting Every Float Number

AmitDiwan
Updated on 22-Aug-2019 08:40:52

190 Views

To get fixed float data type, use DECIMAL(). This will fix the issue of unacceptance. Let us first create a table −mysql> create table DemoTable(Amount DECIMAL(10, 2)); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(2194848.90); Query OK, 1 row affected (0.65 sec) mysql> insert into DemoTable values(90309393.79); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable values(8999999.68); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable values(90900000.99); Query OK, 1 row affected (0.26 sec)Display all records from the table using select statement −mysql> select ... Read More

Print Leaf Nodes in Binary Tree from Left to Right Using One Stack in C++

Sunidhi Bansal
Updated on 22-Aug-2019 08:40:21

260 Views

Program should print the leaf nodes of a binary tree from left to right but the challenge involves is using of only one stackThrough push() function insert nodes of a binary tree and through pop() operation display the leaf nodes.Leaf nodes are the end nodes whose left and right pointer is NULL which means that particular node is not a parent node.ExampleInput : 12 21 32 41 59 33 70 Output : 41 59 33 70Stack is a data structure which is a LIFO structure in which top pointer will point to the last elements inserted so the leaf nodes ... Read More

HTML DOM Input Password Placeholder Property

AmitDiwan
Updated on 22-Aug-2019 08:37:42

409 Views

The HTML DOM Input Password placeholder property is used for setting or returning the placeholder attribute value of an input password field. The placeholder property is used for giving the web page users a hint about the input element by showing a text inside the input field befor the user inputs anything. The placeholder text is greyed by default and isn’t submitted to the form unlike the value property.SyntaxFollowing is the syntax for −Setting the placeholder property −passwordObject.placeholder = textHere, text represents the placeholder text specifying the hint for the user about the password field.ExampleLet us look at an example ... Read More

Longest Prefix which is also Suffix in C Program

Sunidhi Bansal
Updated on 22-Aug-2019 08:36:54

1K+ Views

Given a string in which we have to check that the length of the longest prefix which is also a suffix of the string like there is a string “abcab” so here “ab” is of length 2 and is the longest substring with same prefix and suffix.ExampleInput: str[] = { “aabbccdaabbcc” } Output: 6 Input: abdab Output: 2If we will start the pointer from start and end of the string than they will get overlapped at some point so instead of doing that we will break the string from middle and start matching left and right string. If they are ... Read More

Advertisements