Please write the code in a text editor and explain thank you!
1. LINKED-LIST: Implement a function that finds if a given value is present in a linked-list. The function should look for the first occurrence of the value and return a true if the value is present or false if it is not present in the list. Your code should work on a linked-list of any size including an empty list. Your solution must be RECURSIVE. Non-recursive solutions will not receive any credit. You must comment your code. Below is the declaration of the function:
bool findValueRecursively(Node *head, int value);
As an example if the linked-list contains the elements [10]->[1]->[50]->[10]->null and the function is called passing the head of the list (address of node with value 10) and the value to find to be 10, it should return true. If the function is called on the same list passing the value 40, it should return false. For an empty list it should return false.
2. C-STRINGS: Implement a function that takes as input a const C string containing
only alphabets. The function should allocate memory for a new string on the heap and copy into it the original string converting all upper case letters to lowercase. The function should then return the new string containing on lower case letters. Below is the declaration of the function you are expected to write: char* ToLower(const char * s);
In your implementation, you may use any or all of the following
functions that operate on C-strings int strlen(char *s);//takes a
C-string as input and returns the length of the string not counting
the null terminator
char tolower(char c); //takes a single character as input and
returns the lower-case version of the character. You may also use
other C-string functions covered in class as appropriate.
Here I have attached C function for the problems given above:
1.
bool findValueRecursively(struct node *head, int value){
//if head is present and head's data is equal to given value, we
return true
if(head){
if(head->data == value){
return true;
}
else{
//if head is present and head's data is not equal to given
value, we go to next node
return (findValueRecursively(head->next, value));
}
}
//if we cant find the given value or list is empty, we return
false.
return false;
}
2.
char* ToLower(const char * s){
int len,i;
len = strlen(s); //strlen() will return length of the string
char *newString = (char *)malloc((len+1)*sizeof(char)); //creating
memory of new string of length of given string s
for(i = 0; i < len ; i++){
newString[i] = tolower(s[i]);
}
newString[i]='\0';
//returning newn string
return newString;
}
Hoping that the above solution helps. Please comment for further assistance.
Please write the code in a text editor and explain thank you! 1. LINKED-LIST: Implement a...
Problem Statement This problem provides you with a linked list composed of node objects chained together via node pointers. Each node has a next pointer which points to the next node in the chain. The last node is identified by having a NULL (or nullptr) next pointer. The linked lists for this problem store string data. Your task: identify the longest string stored in the linked list. If two strings are of the same length, return the string that occurred...
() Given the following structure definition and typedef for a linked list of strings: typedef struct node st node; struct node st { char *word; /* a valid string pointer or NULL */ node *next; /* next node in the list or NULL */ }; Write a C function, free list(), that takes as an argument one of these lists, possibly NULL, and frees all the strings as well as the list itself. Write robust code. void free list(node *list){
Assignment 1 In this assignment you will be writing a tool to help you play the word puzzle game AlphaBear. In the game, certain letters must be used at each round or else they will turn into rocks! Therefore, we want to create a tool that you can provide with a list of letters you MUST use and a list of available letters and the program returns a list of all the words that contain required letters and only contain...
In C++ please! *Do not use any other library functions(like strlen) than the one posted(<cstddef>) in the code below!* /** CS 150 C-Strings Follow the instructions on your handout to complete the requested function. You may not use ANY library functions or include any headers, except for <cstddef> for size_t. */ #include <cstddef> // size_t for sizes and indexes ///////////////// WRITE YOUR FUNCTION BELOW THIS LINE /////////////////////// ///////////////// WRITE YOUR FUNCTION ABOVE THIS LINE /////////////////////// // These are OK after...
Programs 1. String Utilities In this exercise you will implement several utility functions involving strings. You will place all of your function prototypes in a header file named string utils.h and all of your function definitions in a source file named string utils.c. You should implement your own main test driver program to test your functions, but you need not hand it in. a. void addChar(char *str, char c, int n) - this function should add a char c at...
C++ PROGRAMMING Implement a bool function whose header is given below. Inside the function, declare, ask, and get a character from the user. The function will return true if the character the user enters is NOT in either of the words, otherwise it will return false. Keep in mind that uppercase and lowercase letters are not the same. You will need to change both words and the character input by the user to the same case (upper or lower) -...
You will implement some helpful string functions. The prototypes are below. The only built-in functions you can use are toupper() and tolower() – found in ctype.h. char* capitalize(char* s); char* str2Lwr(char* s); char* str2Upr(char* s); All of the functions should be "in-place". In-place means that you should update the string pointed to by s, rather than creating a new one. capitalize() should convert the first character of string s to upper case. The value of s is returned. str2Lwr() should...
Please write code in C++ and include all headers not bits/stdc: 17.10 (Occurrences of a specified character in a string) Write a recursive function that finds the number of occurrences of a specified letter in a string using the following function header. int count(const string& s, char a) For example, count("Welcome", 'e') returns 2. Write a test program that prompts the user to enter a string and a character, and displays the number of occurrences for the character in the...
implement delete node function in c++ language I just need a basic doubly linked list code for the delete node portion of the code // Delete node containing word from list if it is present void delNode (DLList list, char *str) ( // Delete node containing word from list if it is present void delNode (DLList list, char *str) (