C How to Program (8th Edition)
C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
Question
Book Icon
Chapter 12, Problem 12.21E
Program Plan Intro

Program plan:

  1. Item, start, result variablesare used for input. There is structure listnode havingdata, nextPtrmember variables which represents the linked listnode.
  2. void insert(node **head, int value) function inserts the node in the a linked list.
  3. node *recsearch(node *head, int value) function searches the passing value in the linked list using recursion.
  4. void printList(node *head) function display the contents of the linked list.

Program description:

The main purpose of the program is to create a linked list using the value input by the user and it asks the user to enter the value to search in the linked list and it uses the recursive function to search the value and return the result.

Blurred answer
Students have asked these similar questions
1. (Store numbers in a linked list) Write a program that lets the user enter numbers and displays numbers as described below. Use a linked list to store the numbers. Do not store duplicate numbers. Add the methods Sort, Shuffle, and Reverse to sort, shuffle, and reverse the list in the application class (driver class).
- Question-2: Functions, Iterations and List • Write a function that takes a positive integer n as its parameter. • Return a list whose o values are numbers between n and 2n.
Topic: Singly Linked ListImplement the following functions in C++ program. Read the question carefully. Below is the "CODE THAT NEEDS TO BE IMPROVED" or "NOT FINAL CODE"  (See attached photo for reference)  bool addAt(int num, int pos) This method will add the integer num to the posth position of the list and returns true if the value of pos is valid. Performing addAt(20, 2) in the example list will add 20 at the 2nd position and the linked list will now look like this: 10 -> 20 -> 30 -> 40 -> 50. When the value of pos is invalid i.e. greater than the size + 1 or less than one, return false.   bool addAt(int num, int pos) {             if (pos == 1) { // case 1: addHead                 addHead(num);                 return true;             }             if (pos == index + 1) { // case 3: addTail                 addTail(num);                 return true;             }             node* currnode = head; //addAt(20, 3)             int count = 0;             while (currnode…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning