0% found this document useful (0 votes)
33 views2 pages

Understanding The Question Is A Part of Exam So No Queries

The document describes functions to implement for a linked list class. Function 1 squares all node values. Function 2 returns the node number with the maximum value. The main function prints the name and roll number, inserts nodes into a linked list, calls traverse, squares nodes, calls traverse again, and calls and displays the maximum node number.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views2 pages

Understanding The Question Is A Part of Exam So No Queries

The document describes functions to implement for a linked list class. Function 1 squares all node values. Function 2 returns the node number with the maximum value. The main function prints the name and roll number, inserts nodes into a linked list, calls traverse, squares nodes, calls traverse again, and calls and displays the maximum node number.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

NOTE: UNDERSTANDING THE QUESTION IS A PART OF EXAM SO NO QUERIES

Single linked list class and some function definitions already given , you have to
implement following functions and write the main accordingly:

NOTE: YOU CAN ONLY USE ALREADY DECLARED POINTERS FOR


FUNCTION DEFINITIONS, YOU CAN NOT RENAME POINTERS NEITHER
USE ANY OTHER POINTER AS GIVEN IN THE FUNCTIONS. New Variable
can be created anywhere if required. Try to minimize function created by you
where possible

#1 void square_all_node( )

Update all node values with square values


example
initial linked list: 2->3->4->5->7->0
new Linked list: 4->9->16->25->49->0 (after function calling)

#2 int Max_value_node_no( )
Return the node# having maximum value
example 2->3->4->5->7->0
Return 5 as maximum value(7) found at node # 5

#3 in main

Print your name and roll no in one line using cout


create the following list by calling insert_at_begin() 2->4->5->0->3->6->9->11
Call traverse function
Call square_all_node function
call traverse function
call max_node_no and display the value returned

Code to be completed:

#include "stdafx.h"
#include<iostream>
using namespace std;
class List
{
private:
struct node
{int data;
node *next;
} *head;

public:
List(){head=NULL;}
~List(){}
bool emptyList(){}

void square_all_node( )
{
node *temp1, *temp2;

int Max_value_node_no( )
{
node *ptr1,*ptr2;
}

void insert_begin(int value)


{
node *ptr;
ptr=new node;
ptr->data=value;
ptr->next=head;
head=ptr;

void traverse()
{
node *ptr;
ptr=head;

while(ptr!=NULL)
{
cout<<ptr->data<<endl;
ptr=ptr->next;
}
}

};

int _tmain(int argc, _TCHAR* argv[])


{

List L1;

system("pause");
return 0;
}

You might also like