Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
943 views
in Computer by (48.9k points)
closed by

A linked list is formed from the objects of the class:

class Node 

int number, 

Node nextNode; 

Write an Algorithm OR a Method to add a node at the end of an existing linked list. 

The method declaration is as follows: void add node (Node start, int num)

1 Answer

+1 vote
by (49.8k points)
selected by
 
Best answer

Algorithm to add a node at the end of an existing linked list. 

Steps: 

1. Start 

2. Set temporary pointer to start node 

3. Repeat steps 4 until it reaches null 

4. move the pointer to the next node 

5. create a new node, assign num to number and link to the temporary node 

6. End Method to add a node at the end of an existing linked list. 

void add node (node start, int num) 

Node A = new Node(start) 

while (A != null) 

A=A.nextNode; 

Node C = new node (); 

C. number = num; 

C.nextNode = null; 

A. next = C; 

}

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...