Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Consider the following code: // Linked Lists: SEARCH for a given target in a list struct Data { int number; char ch; }; struct

C++

Consider the following code: // Linked Lists: SEARCH for a given target in a list

struct Data { int number; char ch; };

struct ListNode { Data data; struct ListNode *next; };

Assume that a linked list has been created and head points to a sentinel node. A sentinel node is an empty data node in the beginning of the list. It sometimes holds a sentinel value. The use of sentinel nodes is a popular trick to simplify the insert and delete operations.

You may also assume that the list is not empty and it is not sorted. The data in the sentinel node is -9999.

Write a function named searchList that is passed the pointer to the first node in the list and a target number. It searches for the target number in the list: if found, it copies the data to its outputparameter and returns true, otherwise returns false. A calling statement for this function is given below:

found = searchList(head, targetNumber, dataOut);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Formal SQL Tuning For Oracle Databases Practical Efficiency Efficient Practice

Authors: Leonid Nossov ,Hanno Ernst ,Victor Chupis

1st Edition

3662570564, 978-3662570562

More Books

Students also viewed these Databases questions

Question

There are N clients who have ordered N handmade items.

Answered: 1 week ago

Question

4. Describe the role of narratives in constructing history.

Answered: 1 week ago

Question

=+What kinds of problems need to be overcome?

Answered: 1 week ago

Question

=+Describe an important trade-off you recently faced

Answered: 1 week ago