Click here to Skip to main content
15,844,602 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: C language exercise - beginner Pin
CPallini6-Oct-21 23:46
mveCPallini6-Oct-21 23:46 
GeneralRe: C language exercise - beginner Pin
David Crow7-Oct-21 3:08
David Crow7-Oct-21 3:08 
AnswerRe: C language exercise - beginner Pin
jsc427-Oct-21 6:18
professionaljsc427-Oct-21 6:18 
GeneralRe: C language exercise - beginner Pin
Graham Breach7-Oct-21 12:30
Graham Breach7-Oct-21 12:30 
GeneralRe: C language exercise - beginner Pin
Bram van Kampen15-Oct-21 14:35
Bram van Kampen15-Oct-21 14:35 
GeneralRe: C language exercise - beginner Pin
Richard MacCutchan15-Oct-21 23:04
mveRichard MacCutchan15-Oct-21 23:04 
AnswerRe: C language exercise - beginner Pin
Bram van Kampen15-Oct-21 14:29
Bram van Kampen15-Oct-21 14:29 
Questiondata structure Pin
User 153459235-Oct-21 16:05
User 153459235-Oct-21 16:05 
Given following definition for singly linked list node and a pointer type:

 

struct Node {

     int num;

     Node* next;

     Node() = delete;

     Node(int num) : num{ num }, next{ nullptr } {}

};

 

typedef Node* NodePtr;

 

 

Use following prototype:

 

void quiz2(NodePtr& head1, NodePtr& target, NodePtr& head2)

 

to design a function that:

Takes in two linked lists, indicated by head1 and head2, and a NodePtr target
Searches target Node in linked list 1 (by comparing address, not by value):
If found, then connect the whole linked list 2 to the target node. In other words, use list 2 to replace nodes after target. Also update head2 to nullptr as the merged linked list should have only one entry point at head1.
If not found, then connect list 2 to the end of list 1, and set head2 to nullptr for the same above reason.
 

For example,

list 1: 10->20->30->40, target is the address of node 20, list 2: 11->12->13, then after calling the function, list 1 should be 10->20->11->12->13.
list 1: 10->20->30->40, target is an address that cannot be found in list 1, list 2: 11->12->13, then after calling the function, list 1 should be 10->20->30->40->11->12->13.
 

When merging, please take care of memory and do not let leak happen. You will be deducted by 10 points if memory leak happens. (Hint: in the first example, what should happen to nodes 30 and 40?)

 

Submit one .cpp file as your answer to Quiz 2.

 

Develop your own work and DO NOT CHEAT. Violator will be found, reported, and penalized with F grade for this course. 

 

Attach FileNo file chosen 


modified 3-Nov-21 21:01pm.

AnswerRe: data structure PinPopular
Dave Kreskowiak5-Oct-21 18:11
mveDave Kreskowiak5-Oct-21 18:11 
AnswerRe: data structure Pin
Maximilien6-Oct-21 13:44
Maximilien6-Oct-21 13:44 
AnswerRe: data structure Pin
Bram van Kampen15-Oct-21 13:50
Bram van Kampen15-Oct-21 13:50 
QuestionRun powershell in C# Pin
jwradhe23-Sep-21 1:43
jwradhe23-Sep-21 1:43 
AnswerRe: Run powershell in C# Pin
Richard MacCutchan23-Sep-21 1:49
mveRichard MacCutchan23-Sep-21 1:49 
AnswerRe: Run powershell in C# Pin
Richard Deeming23-Sep-21 2:14
mveRichard Deeming23-Sep-21 2:14 
GeneralRe: Run powershell in C# Pin
jwradhe23-Sep-21 2:48
jwradhe23-Sep-21 2:48 
GeneralRe: Run powershell in C# Pin
Richard Deeming23-Sep-21 3:43
mveRichard Deeming23-Sep-21 3:43 
GeneralRe: Run powershell in C# Pin
jwradhe23-Sep-21 3:49
jwradhe23-Sep-21 3:49 
GeneralRe: Run powershell in C# Pin
Richard Deeming23-Sep-21 4:21
mveRichard Deeming23-Sep-21 4:21 
GeneralRe: Run powershell in C# Pin
Dave Kreskowiak23-Sep-21 4:29
mveDave Kreskowiak23-Sep-21 4:29 
QuestionExample C code to use API "GetProcessIoCounters" Pin
Narasimha Moorthy20-Sep-21 2:01
Narasimha Moorthy20-Sep-21 2:01 
AnswerRe: Example C code to use API "GetProcessIoCounters" Pin
Richard MacCutchan20-Sep-21 2:11
mveRichard MacCutchan20-Sep-21 2:11 
GeneralRe: Example C code to use API "GetProcessIoCounters" Pin
Narasimha Moorthy20-Sep-21 20:14
Narasimha Moorthy20-Sep-21 20:14 
GeneralRe: Example C code to use API "GetProcessIoCounters" Pin
Richard MacCutchan20-Sep-21 22:19
mveRichard MacCutchan20-Sep-21 22:19 
GeneralRe: Example C code to use API "GetProcessIoCounters" Pin
Victor Nijegorodov20-Sep-21 22:21
Victor Nijegorodov20-Sep-21 22:21 
QuestionConnect to bluetooth service watch and read HR data Pin
Wim Van den Borre20-Sep-21 0:18
Wim Van den Borre20-Sep-21 0:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.