Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 913 of 3366
600 Views
Given a Singly linked list and positive integer N as input. The goal is to find the Nth node from the end in the given list using recursion. If the input list has nodes a → b → c → d → e → f and N is 4 then the 4th node from the end will be c.We will first traverse till the last node in the list and while returning from recursion (backtracking) increment count. When count is equal to N then return pointer to current node as result.Let us see various input output scenarios for this −Input − ... Read More
398 Views
Given a Singly linked list as input. The goal is to split the list into two singly linked lists that have alternate nodes of the original list. If the input list has nodes a → b → c → d → e → f then after the split, two sub-lists will be a → c → e and b → d → f.We will take two pointers N1 and N2 one pointing to the head of the original list and another pointing to the head → next. Now move both pointers to the next of next node and create sublists.ExamplesInput − ... Read More
1K+ Views
To remove rows that have NA in R data frames stored in a list, we can use lapply function along with na.omit function.For example, if we have a list called LIST that contains some data frames each containing few missing values then the removal of rows having missing values from these data frames can be done by using the command given below −lapply(LIST,na.omit)Check out the below given example to understand how it works.ExampleFollowing snippet creates a sample data frame −df1
1K+ Views
We are given with integer values that will be used to form a linked list. The task is to firstly insert and then traverse a singly linked list using a recursive approach.Recursive addition of nodes at the endIf head is NULL → add node to headElse add to head( head → next )Recursive traversal of nodesIf head is NULL → exitElse print( head → next )ExamplesInput − 1 - 2 - 7 - 9 - 10Output − Linked list : 1 → 2 → 7 → 9 → 10 → NULLInput − 12 - 21 - 17 - 94 - 18Output − Linked list ... Read More
2K+ Views
To create boxplots based on two factor data, we can create facets for one of the factors, where each facet will contain the boxplots for the second factor.For example, if we have a data frame called df that contains two factor columns say F1 and F2 and one numerical column say Num then the boxplot based on these two factors can be created by using the below given command −ggplot(df,aes(F1,Num))+geom_boxplot()+facet_wrap(~F2)ExampleFollowing snippet creates a sample data frame −Gender
6K+ Views
To create table of two factor columns in an R data frame, we can use table function and with function.For Example, if we have a data frame called df that contains two factor columns say F1 and F2 then we can create table of these two columns by using the below command −with(df,table(F1,F2))Example 1Following snippet creates a sample data frame −Group
4K+ Views
To remove first character from column name in R data frame, we can use str_sub function of stringr package.For Example, if we have a data frame called df that contains two columns say XID and XDV then we can remove X from both the column names by using the below mentioned command −names(df)=str_sub(names(df),2)Example 1Following snippet creates a sample data frame −XColor
5K+ Views
To increase the width of the X-axis line for a ggplot2 graph in R, we can use theme function where we can set the axis.line.x.bottom argument size to desired size with element_line.Check out the below Example to understand how it can be done.ExampleFollowing snippet creates a sample data frame −x
7K+ Views
To change the color of X-axis line for a graph using ggplot2, we can use theme function where we can set the axis.line.x.bottom argument color to desired color with element_line.Check out the below Example to understand how it can be done. This might be required when we want to highlight the X-axis for viewers.ExampleFollowing snippet creates a sample data frame −x
2K+ Views
Given an integer array Arr[] containing integer numbers in any order. The goal is to find the input integer val present in the array using recursive search on the array.If val is not found in the input array Arr[] then return -1. Print the index of val if found in Arr[].ExamplesInput −Arr[] = {11, 43, 24, 50, 93, 26, 78} val=26Output − 26 found at index 5Explanation −Elements in the array start from index 0 to index=array length -1. First index=0 last index=6 : 11 != 26, 78 != 26 → 0+1 , 6-1 First index=1 last index=5 : 43 != 26, 26 ... Read More