Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

GUIDE FOR SCHOOL OPERATIONS ON LINKED LIST

Study guide for students ISC Computer Science Theory

SOLVED QUESTIONS OF LINKED LIST :


ISC 2011
A linked list is formed from the objects of the class,
class Node
{
int info ;
Node link;
}
Write an algorithm OR a Method for deleting a node from a linked list.
The method declaration is given below :

GFS
void deletenode (Node start)

Algorithm to delete a node in a linked list.


Steps:
1- Start
2- Set temporary pointer to start node
3- Accept info for the node to be deleted
4- if first node is the desired one then
Move the pointer of the start node to the second node
Set link of first node to null
Stop else
5- Repeat step 6 & 7 until the temporary pointer reaches null
6- move temporary pointer to the next node
7- if the desired node is found then
(a) if the node to be deleted is last node then
Set the pointer of the previous node to null
Stop
(b) else
Set the pointer of the previous node to the next node of the node to be deleted
Set the temporary pointer node to null
Stop
8- End

www.guideforshool.com www.facebook.com/guideforschool www.twitter.com/guideforschool


GUIDE FOR SCHOOL OPERATIONS ON LINKED LIST
Study guide for students ISC Computer Science Theory

ISC 2013
A linked list is formed from the objects of the class,
class Node
{
int item;
Node next;
}
Write an Algorithm OR a Method to count the number of nodes in the linked list.
The method declaration is given below:
int count(Node ptr_start)

Algorithm to count the number of nodes in a linked list.

GFS
Steps :
1- Start
2- Set temporary pointer to start node and counter to 0.
3- Repeat steps 4 and 5 until the pointer reaches null
4- Increment the counter
5- move temporary pointer to the next node
6- Return the counter value
7- End

ISC 2014
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 addnode ( Node start, int num )

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

Steps :
1- Start
2- Set temporary pointer to start node
3- Repeat step 4 until it reaches null
4- move pointer to the next node
5- create new node, assign num to number and nextNode to null
6- Set temporary pointer to new node
7- End

www.guideforshool.com www.facebook.com/guideforschool www.twitter.com/guideforschool


GUIDE FOR SCHOOL OPERATIONS ON LINKED LIST
Study guide for students ISC Computer Science Theory

ISC 2015
A linked list is formed from the objects of the class:
class Nodes
{
int num;
Nodes next;
}
Write an Algorithm OR a Method to print the sum of nodes that contains only odd integers of an
existing linked list.
The method declaration is as follows:
void NodesCount( Nodes starPtr )

Algorithm to print the sum of the nodes of odd integers in an existing linked list.

GFS
Steps :
1- Start
2- Set temporary pointer to start node and sum to 0.
3- Repeat steps 4 and 5 until the pointer reaches null.
4- if num is odd, add it to sum
5- Move pointer to the next node
6- Display sum.
7- End

ISC 2016
A linked list is formed from the objects of the class Node. The class structure of the Node is given
below:
class Node
{
String name;
Node next;
}
Write an Algorithm OR a Method to search for a given name in the linked list. The method of
declaration is given below:
boolean searchName(Node start, String v)

ALGORITHM:

Steps :
1- Start
2- Set temporary pointer to the start node
3- Repeat steps 4 until the pointer reaches null. Return false.
4- if name equals to v,
Return true.
Exit.
else
Move pointer to the next node
5- End

www.guideforshool.com www.facebook.com/guideforschool www.twitter.com/guideforschool


GUIDE FOR SCHOOL OPERATIONS ON LINKED LIST
Study guide for students ISC Computer Science Theory

ISC 2017
A linked list is formed from the objects of the class Node. The class structure of the Node is given
below:
class Node
{
int num;
Node next;
}
Write an Algorithm OR a Method to count the nodes that contain only odd integers from an existing
linked list and returns the count. The method declaration is as follows:
int CountOdd( Node startPtr )
ALGORITHM:

Steps :

GFS
1- Start
2- Set temporary pointer to the start node and count to 0
3- Repeat step 4 until the pointer reaches null.
4- if num is odd
Increment counter
else
Move pointer to the next node
5- Return count
6- End

ISC 2018
A linked list is formed from the objects of the class Node. The class structure of the Node is given
below:
class Node
{
int n;
Node link;
}
Write an Algorithm OR a Method to search for a number from an existing linked list.
The method declaration is as follows:
void FindNode( Node str, int b )
ALGORITHM:

Steps :
1- Start
2- Set temporary pointer to the start node
3- Repeat steps 4 until the pointer reaches null. Display number not found.
4- if n equals to b,
Display number found.
Exit.
else
Move pointer to the next node
5- End

www.guideforshool.com www.facebook.com/guideforschool www.twitter.com/guideforschool

You might also like